use of org.apache.sysml.parser.AssignmentStatement in project incubator-systemml by apache.
the class CommonSyntacticValidator method exitAssignmentStatementHelper.
protected void exitAssignmentStatementHelper(ParserRuleContext ctx, String lhs, ExpressionInfo dataInfo, Token lhsStart, ExpressionInfo rhs, StatementInfo info) {
if (lhs.startsWith("$")) {
notifyErrorListeners("assignment of commandline parameters is not allowed. (Quickfix: try using someLocalVariable=ifdef(" + lhs + ", default value))", ctx.start);
return;
}
DataIdentifier target = null;
if (dataInfo.expr instanceof DataIdentifier) {
target = (DataIdentifier) dataInfo.expr;
Expression source = rhs.expr;
int line = ctx.start.getLine();
int col = ctx.start.getCharPositionInLine();
try {
info.stmt = new AssignmentStatement(target, source, line, col, line, col);
setFileLineColumn(info.stmt, ctx);
} catch (LanguageException e) {
// TODO: extract more meaningful info from this exception.
notifyErrorListeners("invalid assignment", lhsStart);
return;
}
} else {
notifyErrorListeners("incorrect lvalue in assignment statement", lhsStart);
return;
}
}
use of org.apache.sysml.parser.AssignmentStatement in project incubator-systemml by apache.
the class CommonSyntacticValidator method setAssignmentStatement.
protected void setAssignmentStatement(ParserRuleContext ctx, StatementInfo info, DataIdentifier target, Expression expression) {
try {
info.stmt = new AssignmentStatement(target, expression, ctx.start.getLine(), ctx.start.getCharPositionInLine(), ctx.start.getLine(), ctx.start.getCharPositionInLine());
setFileLineColumn(info.stmt, ctx);
} catch (LanguageException e) {
// TODO: extract more meaningful info from this exception.
notifyErrorListeners("invalid function call", ctx.start);
return;
}
}
use of org.apache.sysml.parser.AssignmentStatement in project incubator-systemml by apache.
the class PydmlSyntacticValidator method exitIgnoreNewLine.
// -----------------------------------------------------------------
// PyDML Specific
// -----------------------------------------------------------------
@Override
public void exitIgnoreNewLine(IgnoreNewLineContext ctx) {
// This is later ignored by PyDMLParserWrapper
try {
ctx.info.stmt = new AssignmentStatement(null, null, 0, 0, 0, 0);
ctx.info.stmt.setEmptyNewLineStatement(true);
} catch (LanguageException e) {
e.printStackTrace();
}
}
use of org.apache.sysml.parser.AssignmentStatement in project incubator-systemml by apache.
the class PydmlSyntacticValidator method exitIfdefAssignmentStatement.
@Override
public void exitIfdefAssignmentStatement(IfdefAssignmentStatementContext ctx) {
if (!ctx.commandLineParam.getText().startsWith("$")) {
notifyErrorListeners("the first argument of ifdef function should be a commandline argument parameter (which starts with $)", ctx.commandLineParam.start);
return;
}
if (ctx.targetList == null) {
notifyErrorListeners("incorrect lvalue in ifdef function ", ctx.start);
return;
}
String targetListText = ctx.targetList.getText();
if (targetListText.startsWith("$")) {
notifyErrorListeners("lhs of ifdef function cannot be a commandline parameters. Use local variable instead", ctx.start);
return;
}
DataIdentifier target = null;
if (ctx.targetList.dataInfo.expr instanceof DataIdentifier) {
target = (DataIdentifier) ctx.targetList.dataInfo.expr;
Expression source = null;
if (ctx.commandLineParam.dataInfo.expr != null) {
// Since commandline parameter is set
// The check of following is done in fillExpressionInfoCommandLineParameters:
// Command line param cannot be empty string
// If you want to pass space, please quote it
source = ctx.commandLineParam.dataInfo.expr;
} else {
source = ctx.source.info.expr;
}
int line = ctx.start.getLine();
int col = ctx.start.getCharPositionInLine();
try {
ctx.info.stmt = new AssignmentStatement(target, source, line, col, line, col);
setFileLineColumn(ctx.info.stmt, ctx);
} catch (LanguageException e) {
notifyErrorListeners("invalid assignment for ifdef function", ctx.targetList.start);
return;
}
} else {
notifyErrorListeners("incorrect lvalue in ifdef function ", ctx.targetList.start);
return;
}
}
use of org.apache.sysml.parser.AssignmentStatement in project incubator-systemml by apache.
the class DmlSyntacticValidator method exitIfdefAssignmentStatement.
@Override
public void exitIfdefAssignmentStatement(IfdefAssignmentStatementContext ctx) {
if (!ctx.commandLineParam.getText().startsWith("$")) {
notifyErrorListeners("the first argument of ifdef function should be a commandline argument parameter (which starts with $)", ctx.commandLineParam.start);
return;
}
if (ctx.targetList == null) {
notifyErrorListeners("ifdef assignment needs an lvalue ", ctx.start);
return;
}
String targetListText = ctx.targetList.getText();
if (targetListText.startsWith("$")) {
notifyErrorListeners("lhs of ifdef function cannot be a commandline parameters. Use local variable instead", ctx.start);
return;
}
DataIdentifier target = null;
if (ctx.targetList.dataInfo.expr instanceof DataIdentifier) {
target = (DataIdentifier) ctx.targetList.dataInfo.expr;
Expression source = null;
if (ctx.commandLineParam.dataInfo.expr != null) {
// Since commandline parameter is set
// The check of following is done in fillExpressionInfoCommandLineParameters:
// Command line param cannot be empty string
// If you want to pass space, please quote it
source = ctx.commandLineParam.dataInfo.expr;
} else {
source = ctx.source.info.expr;
}
int line = ctx.start.getLine();
int col = ctx.start.getCharPositionInLine();
try {
ctx.info.stmt = new AssignmentStatement(target, source, line, col, line, col);
setFileLineColumn(ctx.info.stmt, ctx);
} catch (LanguageException e) {
notifyErrorListeners("invalid assignment for ifdef function", ctx.targetList.start);
return;
}
} else {
notifyErrorListeners("incorrect lvalue in ifdef function ", ctx.targetList.start);
return;
}
}
Aggregations