Search in sources :

Example 1 with IfStatementContext

use of org.apache.sysml.parser.dml.DmlParser.IfStatementContext in project incubator-systemml by apache.

the class DmlSyntacticValidator method exitIfStatement.

@Override
public void exitIfStatement(IfStatementContext ctx) {
    IfStatement ifStmt = new IfStatement();
    ConditionalPredicate predicate = new ConditionalPredicate(ctx.predicate.info.expr);
    ifStmt.setConditionalPredicate(predicate);
    String fileName = currentFile;
    int line = ctx.start.getLine();
    int col = ctx.start.getCharPositionInLine();
    ifStmt.setAllPositions(fileName, line, col, line, col);
    if (ctx.ifBody.size() > 0) {
        for (StatementContext stmtCtx : ctx.ifBody) {
            ifStmt.addStatementBlockIfBody(getStatementBlock(stmtCtx.info.stmt));
        }
        ifStmt.mergeStatementBlocksIfBody();
    }
    if (ctx.elseBody.size() > 0) {
        for (StatementContext stmtCtx : ctx.elseBody) {
            ifStmt.addStatementBlockElseBody(getStatementBlock(stmtCtx.info.stmt));
        }
        ifStmt.mergeStatementBlocksElseBody();
    }
    ctx.info.stmt = ifStmt;
    setFileLineColumn(ctx.info.stmt, ctx);
}
Also used : IfStatement(org.apache.sysml.parser.IfStatement) ConditionalPredicate(org.apache.sysml.parser.ConditionalPredicate) ImportStatementContext(org.apache.sysml.parser.dml.DmlParser.ImportStatementContext) IfdefAssignmentStatementContext(org.apache.sysml.parser.dml.DmlParser.IfdefAssignmentStatementContext) FunctionStatementContext(org.apache.sysml.parser.dml.DmlParser.FunctionStatementContext) ForStatementContext(org.apache.sysml.parser.dml.DmlParser.ForStatementContext) AssignmentStatementContext(org.apache.sysml.parser.dml.DmlParser.AssignmentStatementContext) IfStatementContext(org.apache.sysml.parser.dml.DmlParser.IfStatementContext) PathStatementContext(org.apache.sysml.parser.dml.DmlParser.PathStatementContext) WhileStatementContext(org.apache.sysml.parser.dml.DmlParser.WhileStatementContext) ParForStatementContext(org.apache.sysml.parser.dml.DmlParser.ParForStatementContext) FunctionCallAssignmentStatementContext(org.apache.sysml.parser.dml.DmlParser.FunctionCallAssignmentStatementContext) StatementContext(org.apache.sysml.parser.dml.DmlParser.StatementContext) FunctionCallMultiAssignmentStatementContext(org.apache.sysml.parser.dml.DmlParser.FunctionCallMultiAssignmentStatementContext)

Aggregations

ConditionalPredicate (org.apache.sysml.parser.ConditionalPredicate)1 IfStatement (org.apache.sysml.parser.IfStatement)1 AssignmentStatementContext (org.apache.sysml.parser.dml.DmlParser.AssignmentStatementContext)1 ForStatementContext (org.apache.sysml.parser.dml.DmlParser.ForStatementContext)1 FunctionCallAssignmentStatementContext (org.apache.sysml.parser.dml.DmlParser.FunctionCallAssignmentStatementContext)1 FunctionCallMultiAssignmentStatementContext (org.apache.sysml.parser.dml.DmlParser.FunctionCallMultiAssignmentStatementContext)1 FunctionStatementContext (org.apache.sysml.parser.dml.DmlParser.FunctionStatementContext)1 IfStatementContext (org.apache.sysml.parser.dml.DmlParser.IfStatementContext)1 IfdefAssignmentStatementContext (org.apache.sysml.parser.dml.DmlParser.IfdefAssignmentStatementContext)1 ImportStatementContext (org.apache.sysml.parser.dml.DmlParser.ImportStatementContext)1 ParForStatementContext (org.apache.sysml.parser.dml.DmlParser.ParForStatementContext)1 PathStatementContext (org.apache.sysml.parser.dml.DmlParser.PathStatementContext)1 StatementContext (org.apache.sysml.parser.dml.DmlParser.StatementContext)1 WhileStatementContext (org.apache.sysml.parser.dml.DmlParser.WhileStatementContext)1