Hi Alexander, I finally had some time to locate and read your "An alternative to left recursion" message <http://www.mail-archive.com/peg@lists.csail.mit.edu/msg00132.html>
If I'm looking at the right message, I must admit that I'm a little confused. You give this example: "Of course, these one-shot gulper rules are no more than syntactic sugar for ordinary PEG rules. id_0 <- e_0 (?) id_1: e_1 / id_2: e_2 / ... / id_n: e_n is essentially equivalent to id_0 <- id_1 / id_2 / ... / id_n / e_0 id_1 <- e_1, e_0 ... id_n <- e_n, e_0" Did you mean: id_1 <- e_0, e_1 ... id_n <- e_0, e_n Assuming that your example was transposed, I'm still not clear on what you expect the resulting parse-tree to look like. I struggled to decide the semantic value of sequential composition, but eventually followed OMeta's convention. The value of matching a sequence is the value of the last pattern in the sequence. Since semantic expressions act as patterns (always matching but consuming no input), I might express the "id_1" rule like this: id_1 = e_0 :h e_1 :t $<#id_1, h, t> The intended meaning is: match e_0, bind the value of e_0 to h, match e_1, bind the value of e_1 to t, generate a new semantic value as a 3-tuple beginning with the literal symbol "id_1" and containing the values of h and t. Before I try to apply these principles to your (*) examples, I want to be sure I'm on the right track. Can you help clear up my confusion? On Wed, May 4, 2011 at 1:47 AM, Alexander Tsyplakov <t...@academ.org> wrote: > Dale Schumacher wrote Tuesday, May 3, 2011, 7:48:05: > DS> Was http://bit.ly/iVXPEJ+ sufficiently clear? Are there any problems > DS> you see with it? > > DS> Are there cases of left-recursion which are not amenable to the > DS> iteration/accumulator approach? > > This is somewhat similar to what I was talking about in a > post to this list in 2008. Google for "An alternative to > left recursion". > > I would prefer to disagree with your approach, however. It > is good if a grammar describes not only the syntax, but also > the semantics. In your approach semantics is hidden in an > additional layer (like building parsing tree). > > Let me reiterate my suggestion. PEG needs what I called > "gulping rules": > > A followed by B becomes C. > > Then C gulps A followed by B. Rules of this kind when > applied finite number of times just add some syntactic > sugar to PEG. But the possibility of infinite repetition in > "gulping rules" is an extension which is a saner alternative > to left recursion. > > David-Sarah Hopwood wrote Tuesday, May 3, 2011, 20:37:52: > DSH> Refactoring to remove left-recursion is always > DSH> possible, but sometimes inconvenient. > > My impression is that left recursion approach is liable to > all kinds of mess. It is a headache to make sense of it. So > keeping one's grammar in a left recursion form can be > potentially harmful. > > Alexander Tsyplakov > > > _______________________________________________ PEG mailing list PEG@lists.csail.mit.edu https://lists.csail.mit.edu/mailman/listinfo/peg