public scala.collection.Set<Tag> toTags(List<Tag> labels, ASTNode loc) { return immutable(labels.stream().flatMap(l -> { java.util.Set<Production> productions = context.tags.get(l.name()); if (productions.isEmpty()) throw KEMException.outerParserError("Could not find any productions for tag: " + l.name(), loc.getSource(), loc.getLocation()); return productions.stream().map(p -> Tag(p.getKLabel(kore))); }).collect(Collectors.toSet())); }
/** * Returns the KLabel for the list terminator. * Constructed as '.List{"<list_klabel>"} * Should be called only if isListDecl is true. * @return String representation of the separator KLabel. */ public String getTerminatorKLabel(boolean kore) { assert isListDecl(); return ".List{" + StringUtil.enquoteCString(getKLabel(kore)) + "}" + (kore ? "_" + getSort().name() : ""); }
.getProductions().stream().filter(p -> p.getKLabel(kore) != null).map(p -> Tag(p.getKLabel(kore))) .collect(Collectors.toSet())); if (p.getKLabel(kore) == null) prod = Production( sort, else prod = Production( KLabel(p.getKLabel(kore)), sort, immutable(items), 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)))));
public void applyUserList(Set<org.kframework.definition.Sentence> res, org.kframework.kore.Sort sort, Production p, UserList userList) { // Transform list declarations of the form Es ::= List{E, ","} into something representable in kore org.kframework.kore.Sort elementSort = userList.getSort(); org.kframework.attributes.Att attrs = convertAttributes(p).add(Att.userList(), userList.getListType()); String kilProductionId = "" + System.identityHashCode(p); Att attrsWithKilProductionId = attrs.add(PRODUCTION_ID, kilProductionId); org.kframework.definition.Production prod1, prod3; // Es ::= E "," Es prod1 = Production(KLabel(p.getKLabel(kore)), sort, Seq(NonTerminal(elementSort), Terminal(userList.getSeparator()), NonTerminal(sort)), attrsWithKilProductionId.add("right")); // Es ::= ".Es" prod3 = Production(KLabel(p.getTerminatorKLabel(kore)), sort, Seq(Terminal("." + sort.toString())), attrsWithKilProductionId.remove("format").remove("strict").add("klabel", p.getTerminatorKLabel(false))); res.add(prod1); res.add(prod3); }