factor Pos out of Position in preparation for serialiable parse tables
[sbp.git] / src / edu / berkeley / sbp / Node.java
index b6f4585..2cb33a9 100644 (file)
@@ -5,13 +5,14 @@ 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 java.io.*;
 import java.util.*;
 import java.lang.reflect.*;
 
 /** a node in the GSS */
 final class Node
-    implements Invokable<Position, Result>,
+    implements Invokable<Pos, Result>,
                IntegerMappable,
                GraphViz.ToGraphViz,
                Iterable<Result> {
@@ -67,17 +68,17 @@ final class Node
     private       HashSet<Result> results = new HashSet<Result>();
     private       HashSet<Result> children = new HashSet<Result>();
 
-    public final void invoke(Position r, Result only) {
+    public final void invoke(Pos r, Result only) {
         boolean emptyProductions = only==null;
-        if (emptyProductions != (r.pos==0)) return;
-        if (r.pos!=0)  reduce(r, r.pos-1, phase(), only);
+        if (emptyProductions != (r.numPops()==0)) return;
+        if (r.numPops()!=0)  reduce(r, r.numPops()-1, phase(), only);
         else {
             Input.Region region = phase().getLocation().createRegion(phase().getLocation());
             new Result(r.rewrite(region, phase().parser().cache()), this, r, phase());
         }
     }
 
-    private void reduce(Position r, int pos, GSS.Phase target, Result only) {
+    private void reduce(Pos r, int pos, GSS.Phase target, Result only) {
         Forest[] holder = r.holder;
         Forest old = holder[pos];
         if (results==null) return;   // FIXME: this should not happen