&& child.production().klabel().get().name().equals("#KRewrite"))) { newItems.add(child); } else if (childSort.equals(Sorts.K()) || !subsorts.lessThan(childSort, expectedSort)) { String msg = "Found sort '" + childSort + "' where list sort '" + expectedSort + "' was expected. Moving on."; warnings.add(new ParseFailedException(
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; }
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); } }
if (module.subsorts().lessThan(s, sort)) { numTerms++; sb.append("\\or{");