use of de.be4.classicalb.core.parser.node.Node 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.Node in project probparsers by bendisposto.
the class RulesMachineChecker method caseASubstitutionDefinitionDefinition.
@Override
public void caseASubstitutionDefinitionDefinition(ASubstitutionDefinitionDefinition node) {
final String name = node.getName().getText();
this.definitions.add(name);
if ("GOAL".equals(name)) {
errorList.add(new CheckException("The GOAL definition must be a predicate.", node));
return;
}
this.identifierScope.createNewScope(new LinkedList<>(node.getParameters()));
node.getRhs().apply(this);
this.identifierScope.removeScope();
}
use of de.be4.classicalb.core.parser.node.Node 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.Node 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);
}
}
use of de.be4.classicalb.core.parser.node.Node in project probparsers by bendisposto.
the class MachineContext method caseAAbstractMachineParseUnit.
@Override
public void caseAAbstractMachineParseUnit(AAbstractMachineParseUnit node) {
this.abstractMachineParseUnit = node;
if (node.getVariant() != null) {
node.getVariant().apply(this);
}
if (node.getHeader() != null) {
node.getHeader().apply(this);
}
List<PMachineClause> machineClauses = node.getMachineClauses();
// Sort the machine clauses: declarations clauses first, then
// properties clauses
MachineClauseSorter.sortMachineClauses(start);
for (PMachineClause e : machineClauses) {
e.apply(this);
}
}
Aggregations