Search in sources :

Example 6 with SiddhiQLParser

use of org.wso2.siddhi.query.compiler.SiddhiQLParser in project siddhi by wso2.

the class SiddhiCompiler method parseAggregationDefinition.

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

Example 7 with SiddhiQLParser

use of org.wso2.siddhi.query.compiler.SiddhiQLParser in project siddhi by wso2.

the class SiddhiCompiler method parseTableDefinition.

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

Example 8 with SiddhiQLParser

use of org.wso2.siddhi.query.compiler.SiddhiQLParser in project siddhi by wso2.

the class SiddhiCompiler method parsePartition.

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

Example 9 with SiddhiQLParser

use of org.wso2.siddhi.query.compiler.SiddhiQLParser in project siddhi by wso2.

the class SiddhiCompiler method parseStreamDefinition.

public static StreamDefinition parseStreamDefinition(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.removeErrorListeners();
    parser.addErrorListener(SiddhiErrorListener.INSTANCE);
    ParseTree tree = parser.definition_stream_final();
    SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
    return (StreamDefinition) eval.visit(tree);
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) StreamDefinition(org.wso2.siddhi.query.api.definition.StreamDefinition) 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