private KLabel apply(KLabel klabel) { if (klabel.name().equals(builtinCellLabel)) { return userCellLabel; } else { return klabel; } } }.apply(rule.body());
private static String encodeStringToMemoFunction(StringBuilder sb, KLabel lbl) { StringBuilder sb2 = new StringBuilder(); sb2.append("memo"); encodeStringToAlphanumeric(sb2, lbl.name()); sb.append(sb2); return sb2.toString(); }
private static String encodeStringToFunction(StringBuilder sb, KLabel lbl) { StringBuilder sb2 = new StringBuilder(); sb2.append("eval"); encodeStringToAlphanumeric(sb2, lbl.name()); sb.append(sb2); return sb2.toString(); }
@Override public DefaultMutableTreeNode apply(InjectedKLabel k) { return new DefaultMutableTreeNode(k.klabel().name()); } }
@Override public void apply(KApply k) { if (k.klabel().name().equals("#externalCell")) { hasConfigVar = true; } super.apply(k); }
@Override public K apply(KApply orig) { String name = orig.klabel().name(); return options.omittedKLabels.contains(name) ? omitTerm(mod, orig) : options.tokenizedKLabels.contains(name) ? tokenizeTerm(mod, orig) : options.flattenedKLabels.contains(name) ? flattenTerm(mod, orig) : options.tokastKLabels.contains(name) ? toKASTTerm(mod, orig) : orig ; } }.apply(term);
@Override public Boolean apply(KApply k) { return k.klabel().name().equals("#RESTORE_CONFIGURATION") || super.apply(k); } }.apply(r.body());
private boolean isInitRule(String initLabel, String cellLabel, Sentence s) { try { // rule initXCell(Init) => <x> ... </x> KRewrite body = (KRewrite) ((Rule) s).body(); KApply left = (KApply) body.left(); KApply right = (KApply) body.right(); return left.klabel().name().equals(initLabel) // initXCell && right.klabel().name().equals(cellLabel); // <x> } catch (ClassCastException ignored) { return false; } }
@Override public Term apply(TermCons tc) { if (tc.production().att().contains("bracket") || tc.production().klabel().get().name().equals("#SyntacticCast") || tc.production().klabel().get().name().equals("#InnerCast") || tc.production().klabel().get().name().equals("#OuterCast")) { return apply(tc.get(0)); } return super.apply(tc); } }
private void forEachKLabel(Consumer<Tuple2<KLabel, Long>> action) { for (KLabel label : iterable(mainModule.definedKLabels())) { if (ConvertDataStructureToLookup.isLookupKLabel(label) || label.name().equals("#KToken")) continue; stream(mainModule.productionsFor().apply(label)).map(p -> Tuple2.apply(p.klabel().get(), stream(p.items()).filter(pi -> pi instanceof NonTerminal).count())).distinct().forEach(action); } }
public scala.collection.Set<K> apply(KApply k) { if (k.klabel().name().equals(Strategy.strategyCellName())) return org.kframework.Collections.Set(k); else return super.apply(k); } }.apply(theNew).head();
public scala.collection.Set<K> apply(KApply k) { if (k.klabel().name().equals("#RESTORE_CONFIGURATION")) return org.kframework.Collections.Set(k.klist().items().get(0)); else return super.apply(k); } }.apply(theNew).head();
private boolean hasCells(KApply k) { for (int i = 0; i < k.klist().size(); i++) { K item = k.klist().items().get(i); if (item instanceof KApply && ((KApply) item).klabel().name().equals("#cells")) { return true; } } return false; }
private Context upContext(K contents) { KApply ruleContents = (KApply) contents; List<K> items = ruleContents.klist().items(); switch (ruleContents.klabel().name()) { case "#ruleNoConditions": return Context(items.get(0), BooleanUtils.TRUE, ruleContents.att()); case "#ruleRequires": return Context(items.get(0), items.get(1), ruleContents.att()); default: throw KEMException.criticalError("Illegal context with ensures clause detected.", contents); } }
private Term convert1(KLabel klabel) { if (klabel instanceof KVariable) { return KVariable(klabel.name(), ((KVariable) klabel).att().add(org.kframework.kore.Sort.class, Sorts.KLabel())); } else { return KLabel(klabel); } }
private boolean isConstructorLike(KLabel klabel) { String labelName = klabel.name(); if (isInjectionLabel(labelName) || isBuiltinModuloConstructor(klabel)) return true; Set<Production> productionSet = module.productionsFor().apply(klabel); assert productionSet.size() == 1 : "Should not have more than one production"; Production production = productionSet.head(); return !production.att().contains(Att.Function()); }
private Production production(KApply term) { if (term.klabel().name().equals(KLabels.INJ)) return Production(INJ_PROD.klabel(), INJ_PROD.sort(), INJ_PROD.items(), Att.empty().add("originalPrd", Production.class, INJ_PROD)); scala.collection.Set<Production> prods = module.productionsFor().apply(((KApply) term).klabel()); assert(prods.size() == 1); return computePolyProd(prods.head()); }
public static K flattenTerm(Module mod, KApply kapp) { List<K> items = new ArrayList<>(); Att att = mod.attributesFor().apply(KLabel(kapp.klabel().name())); if (att.contains("assoc") && att.contains("unit")) { items = Assoc.flatten(kapp.klabel(), kapp.klist().items(), KLabel(att.get("unit"))); } else { items = kapp.klist().items(); } return KApply(kapp.klabel(), KList(items), kapp.att()); }
private static Set<Sentence> genProjection(Sort sort, Module m) { KLabel lbl = getProjectLbl(sort, m); KVariable var = KVariable("K", Att.empty().add(Sort.class, sort)); Rule r = Rule(KRewrite(KApply(lbl, var), var), BooleanUtils.TRUE, BooleanUtils.TRUE, Att().add("projection")); if (m.definedKLabels().contains(lbl)) { return Set(r); } return Set(Production(lbl, sort, Seq(Terminal(lbl.name()), Terminal("("), NonTerminal(Sorts.K()), Terminal(")")), Att().add("function").add("projection")), r); }