use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class RulesMachineChecker method caseAComputationOperation.
@Override
public void caseAComputationOperation(AComputationOperation node) {
currentOperation = new ComputationOperation(node.getName(), this.fileName, this.machineName, machineReferences);
computationMap.put(node, (ComputationOperation) currentOperation);
visitOperationAttributes(node.getAttributes());
node.getBody().apply(this);
currentOperation = null;
}
use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class RulesMachineChecker method checkFailedRuleErrorTypeOperator.
private void checkFailedRuleErrorTypeOperator(AOperatorPredicate node, final List<PExpression> arguments) {
if (arguments.size() != 2) {
this.errorList.add(new CheckException("The FAILED_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 FAILED_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 FAILED_RULE_ERROR_TYPE must be an integer literal.", node));
return;
}
this.referencedRuleOperations.add((AIdentifierExpression) arguments.get(0));
return;
}
use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class RulesMachineChecker method caseAVarSubstitution.
@Override
public void caseAVarSubstitution(AVarSubstitution node) {
final HashSet<String> variables = new HashSet<>();
LinkedList<PExpression> identifiers = node.getIdentifiers();
for (PExpression e : identifiers) {
if (e instanceof AIdentifierExpression) {
AIdentifierExpression id = (AIdentifierExpression) e;
String name = id.getIdentifier().get(0).getText();
variables.add(name);
} else {
errorList.add(new CheckException("There must be a list of identifiers in VAR substitution.", node));
}
}
this.identifierScope.createNewScope(new LinkedList<PExpression>(node.getIdentifiers()), true);
node.getSubstitution().apply(this);
this.identifierScope.removeScope();
}
use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class RulesMachineChecker method checkStringFormatOperator.
private void checkStringFormatOperator(AOperatorExpression node, final LinkedList<PExpression> parameters) {
PExpression firstParam = parameters.get(0);
Integer count = countPlaceHoldersInExpression(firstParam);
if (count != null && count != parameters.size() - 1) {
this.errorList.add(new CheckException("The number of arguments (" + (parameters.size() - 1) + ") does not match the number of placeholders (" + count + ") in the string.", node));
}
LinkedList<PExpression> identifiers = node.getIdentifiers();
for (PExpression pExpression : identifiers) {
pExpression.apply(this);
}
return;
}
use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class RulesMachineChecker method caseAForallSubMessageSubstitution.
@Override
public void caseAForallSubMessageSubstitution(AForallSubMessageSubstitution node) {
if (!isInRule()) {
errorList.add(new CheckException("RULE_FORALL used outside of a RULE operation", node));
return;
}
this.identifierScope.createNewScope(new LinkedList<PExpression>(node.getIdentifiers()));
node.getWhere().apply(this);
node.getExpect().apply(this);
node.getMessage().apply(this);
this.identifierScope.removeScope();
checkErrorType(node.getErrorType());
}
Aggregations