Should the parser stay ANTLR-generated? (intent of #565, needs-design)
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
Piste de recherche
Commencez par lire Core/Antlr, AngouriMath.g, Docs/Contributing/ImproveParser.md et StringizeRoundTripTest afin de comprendre le parser actuel et ses critères d’acceptation. Tout remplacement proposé doit être évalué au regard de la préservation round-trip, des messages d’erreur, du coût d’exécution et du maintien de l’exactitude de Docs/Usage/Syntax.md ; l’issue est terminée lorsque les mainteneurs ont pris une décision étayée par ces vérifications.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Splitting the intent of #565 out of the branch, which is being closed: it proposed replacing the ANTLR-generated parser with one built on Yoakke, and the question it raises is live even though the branch is not.
What the branch did
Deleted the whole of Core/Antlr — the grammar, the four generated files, the .interp/.tokens
artefacts and the bundled antlr-4.8-complete.jar — and replaced it with a hand-assembled parser:
+740 / −7185 across 26 files.
Why ANTLR is worth replacing
Not on parser-theory grounds. On the day-to-day cost of it:
- The generated files are committed, so a grammar change is a two-step ritual — edit
AngouriMath.g, runantlr_rerun.bat, then run a post-processing pass whose only job is to rewrite
publictointernalon the generated classes.Docs/Contributing/ImproveParser.mddocuments it,
and the documentation has to warn you to regenerate the unmodified grammar first and check the diff
is empty, so that a toolchain version difference is not mistaken for your change. - It needs a JDK to change the grammar at all, in a repository that otherwise needs only the .NET
SDK. - A 1 MB jar is in the source tree.
- The error messages are ANTLR's, which is why
MissingOperatorParseExceptionand friends exist to
translate them, and whyDocs/Usage/Syntax.mdhad to be written by hand as a separate statement of
what the parser accepts.
Why it is not obviously worth doing
- The parser works, and its contract is now tested.
StringizeRoundTripTestholds printing to being
parsing's inverse across every node type, and 2.0 fixed several node shapes that did not round-trip.
A rewrite starts that guarantee from zero. - The grammar is the specification.
Syntax.mddescribes it, butAngouriMath.gis the thing that
decides, and it is 480-odd lines of readable declarative rules. A hand-written recursive-descent
parser is more code and less obviously equivalent to a reader. - Yoakke is itself a dependency, and a small one — it would be trading a build-time dependency on a
jar for a run-time dependency on a young library, which for a package with 313k downloads is a
different kind of risk rather than less risk. - Nothing about the parser is currently a bug. The open parse issues are about what the grammar
says — precedence, notation — not about how it is produced.
What would make this decidable
- Is the round trip preserved?
StringizeRoundTripTestover every node type is the acceptance, and
it did not exist when #565 was written. - Are the error messages better? The reason to hand-write a parser is control over failure; if the
replacement's messages are no better than the translated ANTLR ones, the main benefit is only the
build simplification. - What does it cost at run time? Parsing is on the hot path for
FromString, which caches by
string precisely because it is not free. - Does
Syntax.mdstay true, and can it be generated from the new parser rather than maintained
beside it?
I have no recommendation. The four costs above are real and so are the four objections, and this is a
maintainer's call about what the library wants to own. Filed so that the reasoning survives the branch
rather than being rediscovered in another four years.
- Langage dominant
- C#
- Étoiles
- 831
- Forks
- 79
- Merge moyen
- 1 h 24 min
- PR mergées (30 j)
- 540
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de ASC-Community/AngouriMath
-
Opinions wanted
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
ASC-Community/AngouriMath#2120 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 30/100
ASC-Community/AngouriMath#1807 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
ASC-Community/AngouriMath#1692 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 30/100
ASC-Community/AngouriMath#1690 ·
Les mainteneurs répondent en général sous 1 jour
-
Organization-level managementOuverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
ASC-Community/AngouriMath#1649 · 36 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de ASC-Community/AngouriMath
Issues similaires
-
Bug
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
dotnet/roslynator#1859 ·
Les mainteneurs répondent en général sous 1 jour
-
area:jobads-cv BE P3
Difficulté 1/5 1-3 heures Accessibilité débutants 74/100
klasolsson81/jobbliggaren#2240 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
k2-fsa/sherpa-onnx#4100 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
:watch: Not Triaged
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour