use of org.apache.sysml.parser.OutputStatement in project incubator-systemml by apache.
the class CommonSyntacticValidator method setOutputStatement.
protected void setOutputStatement(ParserRuleContext ctx, ArrayList<ParameterExpression> paramExpression, StatementInfo info) {
if (paramExpression.size() < 2) {
notifyErrorListeners("incorrect usage of write function (at least 2 arguments required)", ctx.start);
return;
}
if (paramExpression.get(0).getExpr() instanceof DataIdentifier) {
String fileName = currentFile;
int line = ctx.start.getLine();
int col = ctx.start.getCharPositionInLine();
HashMap<String, Expression> varParams = new HashMap<String, Expression>();
varParams.put(DataExpression.IO_FILENAME, paramExpression.get(1).getExpr());
for (int i = 2; i < paramExpression.size(); i++) {
// DataExpression.FORMAT_TYPE, DataExpression.DELIM_DELIMITER, DataExpression.DELIM_HAS_HEADER_ROW, DataExpression.DELIM_SPARSE
varParams.put(paramExpression.get(i).getName(), paramExpression.get(i).getExpr());
}
DataExpression dataExpression = new DataExpression(DataOp.WRITE, varParams, fileName, line, col, line, col);
info.stmt = new OutputStatement((DataIdentifier) paramExpression.get(0).getExpr(), DataOp.WRITE, fileName, line, col, line, col);
setFileLineColumn(info.stmt, ctx);
((OutputStatement) info.stmt).setExprParams(dataExpression);
} else {
notifyErrorListeners("incorrect usage of write function", ctx.start);
}
}
Aggregations