/** * 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; }
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);
@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); } }