use of de.be4.classicalb.core.parser.exceptions.CheckException in project probparsers by bendisposto.
the class RulesMachineChecker method checkTagsAttribute.
private void checkTagsAttribute(POperationAttribute pOperationAttribute, LinkedList<PExpression> arguments) {
final List<String> tags = new ArrayList<>();
for (PExpression pExpression : arguments) {
if (pExpression instanceof AIdentifierExpression) {
final AIdentifierExpression ident = (AIdentifierExpression) pExpression;
final String identifierAsString = Utils.getTIdentifierListAsString(ident.getIdentifier());
tags.add(identifierAsString);
} else if (pExpression instanceof AStringExpression) {
final AStringExpression stringExpr = (AStringExpression) pExpression;
tags.add(stringExpr.getContent().getText());
} else {
errorList.add(new CheckException("Expected identifier or string after the TAGS attribute.", pOperationAttribute));
}
}
currentOperation.addTags(tags);
return;
}
use of de.be4.classicalb.core.parser.exceptions.CheckException 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.exceptions.CheckException in project probparsers by bendisposto.
the class RulesMachineChecker method checkDependsOnComputationAttribute.
private void checkDependsOnComputationAttribute(POperationAttribute pOperationAttribute, LinkedList<PExpression> arguments) {
List<AIdentifierExpression> list = new ArrayList<>();
for (PExpression pExpression : arguments) {
if (pExpression instanceof AIdentifierExpression) {
list.add((AIdentifierExpression) pExpression);
} else {
errorList.add(new CheckException("Expected a list of identifiers after DEPENDS_ON_COMPUTATION.", pOperationAttribute));
}
}
currentOperation.addAllComputationDependencies(list);
return;
}
use of de.be4.classicalb.core.parser.exceptions.CheckException in project probparsers by bendisposto.
the class RulesMachineChecker method checkReplacesAttribute.
private void checkReplacesAttribute(POperationAttribute pOperationAttribute, LinkedList<PExpression> arguments) {
if (arguments.size() != 1 || !(arguments.get(0) instanceof AIdentifierExpression)) {
errorList.add(new CheckException("Expected exactly one identifier after REPLACES.", pOperationAttribute));
return;
}
final AIdentifierExpression idExpr = (AIdentifierExpression) arguments.get(0);
currentOperation.addReplacesIdentifier(idExpr);
return;
}
use of de.be4.classicalb.core.parser.exceptions.CheckException 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();
}
Aggregations