checkpoint
[sbp.git] / src / edu / berkeley / sbp / Parser.java
index 75f3ace..632729e 100644 (file)
@@ -42,13 +42,6 @@ public abstract class Parser<Tok, Result> {
 
         public final Walk.Cache cache = this;
 
-        public void optimize(Functor<Tok,Integer> f) {
-            for(State<Tok> state : all_states.values()) {
-                state.oreductions = state.reductions.optimize(f);
-                state.oshifts = state.shifts.optimize(f);
-            }
-        }
-
         private void walk(Element e, HashSet<Element> hs) {
             if (e==null) return;
             if (hs.contains(e)) return;
@@ -109,6 +102,11 @@ public abstract class Parser<Tok, Result> {
                     if (p.element() != null && p.element() instanceof Atom)
                         state.shifts.addAll(state.gotoSetTerminals.subset(((Atom)p.element())));
                 }
+            if (top instanceof IntegerTopology)
+                for(State<Tok> state : all_states.values()) {
+                    state.oreductions = state.reductions.optimize(((IntegerTopology)top).functor());
+                    state.oshifts = state.shifts.optimize(((IntegerTopology)top).functor());
+                }
         }
 
         private boolean isRightNullable(Position p) {