X-Git-Url: http://git.megacz.com/?p=sbp.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FParser.java;h=a74ea5ea7459922106b6731373555a7d32183f0e;hp=4aa65151106cb01ece84878d9b80a5c7110b92db;hb=111166986ad83b54d0cae5c03c2304d23e332f29;hpb=75d0fa39d405292f4b831a6d1743f2aeea01ebd4 diff --git a/src/edu/berkeley/sbp/Parser.java b/src/edu/berkeley/sbp/Parser.java index 4aa6515..a74ea5e 100644 --- a/src/edu/berkeley/sbp/Parser.java +++ b/src/edu/berkeley/sbp/Parser.java @@ -77,7 +77,7 @@ public abstract class Parser { public final Walk.Cache cache = this; - private void walk(Element e, HashSet hs) { + private void walk(Element e, HashSet hs) { if (e==null) return; if (hs.contains(e)) return; hs.add(e); @@ -85,7 +85,7 @@ public abstract class Parser { for(Sequence s : (Union)e) walk(s, hs); } - private void walk(Sequence s, HashSet hs) { + private void walk(Sequence s, HashSet hs) { hs.add(s); for(Position p = s.firstp(); p != null; p = p.next()) walk(p.element(), hs); @@ -114,9 +114,9 @@ public abstract class Parser { cache.eof.put(start0, true); // construct the set of states - HashSet all_elements = new HashSet(); + HashSet all_elements = new HashSet(); walk(start0, all_elements); - for(Element e : all_elements) + for(SequenceOrElement e : all_elements) cache.ys.addAll(e, new Walk.YieldSet(e, cache).walk()); HashSet hp = new HashSet(); reachable(start0, hp); @@ -166,7 +166,7 @@ public abstract class Parser { public final int idx = master_state_idx++; private final HashSet hs; - public transient HashMap> gotoSetNonTerminals = new HashMap>(); + public transient HashMap> gotoSetNonTerminals = new HashMap>(); private transient TopologicalBag> gotoSetTerminals = new TopologicalBag>(); private TopologicalBag reductions = new TopologicalBag(); @@ -219,7 +219,7 @@ public abstract class Parser { */ public State(HashSet hs, HashMap,State> all_states, - HashSet all_elements) { + HashSet all_elements) { this.hs = hs; // register ourselves in the all_states hash so that no @@ -258,17 +258,17 @@ public abstract class Parser { // to avoid having to iteratively construct our set of States as shown in most // expositions of the algorithm (ie "keep doing XYZ until things stop changing"). - HashMapBag move = new HashMapBag(); + HashMapBag move = new HashMapBag(); for(Position p : hs) { Element e = p.element(); if (e==null) continue; - for(Element y : cache.ys.getAll(e)) { + for(SequenceOrElement y : cache.ys.getAll(e)) { HashSet hp = new HashSet(); reachable(p.next(), hp); move.addAll(y, hp); } } - OUTER: for(Element y : move) { + OUTER: for(SequenceOrElement y : move) { HashSet h = move.getAll(y); State s = all_states.get(h) == null ? new State(h, all_states, all_elements) : all_states.get(h); // if a reduction is "lame", it should wind up in the dead_state after reducing @@ -279,13 +279,13 @@ public abstract class Parser { for(Sequence seq : u) if (seq.needs.contains((Sequence)y) || seq.hates.contains((Sequence)y)) { // FIXME: what if there are two "routes" to get to the sequence? - ((HashMap)gotoSetNonTerminals).put(y, dead_state); + ((HashMap)gotoSetNonTerminals).put((Sequence)y, dead_state); continue OUTER; } } } + gotoSetNonTerminals.put((Sequence)y, s); } - gotoSetNonTerminals.put(y, s); } }