string literal parse problem

Nov 11, 2010 at 4:21 PM

The following JavaScript:

var s = @string?";

(I actually came across this first by copy/pasting a quoted string from a Word document where the quotes where "smart quotes").

will fail to compile with a null reference exception with this stack trace:

   at Antlr.Runtime.RecognitionException..ctor(String message, Exception inner, IIntStream input)
   at ES3Lexer.ConsumeIdentifierUnicodeStart()
   at ES3Lexer.mIdentifier()
   at Antlr.Runtime.Lexer.NextToken()
   at ES3Lexer.NextToken()
   at Antlr.Runtime.CommonTokenStream.FillBuffer()
   at Antlr.Runtime.CommonTokenStream.LT(Int32 k)
   at ES3Parser.program()
   at Jint.JintEngine.Compile(String source, Boolean debugInformation)
   at Jint.JintEngine.Run(String script, Boolean unwrap)

The ES3Lexer.ConsumeIdentifierUnicodeStart() method is trying to throw an Antrl.Runtime.NoViableAltException(). This default constructor calls the Antlr.Runtime.RecognitionException() default constructor which invokes the this(null,null,null) constructor. However, that constructor throws the NullReferenceException because eventually it tries to dereference the third parameter which the default constructor passed in as null...

Absent a fix in the Antlr code, if the ES3Lexer used this NoViableAltException() constructor:

NoViableAltException(string grammarDecisionDescription, int decisionNumber, int stateNumber, IIntStream input)

then the NullReferenceException would not occur since the input parameter gets passed ot the base constructor...

Hope you find this useful...



Nov 11, 2010 at 4:24 PM

This seems to have been reported as:

Sorry about that.


Nov 11, 2010 at 5:03 PM

Closed issue. Hope the correction is ok for you.

Nov 11, 2010 at 5:04 PM

Well maybe you intended to patch the antlr version ... I will check if there are new version available.