Search in sources :

Example 1 with ConditionalPredicate

use of org.apache.sysml.parser.ConditionalPredicate 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);
    ifStmt.setCtxValuesAndFilename(ctx, currentFile);
    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) AccumulatorAssignmentStatementContext(org.apache.sysml.parser.dml.DmlParser.AccumulatorAssignmentStatementContext) 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)

Example 2 with ConditionalPredicate

use of org.apache.sysml.parser.ConditionalPredicate in project systemml by apache.

the class DmlSyntacticValidator method exitWhileStatement.

@Override
public void exitWhileStatement(WhileStatementContext ctx) {
    WhileStatement whileStmt = new WhileStatement();
    ConditionalPredicate predicate = new ConditionalPredicate(ctx.predicate.info.expr);
    whileStmt.setPredicate(predicate);
    whileStmt.setCtxValuesAndFilename(ctx, currentFile);
    if (ctx.body.size() > 0) {
        for (StatementContext stmtCtx : ctx.body) {
            whileStmt.addStatementBlock(getStatementBlock(stmtCtx.info.stmt));
        }
        whileStmt.mergeStatementBlocks();
    }
    ctx.info.stmt = whileStmt;
    setFileLineColumn(ctx.info.stmt, ctx);
}
Also used : WhileStatement(org.apache.sysml.parser.WhileStatement) 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) AccumulatorAssignmentStatementContext(org.apache.sysml.parser.dml.DmlParser.AccumulatorAssignmentStatementContext) 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)

Example 3 with ConditionalPredicate

use of org.apache.sysml.parser.ConditionalPredicate in project systemml by apache.

the class PydmlSyntacticValidator method exitElifBranch.

@Override
public void exitElifBranch(ElifBranchContext ctx) {
    IfStatement elifStmt = new IfStatement();
    ConditionalPredicate predicate = new ConditionalPredicate(ctx.predicate.info.expr);
    elifStmt.setConditionalPredicate(predicate);
    elifStmt.setCtxValuesAndFilename(ctx, currentFile);
    if (ctx.elifBody.size() > 0) {
        for (StatementContext stmtCtx : ctx.elifBody) {
            elifStmt.addStatementBlockIfBody(getStatementBlock(stmtCtx.info.stmt));
        }
        elifStmt.mergeStatementBlocksIfBody();
    }
    ctx.info.stmt = elifStmt;
    setFileLineColumn(ctx.info.stmt, ctx);
}
Also used : IfStatement(org.apache.sysml.parser.IfStatement) ConditionalPredicate(org.apache.sysml.parser.ConditionalPredicate) FunctionStatementContext(org.apache.sysml.parser.pydml.PydmlParser.FunctionStatementContext) ImportStatementContext(org.apache.sysml.parser.pydml.PydmlParser.ImportStatementContext) AssignmentStatementContext(org.apache.sysml.parser.pydml.PydmlParser.AssignmentStatementContext) PathStatementContext(org.apache.sysml.parser.pydml.PydmlParser.PathStatementContext) FunctionCallMultiAssignmentStatementContext(org.apache.sysml.parser.pydml.PydmlParser.FunctionCallMultiAssignmentStatementContext) IfStatementContext(org.apache.sysml.parser.pydml.PydmlParser.IfStatementContext) IfdefAssignmentStatementContext(org.apache.sysml.parser.pydml.PydmlParser.IfdefAssignmentStatementContext) ForStatementContext(org.apache.sysml.parser.pydml.PydmlParser.ForStatementContext) StatementContext(org.apache.sysml.parser.pydml.PydmlParser.StatementContext) ParForStatementContext(org.apache.sysml.parser.pydml.PydmlParser.ParForStatementContext) FunctionCallAssignmentStatementContext(org.apache.sysml.parser.pydml.PydmlParser.FunctionCallAssignmentStatementContext) WhileStatementContext(org.apache.sysml.parser.pydml.PydmlParser.WhileStatementContext)

Example 4 with ConditionalPredicate

use of org.apache.sysml.parser.ConditionalPredicate in project incubator-systemml by apache.

the class DmlSyntacticValidator method exitWhileStatement.

@Override
public void exitWhileStatement(WhileStatementContext ctx) {
    WhileStatement whileStmt = new WhileStatement();
    ConditionalPredicate predicate = new ConditionalPredicate(ctx.predicate.info.expr);
    whileStmt.setPredicate(predicate);
    whileStmt.setCtxValuesAndFilename(ctx, currentFile);
    if (ctx.body.size() > 0) {
        for (StatementContext stmtCtx : ctx.body) {
            whileStmt.addStatementBlock(getStatementBlock(stmtCtx.info.stmt));
        }
        whileStmt.mergeStatementBlocks();
    }
    ctx.info.stmt = whileStmt;
    setFileLineColumn(ctx.info.stmt, ctx);
}
Also used : WhileStatement(org.apache.sysml.parser.WhileStatement) 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) AccumulatorAssignmentStatementContext(org.apache.sysml.parser.dml.DmlParser.AccumulatorAssignmentStatementContext) 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)

Example 5 with ConditionalPredicate

use of org.apache.sysml.parser.ConditionalPredicate 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);
}
Also used : ElifBranchContext(org.apache.sysml.parser.pydml.PydmlParser.ElifBranchContext) IfStatement(org.apache.sysml.parser.IfStatement) ConditionalPredicate(org.apache.sysml.parser.ConditionalPredicate) FunctionStatementContext(org.apache.sysml.parser.pydml.PydmlParser.FunctionStatementContext) ImportStatementContext(org.apache.sysml.parser.pydml.PydmlParser.ImportStatementContext) AssignmentStatementContext(org.apache.sysml.parser.pydml.PydmlParser.AssignmentStatementContext) PathStatementContext(org.apache.sysml.parser.pydml.PydmlParser.PathStatementContext) FunctionCallMultiAssignmentStatementContext(org.apache.sysml.parser.pydml.PydmlParser.FunctionCallMultiAssignmentStatementContext) IfStatementContext(org.apache.sysml.parser.pydml.PydmlParser.IfStatementContext) IfdefAssignmentStatementContext(org.apache.sysml.parser.pydml.PydmlParser.IfdefAssignmentStatementContext) ForStatementContext(org.apache.sysml.parser.pydml.PydmlParser.ForStatementContext) StatementContext(org.apache.sysml.parser.pydml.PydmlParser.StatementContext) ParForStatementContext(org.apache.sysml.parser.pydml.PydmlParser.ParForStatementContext) FunctionCallAssignmentStatementContext(org.apache.sysml.parser.pydml.PydmlParser.FunctionCallAssignmentStatementContext) WhileStatementContext(org.apache.sysml.parser.pydml.PydmlParser.WhileStatementContext)

Aggregations

ConditionalPredicate (org.apache.sysml.parser.ConditionalPredicate)10 IfStatement (org.apache.sysml.parser.IfStatement)6 AssignmentStatementContext (org.apache.sysml.parser.pydml.PydmlParser.AssignmentStatementContext)6 ForStatementContext (org.apache.sysml.parser.pydml.PydmlParser.ForStatementContext)6 FunctionCallAssignmentStatementContext (org.apache.sysml.parser.pydml.PydmlParser.FunctionCallAssignmentStatementContext)6 FunctionCallMultiAssignmentStatementContext (org.apache.sysml.parser.pydml.PydmlParser.FunctionCallMultiAssignmentStatementContext)6 FunctionStatementContext (org.apache.sysml.parser.pydml.PydmlParser.FunctionStatementContext)6 IfStatementContext (org.apache.sysml.parser.pydml.PydmlParser.IfStatementContext)6 IfdefAssignmentStatementContext (org.apache.sysml.parser.pydml.PydmlParser.IfdefAssignmentStatementContext)6 ImportStatementContext (org.apache.sysml.parser.pydml.PydmlParser.ImportStatementContext)6 ParForStatementContext (org.apache.sysml.parser.pydml.PydmlParser.ParForStatementContext)6 PathStatementContext (org.apache.sysml.parser.pydml.PydmlParser.PathStatementContext)6 StatementContext (org.apache.sysml.parser.pydml.PydmlParser.StatementContext)6 WhileStatementContext (org.apache.sysml.parser.pydml.PydmlParser.WhileStatementContext)6 WhileStatement (org.apache.sysml.parser.WhileStatement)4 AccumulatorAssignmentStatementContext (org.apache.sysml.parser.dml.DmlParser.AccumulatorAssignmentStatementContext)4 AssignmentStatementContext (org.apache.sysml.parser.dml.DmlParser.AssignmentStatementContext)4 ForStatementContext (org.apache.sysml.parser.dml.DmlParser.ForStatementContext)4 FunctionCallAssignmentStatementContext (org.apache.sysml.parser.dml.DmlParser.FunctionCallAssignmentStatementContext)4 FunctionCallMultiAssignmentStatementContext (org.apache.sysml.parser.dml.DmlParser.FunctionCallMultiAssignmentStatementContext)4