Search in sources :

Example 1 with CQLParser

use of org.geotoolkit.cql.CQLParser in project geotoolkit by Geomatys.

the class CQL method compileExpression.

private static Object compileExpression(String cql) {
    try {
        // lexer splits input into tokens
        final ANTLRInputStream input = new ANTLRInputStream(cql);
        final TokenStream tokens = new CommonTokenStream(new CQLLexer(input));
        // parser generates abstract syntax tree
        final CQLParser parser = new CQLParser(tokens);
        final ExpressionContext ctx = parser.expression();
        return ctx;
    } catch (RecognitionException e) {
        throw new IllegalStateException("Recognition exception is never thrown, only declared.");
    }
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) TokenStream(org.antlr.v4.runtime.TokenStream) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) FilterOrExpressionContext(org.geotoolkit.cql.CQLParser.FilterOrExpressionContext) ExpressionContext(org.geotoolkit.cql.CQLParser.ExpressionContext) CQLParser(org.geotoolkit.cql.CQLParser) ANTLRInputStream(org.antlr.v4.runtime.ANTLRInputStream) RecognitionException(org.antlr.v4.runtime.RecognitionException)

Example 2 with CQLParser

use of org.geotoolkit.cql.CQLParser in project geotoolkit by Geomatys.

the class CQL method compileFilter.

private static Object compileFilter(String cql) {
    try {
        // lexer splits input into tokens
        final ANTLRInputStream input = new ANTLRInputStream(cql);
        final TokenStream tokens = new CommonTokenStream(new CQLLexer(input));
        // parser generates abstract syntax tree
        final CQLParser parser = new CQLParser(tokens);
        final FilterContext retfilter = parser.filter();
        return retfilter;
    } catch (RecognitionException e) {
        throw new IllegalStateException("Recognition exception is never thrown, only declared.");
    }
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) TokenStream(org.antlr.v4.runtime.TokenStream) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) CQLParser(org.geotoolkit.cql.CQLParser) ANTLRInputStream(org.antlr.v4.runtime.ANTLRInputStream) RecognitionException(org.antlr.v4.runtime.RecognitionException) FilterContext(org.geotoolkit.cql.CQLParser.FilterContext)

Example 3 with CQLParser

use of org.geotoolkit.cql.CQLParser in project geotoolkit by Geomatys.

the class CQL method compileFilterOrExpression.

private static Object compileFilterOrExpression(String cql) {
    try {
        // lexer splits input into tokens
        final ANTLRInputStream input = new ANTLRInputStream(cql);
        final TokenStream tokens = new CommonTokenStream(new CQLLexer(input));
        // parser generates abstract syntax tree
        final CQLParser parser = new CQLParser(tokens);
        final FilterOrExpressionContext retfilter = parser.filterOrExpression();
        return retfilter;
    } catch (RecognitionException e) {
        throw new IllegalStateException("Recognition exception is never thrown, only declared.");
    }
}
Also used : CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) TokenStream(org.antlr.v4.runtime.TokenStream) CommonTokenStream(org.antlr.v4.runtime.CommonTokenStream) FilterOrExpressionContext(org.geotoolkit.cql.CQLParser.FilterOrExpressionContext) CQLParser(org.geotoolkit.cql.CQLParser) ANTLRInputStream(org.antlr.v4.runtime.ANTLRInputStream) RecognitionException(org.antlr.v4.runtime.RecognitionException)

Aggregations

ANTLRInputStream (org.antlr.v4.runtime.ANTLRInputStream)3 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)3 RecognitionException (org.antlr.v4.runtime.RecognitionException)3 TokenStream (org.antlr.v4.runtime.TokenStream)3 CQLParser (org.geotoolkit.cql.CQLParser)3 FilterOrExpressionContext (org.geotoolkit.cql.CQLParser.FilterOrExpressionContext)2 ExpressionContext (org.geotoolkit.cql.CQLParser.ExpressionContext)1 FilterContext (org.geotoolkit.cql.CQLParser.FilterContext)1