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; }
throw KEMException.compilerError("Missing cell of multiplicity=\"1\": " + sort, k); } else { ordered.set(order.indexOf(sort), cfg.cfg.getUnit(sort));
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)); }
klist.set(i, cfg.getCellAbsentTerm(subcellSorts.get(i))); } else { // Multiplicity.OPTIONAL || Multiplicity.STAR klist.set(i, cfg.cfg.getUnit(subcellSorts.get(i)));