bison
bison copied to clipboard
Add two new options to output the naked grammar and an EBNF
Add two new options to output the naked grammar and an EBNF to view railroad diagram at https://www.bottlecaps.de/rr/ui
Copy and paste the EBNF bellow on https://www.bottlecaps.de/rr/ui tab Edit Grammar then switch to the tab View Diagram.
bison -e examples/c/calc/calc.y
input ::=
/* empty */
| input line
line ::=
'\n'
| expr '\n'
| error '\n'
expr ::=
expr '+' term
| expr '-' term
| term
term ::=
term '*' fact
| term '/' fact
| fact
fact ::=
"number"
| '(' expr ')'
bison -n examples/c/calc/calc.y
input :
/* empty */
| input line
;
line :
'\n'
| expr '\n'
| error '\n'
;
expr :
expr '+' term
| expr '-' term
| term
;
term :
term '*' fact
| term '/' fact
| fact
;
fact :
"number"
| '(' expr ')'
;
Hi!
I'm sorry for the super slow response: I had not seen your PR, and GitHub does not send me notifications (and I couldn't find how to enable them...).
The development of Bison is driven by the [email protected] mailing list, please submit your contribution there.
Have you checked how the grammar is output in the report files? Check -v and y.output, or --html and y.html. I don't think we need the -n option, we already have it, and, AFAICT, Railroad Diagram Generator does not grok it.
An option to output in BNF is interesting, why not. But we'll need documentation, tests, and most importantly, that you sign the FSF disclaimer so that I can included your contribution.
Cheers!
(Please, let's move to [email protected]).
FWIW, I think I just found where to enable notifications :)
I'm working to achieve a LALR(1)/LEX to try grammars online with wasm based on https://github.com/BenHanson/gram_grep and I've got the Bison grammar working, view it here https://mingodad.github.io/parsertl-playground/playground/ select Bison parser (partially working) from the examples, you can edit the Grammar or the Input source and press Parse to see a parser tree.
I hope it can be a nice tool to experiment with LALR(1)/LEX grammars with instant feedback !