- private static class MultiForest<T> extends Forest<T> {
- private final FastSet<Body<T>> results;
- private MultiForest(FastSet<Body<T>> results) { this.results = results; }
- public MultiForest(Input.Location loc, T tag, Forest<T>[] tokens, boolean unwrap, boolean singleton) {
- this.results = new FastSet<Body<T>>(new Body(loc, tag, tokens, unwrap, singleton));
- }
- public Iterator<Body<T>> iterator() { return results.iterator(); }
- public HashSet<Tree<T>> expand(boolean toss) {
- HashSet<Tree<T>> ret = new HashSet<Tree<T>>();
- for(Body<T> b : results)
- ret.addAll(b.expand(toss, new ArrayList<Tree<T>>(), 0, new HashSet<Tree<T>>()));
- if (toss && ret.size() > 1) throw new Ambiguous(this);
- return ret;