Search in sources :

Example 1 with CGRef

use of mb.nabl2.constraints.scopegraph.CGRef in project nabl by metaborg.

the class ScopeGraphComponent method solve.

private boolean solve(CGRef c) {
    final ITerm scopeTerm = unifier().findRecursive((c.getScope()));
    final ITerm refTerm = unifier().findRecursive((c.getReference()));
    if (!(scopeTerm.isGround() && refTerm.isGround())) {
        return false;
    }
    Occurrence ref = Occurrence.matcher().match(refTerm, unifier()).orElseThrow(() -> new TypeException("Expected an occurrence as first argument to " + c));
    Scope scope = Scope.matcher().match(scopeTerm, unifier()).orElseThrow(() -> new TypeException("Expected a scope as second argument to " + c));
    scopeGraph.addRef(ref, scope);
    return true;
}
Also used : Scope(mb.nabl2.scopegraph.terms.Scope) ITerm(mb.nabl2.terms.ITerm) TypeException(mb.nabl2.solver.TypeException) Occurrence(mb.nabl2.scopegraph.terms.Occurrence)

Aggregations

Occurrence (mb.nabl2.scopegraph.terms.Occurrence)1 Scope (mb.nabl2.scopegraph.terms.Scope)1 TypeException (mb.nabl2.solver.TypeException)1 ITerm (mb.nabl2.terms.ITerm)1