Search in sources :

Example 1 with SiddhiQLBaseVisitorImpl

use of org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl in project siddhi by wso2.

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);
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) FunctionDefinition(org.wso2.siddhi.query.api.definition.FunctionDefinition) SiddhiQLBaseVisitorImpl(org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl) ANTLRInputStream(org.antlr.v4.runtime.ANTLRInputStream) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 2 with SiddhiQLBaseVisitorImpl

use of org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl in project siddhi by wso2.

the class SiddhiCompiler method parseTimeConstantDefinition.

public static TimeConstant parseTimeConstantDefinition(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.time_value();
    SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
    return (TimeConstant) eval.visit(tree);
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) SiddhiQLBaseVisitorImpl(org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl) ANTLRInputStream(org.antlr.v4.runtime.ANTLRInputStream) ParseTree(org.antlr.v4.runtime.tree.ParseTree) TimeConstant(org.wso2.siddhi.query.api.expression.constant.TimeConstant)

Example 3 with SiddhiQLBaseVisitorImpl

use of org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl in project siddhi by wso2.

the class SiddhiCompiler method parseStoreQuery.

public static StoreQuery parseStoreQuery(String storeQuery) throws SiddhiParserException {
    ANTLRInputStream input = new ANTLRInputStream(storeQuery);
    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.store_query_final();
    SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
    return (StoreQuery) eval.visit(tree);
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) StoreQuery(org.wso2.siddhi.query.api.execution.query.StoreQuery) SiddhiQLBaseVisitorImpl(org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl) ANTLRInputStream(org.antlr.v4.runtime.ANTLRInputStream) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 4 with SiddhiQLBaseVisitorImpl

use of org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl in project siddhi by wso2.

the class SiddhiCompiler method parse.

public static SiddhiApp parse(String source) {
    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.setErrorHandler(new BailErrorStrategy());
    parser.removeErrorListeners();
    parser.addErrorListener(SiddhiErrorListener.INSTANCE);
    ParseTree tree = parser.parse();
    SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
    return (SiddhiApp) eval.visit(tree);
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) SiddhiApp(org.wso2.siddhi.query.api.SiddhiApp) SiddhiQLBaseVisitorImpl(org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl) ANTLRInputStream(org.antlr.v4.runtime.ANTLRInputStream) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 5 with SiddhiQLBaseVisitorImpl

use of org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl in project siddhi by wso2.

the class SiddhiCompiler method parseQuery.

public static Query parseQuery(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.query_final();
    SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
    return (Query) eval.visit(tree);
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) Query(org.wso2.siddhi.query.api.execution.query.Query) StoreQuery(org.wso2.siddhi.query.api.execution.query.StoreQuery) SiddhiQLBaseVisitorImpl(org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl) ANTLRInputStream(org.antlr.v4.runtime.ANTLRInputStream) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Aggregations

ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)9 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)9 ParseTree (org.antlr.v4.runtime.tree.ParseTree)9 SiddhiQLBaseVisitorImpl (org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl)9 StoreQuery (org.wso2.siddhi.query.api.execution.query.StoreQuery)2 SiddhiApp (org.wso2.siddhi.query.api.SiddhiApp)1 AggregationDefinition (org.wso2.siddhi.query.api.definition.AggregationDefinition)1 FunctionDefinition (org.wso2.siddhi.query.api.definition.FunctionDefinition)1 StreamDefinition (org.wso2.siddhi.query.api.definition.StreamDefinition)1 TableDefinition (org.wso2.siddhi.query.api.definition.TableDefinition)1 Partition (org.wso2.siddhi.query.api.execution.partition.Partition)1 Query (org.wso2.siddhi.query.api.execution.query.Query)1 TimeConstant (org.wso2.siddhi.query.api.expression.constant.TimeConstant)1