@Override public boolean equals(Object obj) { if (obj == null) return false; if (this == obj) return true; if (!(obj instanceof PriorityExtendedAssoc)) return false; PriorityExtendedAssoc syn = (PriorityExtendedAssoc) obj; if (syn.tags.size() != tags.size()) return false; for (int i = 0; i < syn.tags.size(); i++) { if (!syn.tags.get(i).equals(tags.get(i))) return false; } return true; }
@Override public int hashCode() { int hash = 0; for (Tag prd : productions) hash += prd.hashCode(); return hash; }
private boolean isRightAssoc(ProductionReference outer, ProductionReference inner) { Tag parentLabel = new Tag(outer.production().klabel().get().name()); Tag localLabel = new Tag(inner.production().klabel().get().name()); if (m.rightAssoc().contains(new Tuple2<>(parentLabel, localLabel))) { return true; } return false; }
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())); }
/** Parses a list of KLabels and returns them */ final public List<Tag> KLabels() throws ParseException { List<Tag> list = new ArrayList<Tag>(); label_3: while (true) { jj_consume_token(KLABEL); list.add(new Tag(image())); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case KLABEL: ; break; default: jj_la1[6] = jj_gen; break label_3; } } {if (true) return list;} throw new Error("Missing return statement in function"); }
private boolean isLeftAssoc(ProductionReference outer, ProductionReference inner) { Tag parentLabel = new Tag(outer.production().klabel().get().name()); Tag localLabel = new Tag(inner.production().klabel().get().name()); if (m.leftAssoc().contains(new Tuple2<>(parentLabel, localLabel))) { return true; } return false; }
@Override public int hashCode() { int hash = assoc.hashCode(); for (Tag pb : tags) hash += pb.hashCode(); return hash; }
@Override public boolean equals(Object obj) { if (obj == null) return false; if (this == obj) return true; if (!(obj instanceof PriorityBlockExtended)) return false; PriorityBlockExtended pb = (PriorityBlockExtended) obj; if (pb.productions.size() != productions.size()) return false; for (int i = 0; i < pb.productions.size(); i++) { if (!pb.productions.get(i).equals(productions.get(i))) return false; } return true; }
private boolean isPriorityWrong(ProductionReference outer, ProductionReference inner) { Tag parentLabel = new Tag(outer.production().klabel().get().name()); Tag localLabel = new Tag(inner.production().klabel().get().name()); if (m.priorities().lessThan(parentLabel, localLabel)) { return true; } if (m.leftAssoc().contains(new Tuple2<>(parentLabel, localLabel))) { return true; } if (m.rightAssoc().contains(new Tuple2<>(parentLabel, localLabel))) { return true; } return false; }
public Either<java.util.Set<ParseFailedException>, Term> apply(TermCons tc) { if (tc.production().att().contains("bracket")) return Right.apply(tc); //if (Side.RIGHT == side && !(tc.production().items().apply(0) instanceof NonTerminal)) return Right.apply(tc); //if (Side.LEFT == side && !(tc.production().items().apply(tc.production().items().size() - 1) instanceof NonTerminal)) return Right.apply(tc); Tag parentLabel = new Tag(parent.production().klabel().get().name()); Tag localLabel = new Tag(tc.production().klabel().get().name()); if (priorities.lessThan(parentLabel, localLabel)) { String msg = "Priority filter exception. Cannot use " + localLabel + " as a child of " + parentLabel; KException kex = new KException(KException.ExceptionType.ERROR, KException.KExceptionGroup.CRITICAL, msg, tc.source().get(), tc.location().get()); return Left.apply(Sets.newHashSet(new PriorityException(kex))); } if (leftAssoc.contains(new Tuple2<>(parentLabel, localLabel)) && Side.RIGHT == side) { String msg = "Associativity filter exception. Cannot use " + localLabel + " as a right child of " + parentLabel; KException kex = new KException(KException.ExceptionType.ERROR, KException.KExceptionGroup.CRITICAL, msg, tc.source().get(), tc.location().get()); return Left.apply(Sets.newHashSet(new PriorityException(kex))); } if (rigthAssoc.contains(new Tuple2<>(parentLabel, localLabel)) && Side.LEFT == side) { String msg = "Associativity filter exception. Cannot use " + localLabel + " as a left child of " + parentLabel; KException kex = new KException(KException.ExceptionType.ERROR, KException.KExceptionGroup.CRITICAL, msg, tc.source().get(), tc.location().get()); return Left.apply(Sets.newHashSet(new PriorityException(kex))); } return Right.apply(tc); } }
private boolean isPriorityWrong(ProductionReference outer, ProductionReference inner, int position) { if (outer.production().klabel().isEmpty() || inner.production().klabel().isEmpty()) { return false; } Tag parentLabel = new Tag(outer.production().klabel().get().name()); Tag localLabel = new Tag(inner.production().klabel().get().name()); if (!m.subsorts().lessThanEq(inner.production().sort(), ((NonTerminal)outer.production().items().apply(position)).sort())) { return true; } if (m.priorities().lessThan(parentLabel, localLabel)) { return true; } if (m.leftAssoc().contains(new Tuple2<>(parentLabel, localLabel)) && position == outer.production().items().size() - 1) { return true; } if (m.rightAssoc().contains(new Tuple2<>(parentLabel, localLabel)) && position == 0) { return true; } return false; }