Add an IDENTIFIER
lexer rule to handle words which are not keywords.
IDENTIFIER : [a-zA-Z]+;
Now the text nottrue
is a single IDENTIFIER
token which your parser would not accept in place of the distinct keywords in not true
.
Make sure IDENTIFIER
is defined after your other keywords. The lexer will find that both NOT
and IDENTIFIER
match the text not
, and will assign the token type to the first one that appears in the grammar.