[antlr-interest] Possible bug in code generated for Lexer?
Gevik Babakhani
gevik at xs4all.nl
Wed Jun 20 08:34:35 PDT 2007
I am new to this, but I think this is not a bug. See THE BOOK page 114/5.10
the SL3Token will be generated in the Parser code not in the Lexer.
Hope it helps.
> Hi
>
> I reported this before and got no response from anyone. Hopefully this
> time
> I'll be more lucky.
>
> I have the option:
> TokenLabelType=SL3Token
>
> in my parser, where SL3Token extends CommonToken. [I want to save the name
> of included file in the tokens.]
>
> This lexer rule:
>
> INCLUDE
> : 'include' (WS)? f=STRING ;
>
> generates code like this:
>
> public final void mINCLUDE() throws RecognitionException {
> try {
> int _type = INCLUDE;
> SL3Token f=null;
> ..... stuff ......
> f = new CommonToken(input, Token.INVALID_TOKEN_TYPE,
> Token.DEFAULT_CHANNEL, fStart190, getCharIndex()-1);
> ..... more stuff .....
> }
>
> which unfortunately is a Java error since it's trying to assign a
> CommonToken to an SL3Token. I think this must be an Antlr bug.
>
> Regards
>
More information about the antlr-interest
mailing list