public void assertCleanup(Term input, Term expected) { Term actual = treeCleanerVisitor.apply(input).right().get(); if (!actual.equals(expected)) { assertEquals(expected.toString(), actual.toString()); } }
Either<Set<ParseFailedException>, Term> rez = new TreeCleanerVisitor().apply(parsed); if (rez.isLeft()) return new Tuple2<>(rez, warn);
public void throwFirstLeftException(Term input) { Either<Set<ParseFailedException>, Term> result = treeCleanerVisitor.apply(input); if (result.isRight()) { fail("Expected an exception but got:" + result.right().get()); } else { throw result.left().get().iterator().next(); } } }
@Override public Either<Set<ParseFailedException>, Term> apply(TermCons tc) { Either<Set<ParseFailedException>, Term> vis; if (tc.production().isSyntacticSubsort() && tc.production().klabel().isEmpty()) { // eliminating syntactic subsort vis = apply(tc.get(0)); } else if (!tc.production().att().contains("bracket") && tc.production().klabel().isEmpty()) { return Left.apply(Sets.newHashSet(new ParseFailedException(new KException( KException.ExceptionType.ERROR, KException.KExceptionGroup.INNER_PARSER, "Only subsort productions are allowed to have no #klabel attribute", tc.source().get(), tc.location().get())))); } else { // invalidate the hashCode cache vis = super.apply(tc); } return vis; }