change naming: use pred/succ rather than parent/child
[sbp.git] / src / edu / berkeley / sbp / GSS.java
index 32ce6fc..bf58e64 100644 (file)
@@ -4,7 +4,7 @@ package edu.berkeley.sbp;
 import edu.berkeley.sbp.*;
 import edu.berkeley.sbp.util.*;
 import edu.berkeley.sbp.Parser.Table.*;
-import edu.berkeley.sbp.Sequence.Position;
+import edu.berkeley.sbp.Sequence.Pos;
 import edu.berkeley.sbp.Sequence.Pos;
 import java.io.*;
 import java.util.*;
@@ -77,15 +77,15 @@ class GSS {
             while(!reductionQueue.isEmpty()) {
                 Reduction r = reductionQueue.poll();
                 //System.out.println("- " + r);
-                if (r.parentPhase() != null)
-                    if (r.parentPhase().pos > minPhasePos)
+                if (r.predPhase() != null)
+                    if (r.predPhase().pos > minPhasePos)
                         throw new Error();
                 r.perform();
-                if (r.parentPhase() != null) {
-                    if (r.parentPhase().pos < minPhasePos) {
-                        minPhasePos = r.parentPhase().pos;
+                if (r.predPhase() != null) {
+                    if (r.predPhase().pos < minPhasePos) {
+                        minPhasePos = r.predPhase().pos;
                         best = r;
-                    } else if (r.parentPhase().pos == minPhasePos) {
+                    } else if (r.predPhase().pos == minPhasePos) {
                         /*
                         if (best != null && Parser.mastercache.comparePositions(r.reduction(), best.reduction()) < 0)
                             throw new Error("\n"+r+"\n"+best+"\n"+
@@ -113,7 +113,7 @@ class GSS {
         public boolean        isFrontier() { return hash!=null; }
 
         /** perform all shift operations, adding promoted nodes to <tt>next</tt> */
-        private void shift(Phase next, Forest result) throws ParseFailed {
+        private void shift(Phase next, Forest f) throws ParseFailed {
             this.next = next;
             // this massively improves GC performance
             if (prev != null) {
@@ -130,7 +130,8 @@ class GSS {
                         finalResult.merge(r.getForest());
                 }
                 if (token == null) continue;
-                n.state().invokeShifts(token, this, new Result(result, n, null));
+                Result result = new Result(f, n, null);
+                n.state().invokeShifts(token, this, result);
             }
             numNewNodes = next==null ? 0 : next.hash.size();
             viewPos = this.pos;
@@ -189,6 +190,7 @@ class GSS {
                 if (!state.canReduce(token)) return false;
             } while(false);
             Node n = new Node(Phase.this, result, state, fromEmptyReduction);  // ALLOC
+            /** FIXME: this null-result can be used to notice bogus/dead states */
             for(Object s : state.conjunctStates)
                 newNode(new Result(null, n, null), (State)s, fromEmptyReduction);
             return !n.state().doomed();