-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grammar railroad diagram #135
Comments
Thanks for the contribution, @mingodad. A few questions need to be resolved before we move forward with this. I'm not sure whether how this railroad diagram sits with the hand-curated grammar in https://github.com/hydromatic/morel/blob/main/docs/reference.md. The hand-curated grammar doesn't have the extra symbols (e.g. type5, type6, type7) introduced to deal with precedence. It doesn't have the nice railroad arrows, but it's not difficult to read if you know BNF. Also, going forward, I don't know how we would maintain the grammar.ebnf (by hand, or generate it from MorelParser.jj) and I don't know how we would generate grammar.xml (paste the grammar into the Railroad diagram generator site, download the XHTML file and commit, or generate using a maven plugin). |
The EBNF grammar generated from the parser is meant to help understand/develop the parser, it's true that the parser can have some extra details to facilitate parsing but without any influence on the end user point of view. There is allays the possibility of parser grammar and "hand-curated grammar" going out of sync, for the end user a pruned grammar is better but for the developer the full parser grammar is better. Also because the tool makes some simplifications/optimizations it also help refactoring the grammar. |
There is a possibility of generate the
|
With a custom parser to parse the JavaCC grammar for
morel
to produce an EBNF understood by https://www.bottlecaps.de/rr/ui we can have a nice railroad diagram (https://en.wikipedia.org/wiki/Syntax_diagram).I also did a reorder of the rules (reverse then) to get a better navigable railroad diagram, copy and paste the EBNF shown bellow at https://www.bottlecaps.de/rr/ui on the tab "Edit Grammar" then click on the tab "View Diagram".
The text was updated successfully, but these errors were encountered: