use of de.be4.eventbalg.core.parser.node.AWhileStmt in project prob2 by bendisposto.
the class AlgorithmExtractor method extractStmt.
private Block extractStmt(final Block b, final PStmt pStmt) throws ModelGenerationException {
if (pStmt instanceof AWhileStmt) {
AWhileStmt whileStmt = (AWhileStmt) pStmt;
return b.While(whileStmt.getCondition().getText(), extractStmts(whileStmt.getStatements()), extractInvariant(b, whileStmt.getInvariant()), extractVariant(b, whileStmt.getVariant()));
}
if (pStmt instanceof AIfStmt) {
AIfStmt ifStmt = (AIfStmt) pStmt;
Block thenBlock = extractStmts(ifStmt.getThen());
Block elseBlock = extractStmts(ifStmt.getElse());
return b.If(ifStmt.getCondition().getText(), thenBlock, elseBlock);
}
if (pStmt instanceof AAssertStmt) {
return b.Assert(((AAssertStmt) pStmt).getPredicate().getText());
}
if (pStmt instanceof AAssignStmt) {
return b.Assign(((AAssignStmt) pStmt).getAction().getText());
}
if (pStmt instanceof ASimpleAssignStmt) {
return b.Assign(((ASimpleAssignStmt) pStmt).getAction().getText());
}
if (pStmt instanceof AReturnStmt) {
return b.Return(getIdList(((AReturnStmt) pStmt).getIdentifiers()));
}
if (pStmt instanceof ACallStmt) {
return b.Call(((ACallStmt) pStmt).getName().getText(), getIdList(((ACallStmt) pStmt).getArguments()), getIdList(((ACallStmt) pStmt).getResults()));
}
throw new IllegalArgumentException("Unsupported statement type: " + pStmt.getClass() + " " + pStmt.getStartPos());
}
Aggregations