Lines Matching refs:tree
28 package org.antlr.runtime.tree;
36 /** Return a node stream from a doubly-linked tree whose nodes
39 * Emit navigation nodes (DOWN, UP, and EOF) to let show tree structure.
44 protected Object tree;
57 public TreeIterator(Object tree) {
58 this(new CommonTreeAdaptor(),tree);
61 public TreeIterator(TreeAdaptor adaptor, Object tree) {
63 this.tree = tree;
64 this.root = tree;
73 tree = root;
80 if ( tree==null ) return false;
81 if ( adaptor.getChildCount(tree)>0 ) return true;
82 return adaptor.getParent(tree)!=null; // back at root?
88 if ( adaptor.getChildCount(tree)==0 ) { // single node tree (special)
90 return tree;
92 return tree;
98 if ( tree==null ) return eof;
101 if ( adaptor.getChildCount(tree)>0 ) {
102 tree = adaptor.getChild(tree, 0);
103 nodes.add(tree); // real node is next after DOWN
106 // if no children, look for next sibling of tree or ancestor
107 Object parent = adaptor.getParent(tree);
110 adaptor.getChildIndex(tree)+1 >= adaptor.getChildCount(parent) )
113 tree = parent;
114 parent = adaptor.getParent(tree);
118 tree = null; // back at root? nothing left then
125 int nextSiblingIndex = adaptor.getChildIndex(tree) + 1;
126 tree = adaptor.getChild(parent, nextSiblingIndex);
127 nodes.add(tree); // add to queue, might have UP nodes in there