use of de.be4.classicalb.core.parser.node.PExpression in project probparsers by bendisposto.
the class RulesMachineChecker method inAAssignSubstitution.
@Override
public void inAAssignSubstitution(AAssignSubstitution node) {
ArrayList<PExpression> righthand = new ArrayList<>(node.getRhsExpressions());
for (PExpression pExpression : righthand) {
pExpression.apply(this);
}
List<PExpression> copy = new ArrayList<>(node.getLhsExpression());
checkThatIdentifiersAreLocalVariables(copy);
}
use of de.be4.classicalb.core.parser.node.PExpression in project probparsers by bendisposto.
the class RulesMachineChecker method checkErrorTypesAttribute.
private void checkErrorTypesAttribute(POperationAttribute pOperationAttribute, LinkedList<PExpression> arguments) {
if (currentOperation instanceof RuleOperation) {
final RuleOperation rule = (RuleOperation) currentOperation;
if (arguments.size() == 1 && arguments.get(0) instanceof AIntegerExpression) {
AIntegerExpression intExpr = (AIntegerExpression) arguments.get(0);
rule.setErrrorTypes(intExpr);
} else {
errorList.add(new CheckException("Expected exactly one integer after ERROR_TYPES.", pOperationAttribute));
}
} else {
errorList.add(new CheckException("ERROR_TYPES is not an attribute of a FUNCTION or COMPUTATION operation.", pOperationAttribute));
}
return;
}
use of de.be4.classicalb.core.parser.node.PExpression in project probparsers by bendisposto.
the class RulesMachineChecker method checkThatIdentifiersAreLocalVariables.
private void checkThatIdentifiersAreLocalVariables(List<PExpression> copy) {
for (PExpression e : copy) {
if (e instanceof AIdentifierExpression) {
AIdentifierExpression id = (AIdentifierExpression) e;
String name = id.getIdentifier().get(0).getText();
if (!this.identifierScope.isAssignableVariable(name)) {
errorList.add(new CheckException("Identifier '" + name + "' is not a local variable (VAR). Hence, it can not be assigned here.", id));
}
} else {
errorList.add(new CheckException("There must be an identifier on the left side of the assign substitution. A function assignment 'f(1) := 1' is also not permitted.", e));
}
}
}
use of de.be4.classicalb.core.parser.node.PExpression in project probparsers by bendisposto.
the class RulesMachineChecker method checkSucceededRuleErrorTypeOperator.
private void checkSucceededRuleErrorTypeOperator(AOperatorPredicate node, final List<PExpression> arguments) {
if (arguments.size() != 2) {
this.errorList.add(new CheckException("The SUCCEEDED_RULE_ERROR_TYPE predicate operator expects exactly two arguments.", node));
return;
}
PExpression pExpression = node.getIdentifiers().get(0);
if (!(pExpression instanceof AIdentifierExpression)) {
this.errorList.add(new CheckException("The first argument of SUCCEEDED_RULE_ERROR_TYPE must be an identifier.", node));
return;
}
PExpression secondArg = node.getIdentifiers().get(1);
if (!(secondArg instanceof AIntegerExpression)) {
this.errorList.add(new CheckException("The second argument of SUCCEEDED_RULE_ERROR_TYPE must be an integer value.", node));
return;
}
this.referencedRuleOperations.add((AIdentifierExpression) arguments.get(0));
return;
}
use of de.be4.classicalb.core.parser.node.PExpression in project probparsers by bendisposto.
the class RulesMachineChecker method checkGetRuleCounterExamplesOperator.
private void checkGetRuleCounterExamplesOperator(AOperatorExpression node, final LinkedList<PExpression> parameters) {
// the grammar ensures at least one argument
if (parameters.size() > 2) {
this.errorList.add(new CheckException("Invalid number of arguments. Expected one or two arguments.", node));
}
PExpression pExpression = node.getIdentifiers().get(0);
if (!(pExpression instanceof AIdentifierExpression)) {
this.errorList.add(new CheckException("The first argument of GET_RULE_COUNTEREXAMPLES must be an identifier.", node));
return;
}
this.referencedRuleOperations.add((AIdentifierExpression) pExpression);
return;
}
Aggregations