Search in sources :

Example 1 with AOperationsMachineClause

use of de.be4.classicalb.core.parser.node.AOperationsMachineClause in project probparsers by bendisposto.

the class MachineContext method caseAOperationsMachineClause.

@Override
public void caseAOperationsMachineClause(AOperationsMachineClause node) {
    this.operationMachineClause = node;
    this.contextTable = new ArrayList<LinkedHashMap<String, Node>>();
    ArrayList<MachineContext> list = lookupReferencedMachines();
    for (int i = 0; i < list.size(); i++) {
        MachineContext s = list.get(i);
        this.contextTable.add(s.getSetParamter());
        this.contextTable.add(s.getScalarParameter());
        this.contextTable.add(s.getDeferredSets());
        this.contextTable.add(s.getEnumeratedSets());
        this.contextTable.add(s.getEnumValues());
        this.contextTable.add(s.getConstants());
        this.contextTable.add(s.getDefinitions());
        this.contextTable.add(s.getVariables());
    }
    List<POperation> copy = new ArrayList<POperation>(node.getOperations());
    // first collect all operations
    for (POperation e : copy) {
        AOperation op = (AOperation) e;
        String name = Utils.getTIdentifierListAsString(op.getOpName());
        // existString(name);
        if (operations.keySet().contains(name)) {
            throw new ScopeException(String.format("Duplicate operation: '%s'", name));
        }
        operations.put(name, op);
    }
    // visit all operations
    for (POperation e : copy) {
        e.apply(this);
    }
}
Also used : AOperation(de.be4.classicalb.core.parser.node.AOperation) POperation(de.be4.classicalb.core.parser.node.POperation) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ScopeException(de.prob.typechecker.exceptions.ScopeException)

Example 2 with AOperationsMachineClause

use of de.be4.classicalb.core.parser.node.AOperationsMachineClause in project probparsers by bendisposto.

the class CreateFreetypeTest method createMachine.

private Start createMachine(String name) {
    final AFreetypesMachineClause freetypes = createFreetype();
    final AConstantsMachineClause variables = new AConstantsMachineClause(createIdentifiers(VAR_NAME));
    final AMemberPredicate member = new AMemberPredicate(createIdentifier(VAR_NAME), new APowSubsetExpression(createIdentifier(FREETYPE_NAME)));
    final AInvariantMachineClause inv = new AInvariantMachineClause(member);
    final AInitialisationMachineClause init = new AInitialisationMachineClause(createAssignment(VAR_NAME, new AEmptySetExpression()));
    final AOperationsMachineClause operations = createOperations();
    final AMachineHeader header = new AMachineHeader(createIdLits(name), EMPTY_EXPRS);
    final AAbstractMachineParseUnit machine = new AAbstractMachineParseUnit(new AMachineMachineVariant(), header, Arrays.asList(freetypes, variables, inv, init, operations));
    return new Start(machine, new EOF());
}
Also used : AMachineMachineVariant(de.be4.classicalb.core.parser.node.AMachineMachineVariant) AInitialisationMachineClause(de.be4.classicalb.core.parser.node.AInitialisationMachineClause) AMachineHeader(de.be4.classicalb.core.parser.node.AMachineHeader) AConstantsMachineClause(de.be4.classicalb.core.parser.node.AConstantsMachineClause) Start(de.be4.classicalb.core.parser.node.Start) AMemberPredicate(de.be4.classicalb.core.parser.node.AMemberPredicate) AAbstractMachineParseUnit(de.be4.classicalb.core.parser.node.AAbstractMachineParseUnit) AOperationsMachineClause(de.be4.classicalb.core.parser.node.AOperationsMachineClause) AInvariantMachineClause(de.be4.classicalb.core.parser.node.AInvariantMachineClause) AFreetypesMachineClause(de.be4.classicalb.core.parser.node.AFreetypesMachineClause) APowSubsetExpression(de.be4.classicalb.core.parser.node.APowSubsetExpression) AEmptySetExpression(de.be4.classicalb.core.parser.node.AEmptySetExpression) EOF(de.be4.classicalb.core.parser.node.EOF)

Example 3 with AOperationsMachineClause

use of de.be4.classicalb.core.parser.node.AOperationsMachineClause in project probparsers by bendisposto.

the class CreateFreetypeTest method createOperations.

private AOperationsMachineClause createOperations() {
    final AOperation op1 = createAdd("addBool", "b", new ABoolSetExpression(), CONS_BOOL);
    final AOperation op2 = createAdd("addInt", "i", new AIntSetExpression(), CONS_INT);
    final AOperation op3 = createSimpleAdd("addEmpty");
    final AOperationsMachineClause operations = new AOperationsMachineClause(Arrays.<POperation>asList(op1, op2, op3));
    return operations;
}
Also used : AOperationsMachineClause(de.be4.classicalb.core.parser.node.AOperationsMachineClause) AOperation(de.be4.classicalb.core.parser.node.AOperation) ABoolSetExpression(de.be4.classicalb.core.parser.node.ABoolSetExpression) AIntSetExpression(de.be4.classicalb.core.parser.node.AIntSetExpression)

Aggregations

AOperation (de.be4.classicalb.core.parser.node.AOperation)2 AOperationsMachineClause (de.be4.classicalb.core.parser.node.AOperationsMachineClause)2 AAbstractMachineParseUnit (de.be4.classicalb.core.parser.node.AAbstractMachineParseUnit)1 ABoolSetExpression (de.be4.classicalb.core.parser.node.ABoolSetExpression)1 AConstantsMachineClause (de.be4.classicalb.core.parser.node.AConstantsMachineClause)1 AEmptySetExpression (de.be4.classicalb.core.parser.node.AEmptySetExpression)1 AFreetypesMachineClause (de.be4.classicalb.core.parser.node.AFreetypesMachineClause)1 AInitialisationMachineClause (de.be4.classicalb.core.parser.node.AInitialisationMachineClause)1 AIntSetExpression (de.be4.classicalb.core.parser.node.AIntSetExpression)1 AInvariantMachineClause (de.be4.classicalb.core.parser.node.AInvariantMachineClause)1 AMachineHeader (de.be4.classicalb.core.parser.node.AMachineHeader)1 AMachineMachineVariant (de.be4.classicalb.core.parser.node.AMachineMachineVariant)1 AMemberPredicate (de.be4.classicalb.core.parser.node.AMemberPredicate)1 APowSubsetExpression (de.be4.classicalb.core.parser.node.APowSubsetExpression)1 EOF (de.be4.classicalb.core.parser.node.EOF)1 POperation (de.be4.classicalb.core.parser.node.POperation)1 Start (de.be4.classicalb.core.parser.node.Start)1 ScopeException (de.prob.typechecker.exceptions.ScopeException)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1