use of de.be4.classicalb.core.parser.node.PExpression 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.node.PExpression 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.PExpression 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.node.PExpression 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.node.PExpression in project probparsers by bendisposto.
the class RulesMachineChecker method checkOperationExpressionAttribute.
private void checkOperationExpressionAttribute(OccurredAttributes occurredAttributes, POperationAttribute pOperationAttribute) throws AssertionError {
AOperationAttribute attribute = (AOperationAttribute) pOperationAttribute;
LinkedList<PExpression> arguments = attribute.getArguments();
String name = attribute.getName().getText();
occurredAttributes.add(name, pOperationAttribute);
switch(name) {
case RulesGrammar.DEPENDS_ON_RULE:
checkDependsOnRuleAttribute(pOperationAttribute, arguments);
return;
case RulesGrammar.DEPENDS_ON_COMPUTATION:
checkDependsOnComputationAttribute(pOperationAttribute, arguments);
return;
case RulesGrammar.RULEID:
checkRuleIdAttribute(pOperationAttribute, arguments);
return;
case RulesGrammar.ERROR_TYPES:
checkErrorTypesAttribute(pOperationAttribute, arguments);
return;
case RulesGrammar.CLASSIFICATION:
checkClassificationAttribute(pOperationAttribute, arguments);
return;
case RulesGrammar.TAGS:
checkTagsAttribute(pOperationAttribute, arguments);
return;
case RulesGrammar.REPLACES:
checkReplacesAttribute(pOperationAttribute, arguments);
return;
default:
throw new AssertionError("Unexpected operation attribute: " + name);
}
}
Aggregations