[antlr-interest] Avoiding ClassCastExceptions in org.antlr.runtime.tree.BaseTree (Limitation in ANTLR v 3.1)
Terence Parr
parrt at cs.usfca.edu
Tue Jan 20 15:01:29 PST 2009
Cool. done. fixed in my development branch. I changed one of the
method also.
Ter
On Oct 2, 2008, at 6:26 AM, Tim Halloran wrote:
> 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.
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
More information about the antlr-interest
mailing list