On Mon, May 8, 2017 at 6:08 PM, Juancarlo Añez <apal...@gmail.com> wrote:

> 4. If the parsed rule *R* is left-recursive and a parse succeeds, push
> the symbol *R* onto the front of the input stream (so it's the first/next
> symbol) and try to parse *R* again, repeating until the parse fails. When
> there's a fail pop an *R* symbol from the front of the input, and proceed.
>

Correction: It is not *"pop"*. Because there's a form of backtracking in
PEG, the parser should *advance* over the symbol, not *pop* it.

That also means that there's no *push*, but rather an *insert*.

That's how it is actually implemented in TatSu, and that's what allows a
second recursive option to succeed when the first one failed.

Cheers!


-- 
Juancarlo *Añez*
_______________________________________________
PEG mailing list
PEG@lists.csail.mit.edu
https://lists.csail.mit.edu/mailman/listinfo/peg

Reply via email to