Search in sources :

Example 1 with ForStatementContext

use of org.apache.sysml.parser.pydml.PydmlParser.ForStatementContext in project incubator-systemml by apache.

the class PydmlSyntacticValidator method exitForStatement.

@Override
public void exitForStatement(ForStatementContext ctx) {
    ForStatement forStmt = new ForStatement();
    int line = ctx.start.getLine();
    int col = ctx.start.getCharPositionInLine();
    DataIdentifier iterVar = new DataIdentifier(ctx.iterVar.getText());
    HashMap<String, String> parForParamValues = null;
    //1/-1
    Expression incrementExpr = null;
    if (ctx.iterPred.info.increment != null) {
        incrementExpr = ctx.iterPred.info.increment;
    }
    IterablePredicate predicate = new IterablePredicate(iterVar, ctx.iterPred.info.from, ctx.iterPred.info.to, incrementExpr, parForParamValues, currentFile, line, col, line, col);
    forStmt.setPredicate(predicate);
    if (ctx.body.size() > 0) {
        for (StatementContext stmtCtx : ctx.body) {
            forStmt.addStatementBlock(getStatementBlock(stmtCtx.info.stmt));
        }
        forStmt.mergeStatementBlocks();
    }
    ctx.info.stmt = forStmt;
    setFileLineColumn(ctx.info.stmt, ctx);
}
Also used : DataIdentifier(org.apache.sysml.parser.DataIdentifier) BinaryExpression(org.apache.sysml.parser.BinaryExpression) Expression(org.apache.sysml.parser.Expression) ParameterExpression(org.apache.sysml.parser.ParameterExpression) BuiltinFunctionExpression(org.apache.sysml.parser.BuiltinFunctionExpression) IterablePredicate(org.apache.sysml.parser.IterablePredicate) ParForStatement(org.apache.sysml.parser.ParForStatement) ForStatement(org.apache.sysml.parser.ForStatement) 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

BinaryExpression (org.apache.sysml.parser.BinaryExpression)1 BuiltinFunctionExpression (org.apache.sysml.parser.BuiltinFunctionExpression)1 DataIdentifier (org.apache.sysml.parser.DataIdentifier)1 Expression (org.apache.sysml.parser.Expression)1 ForStatement (org.apache.sysml.parser.ForStatement)1 IterablePredicate (org.apache.sysml.parser.IterablePredicate)1 ParForStatement (org.apache.sysml.parser.ParForStatement)1 ParameterExpression (org.apache.sysml.parser.ParameterExpression)1 AssignmentStatementContext (org.apache.sysml.parser.pydml.PydmlParser.AssignmentStatementContext)1 ForStatementContext (org.apache.sysml.parser.pydml.PydmlParser.ForStatementContext)1 FunctionCallAssignmentStatementContext (org.apache.sysml.parser.pydml.PydmlParser.FunctionCallAssignmentStatementContext)1 FunctionCallMultiAssignmentStatementContext (org.apache.sysml.parser.pydml.PydmlParser.FunctionCallMultiAssignmentStatementContext)1 FunctionStatementContext (org.apache.sysml.parser.pydml.PydmlParser.FunctionStatementContext)1 IfStatementContext (org.apache.sysml.parser.pydml.PydmlParser.IfStatementContext)1 IfdefAssignmentStatementContext (org.apache.sysml.parser.pydml.PydmlParser.IfdefAssignmentStatementContext)1 ImportStatementContext (org.apache.sysml.parser.pydml.PydmlParser.ImportStatementContext)1 ParForStatementContext (org.apache.sysml.parser.pydml.PydmlParser.ParForStatementContext)1 PathStatementContext (org.apache.sysml.parser.pydml.PydmlParser.PathStatementContext)1 StatementContext (org.apache.sysml.parser.pydml.PydmlParser.StatementContext)1 WhileStatementContext (org.apache.sysml.parser.pydml.PydmlParser.WhileStatementContext)1