Search in sources :

Example 1 with MachineModifier

use of de.prob.model.eventb.MachineModifier in project prob2 by bendisposto.

the class ComponentExtractor method caseAMachineParseUnit.

@Override
public void caseAMachineParseUnit(final AMachineParseUnit node) {
    String name = node.getName().getText();
    MachineModifier machineM = new MachineModifier(new EventBMachine(name), typeEnv);
    ModelElementList<Context> seen = new ModelElementList<>();
    for (TIdentifierLiteral contextName : node.getSeenNames()) {
        String cName = contextName.getText();
        AbstractElement context = getContext(cName);
        seen = seen.addElement((Context) context);
    }
    machineM = machineM.setSees(seen);
    if (node.getRefinesNames().size() == 1) {
        String mname = node.getRefinesNames().getFirst().getText();
        EventBMachine machine = getMachine(mname);
        machineM = machineM.setRefines(machine);
    } else if (node.getRefinesNames().size() > 1) {
        throw new IllegalArgumentException("Machines can only refine one abstract machine. Found " + node.getRefinesNames().size() + " refined machines");
    }
    machineM = machineM.addComment(getComment(node.getComments()));
    MachineExtractor mE = new MachineExtractor(machineM, typeEnv);
    node.apply(mE);
    modelM = modelM.addMachine(mE.getMachine());
}
Also used : Context(de.prob.model.eventb.Context) AbstractElement(de.prob.model.representation.AbstractElement) ModelElementList(de.prob.model.representation.ModelElementList) EventBMachine(de.prob.model.eventb.EventBMachine) MachineModifier(de.prob.model.eventb.MachineModifier) TIdentifierLiteral(de.be4.eventbalg.core.parser.node.TIdentifierLiteral)

Example 2 with MachineModifier

use of de.prob.model.eventb.MachineModifier in project prob2 by bendisposto.

the class MachineExtractor method caseAEvent.

@Override
public void caseAEvent(final AEvent node) {
    EventExtractor eE = new EventExtractor(new Event(node.getName().getText(), EventType.ORDINARY, false), machineM.getMachine().getRefines(), typeEnv, getComment(node.getComments()));
    node.apply(eE);
    machineM = new MachineModifier(machineM.getMachine().addTo(BEvent.class, eE.getEvent()), typeEnv);
}
Also used : BEvent(de.prob.model.representation.BEvent) AEvent(de.be4.eventbalg.core.parser.node.AEvent) Event(de.prob.model.eventb.Event) MachineModifier(de.prob.model.eventb.MachineModifier)

Example 3 with MachineModifier

use of de.prob.model.eventb.MachineModifier in project prob2 by bendisposto.

the class MachineExtractor method caseAAlgorithm.

@Override
public void caseAAlgorithm(final AAlgorithm node) {
    AlgorithmExtractor aE = new AlgorithmExtractor(typeEnv);
    Block algorithm = aE.extract(node);
    machineM = new MachineModifier(machineM.getMachine().addTo(Block.class, algorithm), typeEnv);
}
Also used : Block(de.prob.model.eventb.algorithm.ast.Block) MachineModifier(de.prob.model.eventb.MachineModifier)

Aggregations

MachineModifier (de.prob.model.eventb.MachineModifier)3 AEvent (de.be4.eventbalg.core.parser.node.AEvent)1 TIdentifierLiteral (de.be4.eventbalg.core.parser.node.TIdentifierLiteral)1 Context (de.prob.model.eventb.Context)1 Event (de.prob.model.eventb.Event)1 EventBMachine (de.prob.model.eventb.EventBMachine)1 Block (de.prob.model.eventb.algorithm.ast.Block)1 AbstractElement (de.prob.model.representation.AbstractElement)1 BEvent (de.prob.model.representation.BEvent)1 ModelElementList (de.prob.model.representation.ModelElementList)1