Search in sources :

Example 1 with CstrSpecParser

use of org.btrplace.safeplace.spec.antlr.CstrSpecParser in project scheduler by btrplace.

the class SpecScanner method parseCore2.

/**
 * @throws SpecException
 */
private Constraint parseCore2(CoreConstraint core) throws IOException {
    CommonTokenStream tokens = getTokens(core.inv());
    CstrSpecParser parser = new CstrSpecParser(tokens);
    ParseTree tree = parser.formula();
    MyCstrSpecVisitor v = new MyCstrSpecVisitor().library(functions);
    Proposition p = v.getProposition(core.name(), tree);
    return new Constraint(core.name(), p);
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) CoreConstraint(org.btrplace.scheduler.CoreConstraint) SideConstraint(org.btrplace.model.constraint.SideConstraint) SatConstraint(org.btrplace.model.constraint.SatConstraint) CstrSpecParser(org.btrplace.safeplace.spec.antlr.CstrSpecParser) Proposition(org.btrplace.safeplace.spec.prop.Proposition) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 2 with CstrSpecParser

use of org.btrplace.safeplace.spec.antlr.CstrSpecParser in project scheduler by btrplace.

the class SpecScanner method makeArgs.

/**
 * @throws SpecException
 */
private List<UserVar<?>> makeArgs(String cl, String[] strings) throws IOException {
    List<UserVar<?>> args = new ArrayList<>();
    for (String arg : strings) {
        CstrSpecParser parser = new CstrSpecParser(getTokens(arg));
        ParseTree tree = parser.typedef();
        MyCstrSpecVisitor v = new MyCstrSpecVisitor().library(functions);
        args.add(v.getUserVar(cl, tree));
    }
    return args;
}
Also used : CstrSpecParser(org.btrplace.safeplace.spec.antlr.CstrSpecParser) ParseTree(org.antlr.v4.runtime.tree.ParseTree) UserVar(org.btrplace.safeplace.spec.term.UserVar)

Example 3 with CstrSpecParser

use of org.btrplace.safeplace.spec.antlr.CstrSpecParser in project scheduler by btrplace.

the class SpecScanner method parseSide.

/**
 * @throws SpecException
 */
private org.btrplace.safeplace.spec.Constraint parseSide(Side s, List<Constraint> known) throws IOException {
    List<UserVar<?>> args = makeArgs(s.impl.getSimpleName(), s.s.args());
    CstrSpecParser parser = new CstrSpecParser(getTokens(s.s.inv()));
    ParseTree tree = parser.formula();
    MyCstrSpecVisitor v = new MyCstrSpecVisitor().library(functions).args(args).constraints(known);
    Proposition p = v.getProposition(s.impl.getSimpleName(), tree);
    return new org.btrplace.safeplace.spec.Constraint(s.impl.getSimpleName(), p).args(args).impl(s.impl);
}
Also used : CoreConstraint(org.btrplace.scheduler.CoreConstraint) SideConstraint(org.btrplace.model.constraint.SideConstraint) SatConstraint(org.btrplace.model.constraint.SatConstraint) CstrSpecParser(org.btrplace.safeplace.spec.antlr.CstrSpecParser) Proposition(org.btrplace.safeplace.spec.prop.Proposition) ParseTree(org.antlr.v4.runtime.tree.ParseTree) UserVar(org.btrplace.safeplace.spec.term.UserVar)

Aggregations

ParseTree (org.antlr.v4.runtime.tree.ParseTree)3 CstrSpecParser (org.btrplace.safeplace.spec.antlr.CstrSpecParser)3 SatConstraint (org.btrplace.model.constraint.SatConstraint)2 SideConstraint (org.btrplace.model.constraint.SideConstraint)2 Proposition (org.btrplace.safeplace.spec.prop.Proposition)2 UserVar (org.btrplace.safeplace.spec.term.UserVar)2 CoreConstraint (org.btrplace.scheduler.CoreConstraint)2 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)1