[antlr-interest] How to best resolve ambiguity?

Martin Traverso mtraverso at gmail.com
Fri Dec 30 17:06:24 PST 2005


Howdy,

What is the best way to resolve the ambiguities caused by 'D' a in rule c in
the following grammar?

grammar T;
a: b ('+' b)*;
b: c ('*' c)*;
c: 'D' a
   | 'x';


Essentially, I want it to parse stuff like:

x * x + x * x
D x * x + x * x    (should parse as D ((x * x) + (x * x)) )
x + D x * x + x * x  (should parse as x + D ((x * x) + (x * x)) )
D x + D x  (should parse as D (x + D x) )
etc.

Thanks,
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20051230/50b6a646/attachment.html


More information about the antlr-interest mailing list