use of de.be4.classicalb.core.parser.node.PExpression 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.PExpression 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.PExpression in project probparsers by bendisposto.
the class RulesMachineChecker method checkClassificationAttribute.
private void checkClassificationAttribute(POperationAttribute pOperationAttribute, LinkedList<PExpression> arguments) {
if (currentOperation instanceof RuleOperation) {
final RuleOperation rule = (RuleOperation) currentOperation;
if (arguments.size() == 1 && arguments.get(0) instanceof AIdentifierExpression) {
AIdentifierExpression identifier = (AIdentifierExpression) arguments.get(0);
String identifierString = Utils.getTIdentifierListAsString(identifier.getIdentifier());
rule.setClassification(identifierString);
} else {
errorList.add(new CheckException("Expected exactly one identifier after CLASSIFICATION.", pOperationAttribute));
}
} else {
errorList.add(new CheckException("CLASSIFICATION 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 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());
}
use of de.be4.classicalb.core.parser.node.PExpression in project probparsers by bendisposto.
the class RulesMachineChecker method inAOperationCallSubstitution.
@Override
public void inAOperationCallSubstitution(AOperationCallSubstitution node) {
LinkedList<TIdentifierLiteral> opNameList = node.getOperation();
if (opNameList.size() > 1) {
errorList.add(new CheckException("Renaming of operation names is not allowed.", node));
}
List<PExpression> copy = new ArrayList<>(node.getResultIdentifiers());
checkThatIdentifiersAreLocalVariables(copy);
if (currentOperation != null) {
currentOperation.addFunctionCall(opNameList.get(0));
}
}
Aggregations