[antlr-interest] token name from token type

Ketan Maheshwari ketancmaheshwari at gmail.com
Tue Mar 30 08:18:04 PDT 2010


Hello (Again)

I am playing with the CommonTree object. It has a method called getType()
that gives an int for token. How do I get the actual token name from that
int?

I saw in the archives that this question is asked but could not really find
the method String getTokenName(int) as answered in that post. Instead, I
find the method String[] getTokenNames() which is not suitable to my need.

Also here in the javadoc for Parser class, a method called String
getTokenName(int ) appears but it does not seem to be available in my parser
class which is an infact extended from parser class.

Thanks for your answers.

Ketan


More information about the antlr-interest mailing list