Hello! I implemented a PEG left recursion in TatSu using a single cache of recursive rule results, plus guards in the memoization cache.
https://github.com/apalala/TatSu/blob/master/tatsu/contexts.py#L475-L557 It's only a few lines of code once the TatSu-specific bookkeeping is ignored. All the test cases that were reported against Grako pass, with correct (left) associativity, including those with indirect left recursion. https://github.com/apalala/TatSu/blob/master/tatsu/test/grammar/left_recursion_test.py I'll find some time to write a (n informal) paper about the algorithm next weekend (the algorithm should be easier to explain if recursion is used in place of the while loop). Your comments are not only welcome, but eagarly awaited. Cheers! -- Juancarlo *Añez*
_______________________________________________ PEG mailing list PEG@lists.csail.mit.edu https://lists.csail.mit.edu/mailman/listinfo/peg