Search in sources :

Example 11 with AIdentifierExpression

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

the class RulesMachineChecker method checkDependsOnRuleAttribute.

private void checkDependsOnRuleAttribute(POperationAttribute pOperationAttribute, LinkedList<PExpression> arguments) {
    final List<AIdentifierExpression> list = new ArrayList<>();
    for (final PExpression pExpression : arguments) {
        if (pExpression instanceof AIdentifierExpression) {
            list.add((AIdentifierExpression) pExpression);
        } else {
            errorList.add(new CheckException("Expected a list of identifiers after DEPENDS_ON_RULE.", pOperationAttribute));
        }
    }
    currentOperation.addAllRuleDependencies(list);
    return;
}
Also used : CheckException(de.be4.classicalb.core.parser.exceptions.CheckException) AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) ArrayList(java.util.ArrayList) PExpression(de.be4.classicalb.core.parser.node.PExpression)

Example 12 with AIdentifierExpression

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

the class ASTBuilder method createEqualPredicate.

public static AEqualPredicate createEqualPredicate(TIdentifierLiteral old, final String value) {
    TIdentifierLiteral e = NodeCloner.cloneNode(old);
    AIdentifierExpression aIdentifier = createAIdentifierExpression(e);
    final AEqualPredicate equal = new AEqualPredicate(aIdentifier, new AStringExpression(new TStringLiteral(value)));
    equal.setStartPos(e.getStartPos());
    equal.setEndPos(e.getEndPos());
    return equal;
}
Also used : AEqualPredicate(de.be4.classicalb.core.parser.node.AEqualPredicate) AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) AStringExpression(de.be4.classicalb.core.parser.node.AStringExpression) TStringLiteral(de.be4.classicalb.core.parser.node.TStringLiteral) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral)

Example 13 with AIdentifierExpression

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

the class ASTBuilder method createIdentifier.

public static AIdentifierExpression createIdentifier(String name) {
    ArrayList<TIdentifierLiteral> list = new ArrayList<>();
    list.add(new TIdentifierLiteral(name));
    return new AIdentifierExpression(list);
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) ArrayList(java.util.ArrayList) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral)

Example 14 with AIdentifierExpression

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

the class ASTBuilder method createIdentifier.

public static AIdentifierExpression createIdentifier(String name, PositionedNode positionNode) {
    ArrayList<TIdentifierLiteral> list = new ArrayList<>();
    TIdentifierLiteral literal = new TIdentifierLiteral(name);
    // literal.setStartPos(positionNode.getStartPos());
    // literal.setEndPos(positionNode.getEndPos());
    list.add(literal);
    AIdentifierExpression result = new AIdentifierExpression(list);
    result.setStartPos(positionNode.getStartPos());
    result.setEndPos(positionNode.getEndPos());
    return result;
}
Also used : AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) ArrayList(java.util.ArrayList) TIdentifierLiteral(de.be4.classicalb.core.parser.node.TIdentifierLiteral)

Example 15 with AIdentifierExpression

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

the class BMachine method addPropertiesPredicates.

public void addPropertiesPredicates(Map<String, String> constantStringValues) {
    if (constantStringValues.size() == 0) {
        return;
    }
    APropertiesMachineClause clause = new APropertiesMachineClause();
    this.parseUnit.getMachineClauses().add(clause);
    List<PPredicate> predList = new ArrayList<>();
    for (Entry<String, String> entry : constantStringValues.entrySet()) {
        AIdentifierExpression identifier = createIdentifier(entry.getKey());
        AStringExpression value = new AStringExpression(new TStringLiteral(entry.getValue()));
        AEqualPredicate equal = new AEqualPredicate(identifier, value);
        predList.add(equal);
    }
    clause.setPredicates(createConjunction(predList));
}
Also used : AEqualPredicate(de.be4.classicalb.core.parser.node.AEqualPredicate) AIdentifierExpression(de.be4.classicalb.core.parser.node.AIdentifierExpression) ArrayList(java.util.ArrayList) AStringExpression(de.be4.classicalb.core.parser.node.AStringExpression) TStringLiteral(de.be4.classicalb.core.parser.node.TStringLiteral) PPredicate(de.be4.classicalb.core.parser.node.PPredicate) APropertiesMachineClause(de.be4.classicalb.core.parser.node.APropertiesMachineClause)

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