KVariable newDotVariable(Sort s) { KVariable newLabel; do { if (s == null) { newLabel = KVariable("DotVar" + (counter++), Att().add("anonymous")); } else { newLabel = KVariable("DotVar" + (counter++), Att().add("anonymous").add(Sort.class, s)); } } while (vars.contains(newLabel)); vars.add(newLabel); return newLabel; }
KVariable newDotVariable(Sort sort) { KVariable newLabel; do { newLabel = KVariable("_" + (counter++), Att().add(Sort.class, sort)); } while (vars.contains(newLabel)); vars.add(newLabel); return newLabel; }
KVariable newDotVariable(Sort sort) { KVariable newLabel; do { newLabel = KVariable("_" + (counter++), Att().add(Sort.class, sort)); } while (vars.contains(newLabel)); vars.add(newLabel); return newLabel; }
KVariable newDotVariable() { KVariable newLabel; do { newLabel = KVariable("_" + (counter++), Att().add("anonymous")); } while (vars.contains(newLabel)); vars.add(newLabel); return newLabel; }
private static Att attributesFromSource(Source source) { if (source != null) { return Att().add(Source.class, source); } return Att(); }
private static org.kframework.attributes.Att attributesFromLocation(Location location) { if (location != null) { return Att().add(Location.class, location); } else return Att(); }
KVariable newDotVariable(Sort sort) { KVariable newLabel; do { newLabel = KVariable("_" + (counter++), Att.empty().add(Sort.class, sort)); } while (vars.contains(newLabel)); vars.add(newLabel); return newLabel; }
@Override public K apply(KVariable k) { if (normalization.containsKey(k)) { return KVariable(normalization.get(k), k.att().add("denormal", k.name())); } return super.apply(k); } }.apply(denormal);
private KVariable normalize(KVariable var) { if (var.att().contains("denormal")) return var; if (!vars.containsKey(var)) { vars.put(var, "_" + counter++); } return KVariable(vars.get(var), var.att().add("denormal", var.name())); }
public org.kframework.definition.Bubble apply(StringSentence sentence) { return Bubble(sentence.getType(), sentence.getContent(), convertAttributes(sentence) .add("contentStartLine", Integer.class, sentence.getContentStartLine()) .add("contentStartColumn", Integer.class, sentence.getContentStartColumn())); }
public K apply(KVariable var) { if (var.name(). equals("HOLE") && transitions.stream().noneMatch(att::contains)) { return KVariable(var.name(), var.att().add(Sort.class, Outer.parseSort(att.getOptional("result").orElse("KResult")))); } return super.apply(var); } }.apply(body);
private Stream<? extends Sentence> genKore(Sort sort) { if (sort.equals(Sorts.K())) { return Stream.of(Rule(KRewrite(KApply(KLabel("is" + sort.toString()), KVariable("K")), BooleanUtils.TRUE), BooleanUtils.TRUE, BooleanUtils.TRUE)); } else { List<Sentence> res = new ArrayList<>(); res.add(Rule(KRewrite(KApply(KLabel("is" + sort.toString()), KVariable(sort.name(), Att().add(Sort.class, sort))), BooleanUtils.TRUE), BooleanUtils.TRUE, BooleanUtils.TRUE)); res.add(Rule(KRewrite(KApply(KLabel("is" + sort.toString()), KVariable("K")), BooleanUtils.FALSE), BooleanUtils.TRUE, BooleanUtils.TRUE, Att().add("owise"))); return res.stream(); } }
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 static Set<Sentence> makeCasts(Sort outerSort, Sort innerSort, Sort castSort) { Set<Sentence> prods = new HashSet<>(); Att attrs1 = Att().add(Sort.class, castSort); prods.add(Production(KLabel("#SyntacticCast"), castSort, Seq(NonTerminal(castSort), Terminal("::" + castSort.toString())), attrs1)); prods.add(Production(KLabel("#SemanticCastTo" + castSort.toString()), castSort, Seq(NonTerminal(castSort), Terminal(":" + castSort.toString())), attrs1)); prods.add(Production(KLabel("#InnerCast"), outerSort, Seq(Terminal("{"), NonTerminal(castSort), Terminal("}"), Terminal("<:" + castSort.toString())), attrs1)); prods.add(Production(KLabel("#OuterCast"), castSort, Seq(Terminal("{"), NonTerminal(innerSort), Terminal("}"), Terminal(":>" + castSort.toString())), attrs1)); return prods; } }
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); }
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()); }
private static Sentence markRegularRules(Definition d, ConfigurationInfoFromModule configInfo, Sentence s, String att) { if (s instanceof org.kframework.definition.Rule) { org.kframework.definition.Rule r = (org.kframework.definition.Rule) s; if (r.body() instanceof KApply) { KLabel klabel = ((KApply) r.body()).klabel(); if (d.mainModule().sortFor().contains(klabel) //is false for rules in specification modules not part of semantics && d.mainModule().sortFor().apply(klabel).equals(configInfo.topCell())) { return Rule.apply(r.body(), r.requires(), r.ensures(), r.att().add(att)); } } } return s; }
@Test public void testRewriteWithCellVariable() { K term = cell("<T>", KRewrite(KVariable("KCell", Att().add(Sort.class, Sort("KCell"))), cell("<k>", intToToken(1)))); K expected = cell("<T>", cell("<ts>", cell("<t>", KRewrite(KVariable("KCell", Att().add(Sort.class, Sort("KCell"))), cell("<k>", intToToken(1)))))); Assert.assertEquals(expected, pass.concretizeCell(term)); }
@Test public void testSimpleSplitting() { KVariable Y = KVariable("Y", Att().add(Sort.class, Sort("OptCell"))); K term = KRewrite(cell("<t>", cell("<env>"), KVariable("X"), Y), KVariable("X")); K expected = KRewrite(cell("<t>", KVariable("X"), cell("<env>"), Y), cell("<t>-fragment", KVariable("X"), app("noEnvCell"), app(".OptCell"))); KExceptionManager kem = new KExceptionManager(new GlobalOptions()); Assert.assertEquals(expected, new SortCells(cfgInfo, labelInfo).sortCells(term)); Assert.assertEquals(0, kem.getExceptions().size()); }