// $ANTLR 3.0.1 Cql.g3 2007-10-18 09:43:18

	package gr.uoa.di.driver.cql;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;


import org.antlr.runtime.tree.*;

public class CqlParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "IDENTIFIER", "STRING", "QUOTE", "WHITESPACE", "'>'", "'='", "'and'", "'or'", "'not'", "'prox'", "'/'", "'('", "')'", "'<'", "'>='", "'<='", "'<>'"
    };
    public static final int QUOTE=6;
    public static final int IDENTIFIER=4;
    public static final int WHITESPACE=7;
    public static final int EOF=-1;
    public static final int STRING=5;

        public CqlParser(TokenStream input) {
            super(input);
        }
        
    protected TreeAdaptor adaptor = new CommonTreeAdaptor();

    public void setTreeAdaptor(TreeAdaptor adaptor) {
        this.adaptor = adaptor;
    }
    public TreeAdaptor getTreeAdaptor() {
        return adaptor;
    }

    public String[] getTokenNames() { return tokenNames; }
    public String getGrammarFileName() { return "Cql.g3"; }


    public static class cql_return extends ParserRuleReturnScope {
        public CqlQuery query;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start cql
    // Cql.g3:22:1: cql returns [CqlQuery query] : q= cqlquery ;
    public final cql_return cql() throws RecognitionException {
        cql_return retval = new cql_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        cqlquery_return q = null;



        try {
            // Cql.g3:22:30: (q= cqlquery )
            // Cql.g3:22:32: q= cqlquery
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_cqlquery_in_cql70);
            q=cqlquery();
            _fsp--;

            adaptor.addChild(root_0, q.getTree());

            						System.out.println("query tree: " +
            								((CommonTree)q.tree).toStringTree() );
            						retval.query = q.query;
            					

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end cql

    public static class cqlquery_return extends ParserRuleReturnScope {
        public CqlQuery query;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start cqlquery
    // Cql.g3:30:1: cqlquery returns [CqlQuery query] : ( qscope q= cqlquery | c= scopedClause );
    public final cqlquery_return cqlquery() throws RecognitionException {
        cqlquery_return retval = new cqlquery_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        cqlquery_return q = null;

        scopedClause_return c = null;

        qscope_return qscope1 = null;



        try {
            // Cql.g3:31:5: ( qscope q= cqlquery | c= scopedClause )
            int alt1=2;
            int LA1_0 = input.LA(1);

            if ( (LA1_0==8) ) {
                alt1=1;
            }
            else if ( ((LA1_0>=IDENTIFIER && LA1_0<=STRING)||(LA1_0>=10 && LA1_0<=13)||LA1_0==15) ) {
                alt1=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("30:1: cqlquery returns [CqlQuery query] : ( qscope q= cqlquery | c= scopedClause );", 1, 0, input);

                throw nvae;
            }
            switch (alt1) {
                case 1 :
                    // Cql.g3:31:7: qscope q= cqlquery
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_qscope_in_cqlquery96);
                    qscope1=qscope();
                    _fsp--;

                    pushFollow(FOLLOW_cqlquery_in_cqlquery101);
                    q=cqlquery();
                    _fsp--;

                    adaptor.addChild(root_0, q.getTree());
                     retval.query = q.query; 

                    }
                    break;
                case 2 :
                    // Cql.g3:32:7: c= scopedClause
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_scopedClause_in_cqlquery113);
                    c=scopedClause();
                    _fsp--;

                    adaptor.addChild(root_0, c.getTree());
                     retval.query = new CqlQuery(c.clause); 

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end cqlquery

    public static class qscope_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start qscope
    // Cql.g3:34:1: qscope : ( '>' prefix '=' uri | '>' uri );
    public final qscope_return qscope() throws RecognitionException {
        qscope_return retval = new qscope_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token char_literal2=null;
        Token char_literal4=null;
        Token char_literal6=null;
        prefix_return prefix3 = null;

        uri_return uri5 = null;

        uri_return uri7 = null;


        CommonTree char_literal2_tree=null;
        CommonTree char_literal4_tree=null;
        CommonTree char_literal6_tree=null;

        try {
            // Cql.g3:36:9: ( '>' prefix '=' uri | '>' uri )
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==8) ) {
                switch ( input.LA(2) ) {
                case IDENTIFIER:
                    {
                    int LA2_2 = input.LA(3);

                    if ( (LA2_2==9) ) {
                        alt2=1;
                    }
                    else if ( ((LA2_2>=IDENTIFIER && LA2_2<=STRING)||LA2_2==8||(LA2_2>=10 && LA2_2<=13)||LA2_2==15) ) {
                        alt2=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("34:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 2, input);

                        throw nvae;
                    }
                    }
                    break;
                case STRING:
                    {
                    int LA2_3 = input.LA(3);

                    if ( ((LA2_3>=IDENTIFIER && LA2_3<=STRING)||LA2_3==8||(LA2_3>=10 && LA2_3<=13)||LA2_3==15) ) {
                        alt2=2;
                    }
                    else if ( (LA2_3==9) ) {
                        alt2=1;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("34:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 3, input);

                        throw nvae;
                    }
                    }
                    break;
                case 10:
                    {
                    int LA2_4 = input.LA(3);

                    if ( (LA2_4==9) ) {
                        alt2=1;
                    }
                    else if ( ((LA2_4>=IDENTIFIER && LA2_4<=STRING)||LA2_4==8||(LA2_4>=10 && LA2_4<=13)||LA2_4==15) ) {
                        alt2=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("34:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 4, input);

                        throw nvae;
                    }
                    }
                    break;
                case 11:
                    {
                    int LA2_5 = input.LA(3);

                    if ( (LA2_5==9) ) {
                        alt2=1;
                    }
                    else if ( ((LA2_5>=IDENTIFIER && LA2_5<=STRING)||LA2_5==8||(LA2_5>=10 && LA2_5<=13)||LA2_5==15) ) {
                        alt2=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("34:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 5, input);

                        throw nvae;
                    }
                    }
                    break;
                case 12:
                    {
                    int LA2_6 = input.LA(3);

                    if ( ((LA2_6>=IDENTIFIER && LA2_6<=STRING)||LA2_6==8||(LA2_6>=10 && LA2_6<=13)||LA2_6==15) ) {
                        alt2=2;
                    }
                    else if ( (LA2_6==9) ) {
                        alt2=1;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("34:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 6, input);

                        throw nvae;
                    }
                    }
                    break;
                case 13:
                    {
                    int LA2_7 = input.LA(3);

                    if ( ((LA2_7>=IDENTIFIER && LA2_7<=STRING)||LA2_7==8||(LA2_7>=10 && LA2_7<=13)||LA2_7==15) ) {
                        alt2=2;
                    }
                    else if ( (LA2_7==9) ) {
                        alt2=1;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("34:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 7, input);

                        throw nvae;
                    }
                    }
                    break;
                default:
                    NoViableAltException nvae =
                        new NoViableAltException("34:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 1, input);

                    throw nvae;
                }

            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("34:1: qscope : ( '>' prefix '=' uri | '>' uri );", 2, 0, input);

                throw nvae;
            }
            switch (alt2) {
                case 1 :
                    // Cql.g3:36:11: '>' prefix '=' uri
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    char_literal2=(Token)input.LT(1);
                    match(input,8,FOLLOW_8_in_qscope129); 
                    char_literal2_tree = (CommonTree)adaptor.create(char_literal2);
                    adaptor.addChild(root_0, char_literal2_tree);

                    pushFollow(FOLLOW_prefix_in_qscope131);
                    prefix3=prefix();
                    _fsp--;

                    adaptor.addChild(root_0, prefix3.getTree());
                    char_literal4=(Token)input.LT(1);
                    match(input,9,FOLLOW_9_in_qscope133); 
                    char_literal4_tree = (CommonTree)adaptor.create(char_literal4);
                    adaptor.addChild(root_0, char_literal4_tree);

                    pushFollow(FOLLOW_uri_in_qscope135);
                    uri5=uri();
                    _fsp--;

                    adaptor.addChild(root_0, uri5.getTree());

                    }
                    break;
                case 2 :
                    // Cql.g3:36:32: '>' uri
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    char_literal6=(Token)input.LT(1);
                    match(input,8,FOLLOW_8_in_qscope139); 
                    char_literal6_tree = (CommonTree)adaptor.create(char_literal6);
                    adaptor.addChild(root_0, char_literal6_tree);

                    pushFollow(FOLLOW_uri_in_qscope141);
                    uri7=uri();
                    _fsp--;

                    adaptor.addChild(root_0, uri7.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end qscope

    public static class prefix_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start prefix
    // Cql.g3:37:1: prefix : term ;
    public final prefix_return prefix() throws RecognitionException {
        prefix_return retval = new prefix_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        term_return term8 = null;



        try {
            // Cql.g3:37:9: ( term )
            // Cql.g3:37:11: term
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_term_in_prefix150);
            term8=term();
            _fsp--;

            adaptor.addChild(root_0, term8.getTree());

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end prefix

    public static class uri_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start uri
    // Cql.g3:38:1: uri : term ;
    public final uri_return uri() throws RecognitionException {
        uri_return retval = new uri_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        term_return term9 = null;



        try {
            // Cql.g3:38:7: ( term )
            // Cql.g3:38:9: term
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_term_in_uri160);
            term9=term();
            _fsp--;

            adaptor.addChild(root_0, term9.getTree());

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end uri

    public static class scopedClause_return extends ParserRuleReturnScope {
        public CqlClause clause;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start scopedClause
    // Cql.g3:39:1: scopedClause returns [CqlClause clause] : left= searchClause (op= booleanGroup right= searchClause )* ;
    public final scopedClause_return scopedClause() throws RecognitionException {
        scopedClause_return retval = new scopedClause_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        searchClause_return left = null;

        booleanGroup_return op = null;

        searchClause_return right = null;



        try {
            // Cql.g3:42:41: (left= searchClause (op= booleanGroup right= searchClause )* )
            // Cql.g3:43:3: left= searchClause (op= booleanGroup right= searchClause )*
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_searchClause_in_scopedClause180);
            left=searchClause();
            _fsp--;

            adaptor.addChild(root_0, left.getTree());
             retval.clause = left.clause; 
            // Cql.g3:44:3: (op= booleanGroup right= searchClause )*
            loop3:
            do {
                int alt3=2;
                int LA3_0 = input.LA(1);

                if ( ((LA3_0>=10 && LA3_0<=13)) ) {
                    alt3=1;
                }


                switch (alt3) {
            	case 1 :
            	    // Cql.g3:44:4: op= booleanGroup right= searchClause
            	    {
            	    pushFollow(FOLLOW_booleanGroup_in_scopedClause189);
            	    op=booleanGroup();
            	    _fsp--;

            	    root_0 = (CommonTree)adaptor.becomeRoot(op.getTree(), root_0);
            	    pushFollow(FOLLOW_searchClause_in_scopedClause194);
            	    right=searchClause();
            	    _fsp--;

            	    adaptor.addChild(root_0, right.getTree());
            	     retval.clause = new CqlBoolean(retval.clause, op.value, right.clause); 

            	    }
            	    break;

            	default :
            	    break loop3;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end scopedClause

    public static class booleanGroup_return extends ParserRuleReturnScope {
        public String value;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start booleanGroup
    // Cql.g3:49:1: booleanGroup returns [String value] : b= bool ( modifierList )? ;
    public final booleanGroup_return booleanGroup() throws RecognitionException {
        booleanGroup_return retval = new booleanGroup_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        bool_return b = null;

        modifierList_return modifierList10 = null;



        try {
            // Cql.g3:49:37: (b= bool ( modifierList )? )
            // Cql.g3:50:2: b= bool ( modifierList )?
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_bool_in_booleanGroup222);
            b=bool();
            _fsp--;

            adaptor.addChild(root_0, b.getTree());
            // Cql.g3:50:9: ( modifierList )?
            int alt4=2;
            int LA4_0 = input.LA(1);

            if ( (LA4_0==14) ) {
                alt4=1;
            }
            switch (alt4) {
                case 1 :
                    // Cql.g3:50:10: modifierList
                    {
                    pushFollow(FOLLOW_modifierList_in_booleanGroup225);
                    modifierList10=modifierList();
                    _fsp--;

                    adaptor.addChild(root_0, modifierList10.getTree());

                    }
                    break;

            }

             retval.value = b.value; 

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end booleanGroup

    public static class bool_return extends ParserRuleReturnScope {
        public String value;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start bool
    // Cql.g3:51:1: bool returns [String value] : ( 'and' | 'or' | 'not' | 'prox' );
    public final bool_return bool() throws RecognitionException {
        bool_return retval = new bool_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token string_literal11=null;
        Token string_literal12=null;
        Token string_literal13=null;
        Token string_literal14=null;

        CommonTree string_literal11_tree=null;
        CommonTree string_literal12_tree=null;
        CommonTree string_literal13_tree=null;
        CommonTree string_literal14_tree=null;

        try {
            // Cql.g3:52:2: ( 'and' | 'or' | 'not' | 'prox' )
            int alt5=4;
            switch ( input.LA(1) ) {
            case 10:
                {
                alt5=1;
                }
                break;
            case 11:
                {
                alt5=2;
                }
                break;
            case 12:
                {
                alt5=3;
                }
                break;
            case 13:
                {
                alt5=4;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("51:1: bool returns [String value] : ( 'and' | 'or' | 'not' | 'prox' );", 5, 0, input);

                throw nvae;
            }

            switch (alt5) {
                case 1 :
                    // Cql.g3:52:4: 'and'
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    string_literal11=(Token)input.LT(1);
                    match(input,10,FOLLOW_10_in_bool242); 
                    string_literal11_tree = (CommonTree)adaptor.create(string_literal11);
                    adaptor.addChild(root_0, string_literal11_tree);

                     retval.value = "and"; 

                    }
                    break;
                case 2 :
                    // Cql.g3:53:4: 'or'
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    string_literal12=(Token)input.LT(1);
                    match(input,11,FOLLOW_11_in_bool249); 
                    string_literal12_tree = (CommonTree)adaptor.create(string_literal12);
                    adaptor.addChild(root_0, string_literal12_tree);

                     retval.value = "or"; 

                    }
                    break;
                case 3 :
                    // Cql.g3:54:4: 'not'
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    string_literal13=(Token)input.LT(1);
                    match(input,12,FOLLOW_12_in_bool256); 
                    string_literal13_tree = (CommonTree)adaptor.create(string_literal13);
                    adaptor.addChild(root_0, string_literal13_tree);

                     retval.value = "not"; 

                    }
                    break;
                case 4 :
                    // Cql.g3:55:4: 'prox'
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    string_literal14=(Token)input.LT(1);
                    match(input,13,FOLLOW_13_in_bool263); 
                    string_literal14_tree = (CommonTree)adaptor.create(string_literal14);
                    adaptor.addChild(root_0, string_literal14_tree);

                     retval.value = "prox"; 

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end bool

    public static class modifierList_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start modifierList
    // Cql.g3:57:1: modifierList : ( modifier )+ ;
    public final modifierList_return modifierList() throws RecognitionException {
        modifierList_return retval = new modifierList_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        modifier_return modifier15 = null;



        try {
            // Cql.g3:59:14: ( ( modifier )+ )
            // Cql.g3:59:16: ( modifier )+
            {
            root_0 = (CommonTree)adaptor.nil();

            // Cql.g3:59:16: ( modifier )+
            int cnt6=0;
            loop6:
            do {
                int alt6=2;
                int LA6_0 = input.LA(1);

                if ( (LA6_0==14) ) {
                    alt6=1;
                }


                switch (alt6) {
            	case 1 :
            	    // Cql.g3:59:17: modifier
            	    {
            	    pushFollow(FOLLOW_modifier_in_modifierList279);
            	    modifier15=modifier();
            	    _fsp--;

            	    adaptor.addChild(root_0, modifier15.getTree());

            	    }
            	    break;

            	default :
            	    if ( cnt6 >= 1 ) break loop6;
                        EarlyExitException eee =
                            new EarlyExitException(6, input);
                        throw eee;
                }
                cnt6++;
            } while (true);


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end modifierList

    public static class modifier_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start modifier
    // Cql.g3:60:1: modifier : ( '/' modifierName comparitorSymbol modifierValue | '/' modifierName );
    public final modifier_return modifier() throws RecognitionException {
        modifier_return retval = new modifier_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token char_literal16=null;
        Token char_literal20=null;
        modifierName_return modifierName17 = null;

        comparitorSymbol_return comparitorSymbol18 = null;

        modifierValue_return modifierValue19 = null;

        modifierName_return modifierName21 = null;


        CommonTree char_literal16_tree=null;
        CommonTree char_literal20_tree=null;

        try {
            // Cql.g3:60:11: ( '/' modifierName comparitorSymbol modifierValue | '/' modifierName )
            int alt7=2;
            int LA7_0 = input.LA(1);

            if ( (LA7_0==14) ) {
                switch ( input.LA(2) ) {
                case IDENTIFIER:
                    {
                    int LA7_2 = input.LA(3);

                    if ( ((LA7_2>=8 && LA7_2<=9)||(LA7_2>=17 && LA7_2<=20)) ) {
                        alt7=1;
                    }
                    else if ( ((LA7_2>=IDENTIFIER && LA7_2<=STRING)||(LA7_2>=10 && LA7_2<=15)) ) {
                        alt7=2;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("60:1: modifier : ( '/' modifierName comparitorSymbol modifierValue | '/' modifierName );", 7, 2, input);

                        throw nvae;
                    }
                    }
                    break;
                case STRING:
                    {
                    int LA7_3 = input.LA(3);

                    if ( ((LA7_3>=IDENTIFIER && LA7_3<=STRING)||(LA7_3>=10 && LA7_3<=15)) ) {
                        alt7=2;
                    }
                    else if ( ((LA7_3>=8 && LA7_3<=9)||(LA7_3>=17 && LA7_3<=20)) ) {
                        alt7=1;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("60:1: modifier : ( '/' modifierName comparitorSymbol modifierValue | '/' modifierName );", 7, 3, input);

                        throw nvae;
                    }
                    }
                    break;
                case 10:
                    {
                    int LA7_4 = input.LA(3);

                    if ( ((LA7_4>=IDENTIFIER && LA7_4<=STRING)||(LA7_4>=10 && LA7_4<=15)) ) {
                        alt7=2;
                    }
                    else if ( ((LA7_4>=8 && LA7_4<=9)||(LA7_4>=17 && LA7_4<=20)) ) {
                        alt7=1;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("60:1: modifier : ( '/' modifierName comparitorSymbol modifierValue | '/' modifierName );", 7, 4, input);

                        throw nvae;
                    }
                    }
                    break;
                case 11:
                    {
                    int LA7_5 = input.LA(3);

                    if ( ((LA7_5>=IDENTIFIER && LA7_5<=STRING)||(LA7_5>=10 && LA7_5<=15)) ) {
                        alt7=2;
                    }
                    else if ( ((LA7_5>=8 && LA7_5<=9)||(LA7_5>=17 && LA7_5<=20)) ) {
                        alt7=1;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("60:1: modifier : ( '/' modifierName comparitorSymbol modifierValue | '/' modifierName );", 7, 5, input);

                        throw nvae;
                    }
                    }
                    break;
                case 12:
                    {
                    int LA7_6 = input.LA(3);

                    if ( ((LA7_6>=IDENTIFIER && LA7_6<=STRING)||(LA7_6>=10 && LA7_6<=15)) ) {
                        alt7=2;
                    }
                    else if ( ((LA7_6>=8 && LA7_6<=9)||(LA7_6>=17 && LA7_6<=20)) ) {
                        alt7=1;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("60:1: modifier : ( '/' modifierName comparitorSymbol modifierValue | '/' modifierName );", 7, 6, input);

                        throw nvae;
                    }
                    }
                    break;
                case 13:
                    {
                    int LA7_7 = input.LA(3);

                    if ( ((LA7_7>=IDENTIFIER && LA7_7<=STRING)||(LA7_7>=10 && LA7_7<=15)) ) {
                        alt7=2;
                    }
                    else if ( ((LA7_7>=8 && LA7_7<=9)||(LA7_7>=17 && LA7_7<=20)) ) {
                        alt7=1;
                    }
                    else {
                        NoViableAltException nvae =
                            new NoViableAltException("60:1: modifier : ( '/' modifierName comparitorSymbol modifierValue | '/' modifierName );", 7, 7, input);

                        throw nvae;
                    }
                    }
                    break;
                default:
                    NoViableAltException nvae =
                        new NoViableAltException("60:1: modifier : ( '/' modifierName comparitorSymbol modifierValue | '/' modifierName );", 7, 1, input);

                    throw nvae;
                }

            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("60:1: modifier : ( '/' modifierName comparitorSymbol modifierValue | '/' modifierName );", 7, 0, input);

                throw nvae;
            }
            switch (alt7) {
                case 1 :
                    // Cql.g3:60:13: '/' modifierName comparitorSymbol modifierValue
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    char_literal16=(Token)input.LT(1);
                    match(input,14,FOLLOW_14_in_modifier290); 
                    char_literal16_tree = (CommonTree)adaptor.create(char_literal16);
                    adaptor.addChild(root_0, char_literal16_tree);

                    pushFollow(FOLLOW_modifierName_in_modifier292);
                    modifierName17=modifierName();
                    _fsp--;

                    adaptor.addChild(root_0, modifierName17.getTree());
                    pushFollow(FOLLOW_comparitorSymbol_in_modifier294);
                    comparitorSymbol18=comparitorSymbol();
                    _fsp--;

                    adaptor.addChild(root_0, comparitorSymbol18.getTree());
                    pushFollow(FOLLOW_modifierValue_in_modifier296);
                    modifierValue19=modifierValue();
                    _fsp--;

                    adaptor.addChild(root_0, modifierValue19.getTree());

                    }
                    break;
                case 2 :
                    // Cql.g3:61:9: '/' modifierName
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    char_literal20=(Token)input.LT(1);
                    match(input,14,FOLLOW_14_in_modifier306); 
                    char_literal20_tree = (CommonTree)adaptor.create(char_literal20);
                    adaptor.addChild(root_0, char_literal20_tree);

                    pushFollow(FOLLOW_modifierName_in_modifier308);
                    modifierName21=modifierName();
                    _fsp--;

                    adaptor.addChild(root_0, modifierName21.getTree());

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end modifier

    public static class modifierName_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start modifierName
    // Cql.g3:62:1: modifierName : term ;
    public final modifierName_return modifierName() throws RecognitionException {
        modifierName_return retval = new modifierName_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        term_return term22 = null;



        try {
            // Cql.g3:62:14: ( term )
            // Cql.g3:62:16: term
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_term_in_modifierName316);
            term22=term();
            _fsp--;

            adaptor.addChild(root_0, term22.getTree());

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end modifierName

    public static class modifierValue_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start modifierValue
    // Cql.g3:63:1: modifierValue : term ;
    public final modifierValue_return modifierValue() throws RecognitionException {
        modifierValue_return retval = new modifierValue_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        term_return term23 = null;



        try {
            // Cql.g3:63:15: ( term )
            // Cql.g3:63:17: term
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_term_in_modifierValue324);
            term23=term();
            _fsp--;

            adaptor.addChild(root_0, term23.getTree());

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end modifierValue

    public static class searchClause_return extends ParserRuleReturnScope {
        public CqlClause clause;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start searchClause
    // Cql.g3:64:1: searchClause returns [CqlClause clause] : ( '(' q= cqlquery ')' | i= index r= relation v= searchTerm | t= searchTerm );
    public final searchClause_return searchClause() throws RecognitionException {
        searchClause_return retval = new searchClause_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token char_literal24=null;
        Token char_literal25=null;
        cqlquery_return q = null;

        index_return i = null;

        relation_return r = null;

        searchTerm_return v = null;

        searchTerm_return t = null;


        CommonTree char_literal24_tree=null;
        CommonTree char_literal25_tree=null;

        try {
            // Cql.g3:68:6: ( '(' q= cqlquery ')' | i= index r= relation v= searchTerm | t= searchTerm )
            int alt8=3;
            switch ( input.LA(1) ) {
            case 15:
                {
                alt8=1;
                }
                break;
            case IDENTIFIER:
                {
                int LA8_2 = input.LA(2);

                if ( ((LA8_2>=IDENTIFIER && LA8_2<=STRING)||(LA8_2>=8 && LA8_2<=9)||(LA8_2>=17 && LA8_2<=20)) ) {
                    alt8=2;
                }
                else if ( (LA8_2==EOF||(LA8_2>=10 && LA8_2<=13)||LA8_2==16) ) {
                    alt8=3;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("64:1: searchClause returns [CqlClause clause] : ( '(' q= cqlquery ')' | i= index r= relation v= searchTerm | t= searchTerm );", 8, 2, input);

                    throw nvae;
                }
                }
                break;
            case STRING:
                {
                int LA8_3 = input.LA(2);

                if ( ((LA8_3>=IDENTIFIER && LA8_3<=STRING)||(LA8_3>=8 && LA8_3<=9)||(LA8_3>=17 && LA8_3<=20)) ) {
                    alt8=2;
                }
                else if ( (LA8_3==EOF||(LA8_3>=10 && LA8_3<=13)||LA8_3==16) ) {
                    alt8=3;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("64:1: searchClause returns [CqlClause clause] : ( '(' q= cqlquery ')' | i= index r= relation v= searchTerm | t= searchTerm );", 8, 3, input);

                    throw nvae;
                }
                }
                break;
            case 10:
                {
                int LA8_4 = input.LA(2);

                if ( (LA8_4==EOF||(LA8_4>=10 && LA8_4<=13)||LA8_4==16) ) {
                    alt8=3;
                }
                else if ( ((LA8_4>=IDENTIFIER && LA8_4<=STRING)||(LA8_4>=8 && LA8_4<=9)||(LA8_4>=17 && LA8_4<=20)) ) {
                    alt8=2;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("64:1: searchClause returns [CqlClause clause] : ( '(' q= cqlquery ')' | i= index r= relation v= searchTerm | t= searchTerm );", 8, 4, input);

                    throw nvae;
                }
                }
                break;
            case 11:
                {
                int LA8_5 = input.LA(2);

                if ( (LA8_5==EOF||(LA8_5>=10 && LA8_5<=13)||LA8_5==16) ) {
                    alt8=3;
                }
                else if ( ((LA8_5>=IDENTIFIER && LA8_5<=STRING)||(LA8_5>=8 && LA8_5<=9)||(LA8_5>=17 && LA8_5<=20)) ) {
                    alt8=2;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("64:1: searchClause returns [CqlClause clause] : ( '(' q= cqlquery ')' | i= index r= relation v= searchTerm | t= searchTerm );", 8, 5, input);

                    throw nvae;
                }
                }
                break;
            case 12:
                {
                int LA8_6 = input.LA(2);

                if ( (LA8_6==EOF||(LA8_6>=10 && LA8_6<=13)||LA8_6==16) ) {
                    alt8=3;
                }
                else if ( ((LA8_6>=IDENTIFIER && LA8_6<=STRING)||(LA8_6>=8 && LA8_6<=9)||(LA8_6>=17 && LA8_6<=20)) ) {
                    alt8=2;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("64:1: searchClause returns [CqlClause clause] : ( '(' q= cqlquery ')' | i= index r= relation v= searchTerm | t= searchTerm );", 8, 6, input);

                    throw nvae;
                }
                }
                break;
            case 13:
                {
                int LA8_7 = input.LA(2);

                if ( (LA8_7==EOF||(LA8_7>=10 && LA8_7<=13)||LA8_7==16) ) {
                    alt8=3;
                }
                else if ( ((LA8_7>=IDENTIFIER && LA8_7<=STRING)||(LA8_7>=8 && LA8_7<=9)||(LA8_7>=17 && LA8_7<=20)) ) {
                    alt8=2;
                }
                else {
                    NoViableAltException nvae =
                        new NoViableAltException("64:1: searchClause returns [CqlClause clause] : ( '(' q= cqlquery ')' | i= index r= relation v= searchTerm | t= searchTerm );", 8, 7, input);

                    throw nvae;
                }
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("64:1: searchClause returns [CqlClause clause] : ( '(' q= cqlquery ')' | i= index r= relation v= searchTerm | t= searchTerm );", 8, 0, input);

                throw nvae;
            }

            switch (alt8) {
                case 1 :
                    // Cql.g3:68:8: '(' q= cqlquery ')'
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    char_literal24=(Token)input.LT(1);
                    match(input,15,FOLLOW_15_in_searchClause345); 
                    pushFollow(FOLLOW_cqlquery_in_searchClause350);
                    q=cqlquery();
                    _fsp--;

                    adaptor.addChild(root_0, q.getTree());
                    char_literal25=(Token)input.LT(1);
                    match(input,16,FOLLOW_16_in_searchClause352); 
                     retval.clause = q.query.root; 

                    }
                    break;
                case 2 :
                    // Cql.g3:69:8: i= index r= relation v= searchTerm
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_index_in_searchClause366);
                    i=index();
                    _fsp--;

                    adaptor.addChild(root_0, i.getTree());
                    pushFollow(FOLLOW_relation_in_searchClause370);
                    r=relation();
                    _fsp--;

                    root_0 = (CommonTree)adaptor.becomeRoot(r.getTree(), root_0);
                    pushFollow(FOLLOW_searchTerm_in_searchClause375);
                    v=searchTerm();
                    _fsp--;

                    adaptor.addChild(root_0, v.getTree());
                     retval.clause = new CqlRelation(i.value, r.value, v.value); 

                    }
                    break;
                case 3 :
                    // Cql.g3:71:8: t= searchTerm
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_searchTerm_in_searchClause394);
                    t=searchTerm();
                    _fsp--;

                    adaptor.addChild(root_0, t.getTree());
                     retval.clause = new CqlTerm(t.value); 

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end searchClause

    public static class index_return extends ParserRuleReturnScope {
        public String value;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start index
    // Cql.g3:73:1: index returns [String value] : t= term ;
    public final index_return index() throws RecognitionException {
        index_return retval = new index_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        term_return t = null;



        try {
            // Cql.g3:73:31: (t= term )
            // Cql.g3:73:33: t= term
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_term_in_index412);
            t=term();
            _fsp--;

            adaptor.addChild(root_0, t.getTree());
             retval.value = t.value; 

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end index

    public static class relation_return extends ParserRuleReturnScope {
        public String value;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start relation
    // Cql.g3:75:1: relation returns [String value] : c= comparitor ( modifierList )? ;
    public final relation_return relation() throws RecognitionException {
        relation_return retval = new relation_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        comparitor_return c = null;

        modifierList_return modifierList26 = null;



        try {
            // Cql.g3:75:33: (c= comparitor ( modifierList )? )
            // Cql.g3:76:7: c= comparitor ( modifierList )?
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_comparitor_in_relation436);
            c=comparitor();
            _fsp--;

            adaptor.addChild(root_0, c.getTree());
             retval.value = c.value; 
            // Cql.g3:76:42: ( modifierList )?
            int alt9=2;
            int LA9_0 = input.LA(1);

            if ( (LA9_0==14) ) {
                alt9=1;
            }
            switch (alt9) {
                case 1 :
                    // Cql.g3:76:43: modifierList
                    {
                    pushFollow(FOLLOW_modifierList_in_relation441);
                    modifierList26=modifierList();
                    _fsp--;

                    adaptor.addChild(root_0, modifierList26.getTree());

                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end relation

    public static class comparitor_return extends ParserRuleReturnScope {
        public String value;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start comparitor
    // Cql.g3:77:1: comparitor returns [String value] : (s= comparitorSymbol | n= namedComparitor );
    public final comparitor_return comparitor() throws RecognitionException {
        comparitor_return retval = new comparitor_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        comparitorSymbol_return s = null;

        namedComparitor_return n = null;



        try {
            // Cql.g3:78:5: (s= comparitorSymbol | n= namedComparitor )
            int alt10=2;
            int LA10_0 = input.LA(1);

            if ( ((LA10_0>=8 && LA10_0<=9)||(LA10_0>=17 && LA10_0<=20)) ) {
                alt10=1;
            }
            else if ( ((LA10_0>=IDENTIFIER && LA10_0<=STRING)) ) {
                alt10=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("77:1: comparitor returns [String value] : (s= comparitorSymbol | n= namedComparitor );", 10, 0, input);

                throw nvae;
            }
            switch (alt10) {
                case 1 :
                    // Cql.g3:78:7: s= comparitorSymbol
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_comparitorSymbol_in_comparitor461);
                    s=comparitorSymbol();
                    _fsp--;

                    adaptor.addChild(root_0, s.getTree());
                     retval.value = s.value; 

                    }
                    break;
                case 2 :
                    // Cql.g3:79:7: n= namedComparitor
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_namedComparitor_in_comparitor473);
                    n=namedComparitor();
                    _fsp--;

                    adaptor.addChild(root_0, n.getTree());
                     retval.value = n.value; 

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end comparitor

    public static class comparitorSymbol_return extends ParserRuleReturnScope {
        public String value;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start comparitorSymbol
    // Cql.g3:80:1: comparitorSymbol returns [String value] : ( '=' | '>' | '<' | '>=' | '<=' | '<>' );
    public final comparitorSymbol_return comparitorSymbol() throws RecognitionException {
        comparitorSymbol_return retval = new comparitorSymbol_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token char_literal27=null;
        Token char_literal28=null;
        Token char_literal29=null;
        Token string_literal30=null;
        Token string_literal31=null;
        Token string_literal32=null;

        CommonTree char_literal27_tree=null;
        CommonTree char_literal28_tree=null;
        CommonTree char_literal29_tree=null;
        CommonTree string_literal30_tree=null;
        CommonTree string_literal31_tree=null;
        CommonTree string_literal32_tree=null;

        try {
            // Cql.g3:81:7: ( '=' | '>' | '<' | '>=' | '<=' | '<>' )
            int alt11=6;
            switch ( input.LA(1) ) {
            case 9:
                {
                alt11=1;
                }
                break;
            case 8:
                {
                alt11=2;
                }
                break;
            case 17:
                {
                alt11=3;
                }
                break;
            case 18:
                {
                alt11=4;
                }
                break;
            case 19:
                {
                alt11=5;
                }
                break;
            case 20:
                {
                alt11=6;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("80:1: comparitorSymbol returns [String value] : ( '=' | '>' | '<' | '>=' | '<=' | '<>' );", 11, 0, input);

                throw nvae;
            }

            switch (alt11) {
                case 1 :
                    // Cql.g3:81:9: '='
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    char_literal27=(Token)input.LT(1);
                    match(input,9,FOLLOW_9_in_comparitorSymbol493); 
                    char_literal27_tree = (CommonTree)adaptor.create(char_literal27);
                    adaptor.addChild(root_0, char_literal27_tree);

                     retval.value = "="; 

                    }
                    break;
                case 2 :
                    // Cql.g3:82:9: '>'
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    char_literal28=(Token)input.LT(1);
                    match(input,8,FOLLOW_8_in_comparitorSymbol505); 
                    char_literal28_tree = (CommonTree)adaptor.create(char_literal28);
                    adaptor.addChild(root_0, char_literal28_tree);

                     retval.value = ">"; 

                    }
                    break;
                case 3 :
                    // Cql.g3:83:9: '<'
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    char_literal29=(Token)input.LT(1);
                    match(input,17,FOLLOW_17_in_comparitorSymbol517); 
                    char_literal29_tree = (CommonTree)adaptor.create(char_literal29);
                    adaptor.addChild(root_0, char_literal29_tree);

                     retval.value = "<"; 

                    }
                    break;
                case 4 :
                    // Cql.g3:84:9: '>='
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    string_literal30=(Token)input.LT(1);
                    match(input,18,FOLLOW_18_in_comparitorSymbol529); 
                    string_literal30_tree = (CommonTree)adaptor.create(string_literal30);
                    adaptor.addChild(root_0, string_literal30_tree);

                     retval.value = ">="; 

                    }
                    break;
                case 5 :
                    // Cql.g3:85:9: '<='
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    string_literal31=(Token)input.LT(1);
                    match(input,19,FOLLOW_19_in_comparitorSymbol541); 
                    string_literal31_tree = (CommonTree)adaptor.create(string_literal31);
                    adaptor.addChild(root_0, string_literal31_tree);

                     retval.value = "<="; 

                    }
                    break;
                case 6 :
                    // Cql.g3:86:9: '<>'
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    string_literal32=(Token)input.LT(1);
                    match(input,20,FOLLOW_20_in_comparitorSymbol553); 
                    string_literal32_tree = (CommonTree)adaptor.create(string_literal32);
                    adaptor.addChild(root_0, string_literal32_tree);

                     retval.value = "<>"; 

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end comparitorSymbol

    public static class namedComparitor_return extends ParserRuleReturnScope {
        public String value;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start namedComparitor
    // Cql.g3:87:1: namedComparitor returns [String value] : i= identifier ;
    public final namedComparitor_return namedComparitor() throws RecognitionException {
        namedComparitor_return retval = new namedComparitor_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        identifier_return i = null;



        try {
            // Cql.g3:87:41: (i= identifier )
            // Cql.g3:88:7: i= identifier
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_identifier_in_namedComparitor576);
            i=identifier();
            _fsp--;

            adaptor.addChild(root_0, i.getTree());
             retval.value = i.value; 

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end namedComparitor

    public static class searchTerm_return extends ParserRuleReturnScope {
        public String value;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start searchTerm
    // Cql.g3:91:1: searchTerm returns [String value] : t= term ;
    public final searchTerm_return searchTerm() throws RecognitionException {
        searchTerm_return retval = new searchTerm_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        term_return t = null;



        try {
            // Cql.g3:91:36: (t= term )
            // Cql.g3:91:38: t= term
            {
            root_0 = (CommonTree)adaptor.nil();

            pushFollow(FOLLOW_term_in_searchTerm595);
            t=term();
            _fsp--;

            adaptor.addChild(root_0, t.getTree());
             retval.value = t.value; 

            }

            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end searchTerm

    public static class term_return extends ParserRuleReturnScope {
        public String value;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start term
    // Cql.g3:93:1: term returns [String value] : (i= identifier | 'and' | 'or' | 'not' | 'prox' );
    public final term_return term() throws RecognitionException {
        term_return retval = new term_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token string_literal33=null;
        Token string_literal34=null;
        Token string_literal35=null;
        Token string_literal36=null;
        identifier_return i = null;


        CommonTree string_literal33_tree=null;
        CommonTree string_literal34_tree=null;
        CommonTree string_literal35_tree=null;
        CommonTree string_literal36_tree=null;

        try {
            // Cql.g3:93:30: (i= identifier | 'and' | 'or' | 'not' | 'prox' )
            int alt12=5;
            switch ( input.LA(1) ) {
            case IDENTIFIER:
            case STRING:
                {
                alt12=1;
                }
                break;
            case 10:
                {
                alt12=2;
                }
                break;
            case 11:
                {
                alt12=3;
                }
                break;
            case 12:
                {
                alt12=4;
                }
                break;
            case 13:
                {
                alt12=5;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("93:1: term returns [String value] : (i= identifier | 'and' | 'or' | 'not' | 'prox' );", 12, 0, input);

                throw nvae;
            }

            switch (alt12) {
                case 1 :
                    // Cql.g3:94:5: i= identifier
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    pushFollow(FOLLOW_identifier_in_term617);
                    i=identifier();
                    _fsp--;

                    adaptor.addChild(root_0, i.getTree());
                     retval.value = i.value; 

                    }
                    break;
                case 2 :
                    // Cql.g3:95:7: 'and'
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    string_literal33=(Token)input.LT(1);
                    match(input,10,FOLLOW_10_in_term627); 
                    string_literal33_tree = (CommonTree)adaptor.create(string_literal33);
                    adaptor.addChild(root_0, string_literal33_tree);

                     retval.value = "and"; 

                    }
                    break;
                case 3 :
                    // Cql.g3:96:7: 'or'
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    string_literal34=(Token)input.LT(1);
                    match(input,11,FOLLOW_11_in_term637); 
                    string_literal34_tree = (CommonTree)adaptor.create(string_literal34);
                    adaptor.addChild(root_0, string_literal34_tree);

                     retval.value = "or"; 

                    }
                    break;
                case 4 :
                    // Cql.g3:97:7: 'not'
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    string_literal35=(Token)input.LT(1);
                    match(input,12,FOLLOW_12_in_term647); 
                    string_literal35_tree = (CommonTree)adaptor.create(string_literal35);
                    adaptor.addChild(root_0, string_literal35_tree);

                     retval.value = "not"; 

                    }
                    break;
                case 5 :
                    // Cql.g3:98:7: 'prox'
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    string_literal36=(Token)input.LT(1);
                    match(input,13,FOLLOW_13_in_term657); 
                    string_literal36_tree = (CommonTree)adaptor.create(string_literal36);
                    adaptor.addChild(root_0, string_literal36_tree);

                     retval.value = "prox"; 

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end term

    public static class identifier_return extends ParserRuleReturnScope {
        public String value;
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start identifier
    // Cql.g3:99:1: identifier returns [String value] : ( IDENTIFIER | STRING );
    public final identifier_return identifier() throws RecognitionException {
        identifier_return retval = new identifier_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token IDENTIFIER37=null;
        Token STRING38=null;

        CommonTree IDENTIFIER37_tree=null;
        CommonTree STRING38_tree=null;

        try {
            // Cql.g3:99:35: ( IDENTIFIER | STRING )
            int alt13=2;
            int LA13_0 = input.LA(1);

            if ( (LA13_0==IDENTIFIER) ) {
                alt13=1;
            }
            else if ( (LA13_0==STRING) ) {
                alt13=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("99:1: identifier returns [String value] : ( IDENTIFIER | STRING );", 13, 0, input);

                throw nvae;
            }
            switch (alt13) {
                case 1 :
                    // Cql.g3:100:5: IDENTIFIER
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    IDENTIFIER37=(Token)input.LT(1);
                    match(input,IDENTIFIER,FOLLOW_IDENTIFIER_in_identifier675); 
                    IDENTIFIER37_tree = (CommonTree)adaptor.create(IDENTIFIER37);
                    adaptor.addChild(root_0, IDENTIFIER37_tree);

                     retval.value = IDENTIFIER37.getText(); 

                    }
                    break;
                case 2 :
                    // Cql.g3:101:7: STRING
                    {
                    root_0 = (CommonTree)adaptor.nil();

                    STRING38=(Token)input.LT(1);
                    match(input,STRING,FOLLOW_STRING_in_identifier685); 
                    STRING38_tree = (CommonTree)adaptor.create(STRING38);
                    adaptor.addChild(root_0, STRING38_tree);

                     retval.value = STRING38.getText(); 

                    }
                    break;

            }
            retval.stop = input.LT(-1);

                retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
                adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end identifier


 

    public static final BitSet FOLLOW_cqlquery_in_cql70 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_qscope_in_cqlquery96 = new BitSet(new long[]{0x000000000000BD30L});
    public static final BitSet FOLLOW_cqlquery_in_cqlquery101 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_scopedClause_in_cqlquery113 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_8_in_qscope129 = new BitSet(new long[]{0x0000000000003C30L});
    public static final BitSet FOLLOW_prefix_in_qscope131 = new BitSet(new long[]{0x0000000000000200L});
    public static final BitSet FOLLOW_9_in_qscope133 = new BitSet(new long[]{0x0000000000003C30L});
    public static final BitSet FOLLOW_uri_in_qscope135 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_8_in_qscope139 = new BitSet(new long[]{0x0000000000003C30L});
    public static final BitSet FOLLOW_uri_in_qscope141 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_term_in_prefix150 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_term_in_uri160 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_searchClause_in_scopedClause180 = new BitSet(new long[]{0x0000000000003C02L});
    public static final BitSet FOLLOW_booleanGroup_in_scopedClause189 = new BitSet(new long[]{0x000000000000BC30L});
    public static final BitSet FOLLOW_searchClause_in_scopedClause194 = new BitSet(new long[]{0x0000000000003C02L});
    public static final BitSet FOLLOW_bool_in_booleanGroup222 = new BitSet(new long[]{0x0000000000004002L});
    public static final BitSet FOLLOW_modifierList_in_booleanGroup225 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_10_in_bool242 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_11_in_bool249 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_12_in_bool256 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_13_in_bool263 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_modifier_in_modifierList279 = new BitSet(new long[]{0x0000000000004002L});
    public static final BitSet FOLLOW_14_in_modifier290 = new BitSet(new long[]{0x0000000000003C30L});
    public static final BitSet FOLLOW_modifierName_in_modifier292 = new BitSet(new long[]{0x00000000001E0300L});
    public static final BitSet FOLLOW_comparitorSymbol_in_modifier294 = new BitSet(new long[]{0x0000000000003C30L});
    public static final BitSet FOLLOW_modifierValue_in_modifier296 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_14_in_modifier306 = new BitSet(new long[]{0x0000000000003C30L});
    public static final BitSet FOLLOW_modifierName_in_modifier308 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_term_in_modifierName316 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_term_in_modifierValue324 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_15_in_searchClause345 = new BitSet(new long[]{0x000000000000BD30L});
    public static final BitSet FOLLOW_cqlquery_in_searchClause350 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_16_in_searchClause352 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_index_in_searchClause366 = new BitSet(new long[]{0x00000000001E0330L});
    public static final BitSet FOLLOW_relation_in_searchClause370 = new BitSet(new long[]{0x0000000000003C30L});
    public static final BitSet FOLLOW_searchTerm_in_searchClause375 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_searchTerm_in_searchClause394 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_term_in_index412 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_comparitor_in_relation436 = new BitSet(new long[]{0x0000000000004002L});
    public static final BitSet FOLLOW_modifierList_in_relation441 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_comparitorSymbol_in_comparitor461 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_namedComparitor_in_comparitor473 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_9_in_comparitorSymbol493 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_8_in_comparitorSymbol505 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_17_in_comparitorSymbol517 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_18_in_comparitorSymbol529 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_19_in_comparitorSymbol541 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_20_in_comparitorSymbol553 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_identifier_in_namedComparitor576 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_term_in_searchTerm595 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_identifier_in_term617 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_10_in_term627 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_11_in_term637 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_12_in_term647 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_13_in_term657 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_IDENTIFIER_in_identifier675 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_STRING_in_identifier685 = new BitSet(new long[]{0x0000000000000002L});

}