Search in sources :

Example 6 with StatementContext

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

the class PydmlSyntacticValidator 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) 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 7 with StatementContext

use of org.apache.sysml.parser.pydml.PydmlParser.StatementContext in project incubator-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)

Aggregations

FunctionStatementContext (org.apache.sysml.parser.pydml.PydmlParser.FunctionStatementContext)7 StatementContext (org.apache.sysml.parser.pydml.PydmlParser.StatementContext)7 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 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 WhileStatementContext (org.apache.sysml.parser.pydml.PydmlParser.WhileStatementContext)6 ConditionalPredicate (org.apache.sysml.parser.ConditionalPredicate)3 DataIdentifier (org.apache.sysml.parser.DataIdentifier)3 BinaryExpression (org.apache.sysml.parser.BinaryExpression)2 BuiltinFunctionExpression (org.apache.sysml.parser.BuiltinFunctionExpression)2 Expression (org.apache.sysml.parser.Expression)2 IfStatement (org.apache.sysml.parser.IfStatement)2 IterablePredicate (org.apache.sysml.parser.IterablePredicate)2 ParForStatement (org.apache.sysml.parser.ParForStatement)2