Search in sources :

Example 1 with StrictParameterizedExpressionContext

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

the class DmlSyntacticValidator method exitParForStatement.

@Override
public void exitParForStatement(ParForStatementContext ctx) {
    ParForStatement parForStmt = new ParForStatement();
    int line = ctx.start.getLine();
    int col = ctx.start.getCharPositionInLine();
    DataIdentifier iterVar = new DataIdentifier(ctx.iterVar.getText());
    HashMap<String, String> parForParamValues = new HashMap<String, String>();
    if (ctx.parForParams != null && ctx.parForParams.size() > 0) {
        for (StrictParameterizedExpressionContext parForParamCtx : ctx.parForParams) {
            String paramVal = parForParamCtx.paramVal.getText();
            if (argVals.containsKey(paramVal))
                paramVal = argVals.get(paramVal);
            parForParamValues.put(parForParamCtx.paramName.getText(), paramVal);
        }
    }
    //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);
    parForStmt.setPredicate(predicate);
    if (ctx.body.size() > 0) {
        for (StatementContext stmtCtx : ctx.body) {
            parForStmt.addStatementBlock(getStatementBlock(stmtCtx.info.stmt));
        }
        parForStmt.mergeStatementBlocks();
    }
    ctx.info.stmt = parForStmt;
    setFileLineColumn(ctx.info.stmt, ctx);
}
Also used : DataIdentifier(org.apache.sysml.parser.DataIdentifier) HashMap(java.util.HashMap) Expression(org.apache.sysml.parser.Expression) ParameterExpression(org.apache.sysml.parser.ParameterExpression) StrictParameterizedExpressionContext(org.apache.sysml.parser.dml.DmlParser.StrictParameterizedExpressionContext) IterablePredicate(org.apache.sysml.parser.IterablePredicate) ParForStatement(org.apache.sysml.parser.ParForStatement) 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

HashMap (java.util.HashMap)1 DataIdentifier (org.apache.sysml.parser.DataIdentifier)1 Expression (org.apache.sysml.parser.Expression)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.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 StrictParameterizedExpressionContext (org.apache.sysml.parser.dml.DmlParser.StrictParameterizedExpressionContext)1 WhileStatementContext (org.apache.sysml.parser.dml.DmlParser.WhileStatementContext)1