use of org.ballerinalang.siddhi.query.api.definition.FunctionDefinition in project ballerina by ballerina-lang.
the class SiddhiCompiler method parseFunctionDefinition.
public static FunctionDefinition parseFunctionDefinition(String source) throws SiddhiParserException {
ANTLRInputStream input = new ANTLRInputStream(source);
SiddhiQLLexer lexer = new SiddhiQLLexer(input);
lexer.removeErrorListeners();
lexer.addErrorListener(SiddhiErrorListener.INSTANCE);
CommonTokenStream tokens = new CommonTokenStream(lexer);
SiddhiQLParser parser = new SiddhiQLParser(tokens);
parser.removeErrorListeners();
parser.addErrorListener(SiddhiErrorListener.INSTANCE);
ParseTree tree = parser.definition_function_final();
SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
return (FunctionDefinition) eval.visit(tree);
}
use of org.ballerinalang.siddhi.query.api.definition.FunctionDefinition in project ballerina by ballerina-lang.
the class SiddhiQLBaseVisitorImpl method visitDefinition_function.
@Override
public FunctionDefinition visitDefinition_function(@NotNull SiddhiQLParser.Definition_functionContext ctx) {
String functionName = (String) visitFunction_name(ctx.function_name());
String languageName = (String) visitLanguage_name(ctx.language_name());
Attribute.Type attributeType = (Attribute.Type) visit(ctx.attribute_type());
String functionBody = (String) visitFunction_body(ctx.function_body());
FunctionDefinition functionDefinition = new FunctionDefinition();
functionDefinition.id(functionName).language(languageName).type(attributeType).body(functionBody);
populateQueryContext(functionDefinition, ctx);
return functionDefinition;
}
Aggregations