- for(Tree<T> tree : ht[i]) {
- /*
- if (unwrap && i==trees.length-1) {
- // I think this is wrong
- Tree[] trees2 = new Tree[trees.length - 1 + tree.numChildren()];
- System.arraycopy(trees, 0, trees2, 0, trees.length-1);
- for(int j=0; j<tree.numChildren(); j++)
- trees2[trees.length-1+j] = tree.child(j);
- target.add(new Tree<T>(location, tag, trees2));
- } else {
- */
- trees[i] = tree;
- gather(tl, ht, target, trees, i+1);
- trees[i] = null;
- //}
- }
- }
- public void expand(TaskList tl, HashSet<Tree<T>> ht) {
- HashSet<Tree<T>>[] children = new HashSet[tokens.length];
- tl.gather(this, children, ht);
- for(int i=0; i<children.length; i++) {
- children[i] = new HashSet<Tree<T>>();
- tl.expand(tokens[i], children[i]);
- }
- }
-
- public void expand(final int i, final TreeBuilder<T> h) {
- if (i==0) h.start(tag, location);
-
- if (i==tokens.length) {
- h.finish(tag, location);
-
- /*
- } else if (unwrap && i==tokens.length-1) {
- if (tokens[i] != null)
- tokens[i].visit(h, null, 0);
- */
-
- } else {
- tokens[i].visit(new TreeBuilder<T>(h.toss) {
- public void start(T head, Input.Region loc) { }
- public void addTree(Tree<T> t) { toks.add(t); }
- public void finish(T head, Input.Region loc) {
- int old = h.toks.size();
- h.addTree(new Tree<T>(loc, head, toks.toArray(tree_hint), unwrap));
- expand(i+1, h);
- while(h.toks.size() > old) h.toks.remove(h.toks.size()-1);
- }
- }, null, null);