+ numReductions = 0;
+
+ int minPhasePos = Integer.MAX_VALUE;
+ int maxOrd = -1;
+ Reduction best = null;
+ //System.out.println("==============================================================================");
+ while(!reductionQueue.isEmpty()) {
+ Reduction r = reductionQueue.poll();
+ //System.out.println("- " + r);
+ if (r.parentPhase() != null)
+ if (r.parentPhase().pos > minPhasePos)
+ throw new Error();
+ r.perform();
+ if (r.parentPhase() != null) {
+ if (r.parentPhase().pos < minPhasePos) {
+ minPhasePos = r.parentPhase().pos;
+ maxOrd = r.reduction().ord;
+ best = r;
+ } else if (r.parentPhase().pos == minPhasePos) {
+ /*
+ if (best != null && Parser.mastercache.comparePositions(r.reduction(), best.reduction()) < 0)
+ throw new Error("\n"+r+"\n"+best+"\n"+
+ Parser.mastercache.comparePositions(r.reduction(), best.reduction())+"\n"+r.compareTo(best)+
+ "\n"+(r.reduction().ord-best.reduction().ord));
+ */
+ maxOrd = r.reduction().ord;
+ best = r;
+ }
+ }
+ numReductions++;
+ }
+ if (token==null) shift(null, null);