[antlr-interest] Avoiding ClassCastExceptions in org.antlr.runtime.tree.BaseTree (Limitation in ANTLR v 3.1)
Tim Halloran
hallorant at gmail.com
Thu Oct 2 06:26:38 PDT 2008
3.1.1 didn't fix the below problem. I can't get into Jira; but I think the
below is really a bug.
On Wed, Sep 24, 2008 at 2:03 PM, Tim Halloran <hallorant at gmail.com> wrote:
> I'm using the standard Tree implementations (extending BaseTree) in
> combination with a custom implementation of Tree. The problem is that
> BaseTree assumes that it is only being used with subclasses of BaseTree
> despite it's implementation really not needing to make this assumption. I
> propose fixing the code to eliminate this problem.
>
> I modified the getChild() and toStringTree() methods in BaseTree.java. I
> changed lines 56 and 297 to cast to Tree, instead of BaseTree. For
> example:
>
> public Tree getChild(int i) {
> if ( children==null || i>=children.size() ) {
> return null;
> }
> return (Tree) children.get(i); // line 56
> }
>
> There might be some other places to change, but I have only encountered
> problems with these.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081002/1dcbc83b/attachment.html
More information about the antlr-interest
mailing list