I have PL/0 as a sample grammar for my Dylan PEG parser at 
http://www.opendylan.org/cgi-bin/viewvc.cgi/trunk/libraries/utilities/peg-parser/.
 The notation is straightforward. I can also send you the Dylan language 
grammar if you are interested, but it is basically an adaptation of the LL(1) 
(or whatever) grammar, and is not optimized for efficient PEG parsing. (I do 
not remember if I recreated the PL/0 grammar as PEG from the ground up, 
but...come on...PL/0 can be parsed by a coin-sorting machine.)

On Jun 3, 2010, at 8:45 AM, Marcus Nordenstam wrote:

> Hello,
> 
> I just saw this mailing list, and figured if there's anywhere people
> may know the answer to this question, it would be here.
> 
> I've been using the peg/leg parser generator tool to make C++ PEG
> parsers (I modified it slightly so that it would generate C++ code
> instead of ANSI C).
> 
> I'm trying to write a simple expression grammar using PEG and, like
> everyone else I guess, have run into the left recursion issue.  The
> primary issue I have is the simplest kind, e.g.:
> 
> sum  <- sum PLUS term
>           / sum MINUS term
>           / term
> 
> term  <- term DIV value
>           / term MUL value
>           / term MOD value
>           / value
> 
> value  <- float-constant
>           / int-constant
>           / POPEN sum PCLOSE
> 
> note that I've written terminals in all caps above.
> 
> Now I can rewrite the grammar to eliminate the left-recursion, but
> doesn't that change the associativity of the parse?  That would be
> quite bad since this grammar is primarily for mathematical
> expressions...
> 
> So my question is: is anyone aware of an implementation (preferably in
> C or C++) which could parse the above grammar?  Even if it's not a
> perfect tool, anything would be a better starting point for me than
> having to implement one of the left-recursion PEG papers from scratch
> :-)
> 
> cheers
> Marcus
> 
> _______________________________________________
> PEG mailing list
> PEG@lists.csail.mit.edu
> https://lists.csail.mit.edu/mailman/listinfo/peg


_______________________________________________
PEG mailing list
PEG@lists.csail.mit.edu
https://lists.csail.mit.edu/mailman/listinfo/peg

Reply via email to