Search in sources :

Example 46 with AIdentifierExpression

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

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

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

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

Example 50 with AIdentifierExpression

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

the class EnumeratedSetElement method createASTNode.

public PExpression createASTNode(Typechecker typechecker) {
    TIdentifierLiteral literal = new TIdentifierLiteral(name);
    ArrayList<TIdentifierLiteral> idList = new ArrayList<TIdentifierLiteral>();
    idList.add(literal);
    AIdentifierExpression id = new AIdentifierExpression(idList);
    typechecker.setType(id, new SetType(this));
    return id;
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) ArrayList(java.util.ArrayList) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral)

Aggregations

AIdentifierExpression (de.be4.classicalb.core.parser.node.AIdentifierExpression)43 PExpression (de.be4.classicalb.core.parser.node.PExpression)27 ArrayList (java.util.ArrayList)25 CheckException (de.be4.classicalb.core.parser.exceptions.CheckException)22 TIdentifierLiteral (de.be4.classicalb.core.parser.node.TIdentifierLiteral)14 Node (de.be4.classicalb.core.parser.node.Node)5 Test (org.junit.Test)5 BException (de.be4.classicalb.core.parser.exceptions.BException)4 VisitorException (de.be4.classicalb.core.parser.exceptions.VisitorException)4 HashSet (java.util.HashSet)4 LinkedList (java.util.LinkedList)4 AExpressionDefinitionDefinition (de.be4.classicalb.core.parser.node.AExpressionDefinitionDefinition)3 AFunctionExpression (de.be4.classicalb.core.parser.node.AFunctionExpression)3 AIntegerExpression (de.be4.classicalb.core.parser.node.AIntegerExpression)3 AStringExpression (de.be4.classicalb.core.parser.node.AStringExpression)3 BParser (de.be4.classicalb.core.parser.BParser)2 IDefinitions (de.be4.classicalb.core.parser.IDefinitions)2 Type (de.be4.classicalb.core.parser.IDefinitions.Type)2 AEqualPredicate (de.be4.classicalb.core.parser.node.AEqualPredicate)2 AExpressionParseUnit (de.be4.classicalb.core.parser.node.AExpressionParseUnit)2