if (r.numPops()!=0) reduce(r, r.numPops()-1, phase(), only);
else {
Input.Region region = phase().getLocation().createRegion(phase().getLocation());
- new Result(r.rewrite(region), this, r, phase());
+ Result.newResult(r.rewrite(region), this, r, phase());
}
}
holder[pos] = old;
}
- Node(GSS.Phase phase, Result result, State state, boolean fromEmptyReduction) {
+ Node(GSS.Phase phase, Result pred, State state, boolean fromEmptyReduction) {
this.phase = phase;
this.state = state;
this.fromEmptyReduction = fromEmptyReduction;
- if (phase.hash.get(state, result.phase()) != null) throw new Error("severe problem!");
- phase.hash.put(state, result.phase(), this);
- addResult(result);
+ if (phase.hash.get(state, pred.phase()) != null) throw new Error("severe problem!");
+ phase.hash.put(state, pred.phase(), this);
+ addResult(pred);
state.invokeEpsilonReductions(phase().token, this);
}
return 1;
}
- public void perform() { new Result(forest, pred, reduction, phase); }
+ public void perform() {
+ Result.newResult(forest, pred, reduction, phase);
+ }
public GSS.Phase predPhase() { return pred.phase(); }
public Pos reduction() { return reduction; }
public GSS.Phase targetPhase() { return phase; }
private HashSet<Node> successors = new HashSet<Node>();
private boolean destroyed = false;
private int usedByNonDoomedNode = 0;
+ private Pos reduction;
public GSS.Phase phase() { return pred==null ? null : pred.phase(); }
public Forest getForest() { return f; }
}
}
- public Result(Forest f, Node pred, Pos reduction) {
- this(f, pred, reduction, null);
+ public static void newResult(Forest f, Node pred, Pos reduction, GSS.Phase target) {
+ Result r = new Result(f, pred, reduction);
+ if (reduction == null) return;
+ Parser.Table.State state0 = (Parser.Table.State)pred.state().gotoSetNonTerminals.get(reduction);
+ target.newNodeFromReduction(r, state0, reduction);
}
- public Result(Forest f, Node pred, Pos reduction, GSS.Phase target) {
+ public Result(Forest f, Node pred, Pos reduction) {
this.f = f;
this.pred = pred;
+ this.reduction = reduction;
if (pred != null) pred.addSucc(this);
- if (reduction == null) return;
- Parser.Table.State state0 = (Parser.Table.State)pred.state().gotoSetNonTerminals.get(reduction);
- target.newNodeFromReduction(this, state0, reduction);
}
// GraphViz //////////////////////////////////////////////////////////////////////////////