Search in sources :

Example 56 with PExpression

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

the class MachineContext method caseAConstantsMachineClause.

@Override
public void caseAConstantsMachineClause(AConstantsMachineClause node) {
    hasConstants = true;
    List<PExpression> copy = new ArrayList<PExpression>(node.getIdentifiers());
    for (PExpression e : copy) {
        AIdentifierExpression c = (AIdentifierExpression) e;
        String name = Utils.getTIdentifierListAsString(c.getIdentifier());
        exist(c.getIdentifier());
        constants.put(name, c);
    }
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) ArrayList(java.util.ArrayList) PExpression(de.be4.classicalb.core.parser.node.PExpression)

Example 57 with PExpression

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

the class MachineContext method visitBDefinition.

public void visitBDefinition(Node node, String name, List<PExpression> copy, Node rightSide) {
    if (!this.definitions.containsValue(node)) {
        return;
    }
    contextTable.add(new LinkedHashMap<String, Node>());
    for (PExpression e : copy) {
        putLocalVariableIntoCurrentScope((AIdentifierExpression) e);
    }
    rightSide.apply(this);
    contextTable.remove(contextTable.size() - 1);
}
Also used : Node(de.be4.classicalb.core.parser.node.Node) PExpression(de.be4.classicalb.core.parser.node.PExpression)

Example 58 with PExpression

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

the class MachineContext method caseAAnySubstitution.

@Override
public void caseAAnySubstitution(AAnySubstitution node) {
    contextTable.add(new LinkedHashMap<String, Node>());
    List<PExpression> copy = new ArrayList<PExpression>(node.getIdentifiers());
    for (PExpression e : copy) {
        putLocalVariableIntoCurrentScope((AIdentifierExpression) e);
    }
    node.getWhere().apply(this);
    node.getThen().apply(this);
}
Also used : Node(de.be4.classicalb.core.parser.node.Node) ArrayList(java.util.ArrayList) PExpression(de.be4.classicalb.core.parser.node.PExpression)

Example 59 with PExpression

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

the class MachineContext method caseAOpSubstitution.

@Override
public void caseAOpSubstitution(AOpSubstitution node) {
    if (node.getName() != null) {
        AIdentifierExpression op = (AIdentifierExpression) node.getName();
        String name = Utils.getTIdentifierListAsString(op.getIdentifier());
        Node o = operations.get(name);
        if (o != null) {
            this.referencesTable.put(op, o);
        } else {
            throw new ScopeException("Unknown operation '" + name + "'");
        }
    }
    {
        List<PExpression> copy = new ArrayList<PExpression>(node.getParameters());
        for (PExpression e : copy) {
            e.apply(this);
        }
    }
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) Node(de.be4.classicalb.core.parser.node.Node) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) PExpression(de.be4.classicalb.core.parser.node.PExpression) ScopeException(de.prob.typechecker.exceptions.ScopeException)

Example 60 with PExpression

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

the class MachineContext method caseAVariablesMachineClause.

@Override
public void caseAVariablesMachineClause(AVariablesMachineClause node) {
    List<PExpression> copy = new ArrayList<PExpression>(node.getIdentifiers());
    for (PExpression e : copy) {
        AIdentifierExpression v = (AIdentifierExpression) e;
        String name = Utils.getTIdentifierListAsString(v.getIdentifier());
        exist(v.getIdentifier());
        variables.put(name, v);
    }
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) ArrayList(java.util.ArrayList) PExpression(de.be4.classicalb.core.parser.node.PExpression)

Aggregations

PExpression (de.be4.classicalb.core.parser.node.PExpression)50 AIdentifierExpression (de.be4.classicalb.core.parser.node.AIdentifierExpression)28 ArrayList (java.util.ArrayList)27 CheckException (de.be4.classicalb.core.parser.exceptions.CheckException)21 TIdentifierLiteral (de.be4.classicalb.core.parser.node.TIdentifierLiteral)12 Test (org.junit.Test)6 Node (de.be4.classicalb.core.parser.node.Node)5 LinkedList (java.util.LinkedList)5 AExpressionParseUnit (de.be4.classicalb.core.parser.node.AExpressionParseUnit)4 AFunctionExpression (de.be4.classicalb.core.parser.node.AFunctionExpression)4 AIntegerExpression (de.be4.classicalb.core.parser.node.AIntegerExpression)4 PSubstitution (de.be4.classicalb.core.parser.node.PSubstitution)4 VisitorException (de.be4.classicalb.core.parser.exceptions.VisitorException)3 ADefinitionExpression (de.be4.classicalb.core.parser.node.ADefinitionExpression)3 AStringExpression (de.be4.classicalb.core.parser.node.AStringExpression)3 Start (de.be4.classicalb.core.parser.node.Start)3 BParser (de.be4.classicalb.core.parser.BParser)2 AExpressionDefinitionDefinition (de.be4.classicalb.core.parser.node.AExpressionDefinitionDefinition)2 AMachineReference (de.be4.classicalb.core.parser.node.AMachineReference)2 AOpSubstitution (de.be4.classicalb.core.parser.node.AOpSubstitution)2