Negating inside lexer- and parser rules
How can the negation meta-character, ~ , be used in ANTLR's lexer- and parser rules? Bart Kiers Negating can occur inside lexer and parser rules . Inside lexer rules you can negate characters, and inside parser rules you can negate tokens (lexer rules). But both lexer- and parser rules can only negate either single characters, or single tokens, respectively. A couple of examples: lexer rules To match one or more characters except lowercase ascii letters, you can do: NO_LOWERCASE : ~('a'..'z')+ ; (the negation-meta-char, ~ , has a higher precedence than the + , so the rule above equals (~('a'..