X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FParser.java;h=4c01e33339ede9670c94187b94ee050bb807968d;hb=5964a1161340a16d7dea471372737f2474576ceb;hp=75f3ace8064784f45d3186eb6a99b21317aeb1a9;hpb=a7b84506c2e1ed63343db215f76afced082e2826;p=sbp.git diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index 75f3ace..4c01e33 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -42,13 +42,6 @@ public abstract class Parser { public final Walk.Cache cache = this; - public void optimize(Functor f) { - for(State state : all_states.values()) { - state.oreductions = state.reductions.optimize(f); - state.oshifts = state.shifts.optimize(f); - } - } - private void walk(Element e, HashSet hs) { if (e==null) return; if (hs.contains(e)) return; @@ -73,7 +66,7 @@ public abstract class Parser { public Table(String startSymbol, Topology top) { this(new Union(startSymbol), top); } public Table(Union ux, Topology top) { Union start0 = new Union("0"); - start0.add(new Sequence.Singleton(ux, null, null)); + start0.add(new Sequence.Singleton(ux)); for(Sequence s : start0) cache.eof.put(s, true); cache.eof.put(start0, true); @@ -109,6 +102,11 @@ public abstract class Parser { if (p.element() != null && p.element() instanceof Atom) state.shifts.addAll(state.gotoSetTerminals.subset(((Atom)p.element()))); } + if (top instanceof IntegerTopology) + for(State 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) {