grammar Test;
IDHEAD: ('a'..'z' | 'A'..'Z' | '_');
IDTAIL: (IDHEAD | '0'..'9');
ID: (IDHEAD IDTAIL*);
fragment
TYPE: ('text' | 'number' | 'bool');
define: 'define' ID 'as' TYPE;
The problem is that the define
rule matches the tokens define
, ID
, as
, but wont match TYPE
. I'm yielding a MissingTokenException.
If I inline the TYPE, as follows, it works as I'm intending:
grammar Test;
IDHEAD: ('a'..'z' | 'A'..'Z' | '_');
IDTAIL: (IDHEAD | '0'..'9');
ID: (IDHEAD IDTAIL*);
fragment
TYPE: ('text' | 'number' | 'bool');
define: 'define' ID 'as' ('text' | 'number' | 'bool');
Update: The fragment
keyword was added in an effort to resolve another conflict: The following token definitions can never be matched because prior tokens match the same input: TYPE
.