[antlr-interest] Possible serious bug using setText in Antlr3

Terence Parr parrt at cs.usfca.edu
Wed Nov 15 08:55:38 PST 2006


On Nov 14, 2006, at 10:16 PM, shmuel siegel wrote:

> The wiki page, "how do I strip quotes", recommends using setText to  
> change the text of the token to be generated. For example
>
> ESC : '\\' 'n' {setText("\n");};
>
> As far as I can tell, this sets an instance variable of the lexer  
> to the specified text. Emit then adds this text to generated  
> tokens. getText will then preferentially return this text rather  
> than build a string from the character stream. So far, so good. But  
> nothing changes the instance variable back to null. So all future  
> tokens will have the same text.
>
> setting text=null in nextToken seems to work for me.

Yes, you are right.  I have that fix already in 3.0b5 coming out  
today :)

Ter


More information about the antlr-interest mailing list