[antlr-interest] Expression grammars and *non*-ambiguities

Andrew Gacek andrew.gacek at gmail.com
Fri Aug 17 11:56:20 PDT 2012

I have investigated this a bit more. The following grammar is flagged
as ambiguous by ANTLR, but the resulting parser seems to make the
correct decisions. Is there a sensible way to rewrite the grammar to
remove the ambiguity?

expr: term;

term: factor ('+' factor)*;

factor: atom ('*' atom)*;

| '(' expr ')'
| 'if' expr 'then' expr 'else' expr

INT: ('0'..'9')+;


More information about the antlr-interest mailing list