/** \file
 *  This C source file was generated by $ANTLR version 3.2 debian-5
 *
 *     -  From the grammar source file : RSP.g
 *     -                            On : 2011-09-11 16:17:22
 *     -                for the parser : RSPParserParser *
 * Editing it, at least manually, is not wise. 
 *
 * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
 *
 *
*/
// [The "BSD licence"]
// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
// http://www.temporal-wave.com
// http://www.linkedin.com/in/jimidle
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
//    derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/* -----------------------------------------
 * Include the ANTLR3 generated header file.
 */
#include    "RSPParser.h"
/* ----------------------------------------- */





/* MACROS that hide the C interface implementations from the
 * generated code, which makes it a little more understandable to the human eye.
 * I am very much against using C pre-processor macros for function calls and bits
 * of code as you cannot see what is happening when single stepping in debuggers
 * and so on. The exception (in my book at least) is for generated code, where you are
 * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
 * hides some indirect calls, but is always referring to the input stream. This is
 * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
 * the runtime interfaces without changing the generated code too often, without
 * confusing the reader of the generated output, who may not wish to know the gory
 * details of the interface inheritance.
 */
 
#define		CTX	ctx

/* Aids in accessing scopes for grammar programmers
 */
#undef	SCOPE_TYPE
#undef	SCOPE_STACK
#undef	SCOPE_TOP
#define	SCOPE_TYPE(scope)   pRSPParser_##scope##_SCOPE
#define SCOPE_STACK(scope)  pRSPParser_##scope##Stack
#define	SCOPE_TOP(scope)    ctx->pRSPParser_##scope##Top
#define	SCOPE_SIZE(scope)		ctx->pRSPParser_##scope##Stack_limit
#define SCOPE_INSTANCE(scope, i)	(ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))

/* Macros for accessing things in the parser
 */
 
#undef	    PARSER		    
#undef	    RECOGNIZER		    
#undef	    HAVEPARSEDRULE
#undef		MEMOIZE
#undef	    INPUT
#undef	    STRSTREAM
#undef	    HASEXCEPTION
#undef	    EXCEPTION
#undef	    MATCHT
#undef	    MATCHANYT
#undef	    FOLLOWSTACK
#undef	    FOLLOWPUSH
#undef	    FOLLOWPOP
#undef	    PRECOVER
#undef	    PREPORTERROR
#undef	    LA
#undef	    LT
#undef	    CONSTRUCTEX
#undef	    CONSUME
#undef	    MARK
#undef	    REWIND
#undef	    REWINDLAST
#undef	    PERRORRECOVERY
#undef	    HASFAILED
#undef	    FAILEDFLAG
#undef	    RECOVERFROMMISMATCHEDSET
#undef	    RECOVERFROMMISMATCHEDELEMENT
#undef		INDEX
#undef      ADAPTOR
#undef		SEEK
#undef	    RULEMEMO		    
#undef		DBG

#define	    PARSER							ctx->pParser  
#define	    RECOGNIZER						PARSER->rec
#define		PSRSTATE						RECOGNIZER->state
#define	    HAVEPARSEDRULE(r)				RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
#define		MEMOIZE(ri,si)					RECOGNIZER->memoize(RECOGNIZER, ri, si)
#define	    INPUT							PARSER->tstream
#define	    STRSTREAM						INPUT
#define		ISTREAM							INPUT->istream
#define		INDEX()							ISTREAM->index(INPUT->istream)
#define	    HASEXCEPTION()					(PSRSTATE->error == ANTLR3_TRUE)
#define	    EXCEPTION						PSRSTATE->exception
#define	    MATCHT(t, fs)					RECOGNIZER->match(RECOGNIZER, t, fs)
#define	    MATCHANYT()						RECOGNIZER->matchAny(RECOGNIZER)
#define	    FOLLOWSTACK					    PSRSTATE->following
#define	    FOLLOWPUSH(x)					FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL)
#define	    FOLLOWPOP()						FOLLOWSTACK->pop(FOLLOWSTACK)
#define	    PRECOVER()						RECOGNIZER->recover(RECOGNIZER)
#define	    PREPORTERROR()					RECOGNIZER->reportError(RECOGNIZER)
#define	    LA(n)							INPUT->istream->_LA(ISTREAM, n)
#define	    LT(n)							INPUT->_LT(INPUT, n)
#define	    CONSTRUCTEX()					RECOGNIZER->exConstruct(RECOGNIZER)
#define	    CONSUME()						ISTREAM->consume(ISTREAM)
#define	    MARK()							ISTREAM->mark(ISTREAM)
#define	    REWIND(m)						ISTREAM->rewind(ISTREAM, m)
#define	    REWINDLAST()					ISTREAM->rewindLast(ISTREAM)
#define		SEEK(n)							ISTREAM->seek(ISTREAM, n)
#define	    PERRORRECOVERY					PSRSTATE->errorRecovery
#define	    FAILEDFLAG						PSRSTATE->failed
#define	    HASFAILED()						(FAILEDFLAG == ANTLR3_TRUE)
#define	    BACKTRACKING					PSRSTATE->backtracking
#define	    RECOVERFROMMISMATCHEDSET(s)		RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s)
#define	    RECOVERFROMMISMATCHEDELEMENT(e)	RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s)
#define     ADAPTOR                         ctx->adaptor
#define		RULEMEMO						PSRSTATE->ruleMemo
#define		DBG								RECOGNIZER->debugger

#define		TOKTEXT(tok, txt)				tok, (pANTLR3_UINT8)txt

/* The 4 tokens defined below may well clash with your own #defines or token types. If so
 * then for the present you must use different names for your defines as these are hard coded
 * in the code generator. It would be better not to use such names internally, and maybe
 * we can change this in a forthcoming release. I deliberately do not #undef these
 * here as this will at least give you a redefined error somewhere if they clash.
 */
#define	    UP	    ANTLR3_TOKEN_UP
#define	    DOWN    ANTLR3_TOKEN_DOWN
#define	    EOR	    ANTLR3_TOKEN_EOR
#define	    INVALID ANTLR3_TOKEN_INVALID


/* =============================================================================
 * Functions to create and destroy scopes. First come the rule scopes, followed
 * by the global declared scopes.
 */



/* ============================================================================= */

/* =============================================================================
 * Start of recognizer
 */



/** \brief Table of all token names in symbolic order, mainly used for
 *         error reporting.
 */
pANTLR3_UINT8   RSPParserTokenNames[30+4]
     = {
        (pANTLR3_UINT8) "<invalid>",       /* String to print to indicate an invalid token */
        (pANTLR3_UINT8) "<EOR>",
        (pANTLR3_UINT8) "<DOWN>", 
        (pANTLR3_UINT8) "<UP>", 
        (pANTLR3_UINT8) "NEWLINE",
        (pANTLR3_UINT8) "OR",
        (pANTLR3_UINT8) "AND",
        (pANTLR3_UINT8) "LPAR",
        (pANTLR3_UINT8) "RPAR",
        (pANTLR3_UINT8) "FIELD",
        (pANTLR3_UINT8) "STR",
        (pANTLR3_UINT8) "NOT",
        (pANTLR3_UINT8) "EQUAL",
        (pANTLR3_UINT8) "INCLUDES",
        (pANTLR3_UINT8) "STARTSW",
        (pANTLR3_UINT8) "ENDSW",
        (pANTLR3_UINT8) "INT",
        (pANTLR3_UINT8) "LESS",
        (pANTLR3_UINT8) "GREATER",
        (pANTLR3_UINT8) "LTE",
        (pANTLR3_UINT8) "GTE",
        (pANTLR3_UINT8) "BEFORE",
        (pANTLR3_UINT8) "AFTER",
        (pANTLR3_UINT8) "DATE",
        (pANTLR3_UINT8) "TODAY",
        (pANTLR3_UINT8) "DAY",
        (pANTLR3_UINT8) "WEEK",
        (pANTLR3_UINT8) "MONTH",
        (pANTLR3_UINT8) "YEAR",
        (pANTLR3_UINT8) "QUOTE",
        (pANTLR3_UINT8) "WS",
        (pANTLR3_UINT8) "DIGIT19",
        (pANTLR3_UINT8) "DIGIT09",
        (pANTLR3_UINT8) "ESCAPED"
       };

        

// Forward declare the locally static matching functions we have generated.
//
static RSPParser_query_return	query    (pRSPParser ctx);
static RSPParser_expr_return	expr    (pRSPParser ctx);
static RSPParser_aexpr_return	aexpr    (pRSPParser ctx);
static RSPParser_crit_return	crit    (pRSPParser ctx);
static RSPParser_strcrit_return	strcrit    (pRSPParser ctx);
static RSPParser_strop_return	strop    (pRSPParser ctx);
static RSPParser_intcrit_return	intcrit    (pRSPParser ctx);
static RSPParser_intop_return	intop    (pRSPParser ctx);
static RSPParser_datecrit_return	datecrit    (pRSPParser ctx);
static RSPParser_dateop_return	dateop    (pRSPParser ctx);
static RSPParser_datespec_return	datespec    (pRSPParser ctx);
static RSPParser_dateref_return	dateref    (pRSPParser ctx);
static RSPParser_dateintval_return	dateintval    (pRSPParser ctx);
static void	RSPParserFree(pRSPParser ctx);
/* For use in tree output where we are accumulating rule labels via label += ruleRef
 * we need a function that knows how to free a return scope when the list is destroyed. 
 * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro.
 */
static	void ANTLR3_CDECL freeScope(void * scope)
{
    ANTLR3_FREE(scope);
}

/** \brief Name of the grammar file that generated this code
 */
static const char fileName[] = "RSP.g";

/** \brief Return the name of the grammar file that generated this code.
 */
static const char * getGrammarFileName()
{
	return fileName;
}
/** \brief Create a new RSPParser parser and return a context for it.
 *
 * \param[in] instream Pointer to an input stream interface.
 *
 * \return Pointer to new parser context upon success.
 */
ANTLR3_API pRSPParser
RSPParserNew   (pANTLR3_COMMON_TOKEN_STREAM instream)
{
	// See if we can create a new parser with the standard constructor
	//
	return RSPParserNewSSD(instream, NULL);
}

/** \brief Create a new RSPParser parser and return a context for it.
 *
 * \param[in] instream Pointer to an input stream interface.
 *
 * \return Pointer to new parser context upon success.
 */
ANTLR3_API pRSPParser
RSPParserNewSSD   (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
{
    pRSPParser ctx;	    /* Context structure we will build and return   */
    
    ctx	= (pRSPParser) ANTLR3_CALLOC(1, sizeof(RSPParser));
    
    if	(ctx == NULL)
    {
		// Failed to allocate memory for parser context
		//
        return  NULL;
    }
    
    /* -------------------------------------------------------------------
     * Memory for basic structure is allocated, now to fill in
     * the base ANTLR3 structures. We initialize the function pointers
     * for the standard ANTLR3 parser function set, but upon return
     * from here, the programmer may set the pointers to provide custom
     * implementations of each function. 
     *
     * We don't use the macros defined in RSPParser.h here, in order that you can get a sense
     * of what goes where.
     */

    /* Create a base parser/recognizer, using the supplied token stream
     */
    ctx->pParser	    = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state);
    /* Install the implementation of our RSPParser interface
     */
    ctx->query	= query;
    ctx->expr	= expr;
    ctx->aexpr	= aexpr;
    ctx->crit	= crit;
    ctx->strcrit	= strcrit;
    ctx->strop	= strop;
    ctx->intcrit	= intcrit;
    ctx->intop	= intop;
    ctx->datecrit	= datecrit;
    ctx->dateop	= dateop;
    ctx->datespec	= datespec;
    ctx->dateref	= dateref;
    ctx->dateintval	= dateintval;
    ctx->free			= RSPParserFree;
    ctx->getGrammarFileName	= getGrammarFileName;
    
    /* Install the scope pushing methods.
     */
    ADAPTOR	= ANTLR3_TREE_ADAPTORNew(instream->tstream->tokenSource->strFactory);
    ctx->vectors	= antlr3VectorFactoryNew(0);
    

	
    /* Install the token table
     */
    PSRSTATE->tokenNames   = RSPParserTokenNames;
    
    
    /* Return the newly built parser to the caller
     */
    return  ctx;
}

/** Free the parser resources
 */
 static void
 RSPParserFree(pRSPParser ctx)
 {
    /* Free any scope memory
     */
    
    ctx->vectors->close(ctx->vectors);
    /* We created the adaptor so we must free it
     */
    ADAPTOR->free(ADAPTOR);
	// Free this parser
	//
    ctx->pParser->free(ctx->pParser);
    ANTLR3_FREE(ctx);

    /* Everything is released, so we can return
     */
    return;
 }
 
/** Return token names used by this parser
 *
 * The returned pointer is used as an index into the token names table (using the token 
 * number as the index).
 * 
 * \return Pointer to first char * in the table.
 */
static pANTLR3_UINT8    *getTokenNames() 
{
        return RSPParserTokenNames; 
}

    
/* Declare the bitsets
 */

/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query42  */
static	ANTLR3_BITWORD FOLLOW_expr_in_query42_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000010) };
static  ANTLR3_BITSET_LIST FOLLOW_expr_in_query42	= { FOLLOW_expr_in_query42_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_NEWLINE_in_query44  */
static	ANTLR3_BITWORD FOLLOW_NEWLINE_in_query44_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000000) };
static  ANTLR3_BITSET_LIST FOLLOW_NEWLINE_in_query44	= { FOLLOW_NEWLINE_in_query44_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_EOF_in_query47  */
static	ANTLR3_BITWORD FOLLOW_EOF_in_query47_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_EOF_in_query47	= { FOLLOW_EOF_in_query47_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr63  */
static	ANTLR3_BITWORD FOLLOW_aexpr_in_expr63_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000022) };
static  ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr63	= { FOLLOW_aexpr_in_expr63_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_OR_in_expr66  */
static	ANTLR3_BITWORD FOLLOW_OR_in_expr66_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000280) };
static  ANTLR3_BITSET_LIST FOLLOW_OR_in_expr66	= { FOLLOW_OR_in_expr66_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr69  */
static	ANTLR3_BITWORD FOLLOW_aexpr_in_expr69_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000022) };
static  ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr69	= { FOLLOW_aexpr_in_expr69_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr81  */
static	ANTLR3_BITWORD FOLLOW_crit_in_aexpr81_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000042) };
static  ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr81	= { FOLLOW_crit_in_aexpr81_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_AND_in_aexpr84  */
static	ANTLR3_BITWORD FOLLOW_AND_in_aexpr84_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000280) };
static  ANTLR3_BITSET_LIST FOLLOW_AND_in_aexpr84	= { FOLLOW_AND_in_aexpr84_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr87  */
static	ANTLR3_BITWORD FOLLOW_crit_in_aexpr87_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000042) };
static  ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr87	= { FOLLOW_crit_in_aexpr87_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_LPAR_in_crit99  */
static	ANTLR3_BITWORD FOLLOW_LPAR_in_crit99_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000280) };
static  ANTLR3_BITSET_LIST FOLLOW_LPAR_in_crit99	= { FOLLOW_LPAR_in_crit99_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_crit101  */
static	ANTLR3_BITWORD FOLLOW_expr_in_crit101_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000100) };
static  ANTLR3_BITSET_LIST FOLLOW_expr_in_crit101	= { FOLLOW_expr_in_crit101_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_RPAR_in_crit103  */
static	ANTLR3_BITWORD FOLLOW_RPAR_in_crit103_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_RPAR_in_crit103	= { FOLLOW_RPAR_in_crit103_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_strcrit_in_crit114  */
static	ANTLR3_BITWORD FOLLOW_strcrit_in_crit114_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_strcrit_in_crit114	= { FOLLOW_strcrit_in_crit114_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_intcrit_in_crit119  */
static	ANTLR3_BITWORD FOLLOW_intcrit_in_crit119_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_intcrit_in_crit119	= { FOLLOW_intcrit_in_crit119_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_datecrit_in_crit124  */
static	ANTLR3_BITWORD FOLLOW_datecrit_in_crit124_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_datecrit_in_crit124	= { FOLLOW_datecrit_in_crit124_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit134  */
static	ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit134_bits[]	= { ANTLR3_UINT64_LIT(0x000000000000F000) };
static  ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit134	= { FOLLOW_FIELD_in_strcrit134_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit136  */
static	ANTLR3_BITWORD FOLLOW_strop_in_strcrit136_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000400) };
static  ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit136	= { FOLLOW_strop_in_strcrit136_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit138  */
static	ANTLR3_BITWORD FOLLOW_STR_in_strcrit138_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit138	= { FOLLOW_STR_in_strcrit138_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit155  */
static	ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit155_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000800) };
static  ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit155	= { FOLLOW_FIELD_in_strcrit155_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_strcrit157  */
static	ANTLR3_BITWORD FOLLOW_NOT_in_strcrit157_bits[]	= { ANTLR3_UINT64_LIT(0x000000000000F000) };
static  ANTLR3_BITSET_LIST FOLLOW_NOT_in_strcrit157	= { FOLLOW_NOT_in_strcrit157_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit159  */
static	ANTLR3_BITWORD FOLLOW_strop_in_strcrit159_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000400) };
static  ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit159	= { FOLLOW_strop_in_strcrit159_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit161  */
static	ANTLR3_BITWORD FOLLOW_STR_in_strcrit161_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit161	= { FOLLOW_STR_in_strcrit161_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_strop0  */
static	ANTLR3_BITWORD FOLLOW_set_in_strop0_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_set_in_strop0	= { FOLLOW_set_in_strop0_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit211  */
static	ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit211_bits[]	= { ANTLR3_UINT64_LIT(0x00000000001E1000) };
static  ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit211	= { FOLLOW_FIELD_in_intcrit211_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit213  */
static	ANTLR3_BITWORD FOLLOW_intop_in_intcrit213_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000010000) };
static  ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit213	= { FOLLOW_intop_in_intcrit213_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit215  */
static	ANTLR3_BITWORD FOLLOW_INT_in_intcrit215_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit215	= { FOLLOW_INT_in_intcrit215_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit232  */
static	ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit232_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000800) };
static  ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit232	= { FOLLOW_FIELD_in_intcrit232_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_intcrit234  */
static	ANTLR3_BITWORD FOLLOW_NOT_in_intcrit234_bits[]	= { ANTLR3_UINT64_LIT(0x00000000001E1000) };
static  ANTLR3_BITSET_LIST FOLLOW_NOT_in_intcrit234	= { FOLLOW_NOT_in_intcrit234_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit236  */
static	ANTLR3_BITWORD FOLLOW_intop_in_intcrit236_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000010000) };
static  ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit236	= { FOLLOW_intop_in_intcrit236_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit238  */
static	ANTLR3_BITWORD FOLLOW_INT_in_intcrit238_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit238	= { FOLLOW_INT_in_intcrit238_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_intop0  */
static	ANTLR3_BITWORD FOLLOW_set_in_intop0_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_set_in_intop0	= { FOLLOW_set_in_intop0_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_datecrit292  */
static	ANTLR3_BITWORD FOLLOW_FIELD_in_datecrit292_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000600000) };
static  ANTLR3_BITSET_LIST FOLLOW_FIELD_in_datecrit292	= { FOLLOW_FIELD_in_datecrit292_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datecrit294  */
static	ANTLR3_BITWORD FOLLOW_dateop_in_datecrit294_bits[]	= { ANTLR3_UINT64_LIT(0x0000000001810000) };
static  ANTLR3_BITSET_LIST FOLLOW_dateop_in_datecrit294	= { FOLLOW_dateop_in_datecrit294_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_datespec_in_datecrit296  */
static	ANTLR3_BITWORD FOLLOW_datespec_in_datecrit296_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_datespec_in_datecrit296	= { FOLLOW_datespec_in_datecrit296_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_dateop0  */
static	ANTLR3_BITWORD FOLLOW_set_in_dateop0_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_set_in_dateop0	= { FOLLOW_set_in_dateop0_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec331  */
static	ANTLR3_BITWORD FOLLOW_dateref_in_datespec331_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec331	= { FOLLOW_dateref_in_datespec331_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_datespec336  */
static	ANTLR3_BITWORD FOLLOW_INT_in_datespec336_bits[]	= { ANTLR3_UINT64_LIT(0x000000001E000000) };
static  ANTLR3_BITSET_LIST FOLLOW_INT_in_datespec336	= { FOLLOW_INT_in_datespec336_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateintval_in_datespec338  */
static	ANTLR3_BITWORD FOLLOW_dateintval_in_datespec338_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000600000) };
static  ANTLR3_BITSET_LIST FOLLOW_dateintval_in_datespec338	= { FOLLOW_dateintval_in_datespec338_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datespec340  */
static	ANTLR3_BITWORD FOLLOW_dateop_in_datespec340_bits[]	= { ANTLR3_UINT64_LIT(0x0000000001800000) };
static  ANTLR3_BITSET_LIST FOLLOW_dateop_in_datespec340	= { FOLLOW_dateop_in_datespec340_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec342  */
static	ANTLR3_BITWORD FOLLOW_dateref_in_datespec342_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec342	= { FOLLOW_dateref_in_datespec342_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_dateref0  */
static	ANTLR3_BITWORD FOLLOW_set_in_dateref0_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_set_in_dateref0	= { FOLLOW_set_in_dateref0_bits, 1	};
/** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_dateintval0  */
static	ANTLR3_BITWORD FOLLOW_set_in_dateintval0_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
static  ANTLR3_BITSET_LIST FOLLOW_set_in_dateintval0	= { FOLLOW_set_in_dateintval0_bits, 1	};
     

 
 
/* ==============================================
 * Parsing rules
 */
/** 
 * $ANTLR start query
 * RSP.g:27:1: query : expr ( NEWLINE )? EOF -> expr ;
 */
static RSPParser_query_return
query(pRSPParser ctx)
{   
    RSPParser_query_return retval;

    pANTLR3_BASE_TREE root_0;

    pANTLR3_COMMON_TOKEN    NEWLINE2;
    pANTLR3_COMMON_TOKEN    EOF3;
    RSPParser_expr_return expr1;
    #undef	RETURN_TYPE_expr1
    #define	RETURN_TYPE_expr1 RSPParser_expr_return

    pANTLR3_BASE_TREE NEWLINE2_tree;
    pANTLR3_BASE_TREE EOF3_tree;
    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NEWLINE;
    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_EOF;
    pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr;
    /* Initialize rule variables
     */


    root_0 = NULL;

    NEWLINE2       = NULL;
    EOF3       = NULL;
    expr1.tree = NULL;

    retval.start = LT(1); retval.stop = retval.start;

    NEWLINE2_tree   = NULL;
    EOF3_tree   = NULL;

    stream_NEWLINE   = NULL;
    #define CREATE_stream_NEWLINE  if (stream_NEWLINE == NULL) {stream_NEWLINE = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NEWLINE"); } 
    stream_EOF   = NULL;
    #define CREATE_stream_EOF  if (stream_EOF == NULL) {stream_EOF = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token EOF"); } 
    stream_expr   = NULL;
    #define CREATE_stream_expr  if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); }

    retval.tree  = NULL;
    {
        // RSP.g:27:7: ( expr ( NEWLINE )? EOF -> expr )
        // RSP.g:27:9: expr ( NEWLINE )? EOF
        {
            FOLLOWPUSH(FOLLOW_expr_in_query42);
            expr1=expr(ctx);

            FOLLOWPOP();
            if  (HASEXCEPTION())
            {
                goto rulequeryEx;
            }

            CREATE_stream_expr; stream_expr->add(stream_expr, expr1.tree, NULL);

            // RSP.g:27:14: ( NEWLINE )?
            {
                int alt1=2;
                switch ( LA(1) ) 
                {
                    case NEWLINE:
                    	{
                    		alt1=1;
                    	}
                        break;
                }

                switch (alt1) 
                {
            	case 1:
            	    // RSP.g:27:14: NEWLINE
            	    {
            	        NEWLINE2 = (pANTLR3_COMMON_TOKEN) MATCHT(NEWLINE, &FOLLOW_NEWLINE_in_query44); 
            	        if  (HASEXCEPTION())
            	        {
            	            goto rulequeryEx;
            	        }
            	         
            	        CREATE_stream_NEWLINE; stream_NEWLINE->add(stream_NEWLINE, NEWLINE2, NULL);


            	    }
            	    break;

                }
            }
            EOF3 = (pANTLR3_COMMON_TOKEN) MATCHT(EOF, &FOLLOW_EOF_in_query47); 
            if  (HASEXCEPTION())
            {
                goto rulequeryEx;
            }
             
            CREATE_stream_EOF; stream_EOF->add(stream_EOF, EOF3, NULL);


             
            /* AST REWRITE
             * elements          : expr
             * token labels      : 
             * rule labels       : retval
             * token list labels : 
             * rule list labels  : 
             */
            {
            	pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;

            	stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR,  RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);

            	root_0			    = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
            	retval.tree    = root_0;
            	// 27:28: -> expr
            	{
            	    ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr));

            	}

            	retval.tree = root_0; // set result root
            	if (stream_retval != NULL) stream_retval->free(stream_retval);


            }
        }

    }
    

    // This is where rules clean up and exit
    //
    goto rulequeryEx; /* Prevent compiler warnings */
    rulequeryEx: ;
    retval.stop = LT(-1);

    	retval.stop = LT(-1);
    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
        if (stream_NEWLINE != NULL) stream_NEWLINE->free(stream_NEWLINE);
        if (stream_EOF != NULL) stream_EOF->free(stream_EOF);
        if (stream_expr != NULL) stream_expr->free(stream_expr);

            if (HASEXCEPTION())
            {
                PREPORTERROR();
                PRECOVER();
                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
            }


    return retval;
}
/* $ANTLR end query */

/** 
 * $ANTLR start expr
 * RSP.g:30:1: expr : aexpr ( OR aexpr )* ;
 */
static RSPParser_expr_return
expr(pRSPParser ctx)
{   
    RSPParser_expr_return retval;

    pANTLR3_BASE_TREE root_0;

    pANTLR3_COMMON_TOKEN    OR5;
    RSPParser_aexpr_return aexpr4;
    #undef	RETURN_TYPE_aexpr4
    #define	RETURN_TYPE_aexpr4 RSPParser_aexpr_return

    RSPParser_aexpr_return aexpr6;
    #undef	RETURN_TYPE_aexpr6
    #define	RETURN_TYPE_aexpr6 RSPParser_aexpr_return

    pANTLR3_BASE_TREE OR5_tree;

    /* Initialize rule variables
     */


    root_0 = NULL;

    OR5       = NULL;
    aexpr4.tree = NULL;

    aexpr6.tree = NULL;

    retval.start = LT(1); retval.stop = retval.start;

    OR5_tree   = NULL;


    retval.tree  = NULL;
    {
        // RSP.g:30:6: ( aexpr ( OR aexpr )* )
        // RSP.g:30:8: aexpr ( OR aexpr )*
        {
            root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));

            FOLLOWPUSH(FOLLOW_aexpr_in_expr63);
            aexpr4=aexpr(ctx);

            FOLLOWPOP();
            if  (HASEXCEPTION())
            {
                goto ruleexprEx;
            }

            ADAPTOR->addChild(ADAPTOR, root_0, aexpr4.tree);

            // RSP.g:30:14: ( OR aexpr )*

            for (;;)
            {
                int alt2=2;
                switch ( LA(1) ) 
                {
                case OR:
                	{
                		alt2=1;
                	}
                    break;

                }

                switch (alt2) 
                {
            	case 1:
            	    // RSP.g:30:15: OR aexpr
            	    {
            	        OR5 = (pANTLR3_COMMON_TOKEN) MATCHT(OR, &FOLLOW_OR_in_expr66); 
            	        if  (HASEXCEPTION())
            	        {
            	            goto ruleexprEx;
            	        }

            	        OR5_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OR5));
            	        root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OR5_tree, root_0));

            	        FOLLOWPUSH(FOLLOW_aexpr_in_expr69);
            	        aexpr6=aexpr(ctx);

            	        FOLLOWPOP();
            	        if  (HASEXCEPTION())
            	        {
            	            goto ruleexprEx;
            	        }

            	        ADAPTOR->addChild(ADAPTOR, root_0, aexpr6.tree);

            	    }
            	    break;

            	default:
            	    goto loop2;	/* break out of the loop */
            	    break;
                }
            }
            loop2: ; /* Jump out to here if this rule does not match */


        }

    }
    

    // This is where rules clean up and exit
    //
    goto ruleexprEx; /* Prevent compiler warnings */
    ruleexprEx: ;
    retval.stop = LT(-1);

    	retval.stop = LT(-1);
    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);

            if (HASEXCEPTION())
            {
                PREPORTERROR();
                PRECOVER();
                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
            }


    return retval;
}
/* $ANTLR end expr */

/** 
 * $ANTLR start aexpr
 * RSP.g:33:1: aexpr : crit ( AND crit )* ;
 */
static RSPParser_aexpr_return
aexpr(pRSPParser ctx)
{   
    RSPParser_aexpr_return retval;

    pANTLR3_BASE_TREE root_0;

    pANTLR3_COMMON_TOKEN    AND8;
    RSPParser_crit_return crit7;
    #undef	RETURN_TYPE_crit7
    #define	RETURN_TYPE_crit7 RSPParser_crit_return

    RSPParser_crit_return crit9;
    #undef	RETURN_TYPE_crit9
    #define	RETURN_TYPE_crit9 RSPParser_crit_return

    pANTLR3_BASE_TREE AND8_tree;

    /* Initialize rule variables
     */


    root_0 = NULL;

    AND8       = NULL;
    crit7.tree = NULL;

    crit9.tree = NULL;

    retval.start = LT(1); retval.stop = retval.start;

    AND8_tree   = NULL;


    retval.tree  = NULL;
    {
        // RSP.g:33:7: ( crit ( AND crit )* )
        // RSP.g:33:9: crit ( AND crit )*
        {
            root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));

            FOLLOWPUSH(FOLLOW_crit_in_aexpr81);
            crit7=crit(ctx);

            FOLLOWPOP();
            if  (HASEXCEPTION())
            {
                goto ruleaexprEx;
            }

            ADAPTOR->addChild(ADAPTOR, root_0, crit7.tree);

            // RSP.g:33:14: ( AND crit )*

            for (;;)
            {
                int alt3=2;
                switch ( LA(1) ) 
                {
                case AND:
                	{
                		alt3=1;
                	}
                    break;

                }

                switch (alt3) 
                {
            	case 1:
            	    // RSP.g:33:15: AND crit
            	    {
            	        AND8 = (pANTLR3_COMMON_TOKEN) MATCHT(AND, &FOLLOW_AND_in_aexpr84); 
            	        if  (HASEXCEPTION())
            	        {
            	            goto ruleaexprEx;
            	        }

            	        AND8_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, AND8));
            	        root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, AND8_tree, root_0));

            	        FOLLOWPUSH(FOLLOW_crit_in_aexpr87);
            	        crit9=crit(ctx);

            	        FOLLOWPOP();
            	        if  (HASEXCEPTION())
            	        {
            	            goto ruleaexprEx;
            	        }

            	        ADAPTOR->addChild(ADAPTOR, root_0, crit9.tree);

            	    }
            	    break;

            	default:
            	    goto loop3;	/* break out of the loop */
            	    break;
                }
            }
            loop3: ; /* Jump out to here if this rule does not match */


        }

    }
    

    // This is where rules clean up and exit
    //
    goto ruleaexprEx; /* Prevent compiler warnings */
    ruleaexprEx: ;
    retval.stop = LT(-1);

    	retval.stop = LT(-1);
    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);

            if (HASEXCEPTION())
            {
                PREPORTERROR();
                PRECOVER();
                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
            }


    return retval;
}
/* $ANTLR end aexpr */

/** 
 * $ANTLR start crit
 * RSP.g:36:1: crit : ( LPAR expr RPAR -> expr | strcrit | intcrit | datecrit );
 */
static RSPParser_crit_return
crit(pRSPParser ctx)
{   
    RSPParser_crit_return retval;

    pANTLR3_BASE_TREE root_0;

    pANTLR3_COMMON_TOKEN    LPAR10;
    pANTLR3_COMMON_TOKEN    RPAR12;
    RSPParser_expr_return expr11;
    #undef	RETURN_TYPE_expr11
    #define	RETURN_TYPE_expr11 RSPParser_expr_return

    RSPParser_strcrit_return strcrit13;
    #undef	RETURN_TYPE_strcrit13
    #define	RETURN_TYPE_strcrit13 RSPParser_strcrit_return

    RSPParser_intcrit_return intcrit14;
    #undef	RETURN_TYPE_intcrit14
    #define	RETURN_TYPE_intcrit14 RSPParser_intcrit_return

    RSPParser_datecrit_return datecrit15;
    #undef	RETURN_TYPE_datecrit15
    #define	RETURN_TYPE_datecrit15 RSPParser_datecrit_return

    pANTLR3_BASE_TREE LPAR10_tree;
    pANTLR3_BASE_TREE RPAR12_tree;
    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_RPAR;
    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_LPAR;
    pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr;
    /* Initialize rule variables
     */


    root_0 = NULL;

    LPAR10       = NULL;
    RPAR12       = NULL;
    expr11.tree = NULL;

    strcrit13.tree = NULL;

    intcrit14.tree = NULL;

    datecrit15.tree = NULL;

    retval.start = LT(1); retval.stop = retval.start;

    LPAR10_tree   = NULL;
    RPAR12_tree   = NULL;

    stream_RPAR   = NULL;
    #define CREATE_stream_RPAR  if (stream_RPAR == NULL) {stream_RPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token RPAR"); } 
    stream_LPAR   = NULL;
    #define CREATE_stream_LPAR  if (stream_LPAR == NULL) {stream_LPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token LPAR"); } 
    stream_expr   = NULL;
    #define CREATE_stream_expr  if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); }

    retval.tree  = NULL;
    {
        {
            //  RSP.g:36:6: ( LPAR expr RPAR -> expr | strcrit | intcrit | datecrit )
            
            ANTLR3_UINT32 alt4;

            alt4=4;

            switch ( LA(1) ) 
            {
            case LPAR:
            	{
            		alt4=1;
            	}
                break;
            case FIELD:
            	{
            		switch ( LA(2) ) 
            		{
            		case NOT:
            			{
            				switch ( LA(3) ) 
            				{
            				case EQUAL:
            					{
            						switch ( LA(4) ) 
            						{
            						case STR:
            							{
            								alt4=2;
            							}
            						    break;
            						case INT:
            							{
            								alt4=3;
            							}
            						    break;

            						default:
            						    CONSTRUCTEX();
            						    EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
            						    EXCEPTION->message      = (void *)"";
            						    EXCEPTION->decisionNum  = 4;
            						    EXCEPTION->state        = 8;


            						    goto rulecritEx;
            						}

            					}
            				    break;
            				case INCLUDES:
            				case STARTSW:
            				case ENDSW:
            					{
            						alt4=2;
            					}
            				    break;
            				case LESS:
            				case GREATER:
            				case LTE:
            				case GTE:
            					{
            						alt4=3;
            					}
            				    break;

            				default:
            				    CONSTRUCTEX();
            				    EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
            				    EXCEPTION->message      = (void *)"";
            				    EXCEPTION->decisionNum  = 4;
            				    EXCEPTION->state        = 3;


            				    goto rulecritEx;
            				}

            			}
            		    break;
            		case EQUAL:
            			{
            				switch ( LA(3) ) 
            				{
            				case INT:
            					{
            						alt4=3;
            					}
            				    break;
            				case STR:
            					{
            						alt4=2;
            					}
            				    break;

            				default:
            				    CONSTRUCTEX();
            				    EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
            				    EXCEPTION->message      = (void *)"";
            				    EXCEPTION->decisionNum  = 4;
            				    EXCEPTION->state        = 4;


            				    goto rulecritEx;
            				}

            			}
            		    break;
            		case BEFORE:
            		case AFTER:
            			{
            				alt4=4;
            			}
            		    break;
            		case LESS:
            		case GREATER:
            		case LTE:
            		case GTE:
            			{
            				alt4=3;
            			}
            		    break;
            		case INCLUDES:
            		case STARTSW:
            		case ENDSW:
            			{
            				alt4=2;
            			}
            		    break;

            		default:
            		    CONSTRUCTEX();
            		    EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
            		    EXCEPTION->message      = (void *)"";
            		    EXCEPTION->decisionNum  = 4;
            		    EXCEPTION->state        = 2;


            		    goto rulecritEx;
            		}

            	}
                break;

            default:
                CONSTRUCTEX();
                EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
                EXCEPTION->message      = (void *)"";
                EXCEPTION->decisionNum  = 4;
                EXCEPTION->state        = 0;


                goto rulecritEx;
            }

            switch (alt4) 
            {
        	case 1:
        	    // RSP.g:36:8: LPAR expr RPAR
        	    {
        	        LPAR10 = (pANTLR3_COMMON_TOKEN) MATCHT(LPAR, &FOLLOW_LPAR_in_crit99); 
        	        if  (HASEXCEPTION())
        	        {
        	            goto rulecritEx;
        	        }
        	         
        	        CREATE_stream_LPAR; stream_LPAR->add(stream_LPAR, LPAR10, NULL);

        	        FOLLOWPUSH(FOLLOW_expr_in_crit101);
        	        expr11=expr(ctx);

        	        FOLLOWPOP();
        	        if  (HASEXCEPTION())
        	        {
        	            goto rulecritEx;
        	        }

        	        CREATE_stream_expr; stream_expr->add(stream_expr, expr11.tree, NULL);
        	        RPAR12 = (pANTLR3_COMMON_TOKEN) MATCHT(RPAR, &FOLLOW_RPAR_in_crit103); 
        	        if  (HASEXCEPTION())
        	        {
        	            goto rulecritEx;
        	        }
        	         
        	        CREATE_stream_RPAR; stream_RPAR->add(stream_RPAR, RPAR12, NULL);


        	         
        	        /* AST REWRITE
        	         * elements          : expr
        	         * token labels      : 
        	         * rule labels       : retval
        	         * token list labels : 
        	         * rule list labels  : 
        	         */
        	        {
        	        	pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;

        	        	stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR,  RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);

        	        	root_0			    = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
        	        	retval.tree    = root_0;
        	        	// 36:25: -> expr
        	        	{
        	        	    ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr));

        	        	}

        	        	retval.tree = root_0; // set result root
        	        	if (stream_retval != NULL) stream_retval->free(stream_retval);


        	        }
        	    }
        	    break;
        	case 2:
        	    // RSP.g:37:4: strcrit
        	    {
        	        root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));

        	        FOLLOWPUSH(FOLLOW_strcrit_in_crit114);
        	        strcrit13=strcrit(ctx);

        	        FOLLOWPOP();
        	        if  (HASEXCEPTION())
        	        {
        	            goto rulecritEx;
        	        }

        	        ADAPTOR->addChild(ADAPTOR, root_0, strcrit13.tree);

        	    }
        	    break;
        	case 3:
        	    // RSP.g:38:4: intcrit
        	    {
        	        root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));

        	        FOLLOWPUSH(FOLLOW_intcrit_in_crit119);
        	        intcrit14=intcrit(ctx);

        	        FOLLOWPOP();
        	        if  (HASEXCEPTION())
        	        {
        	            goto rulecritEx;
        	        }

        	        ADAPTOR->addChild(ADAPTOR, root_0, intcrit14.tree);

        	    }
        	    break;
        	case 4:
        	    // RSP.g:39:4: datecrit
        	    {
        	        root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));

        	        FOLLOWPUSH(FOLLOW_datecrit_in_crit124);
        	        datecrit15=datecrit(ctx);

        	        FOLLOWPOP();
        	        if  (HASEXCEPTION())
        	        {
        	            goto rulecritEx;
        	        }

        	        ADAPTOR->addChild(ADAPTOR, root_0, datecrit15.tree);

        	    }
        	    break;

            }
        }
    }
    

    // This is where rules clean up and exit
    //
    goto rulecritEx; /* Prevent compiler warnings */
    rulecritEx: ;
    retval.stop = LT(-1);

    	retval.stop = LT(-1);
    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
        if (stream_RPAR != NULL) stream_RPAR->free(stream_RPAR);
        if (stream_LPAR != NULL) stream_LPAR->free(stream_LPAR);
        if (stream_expr != NULL) stream_expr->free(stream_expr);

            if (HASEXCEPTION())
            {
                PREPORTERROR();
                PRECOVER();
                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
            }


    return retval;
}
/* $ANTLR end crit */

/** 
 * $ANTLR start strcrit
 * RSP.g:42:1: strcrit : ( FIELD strop STR -> ^( strop FIELD STR ) | FIELD NOT strop STR -> ^( NOT ^( strop FIELD STR ) ) );
 */
static RSPParser_strcrit_return
strcrit(pRSPParser ctx)
{   
    RSPParser_strcrit_return retval;

    pANTLR3_BASE_TREE root_0;

    pANTLR3_COMMON_TOKEN    FIELD16;
    pANTLR3_COMMON_TOKEN    STR18;
    pANTLR3_COMMON_TOKEN    FIELD19;
    pANTLR3_COMMON_TOKEN    NOT20;
    pANTLR3_COMMON_TOKEN    STR22;
    RSPParser_strop_return strop17;
    #undef	RETURN_TYPE_strop17
    #define	RETURN_TYPE_strop17 RSPParser_strop_return

    RSPParser_strop_return strop21;
    #undef	RETURN_TYPE_strop21
    #define	RETURN_TYPE_strop21 RSPParser_strop_return

    pANTLR3_BASE_TREE FIELD16_tree;
    pANTLR3_BASE_TREE STR18_tree;
    pANTLR3_BASE_TREE FIELD19_tree;
    pANTLR3_BASE_TREE NOT20_tree;
    pANTLR3_BASE_TREE STR22_tree;
    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_STR;
    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD;
    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NOT;
    pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_strop;
    /* Initialize rule variables
     */


    root_0 = NULL;

    FIELD16       = NULL;
    STR18       = NULL;
    FIELD19       = NULL;
    NOT20       = NULL;
    STR22       = NULL;
    strop17.tree = NULL;

    strop21.tree = NULL;

    retval.start = LT(1); retval.stop = retval.start;

    FIELD16_tree   = NULL;
    STR18_tree   = NULL;
    FIELD19_tree   = NULL;
    NOT20_tree   = NULL;
    STR22_tree   = NULL;

    stream_STR   = NULL;
    #define CREATE_stream_STR  if (stream_STR == NULL) {stream_STR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token STR"); } 
    stream_FIELD   = NULL;
    #define CREATE_stream_FIELD  if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); } 
    stream_NOT   = NULL;
    #define CREATE_stream_NOT  if (stream_NOT == NULL) {stream_NOT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NOT"); } 
    stream_strop   = NULL;
    #define CREATE_stream_strop  if (stream_strop == NULL) {stream_strop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule strop"); }

    retval.tree  = NULL;
    {
        {
            //  RSP.g:42:9: ( FIELD strop STR -> ^( strop FIELD STR ) | FIELD NOT strop STR -> ^( NOT ^( strop FIELD STR ) ) )
            
            ANTLR3_UINT32 alt5;

            alt5=2;

            switch ( LA(1) ) 
            {
            case FIELD:
            	{
            		switch ( LA(2) ) 
            		{
            		case NOT:
            			{
            				alt5=2;
            			}
            		    break;
            		case EQUAL:
            		case INCLUDES:
            		case STARTSW:
            		case ENDSW:
            			{
            				alt5=1;
            			}
            		    break;

            		default:
            		    CONSTRUCTEX();
            		    EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
            		    EXCEPTION->message      = (void *)"";
            		    EXCEPTION->decisionNum  = 5;
            		    EXCEPTION->state        = 1;


            		    goto rulestrcritEx;
            		}

            	}
                break;

            default:
                CONSTRUCTEX();
                EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
                EXCEPTION->message      = (void *)"";
                EXCEPTION->decisionNum  = 5;
                EXCEPTION->state        = 0;


                goto rulestrcritEx;
            }

            switch (alt5) 
            {
        	case 1:
        	    // RSP.g:42:11: FIELD strop STR
        	    {
        	        FIELD16 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit134); 
        	        if  (HASEXCEPTION())
        	        {
        	            goto rulestrcritEx;
        	        }
        	         
        	        CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD16, NULL);

        	        FOLLOWPUSH(FOLLOW_strop_in_strcrit136);
        	        strop17=strop(ctx);

        	        FOLLOWPOP();
        	        if  (HASEXCEPTION())
        	        {
        	            goto rulestrcritEx;
        	        }

        	        CREATE_stream_strop; stream_strop->add(stream_strop, strop17.tree, NULL);
        	        STR18 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_strcrit138); 
        	        if  (HASEXCEPTION())
        	        {
        	            goto rulestrcritEx;
        	        }
        	         
        	        CREATE_stream_STR; stream_STR->add(stream_STR, STR18, NULL);


        	         
        	        /* AST REWRITE
        	         * elements          : strop, FIELD, STR
        	         * token labels      : 
        	         * rule labels       : retval
        	         * token list labels : 
        	         * rule list labels  : 
        	         */
        	        {
        	        	pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;

        	        	stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR,  RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);

        	        	root_0			    = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
        	        	retval.tree    = root_0;
        	        	// 42:29: -> ^( strop FIELD STR )
        	        	{
        	        	    // RSP.g:42:32: ^( strop FIELD STR )
        	        	    {
        	        	        pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
        	        	        root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_strop == NULL ? NULL : stream_strop->nextNode(stream_strop), root_1));

        	        	        ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
        	        	        ADAPTOR->addChild(ADAPTOR, root_1, stream_STR == NULL ? NULL : stream_STR->nextNode(stream_STR));

        	        	        ADAPTOR->addChild(ADAPTOR, root_0, root_1);
        	        	    }

        	        	}

        	        	retval.tree = root_0; // set result root
        	        	if (stream_retval != NULL) stream_retval->free(stream_retval);


        	        }
        	    }
        	    break;
        	case 2:
        	    // RSP.g:43:4: FIELD NOT strop STR
        	    {
        	        FIELD19 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit155); 
        	        if  (HASEXCEPTION())
        	        {
        	            goto rulestrcritEx;
        	        }
        	         
        	        CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD19, NULL);

        	        NOT20 = (pANTLR3_COMMON_TOKEN) MATCHT(NOT, &FOLLOW_NOT_in_strcrit157); 
        	        if  (HASEXCEPTION())
        	        {
        	            goto rulestrcritEx;
        	        }
        	         
        	        CREATE_stream_NOT; stream_NOT->add(stream_NOT, NOT20, NULL);

        	        FOLLOWPUSH(FOLLOW_strop_in_strcrit159);
        	        strop21=strop(ctx);

        	        FOLLOWPOP();
        	        if  (HASEXCEPTION())
        	        {
        	            goto rulestrcritEx;
        	        }

        	        CREATE_stream_strop; stream_strop->add(stream_strop, strop21.tree, NULL);
        	        STR22 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_strcrit161); 
        	        if  (HASEXCEPTION())
        	        {
        	            goto rulestrcritEx;
        	        }
        	         
        	        CREATE_stream_STR; stream_STR->add(stream_STR, STR22, NULL);


        	         
        	        /* AST REWRITE
        	         * elements          : STR, FIELD, NOT, strop
        	         * token labels      : 
        	         * rule labels       : retval
        	         * token list labels : 
        	         * rule list labels  : 
        	         */
        	        {
        	        	pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;

        	        	stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR,  RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);

        	        	root_0			    = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
        	        	retval.tree    = root_0;
        	        	// 43:25: -> ^( NOT ^( strop FIELD STR ) )
        	        	{
        	        	    // RSP.g:43:28: ^( NOT ^( strop FIELD STR ) )
        	        	    {
        	        	        pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
        	        	        root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_NOT == NULL ? NULL : stream_NOT->nextNode(stream_NOT), root_1));

        	        	        // RSP.g:43:34: ^( strop FIELD STR )
        	        	        {
        	        	            pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
        	        	            root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_strop == NULL ? NULL : stream_strop->nextNode(stream_strop), root_2));

        	        	            ADAPTOR->addChild(ADAPTOR, root_2, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
        	        	            ADAPTOR->addChild(ADAPTOR, root_2, stream_STR == NULL ? NULL : stream_STR->nextNode(stream_STR));

        	        	            ADAPTOR->addChild(ADAPTOR, root_1, root_2);
        	        	        }

        	        	        ADAPTOR->addChild(ADAPTOR, root_0, root_1);
        	        	    }

        	        	}

        	        	retval.tree = root_0; // set result root
        	        	if (stream_retval != NULL) stream_retval->free(stream_retval);


        	        }
        	    }
        	    break;

            }
        }
    }
    

    // This is where rules clean up and exit
    //
    goto rulestrcritEx; /* Prevent compiler warnings */
    rulestrcritEx: ;
    retval.stop = LT(-1);

    	retval.stop = LT(-1);
    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
        if (stream_STR != NULL) stream_STR->free(stream_STR);
        if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD);
        if (stream_NOT != NULL) stream_NOT->free(stream_NOT);
        if (stream_strop != NULL) stream_strop->free(stream_strop);

            if (HASEXCEPTION())
            {
                PREPORTERROR();
                PRECOVER();
                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
            }


    return retval;
}
/* $ANTLR end strcrit */

/** 
 * $ANTLR start strop
 * RSP.g:46:1: strop : ( EQUAL | INCLUDES | STARTSW | ENDSW );
 */
static RSPParser_strop_return
strop(pRSPParser ctx)
{   
    RSPParser_strop_return retval;

    pANTLR3_BASE_TREE root_0;

    pANTLR3_COMMON_TOKEN    set23;

    pANTLR3_BASE_TREE set23_tree;

    /* Initialize rule variables
     */


    root_0 = NULL;

    set23       = NULL;
    retval.start = LT(1); retval.stop = retval.start;

    set23_tree   = NULL;


    retval.tree  = NULL;
    {
        // RSP.g:46:7: ( EQUAL | INCLUDES | STARTSW | ENDSW )
        // RSP.g:
        {
            root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));

            set23=(pANTLR3_COMMON_TOKEN)LT(1);
            if ( ((LA(1) >= EQUAL) && (LA(1) <= ENDSW)) )
            {
                CONSUME();
                ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set23)));
                PERRORRECOVERY=ANTLR3_FALSE;
            }
            else 
            {
                CONSTRUCTEX();
                EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;
                EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;
                EXCEPTION->expectingSet = &FOLLOW_set_in_strop0;
                RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_strop0);    goto rulestropEx;
            }


        }

    }
    

    // This is where rules clean up and exit
    //
    goto rulestropEx; /* Prevent compiler warnings */
    rulestropEx: ;
    retval.stop = LT(-1);

    	retval.stop = LT(-1);
    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);

            if (HASEXCEPTION())
            {
                PREPORTERROR();
                PRECOVER();
                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
            }


    return retval;
}
/* $ANTLR end strop */

/** 
 * $ANTLR start intcrit
 * RSP.g:52:1: intcrit : ( FIELD intop INT -> ^( intop FIELD INT ) | FIELD NOT intop INT -> ^( NOT ^( intop FIELD INT ) ) );
 */
static RSPParser_intcrit_return
intcrit(pRSPParser ctx)
{   
    RSPParser_intcrit_return retval;

    pANTLR3_BASE_TREE root_0;

    pANTLR3_COMMON_TOKEN    FIELD24;
    pANTLR3_COMMON_TOKEN    INT26;
    pANTLR3_COMMON_TOKEN    FIELD27;
    pANTLR3_COMMON_TOKEN    NOT28;
    pANTLR3_COMMON_TOKEN    INT30;
    RSPParser_intop_return intop25;
    #undef	RETURN_TYPE_intop25
    #define	RETURN_TYPE_intop25 RSPParser_intop_return

    RSPParser_intop_return intop29;
    #undef	RETURN_TYPE_intop29
    #define	RETURN_TYPE_intop29 RSPParser_intop_return

    pANTLR3_BASE_TREE FIELD24_tree;
    pANTLR3_BASE_TREE INT26_tree;
    pANTLR3_BASE_TREE FIELD27_tree;
    pANTLR3_BASE_TREE NOT28_tree;
    pANTLR3_BASE_TREE INT30_tree;
    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD;
    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_INT;
    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NOT;
    pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_intop;
    /* Initialize rule variables
     */


    root_0 = NULL;

    FIELD24       = NULL;
    INT26       = NULL;
    FIELD27       = NULL;
    NOT28       = NULL;
    INT30       = NULL;
    intop25.tree = NULL;

    intop29.tree = NULL;

    retval.start = LT(1); retval.stop = retval.start;

    FIELD24_tree   = NULL;
    INT26_tree   = NULL;
    FIELD27_tree   = NULL;
    NOT28_tree   = NULL;
    INT30_tree   = NULL;

    stream_FIELD   = NULL;
    #define CREATE_stream_FIELD  if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); } 
    stream_INT   = NULL;
    #define CREATE_stream_INT  if (stream_INT == NULL) {stream_INT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token INT"); } 
    stream_NOT   = NULL;
    #define CREATE_stream_NOT  if (stream_NOT == NULL) {stream_NOT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NOT"); } 
    stream_intop   = NULL;
    #define CREATE_stream_intop  if (stream_intop == NULL) {stream_intop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule intop"); }

    retval.tree  = NULL;
    {
        {
            //  RSP.g:52:9: ( FIELD intop INT -> ^( intop FIELD INT ) | FIELD NOT intop INT -> ^( NOT ^( intop FIELD INT ) ) )
            
            ANTLR3_UINT32 alt6;

            alt6=2;

            switch ( LA(1) ) 
            {
            case FIELD:
            	{
            		switch ( LA(2) ) 
            		{
            		case NOT:
            			{
            				alt6=2;
            			}
            		    break;
            		case EQUAL:
            		case LESS:
            		case GREATER:
            		case LTE:
            		case GTE:
            			{
            				alt6=1;
            			}
            		    break;

            		default:
            		    CONSTRUCTEX();
            		    EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
            		    EXCEPTION->message      = (void *)"";
            		    EXCEPTION->decisionNum  = 6;
            		    EXCEPTION->state        = 1;


            		    goto ruleintcritEx;
            		}

            	}
                break;

            default:
                CONSTRUCTEX();
                EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
                EXCEPTION->message      = (void *)"";
                EXCEPTION->decisionNum  = 6;
                EXCEPTION->state        = 0;


                goto ruleintcritEx;
            }

            switch (alt6) 
            {
        	case 1:
        	    // RSP.g:52:11: FIELD intop INT
        	    {
        	        FIELD24 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit211); 
        	        if  (HASEXCEPTION())
        	        {
        	            goto ruleintcritEx;
        	        }
        	         
        	        CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD24, NULL);

        	        FOLLOWPUSH(FOLLOW_intop_in_intcrit213);
        	        intop25=intop(ctx);

        	        FOLLOWPOP();
        	        if  (HASEXCEPTION())
        	        {
        	            goto ruleintcritEx;
        	        }

        	        CREATE_stream_intop; stream_intop->add(stream_intop, intop25.tree, NULL);
        	        INT26 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_intcrit215); 
        	        if  (HASEXCEPTION())
        	        {
        	            goto ruleintcritEx;
        	        }
        	         
        	        CREATE_stream_INT; stream_INT->add(stream_INT, INT26, NULL);


        	         
        	        /* AST REWRITE
        	         * elements          : intop, INT, FIELD
        	         * token labels      : 
        	         * rule labels       : retval
        	         * token list labels : 
        	         * rule list labels  : 
        	         */
        	        {
        	        	pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;

        	        	stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR,  RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);

        	        	root_0			    = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
        	        	retval.tree    = root_0;
        	        	// 52:29: -> ^( intop FIELD INT )
        	        	{
        	        	    // RSP.g:52:32: ^( intop FIELD INT )
        	        	    {
        	        	        pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
        	        	        root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_intop == NULL ? NULL : stream_intop->nextNode(stream_intop), root_1));

        	        	        ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
        	        	        ADAPTOR->addChild(ADAPTOR, root_1, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT));

        	        	        ADAPTOR->addChild(ADAPTOR, root_0, root_1);
        	        	    }

        	        	}

        	        	retval.tree = root_0; // set result root
        	        	if (stream_retval != NULL) stream_retval->free(stream_retval);


        	        }
        	    }
        	    break;
        	case 2:
        	    // RSP.g:53:4: FIELD NOT intop INT
        	    {
        	        FIELD27 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit232); 
        	        if  (HASEXCEPTION())
        	        {
        	            goto ruleintcritEx;
        	        }
        	         
        	        CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD27, NULL);

        	        NOT28 = (pANTLR3_COMMON_TOKEN) MATCHT(NOT, &FOLLOW_NOT_in_intcrit234); 
        	        if  (HASEXCEPTION())
        	        {
        	            goto ruleintcritEx;
        	        }
        	         
        	        CREATE_stream_NOT; stream_NOT->add(stream_NOT, NOT28, NULL);

        	        FOLLOWPUSH(FOLLOW_intop_in_intcrit236);
        	        intop29=intop(ctx);

        	        FOLLOWPOP();
        	        if  (HASEXCEPTION())
        	        {
        	            goto ruleintcritEx;
        	        }

        	        CREATE_stream_intop; stream_intop->add(stream_intop, intop29.tree, NULL);
        	        INT30 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_intcrit238); 
        	        if  (HASEXCEPTION())
        	        {
        	            goto ruleintcritEx;
        	        }
        	         
        	        CREATE_stream_INT; stream_INT->add(stream_INT, INT30, NULL);


        	         
        	        /* AST REWRITE
        	         * elements          : intop, NOT, INT, FIELD
        	         * token labels      : 
        	         * rule labels       : retval
        	         * token list labels : 
        	         * rule list labels  : 
        	         */
        	        {
        	        	pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;

        	        	stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR,  RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);

        	        	root_0			    = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
        	        	retval.tree    = root_0;
        	        	// 53:25: -> ^( NOT ^( intop FIELD INT ) )
        	        	{
        	        	    // RSP.g:53:28: ^( NOT ^( intop FIELD INT ) )
        	        	    {
        	        	        pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
        	        	        root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_NOT == NULL ? NULL : stream_NOT->nextNode(stream_NOT), root_1));

        	        	        // RSP.g:53:34: ^( intop FIELD INT )
        	        	        {
        	        	            pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
        	        	            root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_intop == NULL ? NULL : stream_intop->nextNode(stream_intop), root_2));

        	        	            ADAPTOR->addChild(ADAPTOR, root_2, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
        	        	            ADAPTOR->addChild(ADAPTOR, root_2, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT));

        	        	            ADAPTOR->addChild(ADAPTOR, root_1, root_2);
        	        	        }

        	        	        ADAPTOR->addChild(ADAPTOR, root_0, root_1);
        	        	    }

        	        	}

        	        	retval.tree = root_0; // set result root
        	        	if (stream_retval != NULL) stream_retval->free(stream_retval);


        	        }
        	    }
        	    break;

            }
        }
    }
    

    // This is where rules clean up and exit
    //
    goto ruleintcritEx; /* Prevent compiler warnings */
    ruleintcritEx: ;
    retval.stop = LT(-1);

    	retval.stop = LT(-1);
    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
        if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD);
        if (stream_INT != NULL) stream_INT->free(stream_INT);
        if (stream_NOT != NULL) stream_NOT->free(stream_NOT);
        if (stream_intop != NULL) stream_intop->free(stream_intop);

            if (HASEXCEPTION())
            {
                PREPORTERROR();
                PRECOVER();
                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
            }


    return retval;
}
/* $ANTLR end intcrit */

/** 
 * $ANTLR start intop
 * RSP.g:56:1: intop : ( EQUAL | LESS | GREATER | LTE | GTE );
 */
static RSPParser_intop_return
intop(pRSPParser ctx)
{   
    RSPParser_intop_return retval;

    pANTLR3_BASE_TREE root_0;

    pANTLR3_COMMON_TOKEN    set31;

    pANTLR3_BASE_TREE set31_tree;

    /* Initialize rule variables
     */


    root_0 = NULL;

    set31       = NULL;
    retval.start = LT(1); retval.stop = retval.start;

    set31_tree   = NULL;


    retval.tree  = NULL;
    {
        // RSP.g:56:7: ( EQUAL | LESS | GREATER | LTE | GTE )
        // RSP.g:
        {
            root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));

            set31=(pANTLR3_COMMON_TOKEN)LT(1);
            if ( LA(1) == EQUAL || ((LA(1) >= LESS) && (LA(1) <= GTE)) )
            {
                CONSUME();
                ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set31)));
                PERRORRECOVERY=ANTLR3_FALSE;
            }
            else 
            {
                CONSTRUCTEX();
                EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;
                EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;
                EXCEPTION->expectingSet = &FOLLOW_set_in_intop0;
                RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_intop0);    goto ruleintopEx;
            }


        }

    }
    

    // This is where rules clean up and exit
    //
    goto ruleintopEx; /* Prevent compiler warnings */
    ruleintopEx: ;
    retval.stop = LT(-1);

    	retval.stop = LT(-1);
    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);

            if (HASEXCEPTION())
            {
                PREPORTERROR();
                PRECOVER();
                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
            }


    return retval;
}
/* $ANTLR end intop */

/** 
 * $ANTLR start datecrit
 * RSP.g:63:1: datecrit : FIELD dateop datespec -> ^( dateop FIELD datespec ) ;
 */
static RSPParser_datecrit_return
datecrit(pRSPParser ctx)
{   
    RSPParser_datecrit_return retval;

    pANTLR3_BASE_TREE root_0;

    pANTLR3_COMMON_TOKEN    FIELD32;
    RSPParser_dateop_return dateop33;
    #undef	RETURN_TYPE_dateop33
    #define	RETURN_TYPE_dateop33 RSPParser_dateop_return

    RSPParser_datespec_return datespec34;
    #undef	RETURN_TYPE_datespec34
    #define	RETURN_TYPE_datespec34 RSPParser_datespec_return

    pANTLR3_BASE_TREE FIELD32_tree;
    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD;
    pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_datespec;
    pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateop;
    /* Initialize rule variables
     */


    root_0 = NULL;

    FIELD32       = NULL;
    dateop33.tree = NULL;

    datespec34.tree = NULL;

    retval.start = LT(1); retval.stop = retval.start;

    FIELD32_tree   = NULL;

    stream_FIELD   = NULL;
    #define CREATE_stream_FIELD  if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); } 
    stream_datespec   = NULL;
    #define CREATE_stream_datespec  if (stream_datespec == NULL) {stream_datespec = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule datespec"); }
    stream_dateop   = NULL;
    #define CREATE_stream_dateop  if (stream_dateop == NULL) {stream_dateop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateop"); }

    retval.tree  = NULL;
    {
        // RSP.g:63:9: ( FIELD dateop datespec -> ^( dateop FIELD datespec ) )
        // RSP.g:63:11: FIELD dateop datespec
        {
            FIELD32 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_datecrit292); 
            if  (HASEXCEPTION())
            {
                goto ruledatecritEx;
            }
             
            CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD32, NULL);

            FOLLOWPUSH(FOLLOW_dateop_in_datecrit294);
            dateop33=dateop(ctx);

            FOLLOWPOP();
            if  (HASEXCEPTION())
            {
                goto ruledatecritEx;
            }

            CREATE_stream_dateop; stream_dateop->add(stream_dateop, dateop33.tree, NULL);
            FOLLOWPUSH(FOLLOW_datespec_in_datecrit296);
            datespec34=datespec(ctx);

            FOLLOWPOP();
            if  (HASEXCEPTION())
            {
                goto ruledatecritEx;
            }

            CREATE_stream_datespec; stream_datespec->add(stream_datespec, datespec34.tree, NULL);

             
            /* AST REWRITE
             * elements          : FIELD, datespec, dateop
             * token labels      : 
             * rule labels       : retval
             * token list labels : 
             * rule list labels  : 
             */
            {
            	pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;

            	stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR,  RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);

            	root_0			    = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
            	retval.tree    = root_0;
            	// 63:34: -> ^( dateop FIELD datespec )
            	{
            	    // RSP.g:63:37: ^( dateop FIELD datespec )
            	    {
            	        pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
            	        root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_dateop == NULL ? NULL : stream_dateop->nextNode(stream_dateop), root_1));

            	        ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD));
            	        ADAPTOR->addChild(ADAPTOR, root_1, stream_datespec == NULL ? NULL : stream_datespec->nextTree(stream_datespec));

            	        ADAPTOR->addChild(ADAPTOR, root_0, root_1);
            	    }

            	}

            	retval.tree = root_0; // set result root
            	if (stream_retval != NULL) stream_retval->free(stream_retval);


            }
        }

    }
    

    // This is where rules clean up and exit
    //
    goto ruledatecritEx; /* Prevent compiler warnings */
    ruledatecritEx: ;
    retval.stop = LT(-1);

    	retval.stop = LT(-1);
    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
        if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD);
        if (stream_datespec != NULL) stream_datespec->free(stream_datespec);
        if (stream_dateop != NULL) stream_dateop->free(stream_dateop);

            if (HASEXCEPTION())
            {
                PREPORTERROR();
                PRECOVER();
                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
            }


    return retval;
}
/* $ANTLR end datecrit */

/** 
 * $ANTLR start dateop
 * RSP.g:66:1: dateop : ( BEFORE | AFTER );
 */
static RSPParser_dateop_return
dateop(pRSPParser ctx)
{   
    RSPParser_dateop_return retval;

    pANTLR3_BASE_TREE root_0;

    pANTLR3_COMMON_TOKEN    set35;

    pANTLR3_BASE_TREE set35_tree;

    /* Initialize rule variables
     */


    root_0 = NULL;

    set35       = NULL;
    retval.start = LT(1); retval.stop = retval.start;

    set35_tree   = NULL;


    retval.tree  = NULL;
    {
        // RSP.g:66:8: ( BEFORE | AFTER )
        // RSP.g:
        {
            root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));

            set35=(pANTLR3_COMMON_TOKEN)LT(1);
            if ( ((LA(1) >= BEFORE) && (LA(1) <= AFTER)) )
            {
                CONSUME();
                ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set35)));
                PERRORRECOVERY=ANTLR3_FALSE;
            }
            else 
            {
                CONSTRUCTEX();
                EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;
                EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;
                EXCEPTION->expectingSet = &FOLLOW_set_in_dateop0;
                RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_dateop0);    goto ruledateopEx;
            }


        }

    }
    

    // This is where rules clean up and exit
    //
    goto ruledateopEx; /* Prevent compiler warnings */
    ruledateopEx: ;
    retval.stop = LT(-1);

    	retval.stop = LT(-1);
    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);

            if (HASEXCEPTION())
            {
                PREPORTERROR();
                PRECOVER();
                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
            }


    return retval;
}
/* $ANTLR end dateop */

/** 
 * $ANTLR start datespec
 * RSP.g:70:1: datespec : ( dateref | INT dateintval dateop dateref -> ^( dateop dateref INT dateintval ) );
 */
static RSPParser_datespec_return
datespec(pRSPParser ctx)
{   
    RSPParser_datespec_return retval;

    pANTLR3_BASE_TREE root_0;

    pANTLR3_COMMON_TOKEN    INT37;
    RSPParser_dateref_return dateref36;
    #undef	RETURN_TYPE_dateref36
    #define	RETURN_TYPE_dateref36 RSPParser_dateref_return

    RSPParser_dateintval_return dateintval38;
    #undef	RETURN_TYPE_dateintval38
    #define	RETURN_TYPE_dateintval38 RSPParser_dateintval_return

    RSPParser_dateop_return dateop39;
    #undef	RETURN_TYPE_dateop39
    #define	RETURN_TYPE_dateop39 RSPParser_dateop_return

    RSPParser_dateref_return dateref40;
    #undef	RETURN_TYPE_dateref40
    #define	RETURN_TYPE_dateref40 RSPParser_dateref_return

    pANTLR3_BASE_TREE INT37_tree;
    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_INT;
    pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateintval;
    pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateref;
    pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateop;
    /* Initialize rule variables
     */


    root_0 = NULL;

    INT37       = NULL;
    dateref36.tree = NULL;

    dateintval38.tree = NULL;

    dateop39.tree = NULL;

    dateref40.tree = NULL;

    retval.start = LT(1); retval.stop = retval.start;

    INT37_tree   = NULL;

    stream_INT   = NULL;
    #define CREATE_stream_INT  if (stream_INT == NULL) {stream_INT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token INT"); } 
    stream_dateintval   = NULL;
    #define CREATE_stream_dateintval  if (stream_dateintval == NULL) {stream_dateintval = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateintval"); }
    stream_dateref   = NULL;
    #define CREATE_stream_dateref  if (stream_dateref == NULL) {stream_dateref = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateref"); }
    stream_dateop   = NULL;
    #define CREATE_stream_dateop  if (stream_dateop == NULL) {stream_dateop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateop"); }

    retval.tree  = NULL;
    {
        {
            //  RSP.g:70:9: ( dateref | INT dateintval dateop dateref -> ^( dateop dateref INT dateintval ) )
            
            ANTLR3_UINT32 alt7;

            alt7=2;

            switch ( LA(1) ) 
            {
            case DATE:
            case TODAY:
            	{
            		alt7=1;
            	}
                break;
            case INT:
            	{
            		alt7=2;
            	}
                break;

            default:
                CONSTRUCTEX();
                EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
                EXCEPTION->message      = (void *)"";
                EXCEPTION->decisionNum  = 7;
                EXCEPTION->state        = 0;


                goto ruledatespecEx;
            }

            switch (alt7) 
            {
        	case 1:
        	    // RSP.g:70:11: dateref
        	    {
        	        root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));

        	        FOLLOWPUSH(FOLLOW_dateref_in_datespec331);
        	        dateref36=dateref(ctx);

        	        FOLLOWPOP();
        	        if  (HASEXCEPTION())
        	        {
        	            goto ruledatespecEx;
        	        }

        	        ADAPTOR->addChild(ADAPTOR, root_0, dateref36.tree);

        	    }
        	    break;
        	case 2:
        	    // RSP.g:71:4: INT dateintval dateop dateref
        	    {
        	        INT37 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_datespec336); 
        	        if  (HASEXCEPTION())
        	        {
        	            goto ruledatespecEx;
        	        }
        	         
        	        CREATE_stream_INT; stream_INT->add(stream_INT, INT37, NULL);

        	        FOLLOWPUSH(FOLLOW_dateintval_in_datespec338);
        	        dateintval38=dateintval(ctx);

        	        FOLLOWPOP();
        	        if  (HASEXCEPTION())
        	        {
        	            goto ruledatespecEx;
        	        }

        	        CREATE_stream_dateintval; stream_dateintval->add(stream_dateintval, dateintval38.tree, NULL);
        	        FOLLOWPUSH(FOLLOW_dateop_in_datespec340);
        	        dateop39=dateop(ctx);

        	        FOLLOWPOP();
        	        if  (HASEXCEPTION())
        	        {
        	            goto ruledatespecEx;
        	        }

        	        CREATE_stream_dateop; stream_dateop->add(stream_dateop, dateop39.tree, NULL);
        	        FOLLOWPUSH(FOLLOW_dateref_in_datespec342);
        	        dateref40=dateref(ctx);

        	        FOLLOWPOP();
        	        if  (HASEXCEPTION())
        	        {
        	            goto ruledatespecEx;
        	        }

        	        CREATE_stream_dateref; stream_dateref->add(stream_dateref, dateref40.tree, NULL);

        	         
        	        /* AST REWRITE
        	         * elements          : dateintval, dateref, dateop, INT
        	         * token labels      : 
        	         * rule labels       : retval
        	         * token list labels : 
        	         * rule list labels  : 
        	         */
        	        {
        	        	pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;

        	        	stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR,  RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);

        	        	root_0			    = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
        	        	retval.tree    = root_0;
        	        	// 71:34: -> ^( dateop dateref INT dateintval )
        	        	{
        	        	    // RSP.g:71:37: ^( dateop dateref INT dateintval )
        	        	    {
        	        	        pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
        	        	        root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_dateop == NULL ? NULL : stream_dateop->nextNode(stream_dateop), root_1));

        	        	        ADAPTOR->addChild(ADAPTOR, root_1, stream_dateref == NULL ? NULL : stream_dateref->nextTree(stream_dateref));
        	        	        ADAPTOR->addChild(ADAPTOR, root_1, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT));
        	        	        ADAPTOR->addChild(ADAPTOR, root_1, stream_dateintval == NULL ? NULL : stream_dateintval->nextTree(stream_dateintval));

        	        	        ADAPTOR->addChild(ADAPTOR, root_0, root_1);
        	        	    }

        	        	}

        	        	retval.tree = root_0; // set result root
        	        	if (stream_retval != NULL) stream_retval->free(stream_retval);


        	        }
        	    }
        	    break;

            }
        }
    }
    

    // This is where rules clean up and exit
    //
    goto ruledatespecEx; /* Prevent compiler warnings */
    ruledatespecEx: ;
    retval.stop = LT(-1);

    	retval.stop = LT(-1);
    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
        if (stream_INT != NULL) stream_INT->free(stream_INT);
        if (stream_dateintval != NULL) stream_dateintval->free(stream_dateintval);
        if (stream_dateref != NULL) stream_dateref->free(stream_dateref);
        if (stream_dateop != NULL) stream_dateop->free(stream_dateop);

            if (HASEXCEPTION())
            {
                PREPORTERROR();
                PRECOVER();
                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
            }


    return retval;
}
/* $ANTLR end datespec */

/** 
 * $ANTLR start dateref
 * RSP.g:74:1: dateref : ( DATE | TODAY );
 */
static RSPParser_dateref_return
dateref(pRSPParser ctx)
{   
    RSPParser_dateref_return retval;

    pANTLR3_BASE_TREE root_0;

    pANTLR3_COMMON_TOKEN    set41;

    pANTLR3_BASE_TREE set41_tree;

    /* Initialize rule variables
     */


    root_0 = NULL;

    set41       = NULL;
    retval.start = LT(1); retval.stop = retval.start;

    set41_tree   = NULL;


    retval.tree  = NULL;
    {
        // RSP.g:74:9: ( DATE | TODAY )
        // RSP.g:
        {
            root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));

            set41=(pANTLR3_COMMON_TOKEN)LT(1);
            if ( ((LA(1) >= DATE) && (LA(1) <= TODAY)) )
            {
                CONSUME();
                ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set41)));
                PERRORRECOVERY=ANTLR3_FALSE;
            }
            else 
            {
                CONSTRUCTEX();
                EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;
                EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;
                EXCEPTION->expectingSet = &FOLLOW_set_in_dateref0;
                RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_dateref0);    goto ruledaterefEx;
            }


        }

    }
    

    // This is where rules clean up and exit
    //
    goto ruledaterefEx; /* Prevent compiler warnings */
    ruledaterefEx: ;
    retval.stop = LT(-1);

    	retval.stop = LT(-1);
    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);

            if (HASEXCEPTION())
            {
                PREPORTERROR();
                PRECOVER();
                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
            }


    return retval;
}
/* $ANTLR end dateref */

/** 
 * $ANTLR start dateintval
 * RSP.g:78:1: dateintval : ( DAY | WEEK | MONTH | YEAR );
 */
static RSPParser_dateintval_return
dateintval(pRSPParser ctx)
{   
    RSPParser_dateintval_return retval;

    pANTLR3_BASE_TREE root_0;

    pANTLR3_COMMON_TOKEN    set42;

    pANTLR3_BASE_TREE set42_tree;

    /* Initialize rule variables
     */


    root_0 = NULL;

    set42       = NULL;
    retval.start = LT(1); retval.stop = retval.start;

    set42_tree   = NULL;


    retval.tree  = NULL;
    {
        // RSP.g:79:2: ( DAY | WEEK | MONTH | YEAR )
        // RSP.g:
        {
            root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));

            set42=(pANTLR3_COMMON_TOKEN)LT(1);
            if ( ((LA(1) >= DAY) && (LA(1) <= YEAR)) )
            {
                CONSUME();
                ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set42)));
                PERRORRECOVERY=ANTLR3_FALSE;
            }
            else 
            {
                CONSTRUCTEX();
                EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;
                EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;
                EXCEPTION->expectingSet = &FOLLOW_set_in_dateintval0;
                RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_dateintval0);    goto ruledateintvalEx;
            }


        }

    }
    

    // This is where rules clean up and exit
    //
    goto ruledateintvalEx; /* Prevent compiler warnings */
    ruledateintvalEx: ;
    retval.stop = LT(-1);

    	retval.stop = LT(-1);
    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);

            if (HASEXCEPTION())
            {
                PREPORTERROR();
                PRECOVER();
                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
            }


    return retval;
}
/* $ANTLR end dateintval */
/* End of parsing rules
 * ==============================================
 */

/* ==============================================
 * Syntactic predicates
 */
/* End of syntactic predicates
 * ==============================================
 */

 
 



/* End of code
 * =============================================================================
 */
