This application removes left-corner cycles from a context-free grammar to make it more acceptable for LL parsers. Of course, this can change the associativity of operators in the language, and this does not resolve problems with first sets, follow sets, and nullable symbols.
Instructions: Enter productions in the format Sum: Sum + Product
. Multiple productions for the same symbol should be on separate lines. A non-terminal is a [A-Z][a-z]*
, and a terminal is any other non-whitespace string. Whitespace in the right-hand-side will be trimmed away. Epsilon productions are represented as a blank right-hand-side.
Note: I received an email about 10 years later with this bug report. The given example is easy to clean up by hand, but there may be more subtle issues arising from the same defect.
Pim van Leeuwen <p.vanleeuwen@redskies.nl> To: cortex@brainonfire.net Subject: Bug report: left recursion remover Date: Wed, 10 Jul 2019 22:53:14 +0200 Dear Tim, First of all, I'd like to thank you for online left-recursion removal tool; I found it very helpful. I am writing this e-mail, however, to bring to your attention that the tool behaves erroneous with some specific inputs. For example, the input Foo: Foo Foo: 5 will yield an output that is left recursive. One would expect to either see an error message or simply the result that Foo must be 5. This could be solved by initially removing any rules for which the right hand side is equal to the left hand side. I hope this e-mail is helpful to you, and I wish you the best of luck in your future programming efforts :) Best regards, Pim van Leeuwen