Edit: What you are seeing is a lexer error, not a parser error. You need to update your lexer to ensure the lexer is incapable of failing to match an input character by adding the following as the last rule of your lexer. This will pass the erroneous character on to the parser for handling (reporting, recovery, etc.).
ERR_CHAR : . ;
In addition to this, you need to perform the general steps below which apply to configuring the parser for simple string recognition.
You need to do two things for this to work properly:
First, disable the default error reporting mechanism(s).
parser.removeErrorListeners();
Second, disable the default error recovery mechanism(s).
parser.setErrorStrategy(new BailErrorStrategy());
You'll get a ParseCancellationException
, and no other reporting, if your string does not match.
If you aren't using the output from the parse operation, you may also wish to improve the efficiency of the recognition process by disabling parse tree construction.
parser.setBuildParseTree(false);