public static List<K> flattenCells(K cells) { List<K> children = new ArrayList<K>(); flattenCells(children, cells); return children; }
Stream<K> streamSideCells(K side) { List<K> cells = IncompleteCellUtils.flattenCells(side); // TODO error handling return cells.stream(); }
private Stream<K> streamCells(K term) { return IncompleteCellUtils.flattenCells(term).stream(); }
public static List<K> getChildren(KApply cell) { return flattenCells(cell.klist().items().get(1)); }
private K apply(K term) { if (labelInfo.isFunction(term)) return term; List<K> items = IncompleteCellUtils.flattenCells(term); if (items.size() != 1) { return term; } K item = items.get(0); if (isCell(item)) { return term; } else if (item instanceof KRewrite) { final KRewrite rew = (KRewrite) item; if (Stream.concat( IncompleteCellUtils.flattenCells(rew.left()).stream(), IncompleteCellUtils.flattenCells(rew.right()).stream()) .anyMatch(this::isCell)) { return term; } } KLabel computation = cfg.getCellLabel(cfg.getComputationCell()); return IncompleteCellUtils.make(computation, false, item, true); }
private static void flattenCells(List<K> children, K item) { if (item instanceof KApply && KLabels.CELLS.equals(((KApply) item).klabel())) { for (K deeper : ((KApply) item).klist().items()) { flattenCells(children, deeper); } } else { children.add(item); } } public static List<K> flattenCells(K cells) {
List<K> children = IncompleteCellUtils.flattenCells(item); if(children.size() == 1 && children.get(0) == item) { final KLabel label = ((KApply) item).klabel();
} else if (k instanceof KRewrite) { KRewrite rew = (KRewrite) k; List<K> cells = IncompleteCellUtils.flattenCells(rew.left()); cells.addAll(IncompleteCellUtils.flattenCells(rew.right())); Optional<Integer> level = Optional.empty(); for (K item : cells) {
for (K item : IncompleteCellUtils.flattenCells(k)) { // #cells(#cells(x,y),z) => [x,y,z] if (item instanceof KApply) { KApply kapp = (KApply) item;
if (item instanceof KRewrite) { KRewrite rw = (KRewrite) item; for (K leftItem : IncompleteCellUtils.flattenCells(rw.left())) { filterRequired(requiredLeft, leftItem); for (K rightItem : IncompleteCellUtils.flattenCells(rw.right())) { filterRequired(requiredRight, rightItem);