private static Module excludeModulesByTag(Set<String> excludedModuleTags, Module mod) { Set<Module> newImports = stream(mod.imports()).filter(_import -> excludedModuleTags.stream().noneMatch(tag -> _import.att().contains(tag))).collect(Collectors.toSet()); return Module(mod.name(), immutable(newImports), mod.localSentences(), mod.att()); }
convert(attributes, module.att()); sb.append("\n"); return sb.toString();
public Module resolve(Module m) { module = m; funProds.clear(); funRules.clear(); Set<Sentence> newSentences = stream(m.localSentences()).map(this::resolve).collect(Collectors.toSet()); newSentences.addAll(funProds); newSentences.addAll(funRules); return Module(m.name(), m.imports(), immutable(newSentences), m.att()); } }
.andThen(mod -> Module(mod.name(), mod.imports(), Stream.concat(stream(mod.localSentences()), Stream.<Sentence>of(thread, bottom, threadLocal)).collect(org.kframework.Collections.toSet()), mod.att())) .andThen(convertLookups) .andThen(expandMacros)
public Module resolve(Module input) { Set<Sentence> rulesToAdd = stream(input.sentences()) .filter(s -> s instanceof Context) .map(s -> (Context) s) .flatMap(c -> this.resolve(c, input)).collect(Collectors.toCollection(HashSet::new)); if (!rulesToAdd.isEmpty()) { rulesToAdd.add(SyntaxSort(Sorts.K())); } return Module(input.name(), input.imports(), (scala.collection.Set<Sentence>) stream(input.localSentences()).filter(s -> !(s instanceof Context)).collect(Collections.toSet()).$bar(immutable(rulesToAdd)), input.att()); }
public String convertSpecificationModule(Module definition, Module spec) { ConfigurationInfoFromModule configInfo = new ConfigurationInfoFromModule(definition); Sort topCell = configInfo.getRootCell(); sb.append("[]\n"); sb.append("module "); convert(spec.name()); sb.append("\n\n// imports\n"); sb.append("import "); convert(definition.name()); sb.append(" []\n"); sb.append("\n\n// claims\n"); for (Sentence sentence : iterable(spec.sentencesExcept(definition))) { assert sentence instanceof Rule || sentence instanceof ModuleComment : "Unexpected non-rule claim " + sentence.toString(); if (sentence instanceof Rule) { convertRule((Rule) sentence, false, topCell, new HashMap<>(), HashMultimap.create(), true); } } sb.append("endmodule "); convert(new HashMap<>(), spec.att()); sb.append("\n"); return sb.toString(); }
private static Module filterStreamModules(Module input) { if (input.name().equals("STDIN-STREAM") || input.name().equals("STDOUT-STREAM")) { return Module(input.name(), Set(), Set(), input.att()); } return input; }
public static Module resolve(Module m) { Set<Sentence> newSentences = JavaConverters.asScalaSet(stream(m.localSentences()).map(s -> s instanceof Production ? resolve((Production) s) : s).collect(Collectors.toSet())); return Module(m.name(), m.imports(), newSentences, m.att()); }
public Module gen(Module mod) { this.mod = mod; predicateRules = stream(mod.rules()).filter(this::isPredicate).collect(Collectors.toSet()); return Module(mod.name(), mod.imports(), (Set<Sentence>) mod.localSentences().$bar(stream(mod.definedSorts()) .flatMap(this::gen).collect(Collections.toSet())), mod.att()); }
public static Function1<Definition, Definition> excludeModulesByTag(Set<String> excludedModuleTags) { DefinitionTransformer dt = DefinitionTransformer.from(mod -> excludeModulesByTag(excludedModuleTags, mod), "remove modules based on attributes"); return dt.andThen(d -> Definition(d.mainModule(), immutable(stream(d.entryModules()).filter(mod -> excludedModuleTags.stream().noneMatch(tag -> mod.att().contains(tag))).collect(Collectors.toSet())), d.att())); }
public Module resolve(Module input) { Set<Sentence> contextsToAdd = resolve(stream(input.localSentences()) .filter(s -> s instanceof Production) .map(s -> (Production) s) .filter(p -> p.att().contains("strict") || p.att().contains("seqstrict")).collect(Collectors.toSet())); return Module(input.name(), input.imports(), (scala.collection.Set<Sentence>) input.localSentences().$bar(immutable(contextsToAdd)), input.att()); } }
stream((Set<Sentence>) module.localSentences().$bar(ruleSet).$bar(contextSet)).filter(b -> !(b instanceof Bubble)).collect(Collections.toSet()), module.att());
public static Module subsortKItem(Module module) { java.util.Set<Sentence> prods = new HashSet<>(); for (Sort srt : iterable(module.definedSorts())) { if (!RuleGrammarGenerator.isParserSort(srt)) { // KItem ::= Sort Production prod = Production(Sorts.KItem(), Seq(NonTerminal(srt)), Att()); if (!module.sentences().contains(prod)) { prods.add(prod); } } } if (prods.isEmpty()) { return module; } else { return Module(module.name(), module.imports(), Stream.concat(stream(module.localSentences()), prods.stream()) .collect(org.kframework.Collections.toSet()), module.att()); } }
return Module.apply(oldMod.name(), immutable(imports), oldMod.localSentences(), oldMod.att()); }, "apply program parsing modules").apply(mod);
return Module(m.name(), m.imports(), immutable(sentences), m.att());
java.util.Set<Module> imports = mutable(mod.imports()); imports.add(defaultConfiguration); return Module(mod.name(), (Set<Module>) immutable(imports), mod.localSentences(), mod.att());
public Module gen(Module mod) { Set<Sentence> res = new HashSet<>(); for (Sort sort : iterable(mod.definedSorts())) { Production prod = Production(KLabel("is" + sort.toString()), Sorts.Bool(), Seq(Terminal("is" + sort.toString()), Terminal("("), NonTerminal(Sorts.K()), Terminal(")")), Att().add(Attribute.FUNCTION_KEY).add(Attribute.PREDICATE_KEY, Sort.class, sort)); if (!mod.productions().contains(prod)) res.add(prod); } if (!res.isEmpty()) { res.add(SyntaxSort(Sorts.K())); } return Module(mod.name(), mod.imports(), (scala.collection.Set<Sentence>) mod.localSentences().$bar(immutable(res)), mod.att()); } }
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);
return m; return new GenerateSortPredicateSyntax().gen(Module(m.name(), kore ? m.imports() : add(def.getModule("K-REFLECTION").get(), m.imports()), sentences, m.att()));