[antlr-interest] bad prediction on common prefix despite enough lookahead depth
Maurizio de Pascale
mdepascale at dii.unisi.it
Sun Dec 31 10:43:45 PST 2006
Using the small grammar below ANTLR 2.7.7 reports no warning but the
generated lexer fails to parse the input ">>":
in fact, the code generated for nextToken() uses only LA(1) and LA(2) to
predict the C token, despite the lookahead depth set to 3, and then
throws for the missing '='...
Here are the questions:
Is this a bug or am I missing something?
Is D: (">>=")=> C | B | A; the best solution?
Is this related to the linear approximate lookahead?
should it spit out at least a warning?
does ANTLR3 correctly handle this?
thank you in advance,
Maurizio de Pascale
mdepascale at dii.unisi.it
TEST.G:
options {language="Cpp";}
class TestLexer extends Lexer;
options {k=3;}
A : '>' ;
B : '=' ;
C : ">>=" ;
More information about the antlr-interest
mailing list