public final void invoke(Position r, Result only) {
boolean emptyProductions = only==null;
if (emptyProductions != (r.pos==0)) return;
- if (r.pos==0) new Result(r.zero(phase().getLocation().createRegion(phase().getLocation())), this, r, phase());
- else reduce(r, r.pos-1, phase(), only);
+ if (r.pos!=0) reduce(r, r.pos-1, phase(), only);
+ else {
+ Input.Region region = phase().getLocation().createRegion(phase().getLocation());
+ new Result(r.rewrite(region, phase().parser().cache()), this, r, phase());
+ }
}
private void reduce(Position r, int pos, GSS.Phase target, Result only) {
Node child = res.parent();
holder[pos] = res.getForest();
if (pos>0) child.reduce(r, pos-1, target, null);
- else new Reduction(child, r, r.rewrite(child.phase().getLocation().createRegion(target.getLocation())), target);
+ else {
+ Input.Region region = child.phase().getLocation().createRegion(target.getLocation());
+ new Reduction(child, r, r.rewrite(region, phase().parser().cache()), target);
+ }
}
holder[pos] = old;
}
if (results.size()==0) return null;
if (gv.hasNode(this)) return gv.createNode(this);
GraphViz.Node n = gv.createNode(this);
- n.label = ""+state.toStringx();
+ n.label = "state["+state.toInt()+"]";
n.shape = "rectangle";
boolean hasparents = false;
for(Result r : results) n.edge(r, "");