Search in sources :

Example 1 with POperation

use of de.be4.classicalb.core.parser.node.POperation 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 POperation

use of de.be4.classicalb.core.parser.node.POperation 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 ABoolSetExpression (de.be4.classicalb.core.parser.node.ABoolSetExpression)1 AIntSetExpression (de.be4.classicalb.core.parser.node.AIntSetExpression)1 AOperationsMachineClause (de.be4.classicalb.core.parser.node.AOperationsMachineClause)1 POperation (de.be4.classicalb.core.parser.node.POperation)1 ScopeException (de.prob.typechecker.exceptions.ScopeException)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1