checkpoint harmony
authoradam <adam@megacz.com>
Wed, 11 Jan 2006 07:04:14 +0000 (02:04 -0500)
committeradam <adam@megacz.com>
Wed, 11 Jan 2006 07:04:14 +0000 (02:04 -0500)
darcs-hash:20060111070414-5007d-3bde4a25baf840475e966edc71709023ca32745b.gz

src/edu/berkeley/sbp/GSS.java

index b98d077..7fefafc 100644 (file)
@@ -17,11 +17,9 @@ class GSS {
     public int resets = 0;
     public int waits = 0;
 
     public int resets = 0;
     public int waits = 0;
 
-    HashMapBag<Integer,Sequence> inhibited = new HashMapBag<Integer,Sequence>();
-    HashMapBag<Integer,Sequence> assumed = new HashMapBag<Integer,Sequence>();
+    HashMapBag<Integer,Sequence>       inhibited = new HashMapBag<Integer,Sequence>();
     HashMapBag<Sequence,Phase.Waiting> waiting   = new HashMapBag<Sequence,Phase.Waiting>();
     HashMapBag<Sequence,Phase.Waiting> waiting   = new HashMapBag<Sequence,Phase.Waiting>();
-    HashMapBag<Integer,Sequence> performed = new HashMapBag<Integer,Sequence>();
-    HashSet<Phase.Waiting> tail = new     HashSet<Phase.Waiting>();
+    HashMapBag<Integer,Sequence>       performed = new HashMapBag<Integer,Sequence>();
     
     /** corresponds to a positions <i>between tokens</i> the input stream; same as Tomita's U_i's */
     public class Phase implements Invokable<State, Forest, GSS.Phase.Node>, IntegerMappable {
     
     /** corresponds to a positions <i>between tokens</i> the input stream; same as Tomita's U_i's */
     public class Phase implements Invokable<State, Forest, GSS.Phase.Node>, IntegerMappable {
@@ -62,12 +60,10 @@ class GSS {
             this.token = token;
             this.location = location;
             inhibited.clear();
             this.token = token;
             this.location = location;
             inhibited.clear();
-            assumed.clear();
             reset();
         }
 
         public void reset() {
             reset();
         }
 
         public void reset() {
-            tail.clear();
             waiting.clear();
             performed.clear();
             hash = new IntPairMap<Phase.Node>();
             waiting.clear();
             performed.clear();
             hash = new IntPairMap<Phase.Node>();
@@ -83,7 +79,6 @@ class GSS {
             if (n.touched) return;
             n.touched = true;
             for(Position p : n.state) {
             if (n.touched) return;
             n.touched = true;
             for(Position p : n.state) {
-                //if (!p.isLast()) { 
                 if (((p.isFirst() || p.isLast()) && !force) || p.owner().name==null) {
                     for(Node n2 : n.parents())
                         complain(n2, errors, force | p.isFirst());
                 if (((p.isFirst() || p.isLast()) && !force) || p.owner().name==null) {
                     for(Node n2 : n.parents())
                         complain(n2, errors, force | p.isFirst());
@@ -92,17 +87,6 @@ class GSS {
                     HashSet<String> hs = errors.get(seqname);
                     if (hs==null) errors.put(seqname, hs = new HashSet<String>());
                     hs.add(p.element()+"");
                     HashSet<String> hs = errors.get(seqname);
                     if (hs==null) errors.put(seqname, hs = new HashSet<String>());
                     hs.add(p.element()+"");
-                    //String s = "  while parsing " + seqname + ": expected a " + p.element();
-                        //"\n";
-                    /*
-                    s +=       "      parsed: ";
-                    for(Position p2 = p.owner().firstp(); p2 != null && p2 != p && !p2.isLast(); p2 = p2.next()) s += (p2.element() + " ");
-                    s += "\n";
-                    s +=       "    expected: ";
-                    for(Position p2 = p; p2 != null && !p2.isLast(); p2 = p2.next()) s += (p2.element() + " ");
-                    */
-                    //s += "\n";
-                    //errors.add(s);
                 }
             }
         }
                 }
             }
         }
@@ -181,12 +165,6 @@ class GSS {
             Sequence owner = reduction==null ? null : reduction.position.owner();
             if (reduction!=null) {
                 if (inhibited.contains(pos, owner)) return;
             Sequence owner = reduction==null ? null : reduction.position.owner();
             if (reduction!=null) {
                 if (inhibited.contains(pos, owner)) return;
-                /*
-                if (assumed.contains(pos, owner)) {
-                    tail.add(new Waiting(parent, pending, state, fromEmptyReduction, reduction));
-                    return;
-                }
-                */
                 if (owner.needs != null)
                     for(Sequence s : owner.needs)
                         if (!performed.contains(pos, s)) {
                 if (owner.needs != null)
                     for(Sequence s : owner.needs)
                         if (!performed.contains(pos, s)) {
@@ -228,7 +206,7 @@ class GSS {
                 if (token != null && state.canShift(token)) break;
                 if (state.isAccepting()) break;
                 if (token==null) break;
                 if (token != null && state.canShift(token)) break;
                 if (state.isAccepting()) break;
                 if (token==null) break;
-                //if (!state.canReduce(token)) return false;
+                if (!state.canReduce(token)) return false;
                 //if (count > 1) break;
                 //if (r.numPop == 0) break;
                 //r.reduce(pending, parent, null, Phase.this, null);
                 //if (count > 1) break;
                 //if (r.numPop == 0) break;
                 //r.reduce(pending, parent, null, Phase.this, null);
@@ -257,7 +235,6 @@ class GSS {
                     //System.out.println("\nresetting due to " + r.position.owner() + " killing " + seq);
                     //inhibited.clear();
                     inhibited.add(p, seq);
                     //System.out.println("\nresetting due to " + r.position.owner() + " killing " + seq);
                     //inhibited.clear();
                     inhibited.add(p, seq);
-                    //assumed = inhibited;
                     //inhibited = new HashMapBag<Integer,Sequence>();
                     reset = true;
                     resets++;
                     //inhibited = new HashMapBag<Integer,Sequence>();
                     reset = true;
                     resets++;
@@ -285,8 +262,6 @@ class GSS {
                     reducing_list[i] = null;
                     n.queueReductions();
                 }
                     reducing_list[i] = null;
                     n.queueReductions();
                 }
-                //for(Waiting w : tail)
-                //w.perform();
             } catch (Reset r) {
                 reset();
                 reduce();
             } catch (Reset r) {
                 reset();
                 reduce();