use of de.be4.classicalb.core.parser.node.APredicateAttributeOperationAttribute in project probparsers by bendisposto.
the class RulesMachineChecker method checkOperationPredicateAttribute.
private void checkOperationPredicateAttribute(OccurredAttributes occurredAttributes, POperationAttribute pOperationAttribute) throws AssertionError {
APredicateAttributeOperationAttribute attr = (APredicateAttributeOperationAttribute) pOperationAttribute;
PPredicate predicate = attr.getPredicate();
final String attrName = attr.getName().getText();
occurredAttributes.add(attrName, pOperationAttribute);
switch(attrName) {
case RulesGrammar.ACTIVATION:
if (currentOperation instanceof FunctionOperation) {
errorList.add(new CheckException("ACTIVATION is not a valid attribute of a FUNCTION operation.", pOperationAttribute));
} else {
currentOperation.setActivationPredicate(predicate);
}
break;
case RulesGrammar.PRECONDITION:
if (currentOperation instanceof FunctionOperation) {
FunctionOperation func = (FunctionOperation) currentOperation;
func.setPreconditionPredicate(predicate);
} else {
errorList.add(new CheckException("PRECONDITION clause is not allowed for a RULE or COMPUTATION operation", pOperationAttribute));
}
break;
case RulesGrammar.POSTCONDITION:
if (currentOperation instanceof RuleOperation) {
errorList.add(new CheckException("POSTCONDITION attribute is not allowed for a RULE operation", pOperationAttribute));
} else {
currentOperation.setPostcondition(predicate);
}
break;
default:
throw new AssertionError("Unexpected operation attribute: " + attrName);
}
predicate.apply(this);
}
Aggregations