Search in sources :

Example 1 with CGDecl

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

the class ScopeGraphComponent method solve.

// ------------------------------------------------------------------------------------------------------//
private boolean solve(CGDecl c) {
    final ITerm scopeTerm = unifier().findRecursive(c.getScope());
    final ITerm declTerm = unifier().findRecursive(c.getDeclaration());
    if (!(scopeTerm.isGround() && declTerm.isGround())) {
        return false;
    }
    Scope scope = Scope.matcher().match(scopeTerm, unifier()).orElseThrow(() -> new TypeException("Expected a scope as first agument to " + c));
    Occurrence decl = Occurrence.matcher().match(declTerm, unifier()).orElseThrow(() -> new TypeException("Expected an occurrence as second argument to " + c));
    scopeGraph.addDecl(scope, decl);
    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