I've just added moonyacc grammar to https://mingodad.github.io/parsertl-playground/playground/ an Yacc/Lex like online interpreter/editor (select Moonyacc parser from Examples then click Parse to see a parse tree for the content in Input source) and then generated an EBNF understood by https://github.com/GuntherRademacher/rr to generate a nice navigable railroad diagram (see bellow with instructions at the top).
I also changed bison/byacc/lemon to output a naked grammar and also an EBNF grammar see here https://github.com/mingodad/lalr-parser-test , probably it's a good idea to have that on moonyacc too.
I hope it can help document/develop/debug grammars !
//
// EBNF to be viewd at
// (IPV6) https://www.bottlecaps.de/rr/ui
// (IPV4) https://rr.red-dove.com/ui
//
// Copy and paste this at one of the urls shown above in the 'Edit Grammar' tab
// then click the 'View Diagram' tab.
//
spec::=
header decl_list "%%" rule_list trailer
header::=
PERCENT_LBRACE_CODE_PERCENT_RBRACE
| /*%empty*/
trailer::=
PERCENT_LBRACE_CODE_PERCENT_RBRACE
| "%%"
| /*%empty*/
decl_list::=
decl_list decl
| /*%empty*/
decl::=
"%start" nonempty_symbol_list
| "%token" opt_type nonempty_symbol_list
| "%token" opt_type symbol STRING
| "%type" LANGLE_CODE_RANGLE nonempty_symbol_list
| "%position" LANGLE_CODE_RANGLE
| "%left" nonempty_symbol_list
| "%right" nonempty_symbol_list
| "%nonassoc" nonempty_symbol_list
| "%derive" LANGLE_CODE_RANGLE IDENT
opt_type::=
LANGLE_CODE_RANGLE
| /*%empty*/
rule_list::=
rule
| rule_list rule
rule::=
rule_no_modifiers
| "%inline" rule_no_modifiers
rule_no_modifiers::=
symbol rule_type ":" clause_list ";"
rule_type::=
ARROW_CODE
| /*%empty*/
clause_list::=
clause
| clause_list "|" clause
clause::=
item_list rule_prec clause_action
clause_action::=
LBRACE_CODE_RBRACE
| /*%empty*/
rule_prec::=
"%prec" symbol
| /*%empty*/
item_list::=
item_list item
| /*%empty*/
item::=
item_symbol
| IDENT "=" item_symbol
item_symbol::=
symbol
| STRING
nonempty_symbol_list::=
symbol
| nonempty_symbol_list symbol
symbol::=
IDENT
I've just added
moonyaccgrammar to https://mingodad.github.io/parsertl-playground/playground/ anYacc/Lexlike online interpreter/editor (selectMoonyacc parserfromExamplesthen clickParseto see a parse tree for the content inInput source) and then generated anEBNFunderstood by https://github.com/GuntherRademacher/rr to generate a nice navigable railroad diagram (see bellow with instructions at the top).I also changed
bison/byacc/lemonto output a naked grammar and also anEBNFgrammar see here https://github.com/mingodad/lalr-parser-test , probably it's a good idea to have that onmoonyacctoo.I hope it can help document/develop/debug grammars !