soundsgood. i updated antlr v3 mainline:
public Object create(int tokenType, Token fromToken, String text) {
if (fromToken == null) return create(tokenType, text);
fromToken = createToken(fromToken);
fromToken.setType(tokenType);
fromToken.setText(text);
Tree t = (Tree)create(fromToken);
return t;
}
Ter
On Nov 9, 2009, at 4:14 PM, Sam Harwell wrote:
> Currently, BaseTreeAdaptor has the following method:
>
> public Object create(int tokenType, Token fromToken, String
> text) {
> fromToken = createToken(fromToken);
> fromToken.setType(tokenType);
> fromToken.setText(text);
> Tree t = (Tree)create(fromToken);
> return t;
> }
>
> When a grammar has something like the following (and now I forgot
> what exactly caused me to hit this…), and a recoverable error occurs
> in parsing, this method could be called with a null fromToken, and
> the copy constructor for CommonToken will throw a
> NullReferenceException (in C#). The following modification allows
> recovery by falling back in this case to the type/text create method.
>
> public Object create(int tokenType, Token fromToken, String
> text) {
> if (fromToken == null)
> return create(tokenType, text);
>
> fromToken = createToken(fromToken);
> fromToken.setType(tokenType);
> fromToken.setText(text);
> Tree t = (Tree)create(fromToken);
> return t;
> }
>
> Sam
> _______________________________________________
> antlr-dev mailing list
> [email protected]
> http://www.antlr.org/mailman/listinfo/antlr-dev
_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org/mailman/listinfo/antlr-dev