[antlr-interest] AntLR C# target exceptions problem

Jan Newger Jan.Newger at rwth-aachen.de
Mon Apr 13 08:19:53 PDT 2009


Sam Harwell wrote:
> It's a good idea to override ReportError, and this will almost surely
> provide you with the results you want. You can also put a breakpoint in
> NoViableAltException's constructor. 
> 

So you are proposing that I override ReportError and re-throw the
exception? I basically want this code to work as expected (taken from
http://www.antlr.org/wiki/display/ANTLR3/Five+minute+introduction+to+ANTLR+3):

try {
            parser.expr();
        } catch (RecognitionException e)  {
            Console.Error.WriteLine(e.StackTrace);
        }

Since the RecognitionException is swallowed within the parser itself and
the default implementation of ReportError doesn't rethrow it by itself,
this code doesn't work as expected, i.e. the catch block can never be
executed. Correct?

Cheers
Jan


More information about the antlr-interest mailing list