use of org.apache.sysml.parser.FunctionCallIdentifier in project incubator-systemml by apache.
the class CommonSyntacticValidator method createFunctionCall.
protected FunctionCallIdentifier createFunctionCall(ParserRuleContext ctx, String namespace, String functionName, ArrayList<ParameterExpression> paramExpression) {
FunctionCallIdentifier functCall = new FunctionCallIdentifier(paramExpression);
functCall.setFunctionName(functionName);
String inferNamespace = (sourceNamespace != null && sourceNamespace.length() > 0 && DMLProgram.DEFAULT_NAMESPACE.equals(namespace)) ? sourceNamespace : namespace;
functCall.setFunctionNamespace(inferNamespace);
functCall.setCtxValuesAndFilename(ctx, currentFile);
return functCall;
}
use of org.apache.sysml.parser.FunctionCallIdentifier in project incubator-systemml by apache.
the class DmlSyntacticValidator method exitFunctionCallMultiAssignmentStatement.
@Override
public void exitFunctionCallMultiAssignmentStatement(FunctionCallMultiAssignmentStatementContext ctx) {
String[] names = getQualifiedNames(ctx.name.getText());
if (names == null) {
notifyErrorListeners("incorrect function name (only namespace.functionName allowed. Hint: If you are trying to use builtin functions, you can skip the namespace)", ctx.name);
return;
}
String namespace = names[0];
String functionName = names[1];
ArrayList<ParameterExpression> paramExpression = getParameterExpressionList(ctx.paramExprs);
ConvertedDMLSyntax convertedSyntax = convertToDMLSyntax(ctx, namespace, functionName, paramExpression, ctx.name);
if (convertedSyntax == null) {
return;
} else {
namespace = convertedSyntax.namespace;
functionName = convertedSyntax.functionName;
paramExpression = convertedSyntax.paramExpression;
}
FunctionCallIdentifier functCall = new FunctionCallIdentifier(paramExpression);
functCall.setFunctionName(functionName);
functCall.setFunctionNamespace(namespace);
final ArrayList<DataIdentifier> targetList = new ArrayList<>();
for (DataIdentifierContext dataCtx : ctx.targetList) {
if (dataCtx.dataInfo.expr instanceof DataIdentifier) {
targetList.add((DataIdentifier) dataCtx.dataInfo.expr);
} else {
notifyErrorListeners("incorrect type for variable ", dataCtx.start);
return;
}
}
if (namespace.equals(DMLProgram.DEFAULT_NAMESPACE)) {
Expression e = buildForBuiltInFunction(ctx, functionName, paramExpression);
if (e != null) {
setMultiAssignmentStatement(targetList, e, ctx, ctx.info);
return;
}
}
// Override default namespace for imported non-built-in function
String inferNamespace = (sourceNamespace != null && sourceNamespace.length() > 0 && DMLProgram.DEFAULT_NAMESPACE.equals(namespace)) ? sourceNamespace : namespace;
functCall.setFunctionNamespace(inferNamespace);
setMultiAssignmentStatement(targetList, functCall, ctx, ctx.info);
}
use of org.apache.sysml.parser.FunctionCallIdentifier in project incubator-systemml by apache.
the class PydmlSyntacticValidator method exitFunctionCallMultiAssignmentStatement.
@Override
public void exitFunctionCallMultiAssignmentStatement(FunctionCallMultiAssignmentStatementContext ctx) {
String[] names = getQualifiedNames(ctx.name.getText());
if (names == null) {
notifyErrorListeners("incorrect function name (only namespace.functionName allowed. Hint: If you are trying to use builtin functions, you can skip the namespace)", ctx.name);
return;
}
String namespace = names[0];
String functionName = names[1];
ArrayList<ParameterExpression> paramExpression = getParameterExpressionList(ctx.paramExprs);
ConvertedDMLSyntax convertedSyntax = convertToDMLSyntax(ctx, namespace, functionName, paramExpression, ctx.name);
if (convertedSyntax == null) {
return;
} else {
namespace = convertedSyntax.namespace;
functionName = convertedSyntax.functionName;
paramExpression = convertedSyntax.paramExpression;
}
// No need to support dot() function since it will never return multi-assignment function
FunctionCallIdentifier functCall = new FunctionCallIdentifier(paramExpression);
functCall.setFunctionName(functionName);
functCall.setFunctionNamespace(namespace);
final ArrayList<DataIdentifier> targetList = new ArrayList<>();
for (DataIdentifierContext dataCtx : ctx.targetList) {
if (dataCtx.dataInfo.expr instanceof DataIdentifier) {
targetList.add((DataIdentifier) dataCtx.dataInfo.expr);
} else {
notifyErrorListeners("incorrect type for variable ", dataCtx.start);
return;
}
}
if (namespace.equals(DMLProgram.DEFAULT_NAMESPACE)) {
Expression e = buildForBuiltInFunction(ctx, functionName, paramExpression);
if (e != null) {
setMultiAssignmentStatement(targetList, e, ctx, ctx.info);
return;
}
}
// Override default namespace for imported non-built-in function
String inferNamespace = (sourceNamespace != null && sourceNamespace.length() > 0 && DMLProgram.DEFAULT_NAMESPACE.equals(namespace)) ? sourceNamespace : namespace;
functCall.setFunctionNamespace(inferNamespace);
setMultiAssignmentStatement(targetList, functCall, ctx, ctx.info);
}
use of org.apache.sysml.parser.FunctionCallIdentifier in project systemml by apache.
the class CommonSyntacticValidator method createFunctionCall.
protected FunctionCallIdentifier createFunctionCall(ParserRuleContext ctx, String namespace, String functionName, ArrayList<ParameterExpression> paramExpression) {
FunctionCallIdentifier functCall = new FunctionCallIdentifier(paramExpression);
functCall.setFunctionName(functionName);
String inferNamespace = (sourceNamespace != null && sourceNamespace.length() > 0 && DMLProgram.DEFAULT_NAMESPACE.equals(namespace)) ? sourceNamespace : namespace;
functCall.setFunctionNamespace(inferNamespace);
functCall.setCtxValuesAndFilename(ctx, currentFile);
return functCall;
}
use of org.apache.sysml.parser.FunctionCallIdentifier in project systemml by apache.
the class PydmlSyntacticValidator method exitFunctionCallMultiAssignmentStatement.
@Override
public void exitFunctionCallMultiAssignmentStatement(FunctionCallMultiAssignmentStatementContext ctx) {
String[] names = getQualifiedNames(ctx.name.getText());
if (names == null) {
notifyErrorListeners("incorrect function name (only namespace.functionName allowed. Hint: If you are trying to use builtin functions, you can skip the namespace)", ctx.name);
return;
}
String namespace = names[0];
String functionName = names[1];
ArrayList<ParameterExpression> paramExpression = getParameterExpressionList(ctx.paramExprs);
ConvertedDMLSyntax convertedSyntax = convertToDMLSyntax(ctx, namespace, functionName, paramExpression, ctx.name);
if (convertedSyntax == null) {
return;
} else {
namespace = convertedSyntax.namespace;
functionName = convertedSyntax.functionName;
paramExpression = convertedSyntax.paramExpression;
}
// No need to support dot() function since it will never return multi-assignment function
FunctionCallIdentifier functCall = new FunctionCallIdentifier(paramExpression);
functCall.setFunctionName(functionName);
functCall.setFunctionNamespace(namespace);
final ArrayList<DataIdentifier> targetList = new ArrayList<>();
for (DataIdentifierContext dataCtx : ctx.targetList) {
if (dataCtx.dataInfo.expr instanceof DataIdentifier) {
targetList.add((DataIdentifier) dataCtx.dataInfo.expr);
} else {
notifyErrorListeners("incorrect type for variable ", dataCtx.start);
return;
}
}
if (namespace.equals(DMLProgram.DEFAULT_NAMESPACE)) {
Expression e = buildForBuiltInFunction(ctx, functionName, paramExpression);
if (e != null) {
setMultiAssignmentStatement(targetList, e, ctx, ctx.info);
return;
}
}
// Override default namespace for imported non-built-in function
String inferNamespace = (sourceNamespace != null && sourceNamespace.length() > 0 && DMLProgram.DEFAULT_NAMESPACE.equals(namespace)) ? sourceNamespace : namespace;
functCall.setFunctionNamespace(inferNamespace);
setMultiAssignmentStatement(targetList, functCall, ctx, ctx.info);
}
Aggregations