public static KEMException criticalError(String message, ProductionReference node) { return create(ExceptionType.ERROR, KExceptionGroup.CRITICAL, message, null, node.location().orElse(null), node.source().orElse(null)); }
String msg = "Found sort '" + childSort + "' where list sort '" + expectedSort + "' was expected. Moving on."; warnings.add(new ParseFailedException( new KException(KException.ExceptionType.HIDDENWARNING, KException.KExceptionGroup.LISTS, msg, child.source().get(), child.location().get()))); newItems.add(child); } else { TermCons terminator = TermCons.apply(ConsPStack.empty(), ulTerm.pTerminator, child.location(), child.source()); TermCons newTc = TermCons.apply(ConsPStack.from(Arrays.asList(terminator, child)), ul.pList, child.location(), child.source()); newItems.add(newTc); changed = true;
public Either<java.util.Set<ParseFailedException>, Term> apply(ProductionReference pr) { if (pr instanceof TermCons) { TermCons tc = (TermCons) pr; if (VariableTypeInferenceFilter.hasPolySort(tc)) { return VariableTypeInferenceFilter.visitPolyChildren(tc, this::apply); } } if (pr instanceof Constant && pr.production().sort().equals(Sorts.KVariable())) { // skip variables since they will always have a different sort at this stage. return Right.apply(pr); } if ((!strict && !subsorts.lessThanEq(pr.production().sort(), sort)) || (strict && !pr.production().sort().equals(sort))) { String msg = "Unexpected sort " + pr.production().sort() + " for term parsed as production " + pr.production() + ". Expected " + sort + "."; KException kex = new KException(KException.ExceptionType.ERROR, KException.KExceptionGroup.CRITICAL, msg, pr.source().orElse(null), pr.location().orElse(null)); return Left.apply(Sets.newHashSet(new VariableTypeClashException(kex))); } return Right.apply(pr); } }