Jan. 21, 2011
2:38 p.m.
I know how to left-factor the grammar by hand. But should I have to? How powerful is thy magic, Lukas?
There is no magic. You can fix the problem by wrapping one of the parsers in the cycle with #memoize. That could be done automatically (#cycleSet finds the cycles), but I would rather refactor the grammar as it leads to extremely inefficient parsers. If you want to build complicated expression grammars (where typically left-recursion occurs) it might be useful to use the PPExpressionParser, see the class comment for an example. Lukas -- Lukas Renggli www.lukas-renggli.ch