[antlr-interest] On trees and JavaBeans, part 2: tree creation

Scott Stanchfield scott at javadude.com
Tue Apr 19 05:43:19 PDT 2005


Hmmm... interesting, but we still need some way to get data from the nodes
(which would be part of the ASTModel interface)

I'd also like to expose the model as more of a tree so other tools (like
ANTLRWorks) can display the current state of a tree. ANTLRWorks would need
to use an adapter to display the content, similar to TreeCellRenderer in
Swing.

We also need to take into account tree re-writing and creation, which is
where the factory comes in.

Keep it all abstract and insane flexibility ;)

(Swing may have done a lot of things wrong, IMHO, but the model design
behind trees was really well thought out...)

Later,
-- Scott


> The Tree isn't what is changing, but merely some position within it:
> 
>     TreeIterator itr = tree.getIterator();
>     itr = itr.getChild(i);
> 
> We could even define standard TreeIterators for traversals so 
> that a traversal would look more like a standard loop:
> 
>    for (itr = tree.getPreOrderDepthFirstIter(); itr; itr++) ...
> 
> One less thing to reimplement each time.
> 






More information about the antlr-interest mailing list