- //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<NodeType>> ht) { expand(ht, new HashSet<Forest<NodeType>>(), null); }
+
+ static <NodeType> Forest<NodeType> create(Input.Region loc, NodeType head, Forest<NodeType>[] children, boolean lift) {
+ if (loc == null) throw new Error();
+ return new One<NodeType>(loc, head, children, lift);