Can't see my mistake here. Given a simple palindrome grammar:
// test1.g
grammar test1;
start
: 'a' start 'a'
| 'b' start 'b'
| 'a'
| 'b'
|
;
WS : [ \t\r\n]+ -> skip ;
when given the input aabbbaa
, the generated parser reports:
line 1:5 mismatched input 'a' expecting 'b'
But it looks like legal input to me. Antlr v4.1.
The problem here is you did not include a rule like the following:
entry : start EOF;
By omitting the EOF
, you've hit a bug #118 that can manifest in certain stack-sensitive parsing situations (decision is LL, not SLL). The performance impact of fixing this issue was massive (cannot be understated), so until we find another way to address the problem you'll need to be aware of this and make sure to start parsing with a rule that ends with an explicit EOF
symbol.