> Howdy,
> 
> I believe I'm running into a bug in the constructors of class
> RecognitionException in the CSharp code of Antlr.Runtime.

You are right with your analysis. Comparing it with the Java version I see that 
only 2 constructors are there - the empty one as well with the single parameter 
IIntStream input. Not sure if I put those extras in there but my assumption is 
that those are there to make the exceptions more .NET-like. The correct way to 
deal with this issue is either to make those troublesome constructors call the 
base constructors directly or to remove them if Sam Harwell won't incorporate 
them, too.

Johannes
> 
> 5 of the 6 constructors of RecognitionException call this version (with
> various parameters 'nulled' out):
>       public RecognitionException(string message, Exception inner, IIntStream
> input)
> 
> 3 of the 6 call the above constructor with null for the IIntStream input
> parameter. Unfortunately, the 2nd line of this constructor is:
>       this.index = input.Index();
> which immediately throws the infamous 'Object reference not set to an
> instance of an object' exception (since input is null).
> 
> The most obvious way to encounter the bug is to throw a new
> RecognitionException upon discovery of some 
> 'otherwise-not-an-Antlr-exception' situation
> (like the number of expressions in an expression_list doesn't match what a
> function call needed), e.g.:
>       throw new RecognitionException("Improper number of parameters in
> function");
> 
> (Just a simple example, in real life I do a better job of reporting an
> error than this! :-)
> 
> My workaround is either:
>       1) Capture the IIntStream from earlier in the process and call a
> different constructor:
>       throw new RecognitionException("Improper blah,
> blah",MyCapturedIIntStream);
>       2) Throw an exception unrelated to RecognitionException.
> 
> But it should be easy to fix.
> Thanks,
> 
> -John
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser

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

--

You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.


Reply via email to