X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FForest.java;h=bd3b46a996fc4addea796528fd17c3864b4d4474;hp=1c8fbc5b6f8290bb0c6540a37fd2925900e7b89a;hb=280e93a7eec101178dc81f8009eedb2916271f09;hpb=f1dba2b015c3da04fc2fab45604da2e6c9ae0a1d diff --git a/src/edu/berkeley/sbp/Forest.java b/src/edu/berkeley/sbp/Forest.java index 1c8fbc5..bd3b46a 100644 --- a/src/edu/berkeley/sbp/Forest.java +++ b/src/edu/berkeley/sbp/Forest.java @@ -19,18 +19,17 @@ public abstract class Forest implements GraphViz.ToGraphViz { public void expand(HashSet> ht) { expand(ht, new HashSet>(), null); } /** create a new forest */ - public static Forest create(Input.Region loc, T head, Forest[] children, boolean unwrap) { - return new One(loc, head, children, unwrap); + public static Forest create(Input.Region loc, T head, Forest[] children, boolean lift) { + return new One(loc, head, children, lift); } // Package-Private ////////////////////////////////////////////////////////////////////////////// abstract void expand(HashSet> ht, HashSet> ignore, Tree bogus); abstract void gather(HashSet> ignore); + abstract void edges(GraphViz.Node n); boolean ambiguous() { return false; } - public abstract void edges(GraphViz.Node n); - // One ////////////////////////////////////////////////////////////////////////////// @@ -42,21 +41,21 @@ public abstract class Forest implements GraphViz.ToGraphViz { private final Forest[] children; /** if true, the last child's children are considered children of this node */ - private final boolean unwrap; + private final boolean lift; - private One(Input.Region loc, T head, Forest[] children, boolean unwrap) { + private One(Input.Region loc, T head, Forest[] children, boolean lift) { this.location = loc; this.head = head; this.children = children==null ? emptyForestArray : new Forest[children.length]; if (children != null) System.arraycopy(children, 0, this.children, 0, children.length); if (children != null) for(int i=0; i expand1() throws Ambiguous { Tree[] ret = new Tree[children.length]; for(int i=0; i(location, head, ret, unwrap); + return new Tree(location, head, ret, lift); } void gather(HashSet> hf) { @@ -69,7 +68,7 @@ public abstract class Forest implements GraphViz.ToGraphViz { } private void expand(final int i, Tree[] ta, HashSet> ht, HashSet> ignore, Tree bogus) { if (i==children.length) { - ht.add(new Tree(location, head, ta, unwrap)); + ht.add(new Tree(location, head, ta, lift)); } else { HashSet> ht2 = new HashSet>(); children[i].expand(ht2, ignore, bogus); @@ -98,7 +97,7 @@ public abstract class Forest implements GraphViz.ToGraphViz { if (edges) return; edges = true; for(int i=0; i