// Package-Private //////////////////////////////////////////////////////////////////////////////
- static <NodeType> Forest<NodeType> create(Input.Region region, NodeType head, Forest<NodeType>[] children, boolean lift) {
+ static <NodeType> Forest<NodeType> create(Input.Region region, NodeType head, Forest<NodeType>[] children,
+ boolean lift) {
if (region == null) throw new RuntimeException("invoked Forest.create(region=null) -- this should never happen");
return new One<NodeType>(region, head, children, lift);
}
+ static <NodeType> Forest<NodeType> create(Input.Region region, NodeType head, Forest<NodeType>[] children,
+ boolean lift, boolean liftLeft) {
+ if (region == null) throw new RuntimeException("invoked Forest.create(region=null) -- this should never happen");
+ return new One<NodeType>(region, head, children, lift, liftLeft);
+ }
+
/** create a new forest */
public static <NodeType> Forest<NodeType> create(Input.Region region, NodeType head, Forest<NodeType>[] children) {
return Forest.create(region, head, children, false); }
/** if true, the last child's children are considered children of this node */
private final boolean lift;
+ private final boolean liftLeft;
public Input.Region getRegion() { return location; }
private One(Input.Region loc, NodeType head, Forest<NodeType>[] children, boolean lift) {
+ this(loc, head, children, lift, false);
+ }
+ private One(Input.Region loc, NodeType head, Forest<NodeType>[] children, boolean lift, boolean liftLeft) {
this.location = loc;
this.head = head;
if (head==null) throw new RuntimeException("invoked Forest.create(,null,,,) -- this should never happen");
if (children != null) System.arraycopy(children, 0, this.children, 0, children.length);
if (children != null) for(int i=0; i<children.length; i++) if (children[i]==null) throw new Error(i+"");
this.lift = lift;
+ this.liftLeft = liftLeft;
}
public Tree<NodeType> expand1() throws Ambiguous {
Tree<NodeType>[] ret = new Tree[children.length];
for(int i=0; i<children.length; i++) ret[i] = children[i].expand1();
- return new Tree<NodeType>(location, head, ret, lift);
+ return new Tree<NodeType>(location, head, ret, lift, liftLeft);
}
void gather(HashSet<Forest<NodeType>> hf) {
private void expand(final int i, Tree<NodeType>[] ta, HashSet<Tree<NodeType>> ht, HashSet<Forest<NodeType>> ignore,
Tree<NodeType> bogus) {
if (i==children.length) {
- ht.add(new Tree<NodeType>(location, head, ta, lift));
+ ht.add(new Tree<NodeType>(location, head, ta, lift, liftLeft));
} else {
HashSet<Tree<NodeType>> ht2 = new HashSet<Tree<NodeType>>();
children[i].expand(ht2, ignore, bogus);