[antlr-interest] On trees and JavaBeans, part 2: tree creation
Terence Parr
parrt at cs.usfca.edu
Mon Apr 18 19:10:37 PDT 2005
Hi Guys,
I like the flexibility of swing's tree interface, but I don't like the
need to pass in the parent to get the child.
Tree t = tree.getChild(parent, i);
just seems less pleasant than
Tree t = parent.getChild(i);
Also, you still need a tree node of some kind to actually implement a
tree. Perhaps Tree and TreeNode?
I'm open to suggestions still because the payload model requires an
extra node just to wrap the pointer (as an "adaptor") to another kind
of tree node. For example, if you have a DOM tree or something that
doesn't directly satisfy the Tree interface, you must essentially make
a duplicate, parallel tree that points node-for-node from the ANTLR
tree into the DOM tree.
The main issue for me is: when do you really want to walk a "foreign"
(non-ANTLR constructor) tree? It happens sometimes, but usually
because you're building your own trees with actions, which you could
make implement the Tree interface easily. It would be fairly rare
don't you think to want to walk a totally unrelated data structure?
The payload thing works GREAT in most cases as it just points at the
associated token :)
Ter
More information about the antlr-interest
mailing list