for(int i=0; i<num; i++) {
Node n = reducing_list[i];
reducing_list[i] = null;
- n.queueEmptyReductions();
n.queueReductions();
}
}
if (allqueued) return;
allqueued = true;
int where = parents().size();
- for(Parser.Table.Reduction r : token==null ? state.getEofReductions() : state.getReductions(token))
- if (r.numPop > 1)
+ for(Parser.Table.Reduction r : state.getReductions(token))
+ if (r.numPop >= 1)
r.reduce(this, null, null);
- for(int i=0; i<where; i++)
- queueReductions(get(i), false);
}
/** FIXME */
- public void queueReductions(Node n2) { queueReductions(n2, true); }
- public void queueReductions(Node n2, boolean includeLongs) {
+ public void queueReductions(Node n2) {
if (!allqueued) { queueReductions(); return; }
- Node n = this;
- for(Parser.Table.Reduction r : token==null ? n.state.getEofReductions() : n.state.getReductions(token)) {
-
- // UGLY HACK
- // The problem here is that a "reduction of length 1"
- // performed twice with different values of n2 needs
- // to only create a *single* new result, but must add
- // multiple parents to the node holding that result.
- // The current reducer doesn't differentiate between
- // the next node of an n-pop reduction and the
- // ultimate parent of the last pop, so we need to
- // cache instances here as a way of avoiding
- // recreating them.
- if (r.numPop <= 0) continue;
- if (r.numPop == 1) {
- Forest ret = n.cache().get(r);
- if (ret != null) r.reduce(this, n2, ret);
- else n.cache().put(r, r.reduce(this, n2, null));
- } else {
- if (includeLongs) r.reduce(this, n2, null);
- }
- }
+ for(Parser.Table.Reduction r : state.getReductions(token))
+ if (r.numPop > 0)
+ r.reduce(this, n2, null);
}