- if (only == null || res == only) {
- Node child = res.parent();
- holder[pos] = res.getForest();
- if (pos>0) child.reduce(r, pos-1, target, null);
- 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 (only == null || res == only)
+ for(Node pred : res.getPreds())
+ reduce2(r, pos, target, pred, res.getForest());
+ }
+
+ void reduce2(Pos r, int pos, GSS.Phase target, Node pred, Forest f) {
+ Forest[] holder = r.holder;
+ Forest old = pos >= holder.length ? null : holder[pos];
+ if (pos < holder.length) holder[pos] = f;
+ if (pos>0) pred.reduce(r, pos-1, target, null);
+ else {
+ Input.Region region = pred.phase().getLocation().createRegion(target.getLocation());
+ new Reduction(pred, r, r.rewrite(region), target);
+ }
+ if (pos < holder.length) holder[pos] = old;