Hello. I'm using a famous instrument for generating text editor for Eclipse (Xtext). Xtext generates an antlr grammar to create parser. When working with this instrument I got some errors and started to test antlr and I found some strange thing. For the next grammar (which is a simplified version of generated one):
grammar InternalMyDsl2;
model: translation_unit;
translation_unit: (declaration ';')*;
entryRulenest_rule :
nest_rule
EOF
;
nest_rule: ID?;
entryRuledeclaration:
declaration
EOF
;
declaration: 'decl' nest_rule ID EOF?;
fragment LETTER : ('$'|'A'..'Z'|'a'..'z'|'_');
ID : LETTER (LETTER|'0'..'9')*;
WS : (' '|'\t'|'\r'|'\n')+;
ANY_OTHER : .;
I get the next error from antlr3.5:
>java -jar antlr-3.5-complete.jar InternalMyDsl2.g
error(202): InternalMyDsl2.g:12:12: the decision cannot distinguish between alternative(s) 1,2 for input such as "ID EOF EOF"
Why? Can anybody explain me - where are these alternatives?