@Override public boolean equals(Object obj) { if (obj == null) return false; if (obj == this) return true; if (!(obj instanceof NonTerminal)) return false; NonTerminal nt = (NonTerminal) obj; if (!sort.equals(nt.sort)) return false; return true; }
/** * Gets the corresponding {@code Sort} from its {@code String} * representation. * * @param name * the name of the sort * @return the sort */ public static Sort of(org.kframework.kore.Sort sort) { return cache.computeIfAbsent(sort.toString(), s -> new Sort(sort.name(), sort.params(), maxOrdinal.getAndIncrement())); }
@Override public int hashCode() { return sort.hashCode(); }
public static boolean isParserSort(Sort s) { return kSorts.contains(s) || s.name().startsWith("#"); }
private Stream<? extends Sentence> genKore(Sort sort) { if (sort.equals(Sorts.K())) { return Stream.of(Rule(KRewrite(KApply(KLabel("is" + sort.toString()), KVariable("K")), BooleanUtils.TRUE), BooleanUtils.TRUE, BooleanUtils.TRUE)); } else { List<Sentence> res = new ArrayList<>(); res.add(Rule(KRewrite(KApply(KLabel("is" + sort.toString()), KVariable(sort.name(), Att().add(Sort.class, sort))), BooleanUtils.TRUE), BooleanUtils.TRUE, BooleanUtils.TRUE)); res.add(Rule(KRewrite(KApply(KLabel("is" + sort.toString()), KVariable("K")), BooleanUtils.FALSE), BooleanUtils.TRUE, BooleanUtils.TRUE, Att().add("owise"))); return res.stream(); } }
private boolean isExceptionSort(Sort srt) { return kSorts.contains(srt) || srt.name().startsWith("#"); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; KToken kToken = (KToken) o; if (!s.equals(kToken.s)) return false; return sort.equals(kToken.sort); }
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) : ""); }
@Override public int hashCode() { int result = s.hashCode(); result = 31 * result + sort.hashCode(); return result; } }
private boolean isPredicateFor(Rule r, Sort s) { Optional<Sort> sort = getPredicateSort(r); return sort.isPresent() && sort.get().equals(s); }
/** * 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() : ""); }
@Override public int hashCode() { return this.separator.hashCode() + this.sort.hashCode(); }
public Term apply(Constant c) { if (c.production().sort().equals(Sorts.KVariable()) && !declaredNames.contains(getVarKey(c))) { if (vars.isEmpty()) vars.add(HashMultimap.<VarKey, Sort>create()); for (Multimap<VarKey, Sort> vars2 : vars) vars2.put(getVarKey(c), sort); } return c; } }
private void check(Production p) { if (p.att().contains(Attribute.CELL_KEY)) { for (ProductionItem i : mutable(p.items())) { if (i instanceof NonTerminal) { Sort sort = ((NonTerminal) i).sort(); if (sort.name().endsWith("Cell")) { if (cells.contains(sort)) { Production cell = new ConfigurationInfoFromModule(module).cellProductionsFor().get(sort).get().head(); errors.add(KEMException.compilerError("Cell " + cell.klabel().get() + " found twice in configuration.", p)); } cells.add(sort); } } } } } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((items == null) ? 0 : items.hashCode()); result = prime * result + ((getAttribute("klabel") == null) ? 0 : getAttribute("klabel").hashCode()); result = prime * result + ((sort == null) ? 0 : sort.hashCode()); result = prime * result + ((binderMap == null) ? 0 : binderMap.hashCode()); return result; }
@Override public boolean equals(Object obj) { if (obj == null) return false; if (obj == this) return true; if (!(obj instanceof UserList)) return false; UserList srt = (UserList) obj; if (!sort.equals(srt.getSort())) return false; if (!separator.equals(srt.getSeparator())) return false; return true; }