use of de.be4.classicalb.core.parser.exceptions.CheckException 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.exceptions.CheckException 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.exceptions.CheckException 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.exceptions.CheckException in project probparsers by bendisposto.
the class RulesMachineChecker method runChecks.
public void runChecks() throws BCompoundException {
start.apply(this);
if (!errorList.isEmpty()) {
final List<BException> bExceptionList = new ArrayList<>();
final String filePath = file == null ? "UnknownFile" : file.getAbsolutePath();
for (CheckException checkException : errorList) {
final BException bException = new BException(filePath, checkException);
bExceptionList.add(bException);
}
throw new BCompoundException(bExceptionList);
}
}
use of de.be4.classicalb.core.parser.exceptions.CheckException in project probparsers by bendisposto.
the class RulesMachineChecker method caseAMachineHeader.
@Override
public void caseAMachineHeader(AMachineHeader node) {
if (!node.getParameters().isEmpty()) {
errorList.add(new CheckException("A RULES_MACHINE must not have any machine parameters", node));
}
LinkedList<TIdentifierLiteral> nameList = node.getName();
if (nameList.size() > 1) {
errorList.add(new CheckException("Renaming of a RULES_MACHINE name is not allowed.", node));
}
this.nameLiteral = nameList.get(0);
this.machineName = nameLiteral.getText();
}
Aggregations