[antlr-interest] TreeAdaptor
Sean Walton
swalton at cs.utah.edu
Mon Aug 14 05:41:17 PDT 2006
Terence Parr wrote:
> On Aug 10, 2006, at 7:15 AM, Emond Papegaaij wrote:
>
>> Hello
>>
>> I'm trying to implement my own version of the TreeAdaptor interface, but
>> have a few questions:
>>
>> What is the 'getUniqueID' used for? Is it supposed to simply return a
>> unique number for every node? As the Javadoc states using
>> 'hashCode()' is
>> dangerous. Maybe 'System.identityHashCode()' is an option?
>
> Didn't know about that! Sweet...yes, that is it. We need this for
> sending events to the debugger. Added to list.
>
>> What are the 'getChild(int i)' and 'getChildCount()' methods supposed to
>> do? They are not being used anywhere. On which children do they operate?
>> Maybe an additional method argument 'Object node' needs to be added?
>
> doh! Changed to:
>
> /** Get a child 0..n-1 node */
> public Object getChild(Object t, int i);
>
> /** How many children? If 0, then this is a leaf node */
> public int getChildCount(Object t);
>
> Change 2870.
>
> Ter
>
You know, this wasn't necessary. The 'getChild()' and 'getChildCount()'
methods simply *used to* operate on the current node, because the child
can be a parent to a different child. The new method looks more like a
static call, because it is now independent (i.e., 'static') from the
current node, resolving getChild() through 't' and not the current
instance. If that is the case, it is a more confusing interface than
the first.
-Sean
More information about the antlr-interest
mailing list