[antlr-interest] Re: Unexpected char when generating lexer
Xue Yong Zhi
seclib at seclib.com
Tue Dec 20 12:40:15 PST 2005
I have seen a similar issue and did what you did (remove '$').
Look like a bug for me.
Xue Yong Zhi
http://seclib.blogspot.com
Thiago Arrais wrote:
> 2005/12/20, Gregg Reynolds <dev at arabink.com>:
>
>>Try using single quotes: '\u0000'. That works for me.
>
>
> Weird. The following grammar (with single quotes) gives me the same error.
>
> ---- start grammar ---
> class TestLexer extends Lexer;
>
> ASCII : "NUL" { $setText('\u0000'); } ;
> ---- end grammar ---
>
> I have antlr 2.7.5 here. What version are you using?
>
> This is pretty weird, the docs for my version say that the semantic
> action blocks are simple character sequences. Although, in these
> special case, they aren't (i.e. the '$' isn't pure Java and needs to
> be translated into Java code by antlr).
>
> When fed with this other slightly different grammar, antlr is able to
> generate code. This one doesn't have the '$' special character.
>
> ---- start grammar ---
> class TestLexer extends Lexer;
>
> ASCII : "NUL" { setText("\u0000") ;} ;
> ---- end grammar ---
>
> This approach worked for me, but I wonder if there is any hidden issue now.
>
> Any ideas?
>
> Thanks,
>
> Thiago Arrais
>
More information about the antlr-interest
mailing list