[antlr-interest] AntLR C# target exceptions problem

Sam Harwell sharwell at pixelminegames.com
Mon Apr 13 08:14:21 PDT 2009


The error handling mechanisms are fairly complicated, but adding your
own handlers is easy.

Just call the base versions after you do what you want:

public override void ReportError( RecognitionException e )
{
  // do something, the StackTrace for e will tell you where the error
occurred
  base.ReportError( e );
}

You can read more details about the ErrorHandling here:
http://www.antlr.org/wiki/display/ANTLR3/Error+reporting+and+recovery

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jan Newger
Sent: Monday, April 13, 2009 10:08 AM
To: Johannes Luber
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] AntLR C# target exceptions problem

Thanks for your quick response, Johannes. Actually, I don't want to
override the error reporting mechanism, I just want the runtime to throw
the respective exceptions when the input is malformed (just in the same
way the java runtime does it).
Is the behavior I previously described considered a bug or is this "by
design"? It seems odd to me that exceptions are swallowed within the
parser itself. So even if I where to replace the error reporting
mechanism, I would change the error message of an exception which never
reaches my code in the first place. IMHO this is ether a serious bug or
I'm doing something incredibly stupid here.

Cheers
Jan

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


More information about the antlr-interest mailing list