[antlr-interest] Confusion over token definitions and alternatives being disabled
Kieran Simpson
kierans777 at gmail.com
Tue Mar 6 03:19:06 PST 2012
I have the following token defs for my grammar:
ANY_TEXT: ( options {greedy=false;} : . )+;
COMMENT
: '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
| '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
;
WS: ( ' ' | '\t' | '\r' | '\n') {$channel=HIDDEN;};
In Antlrworks, when I try to use an interpreter on a rule that uses
ANY_TEXT I'm informed:
"The following alternatives can never be matched: 1" (where the line
number is the ANY_TEXT definition)
"The following token definitions can never be matched because prior
tokens match the same input: COMMENT,WS"
I can see how ANY_TEXT could match a COMMENT or a WS, but not how those
token definitions would match input that ANY_TEXT would match (eg: "foo").
Cheers,
More information about the antlr-interest
mailing list