Howdy,
I believe I'm running into a bug in the constructors of class
RecognitionException in the CSharp code of Antlr.Runtime.
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
--
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.