Source:
<code><START> public Tuple2<Either<Set<ParseFailedException>, Term>, Set<ParseFailedException>> parseString(CharSequence input, String startSymbol) { <END> Parser parser = new Parser(input); Term parsed = parser.parse(grammar.get(startSymbol), 0); if (parsed.equals(Ambiguity.apply())) { Parser.ParseError errors = parser.getErrors(); throw new AssertionError("There are parsing errors: " + errors.toString()); } Set<ParseFailedException> warn = new AmbFilter().warningUnit(); Either<Set<ParseFailedException>, Term> rez = new TreeCleanerVisitor().apply(parsed); if (rez.isLeft()) return new Tuple2<>(rez, warn); rez = new CorrectRewritePriorityVisitor().apply(rez.right().get()); if (rez.isLeft()) return new Tuple2<>(rez, warn); rez = new CorrectKSeqPriorityVisitor().apply(rez.right().get()); if (rez.isLeft()) return new Tuple2<>(rez, warn); rez = new CorrectCastPriorityVisitor().apply(rez.right().get()); if (rez.isLeft()) return new Tuple2<>(rez, warn); rez = new PriorityVisitor(module.priorities(), module.leftAssoc(), module.rightAssoc()).apply(rez.right().get()); if (rez.isLeft()) return new Tuple2<>(rez, warn); Tuple2<Either<Set<ParseFailedException>, Term>, Set<ParseFailedException>> rez2 = new VariableTypeInferenceFilter(module.subsorts(), module.definedSorts()).apply(rez.right().get()); if (rez2._1().isLeft()) return rez2; warn = rez2._2(); Term rez3 = new PreferAvoidVisitor().apply(rez2._1().right().get()); rez2 = new AmbFilter().apply(rez.right().get()); warn = new AmbFilter().mergeWarnings(rez2._2(), warn); return new Tuple2<>(Right.apply(rez3), warn); }</code><technical_language>I recommend Apache Commons Lang3's Pair class for consistency rest of code base</technical_language>

Target:
public Tuple2<Either<Set<ParseFailedException>, Term>, Set<ParseFailedException>> parseString(CharSequence input, String startSymbol) { Parser parser = new Parser(input); Term parsed = parser.parse(grammar.get(startSymbol), 0); if (parsed.equals(Ambiguity.apply())) { Parser.ParseError errors = parser.getErrors(); throw new AssertionError("There are parsing errors: " + errors.toString()); } Set<ParseFailedException> warn = new AmbFilter().warningUnit(); Either<Set<ParseFailedException>, Term> rez = new TreeCleanerVisitor().apply(parsed); if (rez.isLeft()) return new Tuple2<>(rez, warn); rez = new CorrectRewritePriorityVisitor().apply(rez.right().get()); if (rez.isLeft()) return new Tuple2<>(rez, warn); rez = new CorrectKSeqPriorityVisitor().apply(rez.right().get()); if (rez.isLeft()) return new Tuple2<>(rez, warn); rez = new CorrectCastPriorityVisitor().apply(rez.right().get()); if (rez.isLeft()) return new Tuple2<>(rez, warn); rez = new PriorityVisitor(module.priorities(), module.leftAssoc(), module.rightAssoc()).apply(rez.right().get()); if (rez.isLeft()) return new Tuple2<>(rez, warn); Tuple2<Either<Set<ParseFailedException>, Term>, Set<ParseFailedException>> rez2 = new VariableTypeInferenceFilter(module.subsorts(), module.definedSorts()).apply(rez.right().get()); if (rez2._1().isLeft()) return rez2; warn = rez2._2(); Term rez3 = new PreferAvoidVisitor().apply(rez2._1().right().get()); rez2 = new AmbFilter().apply(rez.right().get()); warn = new AmbFilter().mergeWarnings(rez2._2(), warn); return new Tuple2<>(Right.apply(rez2._1().right().get()), warn); }