use of mb.nabl2.constraints.relations.CCheckRelation in project nabl by metaborg.
the class RelationComponent method solve.
public Optional<SolveResult> solve(CCheckRelation c) {
final ITerm left = unifier().findRecursive(c.getLeft());
final ITerm right = unifier().findRecursive(c.getRight());
if (!(left.isGround() && right.isGround())) {
return Optional.empty();
}
return c.getRelation().match(IRelationName.Cases.of(// @formatter:off
name -> {
if (!isComplete.test(name)) {
return Optional.empty();
}
if (relation(name).contains(left, right)) {
return Optional.of(SolveResult.empty());
} else {
return Optional.empty();
}
}, extName -> {
final ITerm msginfo = MessageInfo.build(c.getMessageInfo());
return callExternal(extName, left, right, msginfo).map(csTerm -> {
return Constraints.matchConstraintOrList().match(csTerm, unifier()).map(SolveResult::constraints).orElseThrow(() -> new IllegalArgumentException("Expected list of constraints, got " + csTerm));
});
}));
}
Aggregations