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

Reply via email to