use of org.apache.sysml.parser.pydml.PydmlParser.ElifBranchContext in project incubator-systemml by apache.
the class PydmlSyntacticValidator method exitIfStatement.
@Override
public void exitIfStatement(IfStatementContext ctx) {
IfStatement ifStmt = new IfStatement();
ConditionalPredicate predicate = new ConditionalPredicate(ctx.predicate.info.expr);
ifStmt.setConditionalPredicate(predicate);
ifStmt.setCtxValuesAndFilename(ctx, currentFile);
if (ctx.ifBody.size() > 0) {
for (StatementContext stmtCtx : ctx.ifBody) {
ifStmt.addStatementBlockIfBody(getStatementBlock(stmtCtx.info.stmt));
}
ifStmt.mergeStatementBlocksIfBody();
}
IfStatement tailIfStmt = ifStmt;
if (ctx.elifBranches.size() > 0) {
for (ElifBranchContext elifCtx : ctx.elifBranches) {
tailIfStmt.addStatementBlockElseBody(getStatementBlock(elifCtx.info.stmt));
tailIfStmt = (IfStatement) elifCtx.info.stmt;
}
}
if (ctx.elseBody.size() > 0) {
for (StatementContext stmtCtx : ctx.elseBody) {
tailIfStmt.addStatementBlockElseBody(getStatementBlock(stmtCtx.info.stmt));
}
tailIfStmt.mergeStatementBlocksElseBody();
}
ctx.info.stmt = ifStmt;
setFileLineColumn(ctx.info.stmt, ctx);
}
use of org.apache.sysml.parser.pydml.PydmlParser.ElifBranchContext in project systemml by apache.
the class PydmlSyntacticValidator method exitIfStatement.
@Override
public void exitIfStatement(IfStatementContext ctx) {
IfStatement ifStmt = new IfStatement();
ConditionalPredicate predicate = new ConditionalPredicate(ctx.predicate.info.expr);
ifStmt.setConditionalPredicate(predicate);
ifStmt.setCtxValuesAndFilename(ctx, currentFile);
if (ctx.ifBody.size() > 0) {
for (StatementContext stmtCtx : ctx.ifBody) {
ifStmt.addStatementBlockIfBody(getStatementBlock(stmtCtx.info.stmt));
}
ifStmt.mergeStatementBlocksIfBody();
}
IfStatement tailIfStmt = ifStmt;
if (ctx.elifBranches.size() > 0) {
for (ElifBranchContext elifCtx : ctx.elifBranches) {
tailIfStmt.addStatementBlockElseBody(getStatementBlock(elifCtx.info.stmt));
tailIfStmt = (IfStatement) elifCtx.info.stmt;
}
}
if (ctx.elseBody.size() > 0) {
for (StatementContext stmtCtx : ctx.elseBody) {
tailIfStmt.addStatementBlockElseBody(getStatementBlock(stmtCtx.info.stmt));
}
tailIfStmt.mergeStatementBlocksElseBody();
}
ctx.info.stmt = ifStmt;
setFileLineColumn(ctx.info.stmt, ctx);
}
Aggregations