[antlr-interest] Appropriate use of honey badger listeners
Gerald Rosenberg
gerald at certiv.net
Thu Jan 12 20:29:47 PST 2012
On 1/12/2012 3:39 PM, Terence Parr wrote:
> On Jan 11, 2012, at 8:39 PM, Kyle Ferrio wrote:
>
>> Hi Ter,
>>
>> I don't have answers, but I have questions which might at least cut off some dead ends...
>>
>> I agree that point #2 seems pretty clear. And I realize that this:
>>
>> newtree = listener.someEvent(oldtree);
>> if ( newtree!=oldtree ) replace-oldtree-with-newtree;
>>
>> is pseudo-code. You probably have this all worked out, but it occurs to me that comparing two trees may be more expensive than necessary.
> I would be comparing pointers. if the pointers are different, I would slip in the new pointer. only the replace operation is pseudocode. In reality it would simply be "set the ith child pointer to the new pointer".
Hi Ter,
If oldtree and newtree can be any parse tree nodes, then listeners will
be registered against specific nodes, right? If any listener can toss
a subtree, then other listeners and their monitors that have stashed
data or are otherwise associated with subordinate nodes will be hosed.
So, how will listeners on the subtree get notified to potentially
re-register to nodes of the subtree? Even if only the root node of the
subtree is changed, how will listeners on lower subtree nodes be
informed of the change so they can determine whether to notify their
monitors?
Tx,
Gerald
More information about the antlr-interest
mailing list