Inside the parser rules .. does not work as a range operator for characters, as in lexer rules. Also note that even if you defined literals inside parser rules, ANTLR created lexer rules for them on the fly by doing the following:
my_cmd : 'start' '0'..'9'+ Name_string ;
is equivalent to:
my_cmd : Start D0..D9+ Name_string ; Start : 'start'; D0 : '0'; D9 : '9';
If I need memory, earlier versions of ANTLR v3 support for the range operator inside the parser rules mean: matching any token between D0 and D9 , but that / was extremely fragile. Adding a rule between D0 and D9 will change its value:
D0 : '0'; FOO : 'foo'; D9 : '9';
Parser rule:
my_cmd : '0'..'9'+ ;
will now correspond to one of the following tokens: D0 , FOO or D9 .
This support .. inside the parser rules has been removed (at least) v3.3 and higher. Therefore, do not use the rules .. inside the parser rules.
source share