Search in sources :

Example 1 with AIdentifierExpression

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

the class MachineContext method caseALetSubstitution.

@Override
public void caseALetSubstitution(ALetSubstitution node) {
    contextTable.add(new LinkedHashMap<String, Node>());
    List<PExpression> copy = new ArrayList<PExpression>(node.getIdentifiers());
    for (PExpression e : copy) {
        putLocalVariableIntoCurrentScope((AIdentifierExpression) e);
    }
    node.getPredicate().apply(this);
    node.getSubstitution().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 2 with AIdentifierExpression

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

the class MachineContext method caseAMachineHeader.

@Override
public void caseAMachineHeader(AMachineHeader node) {
    this.header = node;
    if (machineName == null) {
        List<TIdentifierLiteral> nameList = new ArrayList<TIdentifierLiteral>(node.getName());
        this.machineName = Utils.getTIdentifierListAsString(nameList);
    }
    List<PExpression> copy = new ArrayList<PExpression>(node.getParameters());
    for (PExpression e : copy) {
        AIdentifierExpression p = (AIdentifierExpression) e;
        String name = Utils.getTIdentifierListAsString(p.getIdentifier());
        exist(p.getIdentifier());
        if (Character.isUpperCase(name.charAt(0))) {
            this.machineSetParameter.put(name, p);
        } else {
            this.machineScalarParameter.put(name, p);
        }
    }
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) ArrayList(java.util.ArrayList) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral) PExpression(de.be4.classicalb.core.parser.node.PExpression)

Example 3 with AIdentifierExpression

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

the class MachineContext method caseAAbstractConstantsMachineClause.

@Override
public void caseAAbstractConstantsMachineClause(AAbstractConstantsMachineClause 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 4 with AIdentifierExpression

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

the class MachineContext method caseASeesMachineClause.

@Override
public void caseASeesMachineClause(ASeesMachineClause node) {
    this.seesMachineClause = node;
    List<PExpression> copy = new ArrayList<PExpression>(node.getMachineNames());
    for (PExpression e : copy) {
        AIdentifierExpression p = (AIdentifierExpression) e;
        String name = Utils.getTIdentifierListAsString(p.getIdentifier());
        try {
            exist(p.getIdentifier());
        } catch (ScopeException e2) {
            throw new ScopeException("Machine '" + name + "' is seen twice.");
        }
        seenMachines.put(name, p);
    }
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) ArrayList(java.util.ArrayList) PExpression(de.be4.classicalb.core.parser.node.PExpression) ScopeException(de.prob.typechecker.exceptions.ScopeException)

Example 5 with AIdentifierExpression

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

the class MachineContext method caseAConcreteVariablesMachineClause.

@Override
public void caseAConcreteVariablesMachineClause(AConcreteVariablesMachineClause 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

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