[antlr-interest] C# target: .NET Framework bug causing NullReferenceException, must use this workaround

Sam Harwell sharwell at pixelminegames.com
Fri Aug 8 14:11:08 PDT 2008


Here is the bug report I filed with MS:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Fe
edbackID=361125

The error occurs in
Antlr.Runtime.BaseRecognizer.GetErrorMessage(RecognitionException e,
string[] tokenNames):

msg = "mismatched tree node: " + mtne.Node + " expecting " + tokenName;

This line must be changed to:

string mismatchedNode = null;
if ( mtne.Node != null )
{
	mismatchedNode = mtne.Node.ToString();
}
msg = "mismatched tree node: " + mismatchedNode + " expecting " +
tokenName;

According to ECMA-334, it is fine if mismatchedNode is null at the time
of concatenation.

Sam


More information about the antlr-interest mailing list