}
public String toString() { return "[reduce " + position + "]"; }
- public Forest reduce(GSS.Phase.Node parent, GSS.Phase.Node onlychild, Forest rex) {
- Forest ret = reduce(parent, numPop-1, rex, onlychild, parent.phase());
- return ret;
+ public Forest reduce(GSS.Phase.Node parent) {
+ if (numPop==0) return finish(parent, zero(), parent.phase());
+ return reduce(parent, numPop-1, null, null, parent.phase());
}
public Forest reduce(GSS.Phase.Node parent, GSS.Phase.Node onlychild) {
for(GSS.Phase.Node child : parent.parents())
reduce(child, pos-1, rex, null, target);
} else {
- State state = parent.state.gotoSetNonTerminals.get(position.owner());
- if (state!=null)
- target.newNode(parent, rex, state, numPop<=0, parent.phase());
+ return finish(parent, rex, target);
}
return rex;
}
+ private Forest finish(GSS.Phase.Node parent, Forest result, GSS.Phase target) {
+ State state = parent.state.gotoSetNonTerminals.get(position.owner());
+ if (state!=null)
+ target.newNode(parent, result, state, numPop<=0, parent.phase());
+ return result;
+ }
}
}