Search in sources :

Example 1 with PContextClause

use of de.be4.classicalb.core.parser.node.PContextClause in project prob2 by bendisposto.

the class ContextTranslator method processAxiomsAndTheorems.

private List<PContextClause> processAxiomsAndTheorems() {
    List<PContextClause> axiomsAndThms = new ArrayList<>();
    List<PPredicate> axioms = new ArrayList<>();
    List<PPredicate> thms = new ArrayList<>();
    for (EventBAxiom axiom : context.getAxioms()) {
        PPredicate ppred = (PPredicate) ((EventB) axiom.getPredicate()).getAst();
        nodeInfos.put(ppred, new Tuple2<>(context.getName(), axiom.getName()));
        if (axiom.isTheorem()) {
            thms.add(ppred);
        } else {
            axioms.add(ppred);
        }
    }
    axiomsAndThms.add(new AAxiomsContextClause(axioms));
    axiomsAndThms.add(new ATheoremsContextClause(thms));
    return axiomsAndThms;
}
Also used : EventBAxiom(de.prob.model.eventb.EventBAxiom) ArrayList(java.util.ArrayList) ATheoremsContextClause(de.be4.classicalb.core.parser.node.ATheoremsContextClause) PPredicate(de.be4.classicalb.core.parser.node.PPredicate) AAxiomsContextClause(de.be4.classicalb.core.parser.node.AAxiomsContextClause) PContextClause(de.be4.classicalb.core.parser.node.PContextClause)

Example 2 with PContextClause

use of de.be4.classicalb.core.parser.node.PContextClause in project prob2 by bendisposto.

the class ContextTranslator method processConstants.

private List<PContextClause> processConstants() {
    List<PContextClause> constants = new ArrayList<>();
    List<PExpression> concrete = new ArrayList<>();
    List<PExpression> abstractC = new ArrayList<>();
    for (EventBConstant eventBConstant : context.getConstants()) {
        if (eventBConstant.isAbstract()) {
            abstractC.add((PExpression) ((EventB) eventBConstant.getExpression()).getAst());
        } else {
            concrete.add((PExpression) ((EventB) eventBConstant.getExpression()).getAst());
        }
    }
    constants.add(new AConstantsContextClause(concrete));
    constants.add(new AAbstractConstantsContextClause(abstractC));
    return constants;
}
Also used : AConstantsContextClause(de.be4.classicalb.core.parser.node.AConstantsContextClause) EventB(de.prob.animator.domainobjects.EventB) ArrayList(java.util.ArrayList) EventBConstant(de.prob.model.eventb.EventBConstant) PExpression(de.be4.classicalb.core.parser.node.PExpression) PContextClause(de.be4.classicalb.core.parser.node.PContextClause) AAbstractConstantsContextClause(de.be4.classicalb.core.parser.node.AAbstractConstantsContextClause)

Example 3 with PContextClause

use of de.be4.classicalb.core.parser.node.PContextClause in project prob2 by bendisposto.

the class ContextTranslator method translateContext.

public Node translateContext() {
    AEventBContextParseUnit ast = new AEventBContextParseUnit();
    ast.setName(new TIdentifierLiteral(context.getName()));
    List<PContextClause> clauses = new ArrayList<>();
    clauses.add(processExtends());
    clauses.addAll(processConstants());
    clauses.addAll(processAxiomsAndTheorems());
    clauses.add(processSets());
    ast.setContextClauses(clauses);
    return ast;
}
Also used : AEventBContextParseUnit(de.be4.classicalb.core.parser.node.AEventBContextParseUnit) ArrayList(java.util.ArrayList) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral) PContextClause(de.be4.classicalb.core.parser.node.PContextClause)

Aggregations

PContextClause (de.be4.classicalb.core.parser.node.PContextClause)3 ArrayList (java.util.ArrayList)3 AAbstractConstantsContextClause (de.be4.classicalb.core.parser.node.AAbstractConstantsContextClause)1 AAxiomsContextClause (de.be4.classicalb.core.parser.node.AAxiomsContextClause)1 AConstantsContextClause (de.be4.classicalb.core.parser.node.AConstantsContextClause)1 AEventBContextParseUnit (de.be4.classicalb.core.parser.node.AEventBContextParseUnit)1 ATheoremsContextClause (de.be4.classicalb.core.parser.node.ATheoremsContextClause)1 PExpression (de.be4.classicalb.core.parser.node.PExpression)1 PPredicate (de.be4.classicalb.core.parser.node.PPredicate)1 TIdentifierLiteral (de.be4.classicalb.core.parser.node.TIdentifierLiteral)1 EventB (de.prob.animator.domainobjects.EventB)1 EventBAxiom (de.prob.model.eventb.EventBAxiom)1 EventBConstant (de.prob.model.eventb.EventBConstant)1