[antlr-interest] Lexer error reporting

Bill Andersen bill.andersen at mac.com
Wed Nov 23 08:41:52 PST 2011


Hi Folks...

Been trying to figure out how to shut off default Lexer behavior to print messages to System.err, such as:

	line 2:4 no viable alternative at character ' '

Instead, I'd like to catch these and do something with them.  Overriding reportError(RecognitionException) doesn't work and no other option seems obvious.

Doing this with a parser is easy - I just overrode emitErrorMessage in a custom subclass of Parser.  Got that done already, but can't seem to find out how to do the same in the lexer.

Any help appreciated.

	.bill



More information about the antlr-interest mailing list