this.singleton = singleton;
}
- public TreeMaker<T> expand(int i, TreeMaker<T> h) {
+ public TreeMaker<T> expand(final int i, final TreeMaker<T> h) {
if (singleton) {
tokens[0].visit(h, null, i);
tokens[i].visit(h, null, 0);
} else {
- //boolean hit = false;
- //tokens[i].visit(this, h, i);
-
- for(Tree<T> r : tokens[i].expand(h.toss)) {
- //hit = true;
- int old = h.toks.size();
- h.toks.add(r);
- expand(i+1, h);
- while(h.toks.size() > old) h.toks.remove(h.toks.size()-1);
- }
-
- //if (!hit) throw new Error();
+ tokens[i].visit(new TreeMaker<T>(h.toss) {
+ public void add(Tree<T> r) {
+ int old = h.toks.size();
+ h.toks.add(r);
+ expand(i+1, h);
+ while(h.toks.size() > old) h.toks.remove(h.toks.size()-1);
+ }
+ }, null, null);
}
return h;
}
}
public abstract <B,C> void visit(Invokable<Forest.Body<T>,B,C> ivbc, B b, C c);
- private static abstract class TreeMaker<T> /*extends HashSet<Tree<T>>*/ implements Invokable<Forest.Body<T>,Boolean,Integer> {
+ private static abstract class TreeMaker<T> implements Invokable<Forest.Body<T>,Boolean,Integer> {
public ArrayList<Tree<T>> toks = new ArrayList<Tree<T>>();
private boolean toss;
public TreeMaker(boolean toss) { this.toss = toss; }