Search in sources :

Example 16 with Parser

use of org.wso2.ballerinalang.compiler.parser.Parser 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)

Example 17 with Parser

use of org.wso2.ballerinalang.compiler.parser.Parser 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 18 with Parser

use of org.wso2.ballerinalang.compiler.parser.Parser 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 19 with Parser

use of org.wso2.ballerinalang.compiler.parser.Parser 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 20 with Parser

use of org.wso2.ballerinalang.compiler.parser.Parser 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)10 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)10 ParseTree (org.antlr.v4.runtime.tree.ParseTree)9 SiddhiQLBaseVisitorImpl (org.wso2.siddhi.query.compiler.internal.SiddhiQLBaseVisitorImpl)9 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)7 Token (org.antlr.v4.runtime.Token)4 JsonObject (com.google.gson.JsonObject)3 JsonParser (com.google.gson.JsonParser)3 Response (feign.Response)3 ArrayList (java.util.ArrayList)3 BallerinaParser (org.wso2.ballerinalang.compiler.parser.antlr4.BallerinaParser)3 IdentityProviderException (org.wso2.carbon.apimgt.core.exception.IdentityProviderException)3 JsonArray (com.google.gson.JsonArray)2 IOException (java.io.IOException)2 InputMismatchException (org.antlr.v4.runtime.InputMismatchException)2 ParserRuleContext (org.antlr.v4.runtime.ParserRuleContext)2 CompletionItem (org.eclipse.lsp4j.CompletionItem)2 BLangNode (org.wso2.ballerinalang.compiler.tree.BLangNode)2 BLangVariableDef (org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1