@Override public void apply(KApply k) { if (cfg.isParentCell(k.klabel())) { if (inRewrite) { processSide(k, inRhs, k.klist().stream() .flatMap(this::streamCells) .collect(Collectors.toList())); } else { processSide(k, false, k.klist().stream() .flatMap(this::streamCells).map(this::left).flatMap(this::streamCells) .collect(Collectors.toList())); processSide(k, true, k.klist().stream() .flatMap(this::streamCells).map(this::right).flatMap(this::streamCells) .collect(Collectors.toList())); } } super.apply(k); }
K concretize(K term) { if (term instanceof KApply) { KApply app = (KApply) term; KApply newTerm = KApply(app.klabel(), KList(app.klist().stream() .map(this::concretize).collect(Collectors.toList()))); if (cfg.isParentCell(newTerm.klabel())) { return concretizeCell(newTerm); } else { return newTerm; } } else if (term instanceof KRewrite) { KRewrite rew = (KRewrite) term; return KRewrite(concretize(rew.left()), concretize(rew.right())); } else if (term instanceof KSequence) { return KSequence(((KSequence) term).stream() .map(this::concretize).collect(Collectors.toList())); } else { return term; } }
Optional<K> theStrategy = ((KApply) subject.term()).klist().stream() .filter(t -> t instanceof KApply && ((KApply) t).klabel().name().contains(Strategy.strategyCellName())) .findFirst(); K s = constructor.KApply1(((KApply) theStrategy.get()).klabel(), constructor.KList(Collections.singletonList(sContent)), emptyAtt); Term entireConf = constructor.KApply1(((KApply) subject.term()).klabel(), constructor.KList(((KApply) subject.term()).klist().stream().map(k -> k instanceof KApply && ((KApply) k).klabel().name().contains(Strategy.strategyCellName()) ? s : k).collect(Collectors.toList())), emptyAtt); return Optional.of(new ConstrainedTerm(entireConf, subject.termContext()));
klist.stream().map(k -> ((KApply) k).klist().items()).map(l -> Pair.of(convert(l.get(0)), getRuleSet((KApply) l.get(1)))).collect(Collectors.toList()), global);