Search in sources :

Example 1 with CGExportEdge

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

the class ScopeGraphComponent method solve.

private boolean solve(CGExportEdge c) {
    ITerm scopeTerm = unifier().findRecursive(c.getScope());
    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 third argument to " + c));
    Occurrence decl = Occurrence.matcher().match(declTerm, unifier()).orElseThrow(() -> new TypeException("Expected an occurrence as first argument to " + c));
    scopeGraph.addExportEdge(decl, c.getLabel(), 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