- public HashSet<Tree<T>> expand(boolean toss, ArrayList<Tree<T>> toks, int i, HashSet<Tree<T>> h) {
- if (singleton) {
- for(Body<T> b : tokens[0]) b.expand(toss, toks, i, h);
-
- } else if (i==tokens.length) {
- h.add(new Tree<T>(null, tag, toks.toArray(tree_hint)));
-
- } else if (unwrap && i==tokens.length-1) {
- if (tokens[i] != null)
- for(Body b : tokens[i])
- b.expand(toss, toks, 0, h);
-
+ public Tree<T> expand1() throws Ambiguous {
+ Tree<T>[] ret = new Tree[children.length];
+ for(int i=0; i<children.length; i++)
+ ret[i] = children[i].expand1();
+ return new Tree<T>(location, head, ret, unwrap);
+ }
+ public void gather(HashSet<Forest<T>> hf) {
+ hf.add(this);
+ for(Forest<T> f : children) f.gather(hf);
+ }
+ public void expand(HashSet<Tree<T>> ht, HashSet<Forest<T>> ignore, Tree<T> bogus) {
+ if (ignore.contains(this)) { ht.add(bogus); return; }
+ expand(0, new Tree[children.length], ht, ignore, bogus);
+ }
+ public void expand(final int i, Tree<T>[] ta, HashSet<Tree<T>> ht, HashSet<Forest<T>> ignore, Tree<T> bogus) {
+ if (i==children.length) {
+ ht.add(new Tree<T>(location, head, ta, unwrap));