got new tib tokenizer going
[sbp.git] / src / edu / berkeley / sbp / Parser.java
index fac14b0..1a0d307 100644 (file)
@@ -36,16 +36,18 @@ public abstract class Parser<T extends Token, R> {
     public Forest<R> parse(Token.Stream<T> input) throws IOException, Failed {
         GSS gss = new GSS();
         Token.Location loc = input.getLocation();
-        GSS.Phase current = gss.new Phase(null, input.next(), loc);
+        GSS.Phase current = gss.new Phase(null, input.next(1), loc);
         current.newNode(null, null, pt.start, true);
+        int count = 1;
         for(;;) {
             loc = input.getLocation();
-            GSS.Phase next = gss.new Phase(current, input.next(), loc);
+            GSS.Phase next = gss.new Phase(current, input.next(count), loc);
             current.reduce();
             Forest forest = current.token==null ? null : shiftedToken((T)current.token, loc);
             current.shift(next, forest);
-            if (current.isDone()) return (Forest<R>)current.finalResult;
+            count = next.hash.size();
             current.checkFailure();
+            if (current.isDone()) return (Forest<R>)current.finalResult;
             current = next;
         }
     }