On Nov 12, 2010, at 1:14 PM, Peter Cashin wrote: > ... I don't find left recursion intuitive despite playing with it for years > (but some others seem to have better intuition). I don't think its a very > good idea for grammar language specifications.
Hi Peter, The only time that left recursion makes sense to me is in expressions, or any other construct, that is postfix operators. It feels right for me to do E <- E '[' E ']' E <- E '(' Elist ')' E <- INTEGER E <- ID But, that's the only time I feel like using it and that it makes sense to my brain. For ANTLR v4, I have a prototype mechanism that let you specify left recursive grammars for expressions. Instead of converting to loops, it retains the proper parse tree construction / recursion an LR parser would make. here is what I wrote up on a while back: http://www.antlr.org/wiki/display/~admin/2008/04/10/Still+more+about+expression+parsing It leverages the original work by Keith Clarke I believe http://www.eecs.qmul.ac.uk/~keithc/compilers/posted-expr-code-96-04-026.html since I wrote that blog entry, I had a student implement a prototype works pretty darn well. Ter _______________________________________________ PEG mailing list PEG@lists.csail.mit.edu https://lists.csail.mit.edu/mailman/listinfo/peg