[antlr-interest] org.antlr.runtime.CommonToken cannot be cast to org.antlr.runtime.tree.Tree

Bart Kiers bkiers at gmail.com
Wed Jan 26 13:57:50 PST 2011


On Wed, Jan 26, 2011 at 10:40 PM, Ching <zching01 at gmail.com> wrote:

> Can anyone tell me why I got this exception? My output is AST. Thanks.
>
>
Err, that error is pretty self-explanatory: you're trying to cast
a org.antlr.runtime.CommonToken to a org.antlr.runtime.tree.Tree, which is
illegal. As you can see from ANTLR's class hierarchy:
http://www.antlr.org/api/Java/hierarchy.html
the two can't be cast (either CommonToken->Tree or Tree->CommonToken).

Perhaps you don't understand where this happens in your grammar? In that
case, please show your grammar as well.

Regards,

Bart.


More information about the antlr-interest mailing list