[antlr-interest] How to stop lexer reporting errors to standard output?

Vaclav Barta vbar at comp.cz
Thu Aug 16 01:52:27 PDT 2007


Thomas Brandon wrote:
> On 8/16/07, Vaclav Barta <vbar at comp.cz> wrote:
>> Thomas Brandon wrote:
>>> On 8/16/07, Vaclav Barta <vbar at comp.cz> wrote:
>>>> I'm writing a library (parsing SQL, among other things) using ANTLR
>>>> (3.0, C# target), and I'd like it not to try any error recovery, but
>>>> just throw an exception on invalid input (so that the library user can
>>>> decide what to do about the error). I've managed to suppress error
>>>> recovery by specifying an empty @rulecatch, but I still occasionally get
>>>> warnings on standard output, i.e.
>>> Override reportError in your lexer and do general handling there.
>> Err, how?
> Not familiar with C# runtime but I think that should be
> @lexer::members not @lexer::override. Couldn't see any reference to
> override action scope in the C# target. But if it's spitting out the
> code in the generated file then that should work too. It looks like
Yes,

@lexer::members {
	public override void ReportError(RecognitionException e)
	{
	}
}

does it - many thanks.

          Bye
                  Vasek



More information about the antlr-interest mailing list