use of de.be4.classicalb.core.parser.node.AIdentifierExpression in project probparsers by bendisposto.
the class ExpressionTest method testProverComprehensionSets.
@Test
public void testProverComprehensionSets() throws Exception {
final String expression = "SET(i).(i>0)";
parser.getOptions().setRestrictProverExpressions(false);
final String expected = "AProverComprehensionSetExpression([AIdentifierExpression([i])],AGreaterPredicate(AIdentifierExpression([i]),AIntegerExpression(0)))";
final String prover = getExpressionAsString(expression);
assertEquals(expected, prover);
parser.getOptions().setRestrictProverExpressions(true);
try {
getExpressionAsString(expression);
fail("exception expected");
} catch (BCompoundException e) {
assertTrue(e.getCause() instanceof CheckException);
}
}
use of de.be4.classicalb.core.parser.node.AIdentifierExpression in project probparsers by bendisposto.
the class RulesMachineChecker method checkThatIdentifiersAreLocalVariables.
private void checkThatIdentifiersAreLocalVariables(List<PExpression> copy) {
for (PExpression e : copy) {
if (e instanceof AIdentifierExpression) {
AIdentifierExpression id = (AIdentifierExpression) e;
String name = id.getIdentifier().get(0).getText();
if (!this.identifierScope.isAssignableVariable(name)) {
errorList.add(new CheckException("Identifier '" + name + "' is not a local variable (VAR). Hence, it can not be assigned here.", id));
}
} else {
errorList.add(new CheckException("There must be an identifier on the left side of the assign substitution. A function assignment 'f(1) := 1' is also not permitted.", e));
}
}
}
use of de.be4.classicalb.core.parser.node.AIdentifierExpression in project probparsers by bendisposto.
the class RulesMachineChecker method checkSucceededRuleErrorTypeOperator.
private void checkSucceededRuleErrorTypeOperator(AOperatorPredicate node, final List<PExpression> arguments) {
if (arguments.size() != 2) {
this.errorList.add(new CheckException("The SUCCEEDED_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 SUCCEEDED_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 SUCCEEDED_RULE_ERROR_TYPE must be an integer value.", node));
return;
}
this.referencedRuleOperations.add((AIdentifierExpression) arguments.get(0));
return;
}
use of de.be4.classicalb.core.parser.node.AIdentifierExpression 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;
}
use of de.be4.classicalb.core.parser.node.AIdentifierExpression in project probparsers by bendisposto.
the class MachineContext method caseAConstantsMachineClause.
@Override
public void caseAConstantsMachineClause(AConstantsMachineClause node) {
hasConstants = true;
List<PExpression> copy = new ArrayList<PExpression>(node.getIdentifiers());
for (PExpression e : copy) {
AIdentifierExpression c = (AIdentifierExpression) e;
String name = Utils.getTIdentifierListAsString(c.getIdentifier());
exist(c.getIdentifier());
constants.put(name, c);
}
}
Aggregations