public Production(NonTerminal sort, java.util.List<ProductionItem> items) { super(); this.items = items; this.sort = sort.getSort(); }
public Production(NonTerminal sort, java.util.List<ProductionItem> items, String ownerModule) { super(); this.items = items; this.sort = sort.getSort(); this.ownerModuleName = ownerModule; }
private String getPrefixLabel(boolean kore) { String label = ""; List<String> sorts = new ArrayList<>(); for (ProductionItem pi : items) { if (pi instanceof NonTerminal) { label += "_"; sorts.add(((NonTerminal) pi).getSort().name()); } else if (pi instanceof Terminal) { label += ((Terminal) pi).getTerminal(); } else if (pi instanceof UserList) { label += "_" + ((UserList) pi).separator + "_"; sorts.add(((UserList) pi).sort.name()); sorts.add(sort.name()); } } return label + "_" + ownerModuleName + (kore ? "_" + sorts.stream().reduce("", (s1, s2) -> s1 + "_" + s2) : ""); }
private static void check(ModuleItem i) { if (i instanceof Syntax) { Syntax s = (Syntax) i; for (PriorityBlock b : s.getPriorityBlocks()) { for (Production p : b.getProductions()) { if (p.getItems().size() == 1 && p.getItems().get(0) instanceof UserList) { // Syntax Es ::= List{E,""} Sort listSort = s.getDeclaredSort().getSort(); // Es Sort elemSort = ((UserList) p.getItems().get(0)).getSort(); // E if (isBaseSort(listSort)) { throw KEMException.compilerError(listSort + " can not be extended to be a list sort.", p); } if (listSort.equals(elemSort)) { throw KEMException.compilerError("Circular lists are not allowed.", p); } } else { for (ProductionItem it : p.getItems()) { if (it instanceof UserList) { // Syntax Es ::= ... List{E,""} ... throw KEMException.compilerError("Inline list declarations are not allowed.", it); } } } } } } } }
public Set<org.kframework.definition.Sentence> apply(Syntax s) { Set<org.kframework.definition.Sentence> res = new HashSet<>(); org.kframework.kore.Sort sort = s.getDeclaredSort().getSort(); if (it instanceof NonTerminal) { NonTerminal nt = (NonTerminal)it; items.add(NonTerminal(nt.getSort(), nt.getName())); } else if (it instanceof UserList) { throw new AssertionError("Lists should have applied before.");