You are comparing objectsm which isn't a good idea really anyway. Instead
use getType and check for the Token.EOF type.

while ((token = lexer.nextToken()).getType() !=
org.antlr.runtime.Token.EOF)

Which I think Javac will handle.

Jim

> -----Original Message-----
> From: antlr-dev-boun...@antlr.org [mailto:antlr-dev-boun...@antlr.org]
> On Behalf Of Frank Schilder
> Sent: Tuesday, January 18, 2011 8:04 AM
> To: antlr-dev@antlr.org
> Subject: [antlr-dev] ANTLR 3.3 and token.EOF_TOKEN
>
>
>
> After updating to 3.3, the following while-loop in my code for calling
> a lexer never stops (i.e. The condition never becomes true):
>
> while ((token = lexer.nextToken()) !=
> org.antlr.runtime.Token.EOF_TOKEN)
> {...}
>
>
> In order to fix this problem, I changed my code to get the token before
> I call the while-loop and check for the type directly, which works
> fine, but I would prefer the above code because it's shorter.
>
> I noticed the following line in the release notes:
> - Instead of sharing Token.EOF_TOKEN, I'm now creating EOF tokens so I
> can set the char position for better error messages.
>
> That change seems to be the cause of my problem.
>
> Thanks,
> Frank
>
>
> _______________________________________________
> antlr-dev mailing list
> antlr-dev@antlr.org
> http://www.antlr.org/mailman/listinfo/antlr-dev
_______________________________________________
antlr-dev mailing list
antlr-dev@antlr.org
http://www.antlr.org/mailman/listinfo/antlr-dev

Reply via email to