[antlr-interest] trees with payloads??

John D. Mitchell johnm-antlr at non.net
Wed Nov 10 14:11:48 PST 2004


>>>>> "Terence" == Terence Parr <parrt at cs.usfca.edu> writes:
[...]

> After Loring bitched at me on the phone yesterday <snicker>, I'm
> beginning to think he's right: if separating the node data from the
> navigation is the right concept, then trees should be a single
> implementation that simply carry a "payload" object defined by the user.
> This is like Sun's MutableTreeNode.

Go Loring!  :-? :-)

I strongly concur.


[...]

> As a bonus to the payload strategy, we can enhance the tree functionality
> later w/o forcing alterations in people's application; their payload
> objects still fit in our nodes.

Yea!

> This all comes at the cost of an additional object creation (payload
> creation + node creation).

In Java, who cares.

For people who care (embedded C), the code gen could be made smart enough
to do just one single allocation for both "objects".


> Side note: Mitchell suggested Tokens and Tree nodes should have not only
> fixed fields like this, but the ability to dynamically acquire
> "attributes"; this would basically be a hashmap.  It cuts down on a
> bazillion subclasses.  It would be useful when parsing xml for example.
> The TAG token could have a list of tag attributes w/o creating subclasses
> etc...

Yeah, that's a damn good idea!  :-?

LinkedHashSet is your friend.

Have fun,
	John


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list