use of de.be4.classicalb.core.parser.node.AOperatorExpression 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.AOperatorExpression in project probparsers by bendisposto.
the class RulesTransformation method translateGetRuleCounterExamplesOperator.
private void translateGetRuleCounterExamplesOperator(AOperatorExpression node) {
final PExpression pExpression = node.getIdentifiers().get(0);
final AIdentifierExpression id = (AIdentifierExpression) pExpression;
final String ruleName = id.getIdentifier().get(0).getText();
final AbstractOperation operation = allOperations.get(ruleName);
if (operation == null || !(operation instanceof RuleOperation)) {
errorList.add(new CheckException(String.format("'%s' does not match any rule visible to this machine.", ruleName), node));
return;
}
final RuleOperation rule = (RuleOperation) operation;
final String name = id.getIdentifier().get(0).getText() + RULE_COUNTER_EXAMPLE_VARIABLE_SUFFIX;
if (node.getIdentifiers().size() == 1) {
final AIdentifierExpression ctVariable = createIdentifier(name, pExpression);
final ARangeExpression range = createPositinedNode(new ARangeExpression(ctVariable), node);
node.replaceBy(range);
} else {
PExpression funcCall = getSetOfErrorMessagesByErrorType(name, node.getIdentifiers().get(1), rule.getNumberOfErrorTypes());
node.replaceBy(funcCall);
}
return;
}
use of de.be4.classicalb.core.parser.node.AOperatorExpression in project probparsers by bendisposto.
the class RulesLanguageExceptionTest method testUnkownExpressionOperatorException.
@Test(expected = AssertionError.class)
public void testUnkownExpressionOperatorException() throws Exception {
AOperatorExpression operator = new AOperatorExpression(new TKwExpressionOperator("foo"), new ArrayList<PExpression>());
RulesMachineChecker rulesMachineVisitor = new RulesMachineChecker(null, null, null, null);
operator.apply(rulesMachineVisitor);
}
use of de.be4.classicalb.core.parser.node.AOperatorExpression in project probparsers by bendisposto.
the class RulesMachineChecker method checkGetRuleCounterExamplesOperator.
private void checkGetRuleCounterExamplesOperator(AOperatorExpression node, final LinkedList<PExpression> parameters) {
// the grammar ensures at least one argument
if (parameters.size() > 2) {
this.errorList.add(new CheckException("Invalid number of arguments. Expected one or two arguments.", node));
}
PExpression pExpression = node.getIdentifiers().get(0);
if (!(pExpression instanceof AIdentifierExpression)) {
this.errorList.add(new CheckException("The first argument of GET_RULE_COUNTEREXAMPLES must be an identifier.", node));
return;
}
this.referencedRuleOperations.add((AIdentifierExpression) pExpression);
return;
}
Aggregations