Search in sources :

Example 1 with SiddhiQLBaseVisitorImpl

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

the class SiddhiCompiler method parseQuery.

public static Query parseQuery(String query) throws SiddhiParserException {
    CharStream input = CharStreams.fromString(query);
    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) OnDemandQuery(io.siddhi.query.api.execution.query.OnDemandQuery) Query(io.siddhi.query.api.execution.query.Query) StoreQuery(io.siddhi.query.api.execution.query.StoreQuery) SiddhiQLBaseVisitorImpl(io.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl) CharStream(org.antlr.v4.runtime.CharStream) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 2 with SiddhiQLBaseVisitorImpl

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

the class SiddhiCompiler method parseFunctionDefinition.

public static FunctionDefinition parseFunctionDefinition(String functionDefinition) throws SiddhiParserException {
    CharStream input = CharStreams.fromString(functionDefinition);
    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(io.siddhi.query.api.definition.FunctionDefinition) SiddhiQLBaseVisitorImpl(io.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl) CharStream(org.antlr.v4.runtime.CharStream) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 3 with SiddhiQLBaseVisitorImpl

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

the class SiddhiCompiler method parsePartition.

public static Partition parsePartition(String partition) throws SiddhiParserException {
    CharStream input = CharStreams.fromString(partition);
    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(io.siddhi.query.api.execution.partition.Partition) SiddhiQLBaseVisitorImpl(io.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl) CharStream(org.antlr.v4.runtime.CharStream) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 4 with SiddhiQLBaseVisitorImpl

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

the class SiddhiCompiler method parseExpression.

public static Expression parseExpression(String expression) {
    CharStream input = CharStreams.fromString(expression);
    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.expression();
    SiddhiQLVisitor eval = new SiddhiQLBaseVisitorImpl();
    return (Expression) eval.visit(tree);
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) Expression(io.siddhi.query.api.expression.Expression) SiddhiQLBaseVisitorImpl(io.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl) CharStream(org.antlr.v4.runtime.CharStream) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 5 with SiddhiQLBaseVisitorImpl

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

the class SiddhiCompiler method parse.

public static SiddhiApp parse(String siddhiApp) {
    CharStream input = CharStreams.fromString(siddhiApp);
    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(io.siddhi.query.api.SiddhiApp) SiddhiQLBaseVisitorImpl(io.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl) CharStream(org.antlr.v4.runtime.CharStream) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Aggregations

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