checkpoint
authoradam <adam@megacz.com>
Wed, 4 Jan 2006 10:47:24 +0000 (05:47 -0500)
committeradam <adam@megacz.com>
Wed, 4 Jan 2006 10:47:24 +0000 (05:47 -0500)
darcs-hash:20060104104724-5007d-c98ffc2ae2c190a82c47d6e03295e7fb1dff0dd8.gz

src/edu/berkeley/sbp/GSS.java
src/edu/berkeley/sbp/Parser.java

index 5847d6b..a4f3d6a 100644 (file)
@@ -186,9 +186,6 @@ class GSS {
             private Forest.Ref holder = null;
             private boolean allqueued = false;
 
-            /** the set of nodes to which there is an edge starting at this node */
-            //public final FastSet<Node> parents = new FastSet<Node>();  /* ALLOC */
-
             /** what state this node is in */
             public final Parser.Table.State state;
 
@@ -212,7 +209,7 @@ class GSS {
                 if (!allqueued) { queueReductions(); return; }
                 for(Parser.Table.Reduction r : state.getReductions(token))
                     if (r.numPop > 0)
-                        r.reduce(this, n2, null);
+                        r.reduce(this, n2);
             }
 
 
index 90f86f2..f087a05 100644 (file)
@@ -316,6 +316,19 @@ public abstract class Parser<T extends Token, R> {
                 return ret;
             }
 
+            public Forest reduce(GSS.Phase.Node parent, GSS.Phase.Node onlychild) {
+                int pos = numPop-1;
+                if (pos>=0) holder[pos] = parent.pending();
+                Forest rex = null;
+                if (pos==0) {
+                    if (rex==null) {
+                        System.arraycopy(holder, 0, position.holder, 0, holder.length);
+                        rex = position.rewrite(parent.phase().getLocation());
+                    }
+                }
+                return reduce(onlychild, pos-1, rex, null, parent.phase());
+            }
+
             private Forest zero = null;
             public Forest zero() {
                 if (zero != null) return zero;