[antlr-interest] TokenLabelType doesn't work because of "EOF_TOKEN = new CommonToken(EOF)"
arjode at uni-koblenz.de
arjode at uni-koblenz.de
Mon Jun 16 02:03:04 PDT 2008
Hi all,
I try to use my own token class (which extends "CommonToken"). For this
I've set the "TokenLabelType" option and overriden "Lexer.emit()". But
I've got class cast exceptions because the EOF_TOKEN is hardcoded to the
type of "CommonToken" in the "Token" interface.
public static final Token EOF_TOKEN = new CommonToken(EOF);
This way "Token" depends on "CommonToken" ... looks bad, doesn't it? This
way the "TokenLabelType" option can't work as any cast to "MyTokenType"
can fail (and ANTLR generates such casts in the parser). Or is there
something else I have to do to use my own token type?
Thanks,
Arne
More information about the antlr-interest
mailing list