@Override public Set<K> unit() { return Collections.<K>Set(); }
@Override public Set<E> unit() { return Collections.<E>Set(); }
@Override public Set<K> unit() { return Collections.<K>Set(); }
@Override public scala.collection.Set<K> apply(KVariable k) { if (k.name().equals("HOLE")) { return org.kframework.Collections.Set(k); } else { return super.apply(k); } } }.apply(body).size();
@Override public scala.collection.Set<K> apply(KRewrite k) { return this.merge(org.kframework.Collections.Set(k), super.apply(k)); } }.apply(body).size();
/** * Creates the seed module that can be used to parse rules. * Imports module markers RULE-CELLS and K found in /include/kast.k. * @param mod The user defined module from which to start. * @return a new module which imports the original user module and a set of marker modules. */ public Module getRuleGrammar(Module mod) { // import RULE-CELLS in order to parse cells specific to rules Module newM = new Module( mod.name() + "-" + RULE_CELLS , Set(mod, baseK.getModule(K).get(), baseK.getModule(RULE_CELLS).get(), baseK.getModule(DEFAULT_LAYOUT).get()) , Set() , Att() ); return newM; }
/** * Creates the seed module that can be used to parse configurations. * Imports module markers CONFIG-CELLS and K found in /include/kast.k. * @param mod The user defined module from which to start. * @return a new module which imports the original user module and a set of marker modules. */ public Module getConfigGrammar(Module mod) { // import CONFIG-CELLS in order to parse cells specific to configurations Module newM = new Module( mod.name() + "-" + CONFIG_CELLS , Set(mod, baseK.getModule(K).get(), baseK.getModule(CONFIG_CELLS).get(), baseK.getModule(DEFAULT_LAYOUT).get()) , Set() , Att() ); return newM; }
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();
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 static Definition addSemanticsModule(Definition d) { java.util.Set<Module> allModules = mutable(d.modules()); Module languageParsingModule = Constructors.Module("LANGUAGE-PARSING", Set(d.mainModule(), d.getModule(d.att().get(Att.syntaxModule())).get(), d.getModule("K-TERM").get(), d.getModule(RuleGrammarGenerator.ID_PROGRAM_PARSING).get()), Set(), Att()); allModules.add(languageParsingModule); return Constructors.Definition(d.mainModule(), immutable(allModules), d.att()); }
@Test public void testFrom() throws Exception { org.kframework.definition.Definition actual = Definition.from("module X endmodule"); Module modSyntax = Module.apply("X$SYNTAX", Set()); Module mod = new Module("X", Set(modSyntax), Set(), Att()); assertEquals(org.kframework.definition.Definition.apply(mod, Set(mod, modSyntax), Att()), actual); } }
return Module.apply(mod.name() + POSTFIX, immutable(modules), Set(), Att());
@Override public scala.collection.Set<Sort> getCellBagSortsOfCell(Sort k) { return Set(Sort(k.name() + "Bag", k.params())); } }
res.add(SyntaxAssociativity(applyAssoc("left"), Set(Tag(p.getKLabel(kore))))); else if (p.containsAttribute("right")) res.add(SyntaxAssociativity(applyAssoc("right"), Set(Tag(p.getKLabel(kore))))); else if (p.containsAttribute("non-assoc")) res.add(SyntaxAssociativity(applyAssoc("non-assoc"), Set(Tag(p.getKLabel(kore)))));
throw KEMException.compilerError("Module Map must be visible at the configuration declaration, in module " + module.name()); return Module(module.name(), (Set<Module>) module.imports().$bar(Set(mapModule)), (Set<Sentence>) module.localSentences().$bar(configDeclSyntax), module.att()); throw KEMException.compilerError("Module Map must be visible at the configuration declaration, in module " + module.name()); return Module(module.name(), (Set<Module>) module.imports().$bar(Set(mapModule)), (Set<Sentence>) module.localSentences().$bar(configDeclRules), module.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); }
disambProds.addAll(res); Module extensionM = new Module(mod.name() + "-EXTENSION", Set(mod), immutable(extensionProds), mod.att()); Module disambM = new Module(mod.name() + "-DISAMB", Set(), immutable(disambProds), mod.att()); Module parseM = new Module(mod.name() + "-PARSER", Set(), immutable(parseProds), mod.att()); return new ParseInModule(mod, extensionM, disambM, parseM, strict);
if (realProds.head().items().size() == 1) { return Tuple4.apply(Set(), Lists.newArrayList(sort), KApply(KLabel(getInitLabel(sort))), true); } else if (realProds.head().items().size() == 4) { return Tuple4.apply(Set(), Lists.newArrayList(sort), KApply(KLabel(getInitLabel(sort)), INIT), true); Set<Sentence> accumSentences = Set(); List<Sort> sorts = Lists.newArrayList(); List<K> initializers = Lists.newArrayList();
cell("opt", Collections.singletonMap("multiplicity", "?"), KApply(KLabel(".Opt"), KList(), Att.empty().add(Production.class, prod)))))); Module m1 = Module("CONFIG", Set(def.getModule("KSEQ").get()), Set(prod), Att()); RuleGrammarGenerator parserGen = new RuleGrammarGenerator(def); Module m = RuleGrammarGenerator.getCombinedGrammar(parserGen.getConfigGrammar(m1), true).getExtensionModule(); Att initializerAtts = Att().add("initializer"); Att productionAtts = initializerAtts.add("function").add("noThread"); Set<Sentence> reference = Set(Production(KLabel("<threads>"), Sort("ThreadsCell"), Seq(Terminal("<threads>"), NonTerminal(Sort("ThreadCellBag")), Terminal("</threads>")), Att().add("cell").add("cellName", "threads").add("topcell").add("format", "%1%i%n%2%d%n%3")), ); assertEquals("Produced unexpected productions", Set(), gen.$amp$tilde(reference)); assertEquals("Missing expected productions", Set(), reference.$amp$tilde(gen));