@Override public boolean equals(Object obj) { if (obj == null) return false; if (this == obj) return true; if (!(obj instanceof Syntax)) return false; Syntax syn = (Syntax) obj; if (!syn.getDeclaredSort().equals(this.sort)) return false; if (syn.priorityBlocks.size() != priorityBlocks.size()) return false; for (int i = 0; i < syn.priorityBlocks.size(); i++) { if (!syn.priorityBlocks.get(i).equals(priorityBlocks.get(i))) return false; } return true; }
public void visit(Syntax syntax) { this.sort = syntax.getDeclaredSort().getRealSort(); syntax.getPriorityBlocks().forEach(pb -> pb.getProductions().forEach(this::visit)); }
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();