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

Piotr Kaleta piotrek.kaleta at gmail.com
Wed Jan 26 15:19:18 PST 2011


You might need to introduce the Tree adaptor if you're using the custom type
of tree nodes. It's described here:
http://www.antlr.org/wiki/display/ANTLR3/Tree+construction

On Thu, Jan 27, 2011 at 8:57 AM, Bart Kiers <bkiers at gmail.com> wrote:

> 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.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>



-- 
Piotr Kaleta


More information about the antlr-interest mailing list