- //public abstract HashSet<Tree<T>> expand(boolean toss);
- public HashSet<Tree<T>> expand(boolean toss) {
- HashSet<Tree<T>> ret = new HashSet<Tree<T>>();
- for(Body<T> b : this)
- 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;
- }
-
- static <T> Forest<T> singleton(Input.Location loc) { return create(loc, null, new Forest[] { }, false, true); }
- static <T> Forest<T> singleton(Input.Location loc, Forest<T> body) { return create(loc, null, new Forest[] { body }, false, true); }
- static <T> Forest<T> leaf(Input.Location loc, T tag) { return create(loc, tag, null, false, false); }
- public static <T> Forest<T> create(Input.Location loc, T tag, Forest<T>[] tokens, boolean unwrap, boolean singleton) {
- return new MultiForest<T>(new Body<T>(loc, tag, tokens, unwrap, singleton));
+ public void expand(HashSet<Tree<T>> ht) { expand(ht, new HashSet<Forest<T>>(), null); }
+
+ /** create a new forest */
+ public static <T> Forest<T> create(Input.Region loc, T head, Forest<T>[] children, boolean lift) {
+ return new One<T>(loc, head, children, lift);