I am trying to integrate an ANTLR-defined grammar into NetBeans, and so far valid syntax is working fine. However, currently if you enter any character that's not defined in the language somewhere (for example, the '?' character) the custom editor immediately crashes because it fails to find a rule for that character.
Is there a way in ANTLR to catch and skip EVERY character that doesn't match a rule (and perhaps output an error message) without having the whole lexer crash and burn? I would like to just flag invalid characters, skip over them, and continue lexing, something like:
//some rules + tokens
invalidCharacter
: <<catch all other characters>>
{System.out.println("undefined character entered!")}
;
Any help would be apprciated.