use of de.be4.classicalb.core.parser.node.ASelectSubstitution in project prob2 by bendisposto.
the class DomBuilder method inAOperation.
@Override
public void inAOperation(final AOperation node) {
String name = extractIdentifierName(node.getOpName());
if (prefix != null && !prefix.equals(name)) {
name = prefix + "." + name;
}
List<PExpression> paramIds = node.getParameters();
final List<String> params = extractIdentifiers(paramIds);
final List<String> output = extractIdentifiers(node.getReturnValues());
Operation operation = new Operation(name, params, output);
PSubstitution body = node.getOperationBody();
List<ClassicalBGuard> guards = new ArrayList<>();
if (body instanceof ASelectSubstitution) {
PPredicate condition = ((ASelectSubstitution) body).getCondition();
List<PPredicate> predicates = getPredicates(condition);
for (PPredicate pPredicate : predicates) {
guards.add(new ClassicalBGuard(createPredicateAST(pPredicate)));
}
}
if (body instanceof APreconditionSubstitution) {
PPredicate condition = ((APreconditionSubstitution) body).getPredicate();
List<PPredicate> predicates = getPredicates(condition);
for (PPredicate pPredicate : predicates) {
guards.add(new ClassicalBGuard(createPredicateAST(pPredicate)));
}
}
List<ClassicalBAction> actions = new ArrayList<>();
actions.add(new ClassicalBAction(createSubstitutionAST(body)));
operation = operation.set(Action.class, new ModelElementList<>(actions));
operation = operation.set(Guard.class, new ModelElementList<>(guards));
operations.add(operation);
}
Aggregations