@Override public Term apply(TermCons tc) { if (tc.production().sort().name().equals("RuleContent")) { Term t = new PushTopAmbiguityUp2().apply(tc.get(0)); if (t instanceof Ambiguity) { Ambiguity old = (Ambiguity)t; Set<Term> newTerms = new HashSet<>(); for (Term child : old.items()) { Term newTerm = tc.with(0, child); newTerms.add(newTerm); } return Ambiguity.apply(newTerms); } } return super.apply(tc); }
@Override public Term apply(TermCons tc) { if (tc.production().klabel().isDefined() && tc.production().klabel().get().equals(KLabels.KREWRITE)) { Term t = tc.get(0); if (t instanceof Ambiguity) { Ambiguity old = (Ambiguity)t; Set<Term> newTerms = new HashSet<>(); for (Term child : old.items()) { Term newTerm = tc.with(0, child); newTerms.add(newTerm); } return Ambiguity.apply(newTerms); } } return super.apply(tc); } }
@Override public Either<java.util.Set<ParseFailedException>, Term> apply(TermCons tc) { assert tc.production() != null : this.getClass() + ":" + " production not found." + tc; if (!tc.production().isSyntacticSubsort() && tc.production().klabel().isDefined() && (tc.production().klabel().get().name().equals("#SyntacticCast") || tc.production().klabel().get().name().startsWith("#SemanticCastTo"))) { // match only on the outermost elements Either<java.util.Set<ParseFailedException>, Term> rez = new PriorityVisitor2(tc).apply(tc.get(0)); if (rez.isLeft()) return rez; tc = tc.with(0, rez.right().get()); } return super.apply(tc); }
return apply(first.with(i, new Ambiguity(a.items().stream().map(t -> (TermCons)t).map(t -> t.get(idx)).collect(Collectors.toSet()))));
@Override public Either<java.util.Set<ParseFailedException>, Term> apply(TermCons tc) { assert tc.production() != null : this.getClass() + ":" + " production not found." + tc; if (!tc.production().isSyntacticSubsort() && tc.production().klabel().isDefined() && !exceptions.contains(tc.production().klabel().get().name())) { // match only on the outermost elements if (tc.production().items().apply(0) instanceof NonTerminal) { Either<java.util.Set<ParseFailedException>, Term> rez = new PriorityVisitor2(tc).apply(tc.get(0)); if (rez.isLeft()) return rez; tc = tc.with(0, rez.right().get()); } if (tc.production().items().apply(tc.production().items().size() - 1) instanceof NonTerminal) { int last = tc.items().size() - 1; Either<java.util.Set<ParseFailedException>, Term> rez = new PriorityVisitor2(tc).apply(tc.get(last)); if (rez.isLeft()) return rez; tc = tc.with(last, rez.right().get()); } } return super.apply(tc); }
@Override public Either<java.util.Set<ParseFailedException>, Term> apply(TermCons tc) { assert tc.production() != null : this.getClass() + ":" + " production not found." + tc; if (!tc.production().isSyntacticSubsort() && tc.production().klabel().isDefined() && !exceptions.contains(tc.production().klabel().get().name())) { // match only on the outermost elements if (tc.production().items().apply(0) instanceof NonTerminal) { Either<java.util.Set<ParseFailedException>, Term> rez = new PriorityVisitor2(tc).apply(tc.get(0)); if (rez.isLeft()) return rez; tc = tc.with(0, rez.right().get()); } if (tc.production().items().apply(tc.production().items().size() - 1) instanceof NonTerminal) { int last = tc.items().size() - 1; Either<java.util.Set<ParseFailedException>, Term> rez = new PriorityVisitor2(tc).apply(tc.get(last)); if (rez.isLeft()) return rez; tc = tc.with(last, rez.right().get()); } } return super.apply(tc); }
@Override public Either<java.util.Set<ParseFailedException>, Term> apply(TermCons tc) { assert tc.production() != null : this.getClass() + ":" + " production not found." + tc; if (!tc.production().isSyntacticSubsort() && !tc.production().att().contains("bracket")) { // match only on the outermost elements if (tc.production().items().apply(0) instanceof NonTerminal) { Either<java.util.Set<ParseFailedException>, Term> rez = new PriorityVisitor2(tc, PriorityVisitor2.Side.LEFT, priorities, leftAssoc, rightAssoc).apply(tc.get(0)); if (rez.isLeft()) return rez; tc = tc.with(0, rez.right().get()); } if (tc.production().items().apply(tc.production().items().size() - 1) instanceof NonTerminal) { int last = tc.items().size() - 1; Either<java.util.Set<ParseFailedException>, Term> rez = new PriorityVisitor2(tc, PriorityVisitor2.Side.RIGHT, priorities, leftAssoc, rightAssoc).apply(tc.get(last)); if (rez.isLeft()) return rez; tc = tc.with(last, rez.right().get()); } } return super.apply(tc); }