[antlr-interest] Heterogeneous token types

C.P.T.de.Gouw at cwi.nl C.P.T.de.Gouw at cwi.nl
Wed Feb 3 14:32:39 PST 2010


> I think you override emit()

That is indeed what I'm doing, good to hear I'm on the right track :)

But if I refer to a token in a parser action (with $token), it's of type
CommonToken, and not the subclass of Token that I'm emitting. I can't use
the TokenLabelType option, since different tokens emit different types of
token Objects.

Obviously I can cast $token in the parser action to the appropriate type,
but I hoped this would not be necessary.


Stijn


More information about the antlr-interest mailing list