Feature request: remove direct left recursion option.
Hi Kate,
Thanks for writing this great tool!
Railroad Diagram Generator has an option to remove direct left recursion from a production. This is really great option to have when one wants to implementing a recursive descent parser for grammars that have a lot of left recursion such as C89 etc.
For example:
MULTIPLICATIVE_EXPRESSION ::=
CAST_EXPRESSION |
MULTIPLICATIVE_EXPRESSION '*' CAST_EXPRESSION |
MULTIPLICATIVE_EXPRESSION '/' CAST_EXPRESSION |
MULTIPLICATIVE_EXPRESSION '%' CAST_EXPRESSION
will be simplified to:
MULTIPLICATIVE_EXPRESSION
::= CAST_EXPRESSION ( ( '*' | '/' | '%' ) CAST_EXPRESSION )*
which also leads to a better understanding via the produced railroad diagram.
Would it be possible to add this as a feature?
Regards, Niels.
Hi, thanks for this! There're a whole bunch of common grammar transformations. This is a good one. Originally I'd intended this tool to be mainly about these, and then I never actually implemented any of them.
So yes, this is exactly something that could be done. It'd apply before any output, it isn't specific to generating diagrams. So you'd be able to use this for BNF output, for example.
Would you like to implement it? 😅