Search in sources :

Example 1 with UserVar

use of org.btrplace.safeplace.spec.term.UserVar in project scheduler by btrplace.

the class MyCstrSpecVisitor method visitTypedef.

@Override
public List<UserVar<?>> visitTypedef(@NotNull CstrSpecParser.TypedefContext ctx) {
    Term<?> parent = (Term<?>) visit(ctx.term());
    if (parent.type() instanceof Atomic) {
        throw new SpecException(filename, ctx.op.getCharPositionInLine(), "The right-hand side must be a collection");
    }
    List<UserVar<?>> vars = new ArrayList<>();
    for (TerminalNode n : ctx.ID()) {
        String lbl = n.getText();
        UserVar v = new UserVar(lbl, ctx.op.getText(), parent);
        symbols.put(v);
        vars.add(v);
    }
    return vars;
}
Also used : ArrayList(java.util.ArrayList) Atomic(org.btrplace.safeplace.spec.type.Atomic) Term(org.btrplace.safeplace.spec.term.Term) ProtectedTerm(org.btrplace.safeplace.spec.term.ProtectedTerm) TerminalNode(org.antlr.v4.runtime.tree.TerminalNode) UserVar(org.btrplace.safeplace.spec.term.UserVar)

Example 2 with UserVar

use of org.btrplace.safeplace.spec.term.UserVar in project scheduler by btrplace.

the class MyCstrSpecVisitor method visitExists.

@Override
public Exists visitExists(@NotNull CstrSpecParser.ExistsContext ctx) {
    List<UserVar<?>> vars = visitTypedef(ctx.typedef());
    Proposition p = (Proposition) visit(ctx.formula());
    return new Exists(vars, p);
}
Also used : Exists(org.btrplace.safeplace.spec.prop.Exists) Proposition(org.btrplace.safeplace.spec.prop.Proposition) ProtectedProposition(org.btrplace.safeplace.spec.prop.ProtectedProposition) UserVar(org.btrplace.safeplace.spec.term.UserVar)

Example 3 with UserVar

use of org.btrplace.safeplace.spec.term.UserVar in project scheduler by btrplace.

the class MyCstrSpecVisitor method visitListInComprehension.

@Override
public ListBuilder<?> visitListInComprehension(@NotNull CstrSpecParser.ListInComprehensionContext ctx) {
    // Get the binder
    List<UserVar<?>> v = visitTypedef(ctx.typedef());
    Proposition p = Proposition.True;
    if (ctx.COMMA() != null) {
        p = (Proposition) visit(ctx.formula());
    }
    Term<?> t = (Term<?>) visit(ctx.term());
    return new ListBuilder<>(t, v.get(0), p);
}
Also used : ListBuilder(org.btrplace.safeplace.spec.term.ListBuilder) Term(org.btrplace.safeplace.spec.term.Term) ProtectedTerm(org.btrplace.safeplace.spec.term.ProtectedTerm) Proposition(org.btrplace.safeplace.spec.prop.Proposition) ProtectedProposition(org.btrplace.safeplace.spec.prop.ProtectedProposition) UserVar(org.btrplace.safeplace.spec.term.UserVar)

Example 4 with UserVar

use of org.btrplace.safeplace.spec.term.UserVar in project scheduler by btrplace.

the class ForAll method toString.

@Override
public String toString() {
    StringBuilder b = new StringBuilder("!(");
    Iterator<UserVar<?>> ite = vars.iterator();
    while (ite.hasNext()) {
        Var v = ite.next();
        if (ite.hasNext()) {
            b.append(v.label());
            b.append(',');
        } else {
            b.append(v.pretty());
        }
    }
    return b.append(") ").append(prop).toString();
}
Also used : UserVar(org.btrplace.safeplace.spec.term.UserVar) Var(org.btrplace.safeplace.spec.term.Var) UserVar(org.btrplace.safeplace.spec.term.UserVar)

Example 5 with UserVar

use of org.btrplace.safeplace.spec.term.UserVar in project scheduler by btrplace.

the class MyCstrSpecVisitor method visitAll.

@Override
public Proposition visitAll(@NotNull CstrSpecParser.AllContext ctx) {
    List<UserVar<?>> vars = visitTypedef(ctx.typedef());
    Proposition p = (Proposition) visit(ctx.formula());
    return new ForAll(vars, p);
}
Also used : Proposition(org.btrplace.safeplace.spec.prop.Proposition) ProtectedProposition(org.btrplace.safeplace.spec.prop.ProtectedProposition) ForAll(org.btrplace.safeplace.spec.prop.ForAll) UserVar(org.btrplace.safeplace.spec.term.UserVar)

Aggregations

UserVar (org.btrplace.safeplace.spec.term.UserVar)9 Proposition (org.btrplace.safeplace.spec.prop.Proposition)5 ProtectedProposition (org.btrplace.safeplace.spec.prop.ProtectedProposition)4 ProtectedTerm (org.btrplace.safeplace.spec.term.ProtectedTerm)3 Term (org.btrplace.safeplace.spec.term.Term)3 ArrayList (java.util.ArrayList)2 ParseTree (org.antlr.v4.runtime.tree.ParseTree)2 SatConstraint (org.btrplace.model.constraint.SatConstraint)2 CstrSpecParser (org.btrplace.safeplace.spec.antlr.CstrSpecParser)2 TerminalNode (org.antlr.v4.runtime.tree.TerminalNode)1 SideConstraint (org.btrplace.model.constraint.SideConstraint)1 Exists (org.btrplace.safeplace.spec.prop.Exists)1 ForAll (org.btrplace.safeplace.spec.prop.ForAll)1 ListBuilder (org.btrplace.safeplace.spec.term.ListBuilder)1 SetBuilder (org.btrplace.safeplace.spec.term.SetBuilder)1 Var (org.btrplace.safeplace.spec.term.Var)1 Atomic (org.btrplace.safeplace.spec.type.Atomic)1 CoreConstraint (org.btrplace.scheduler.CoreConstraint)1