checkpoint harmony
[sbp.git] / src / edu / berkeley / sbp / Parser.java
index f642878..18bec5a 100644 (file)
@@ -91,7 +91,7 @@ public abstract class Parser<T extends Token, R> {
                     if (start0.contains(p.owner()) && p.next()==null)
                         state.accept = true;
 
                     if (start0.contains(p.owner()) && p.next()==null)
                         state.accept = true;
 
-                    if (p.isRightNullable(cache)) {
+                    if (isRightNullable(p)) {
                         Walk.Follow wf = new Walk.Follow(top.empty(), p.owner(), all_elements, cache);
                         Reduction red = new Reduction(p);
 
                         Walk.Follow wf = new Walk.Follow(top.empty(), p.owner(), all_elements, cache);
                         Reduction red = new Reduction(p);
 
@@ -121,6 +121,12 @@ public abstract class Parser<T extends Token, R> {
             }
         }
 
             }
         }
 
+        private boolean isRightNullable(Position p) {
+            if (p.isLast()) return true;
+            if (!p.element().possiblyEpsilon(this)) return false;
+            return isRightNullable(p.next());
+        }
+
         /** a single state in the LR table and the transitions possible from it */
 
         public class State implements Comparable<Table.State>, IntegerMappable, Iterable<Position> {
         /** a single state in the LR table and the transitions possible from it */
 
         public class State implements Comparable<Table.State>, IntegerMappable, Iterable<Position> {