[antlr-interest] Why is this ambiguous..
Peter Kooiman
peter at crispu.com
Thu Apr 7 05:49:54 PDT 2011
Hello,
While working on a grammar I had something that boils down to
grammar T;
start: (y | y C)+ EOF;
y: B (A)? | A;
A : 'a';
B : 'b';
C : 'c';
This gives an expected warning on rule y, that's fine, ANTLR does the right thing and matches A greedily.
However it also gives a warning on rule start:
T.g:2:19: Decision can match input such as "B {EOF, B..A}" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
I quite understand the need to left factor this, I was just wondering why ANTLR gives this warning. It must be staring me in the face but I don't see it...
How is this non-deterministic on input B EOF? Is ANTLR unable to see past rule y for some reason?
Thanks
Peter
More information about the antlr-interest
mailing list