TreeCleanerVisitor extends SetsTransformerWithErrors<KEMException> { @Override public Either<Set<KEMException>, Term> apply(TermCons tc) { Either<Set<KEMException>, Term> vis; if (tc.production().isSyntacticSubsort() && tc.production().klabel().isEmpty()) { vis = apply(tc.get(0)); } else if (!tc.production().att().contains(Att.BRACKET()) && tc.production().klabel().isEmpty()) { return Left.apply(Sets.newHashSet(KEMException.innerParserError( "Only subsort productions are allowed to have no #klabel attribute", tc))); } else { vis = super.apply(tc); } return vis; }  @Override Either<Set<KEMException>, Term> apply(TermCons tc); @Override Either<Set<KEMException>, Term> apply(KList node);  }
@Test public void testAmb() throws Exception { assertCleanup(Ambiguity.apply(foo), foo); }
@Test public void testAmb2() throws Exception { Ambiguity two = Ambiguity.apply(foo, bar); assertCleanup(two, two); }
@Test(expected = KEMException.class) public void testNoKLabel() throws Exception { throwFirstLeftException(TermCons.apply(ConsPStack.from(Arrays.asList(bar, foo)), noKLabelProduction, new Location(0, 0, 0, 0), new Source(""))); }
@Test public void testKList() throws Exception { assertCleanup(Ambiguity.apply(KList.apply(ConsPStack.singleton(foo))), foo); }