private List<Term> lowerKList(Term listTerm) { List<Term> items = new ArrayList<>(); lowerKListAcc(listTerm, items); return items; }
if (label.name().equals("#KApply")) { Term labelTerm = ((TermCons) child).get(0); Optional<KLabel> optLabel = klabelFromTerm(labelTerm); if (optLabel.isPresent() && m.productionsFor().contains(optLabel.get())) { Collection<Production> productions = mutable(m.productionsFor().get(optLabel.get()).get()); List<Term> rawArgs = lowerKList(((TermCons) child).get(1)); assert rawArgs.stream().allMatch(ProductionReference.class::isInstance); @SuppressWarnings("unchecked") List<ProductionReference> args = (List<ProductionReference>) (List) rawArgs; Optional<Sort> leastSort = least(productions.stream().map(Production::sort).collect(Collectors.toList())); if (leastSort.isPresent()) { return leastSort.get(); Optional<Sort> greatestSort = greatest(productions.stream().map(Production::sort).collect(Collectors.toList())); if (greatestSort.isPresent()) { return greatestSort.get();
rez2 = new AmbFilter(strict && inferSortChecks).apply(rez3); warn = Sets.union(rez2._2(), warn); rez2 = new AddEmptyLists(disambModule).apply(rez2._1().right().get()); warn = Sets.union(rez2._2(), warn); if (rez2._1().isLeft())
Sort childSort = getSort(child); if (listSorts.contains(expectedSort) && !(subsorts.lessThanEq(childSort, expectedSort) && listSorts.contains(childSort))) {
private void lowerKListAcc(Term term, List<Term> items) { if (term instanceof TermCons) { TermCons cons = (TermCons) term; if (cons.production().klabel().isDefined()) { String labelName = cons.production().klabel().get().name(); if (labelName.equals("#KList")) { assert cons.items().size() == 2; lowerKListAcc(cons.get(0), items); lowerKListAcc(cons.get(1), items); return; } else if (labelName.equals("#EmptyKList")) { return; } } } items.add(term); } }