X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fsbp%2FGSS.java;h=91ef7652187e7b7f2ee88c4d0fe112cb79e74eba;hb=dcf8aafe73cbd899d8aebd2ef92df5a75a2c2b69;hp=f0a4cea21c0f741f4247c0f662192bd1bdfe9840;hpb=f57e7386abbd8d301f46c0f68a32bffbb1c15253;p=sbp.git
diff --git a/src/edu/berkeley/sbp/GSS.java b/src/edu/berkeley/sbp/GSS.java
index f0a4cea..91ef765 100644
--- a/src/edu/berkeley/sbp/GSS.java
+++ b/src/edu/berkeley/sbp/GSS.java
@@ -25,7 +25,7 @@ class GSS {
/** corresponds to a positions between tokens the input stream; same as Tomita's U_i's */
class Phase implements Invokable, IntegerMappable, GraphViz.ToGraphViz, Iterable {
- public ArrayList reductionQueue = new ArrayList();
+ public PriorityQueue reductionQueue = new PriorityQueue();
public void invoke(State st, Result result, Object o) {
//shifts++;
@@ -89,40 +89,15 @@ class GSS {
if (token == null) continue;
n.state().invokeShifts(token, this, new Result(result, n, null), null);
}
+ for(Node n : hash.values()) n.check();
if (!good && token!=null) ParseFailed.error("unexpected character", this);
if (token==null && finalResult==null) ParseFailed.error("unexpected end of file", this);
}
/** perform all reduction operations */
public void reduce() throws ParseFailed {
- Reduction last = null;
- while(!reductionQueue.isEmpty()) {
- Reduction r = null;
-
- // ugly
- OUTER: for(int i=0; i 0)
- continue OUTER;
- }
- r = reductionQueue.get(i);
- reductionQueue.remove(r);
- break;
- }
-
- /*
- if (last == null) last = r;
- else if (r.compareTo(last) > 0) last = r;
- else if (r.compareTo(last) < 0) {
- if (r.targetPhase() != null)
- System.out.println("err " + last.compareTo(r) + " " + last.targetPhase().pos() +
- " " + r.targetPhase().pos() + " " + pos);
- }
- */
-
- r.perform();
- }
+ while(!reductionQueue.isEmpty())
+ reductionQueue.poll().perform();
}
public void newNodeFromReduction(Result result, State state, boolean fromEmptyReduction, Position reduction) {