private void addDefaultCells(K item, Map<Sort, K> splitLeft, Map<Sort, K> splitRight) { for (Sort s : Sets.difference(splitLeft.keySet(), splitRight.keySet())) { if (cfg.getMultiplicity(s) == Multiplicity.ONE) { throw KEMException.compilerError("Cannot rewrite a multiplicity=\"1\" cell to or from the cell unit.", item); } else { splitRight.put(s, cfg.cfg.getUnit(s)); } } }
private K concatenateStarCells(Sort sort, List<K> children) { if (cfg.getMultiplicity(sort) != Multiplicity.STAR) { throw KEMException.compilerError("Attempting to concatenate cells not of multiplicity=\"*\" " + "into a cell collection.", children.iterator().next()); } if (children.size() == 0) { return cfg.cfg.getUnit(sort); } KLabel concat = cfg.cfg.getConcat(sort); int ix = children.size(); K result = children.get(--ix); while (ix > 0) { result = KApply(concat,children.get(--ix),result); } return result; }
private Sort getPredicateSort(Sort s) { if (cfg.getMultiplicity(s) == Multiplicity.STAR) { scala.collection.Set<Sort> sorts = cfg.cfg.getCellBagSortsOfCell(s); if (sorts.size() != 1) { throw KEMException.compilerError("Expected exactly one cell collection sort for the sort " + s + "; found " + sorts); } return stream(sorts).findFirst().get(); } return s; }
for (K k : cells) { Sort sort = cfg.getCellSort(k); if (cfg.getMultiplicity(sort) != ConfigurationInfo.Multiplicity.STAR) { if (used.contains(sort)) { return false; if (!children.isEmpty()) { Sort label = cfg.getCellSort(children.get(0)); if (cfg.getMultiplicity(label) == ConfigurationInfo.Multiplicity.STAR) { forcedSeparate = false; } else { for (KRewrite rew2 : rewrites) { Set<Sort> left1NonRepeatable = streamSideCells(rew1.left()).map(cfg::getCellSort) .filter(l -> cfg.getMultiplicity(l) != ConfigurationInfo.Multiplicity.STAR) .collect(Collectors.toSet()); boolean lhsConflict = streamSideCells(rew2.left()).map(cfg::getCellSort) .filter(l -> cfg.getMultiplicity(l) != ConfigurationInfo.Multiplicity.STAR) .collect(Collectors.toSet()); boolean rhsConflict = streamSideCells(rew2.right()).map(cfg::getCellSort)
if (cfg.getMultiplicity(sort) == Multiplicity.ONE) { throw KEMException.compilerError("Missing cell of multiplicity=\"1\": " + sort, k); } else {
K replacementTerm() { getSplit(var); KLabel fragmentLabel = cfg.getCellFragmentLabel(parentCell); if (fragmentLabel == null) { throw KEMException.compilerError("Unsupported cell fragment with types: " + remainingCells, var); } List<Sort> children = cfg.getChildren(parentCell); List<K> arguments = new ArrayList<>(children.size()); for (Sort child : children) { K arg = split.get(child); if (arg == null) { if (cfg.getMultiplicity(child) == Multiplicity.ONE) { arg = cfg.getCellAbsentTerm(child); } else { arg = cfg.cfg.getUnit(child); } } assert arg != null; arguments.add(arg); } return KApply(fragmentLabel, immutable(arguments)); }
Map<Sort, K> getSplit(KVariable var) { if(split != null) { return split; } if (remainingCells.size() == 0) { split = Collections.emptyMap(); } else if (remainingCells.size() == 1) { Sort s = Iterables.getOnlyElement(remainingCells); if (cfg.getMultiplicity(s) == Multiplicity.STAR) { split = ImmutableMap.of(s, KVariable( var.name(), var.att().add(Sort.class, getPredicateSort(s)))); } else { split = ImmutableMap.of(s, KVariable(var.name(), var.att().add(Sort.class, s).add("cellSort"))); } } else { split = new HashMap<>(); for (Sort cell : remainingCells) { split.put(cell, newDotVariable(var.att().add(Sort.class, cell).add("cellSort"))); } } return split; } }
klist.set(i, cellFragment.klist().items().get(i)); } else { if (cfg.getMultiplicity(subcellSorts.get(i)) == Multiplicity.ONE) { klist.set(i, cfg.getCellAbsentTerm(subcellSorts.get(i))); } else { // Multiplicity.OPTIONAL || Multiplicity.STAR
Set<Sort> requiredRight; for (Sort child : cfg.getChildren(label)) { if (cfg.getMultiplicity(child) == ConfigurationInfo.Multiplicity.ONE) { requiredLeft.add(child);
KApply kApply = (KApply) item; Sort s = cfg.getCellSort(kApply.klabel()); if (s != null && cfg.getMultiplicity(s) != Multiplicity.STAR) { remainingCells.remove(s);