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

Thomas Brandon tbrandonau at gmail.com
Thu Aug 16 01:20:58 PDT 2007


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?
>
> @lexer::override {
>         public override void ReportError(RecognitionException e)
>         {
>         }
> }
>
> (method signature taken from Antlr.Runtime.BaseRecognizer) compiles OK
> but makes no difference.
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
the C# target funnels all errors through Lexer.ReportError so
something like this should work.

Tom.
>
>         Bye
>                 Vasek
>
>


More information about the antlr-interest mailing list