Search in sources :

Example 1 with NIn

use of org.btrplace.safeplace.spec.prop.NIn in project scheduler by btrplace.

the class MyCstrSpecVisitor method visitTermComparison.

@Override
public Proposition visitTermComparison(@NotNull CstrSpecParser.TermComparisonContext c) {
    CstrSpecParser.ComparisonContext ctx = c.comparison();
    Term t1 = (Term<?>) visit(ctx.t1);
    Term t2 = (Term<?>) visit(ctx.t2);
    switch(ctx.op.getType()) {
        case CstrSpecParser.INCL:
            assertEqualsTypes(ctx.op, t1.type(), t2.type());
            return new Inc(t1, t2);
        case CstrSpecParser.NOT_INCL:
            assertEqualsTypes(ctx.op, t1.type(), t2.type());
            return new NInc(t1, t2);
        case CstrSpecParser.EQ:
            assertEqualsTypes(ctx.op, t1.type(), t2.type());
            return new Eq(t1, t2);
        case CstrSpecParser.NOT_EQ:
            assertEqualsTypes(ctx.op, t1.type(), t2.type());
            return new NEq(t1, t2);
        case CstrSpecParser.LT:
            assertEqualsTypes(ctx.op, IntType.getInstance(), t1.type(), t2.type());
            return new Lt(t1, t2);
        case CstrSpecParser.LEQ:
            assertEqualsTypes(ctx.op, IntType.getInstance(), t1.type(), t2.type());
            return new Leq(t1, t2);
        case CstrSpecParser.GT:
            assertEqualsTypes(ctx.op, IntType.getInstance(), t1.type(), t2.type());
            return new Lt(t2, t1);
        case CstrSpecParser.GEQ:
            assertEqualsTypes(ctx.op, IntType.getInstance(), t1.type(), t2.type());
            return new Leq(t2, t1);
        case CstrSpecParser.IN:
            assertIn(ctx.op, t1, t2);
            return new In(t1, t2);
        case CstrSpecParser.NOT_IN:
            assertIn(ctx.op, t1, t2);
            return new NIn(t1, t2);
        case CstrSpecParser.PART:
            assertIn(ctx.op, t2, t1);
            return new Packings(t1, t2);
        case CstrSpecParser.NOT_PART:
            assertIn(ctx.op, t2, t1);
            return new NoPackings(t1, t2);
        default:
            throw SpecException.unsupportedOperation(filename, t1.type(), ctx.op, t2.type());
    }
}
Also used : In(org.btrplace.safeplace.spec.prop.In) NIn(org.btrplace.safeplace.spec.prop.NIn) CstrSpecParser(org.btrplace.safeplace.spec.antlr.CstrSpecParser) NoPackings(org.btrplace.safeplace.spec.prop.NoPackings) Lt(org.btrplace.safeplace.spec.prop.Lt) Term(org.btrplace.safeplace.spec.term.Term) ProtectedTerm(org.btrplace.safeplace.spec.term.ProtectedTerm) Eq(org.btrplace.safeplace.spec.prop.Eq) NEq(org.btrplace.safeplace.spec.prop.NEq) NIn(org.btrplace.safeplace.spec.prop.NIn) NInc(org.btrplace.safeplace.spec.prop.NInc) NoPackings(org.btrplace.safeplace.spec.prop.NoPackings) Packings(org.btrplace.safeplace.spec.prop.Packings) Leq(org.btrplace.safeplace.spec.prop.Leq) NEq(org.btrplace.safeplace.spec.prop.NEq) NInc(org.btrplace.safeplace.spec.prop.NInc) Inc(org.btrplace.safeplace.spec.prop.Inc)

Aggregations

CstrSpecParser (org.btrplace.safeplace.spec.antlr.CstrSpecParser)1 Eq (org.btrplace.safeplace.spec.prop.Eq)1 In (org.btrplace.safeplace.spec.prop.In)1 Inc (org.btrplace.safeplace.spec.prop.Inc)1 Leq (org.btrplace.safeplace.spec.prop.Leq)1 Lt (org.btrplace.safeplace.spec.prop.Lt)1 NEq (org.btrplace.safeplace.spec.prop.NEq)1 NIn (org.btrplace.safeplace.spec.prop.NIn)1 NInc (org.btrplace.safeplace.spec.prop.NInc)1 NoPackings (org.btrplace.safeplace.spec.prop.NoPackings)1 Packings (org.btrplace.safeplace.spec.prop.Packings)1 ProtectedTerm (org.btrplace.safeplace.spec.term.ProtectedTerm)1 Term (org.btrplace.safeplace.spec.term.Term)1