1/** \file
2 *  This C source file was generated by $ANTLR version 3.2 debian-5
3 *
4 *     -  From the grammar source file : DAAP.g
5 *     -                            On : 2011-09-11 15:48:49
6 *     -                for the parser : DAAPParserParser *
7 * Editing it, at least manually, is not wise.
8 *
9 * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws.
10 *
11 *
12*/
13// [The "BSD licence"]
14// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
15// http://www.temporal-wave.com
16// http://www.linkedin.com/in/jimidle
17//
18// All rights reserved.
19//
20// Redistribution and use in source and binary forms, with or without
21// modification, are permitted provided that the following conditions
22// are met:
23// 1. Redistributions of source code must retain the above copyright
24//    notice, this list of conditions and the following disclaimer.
25// 2. Redistributions in binary form must reproduce the above copyright
26//    notice, this list of conditions and the following disclaimer in the
27//    documentation and/or other materials provided with the distribution.
28// 3. The name of the author may not be used to endorse or promote products
29//    derived from this software without specific prior written permission.
30//
31// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
32// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
33// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
34// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
35// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
36// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
40// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42/* -----------------------------------------
43 * Include the ANTLR3 generated header file.
44 */
45#include    "DAAPParser.h"
46/* ----------------------------------------- */
47
48
49
50
51
52/* MACROS that hide the C interface implementations from the
53 * generated code, which makes it a little more understandable to the human eye.
54 * I am very much against using C pre-processor macros for function calls and bits
55 * of code as you cannot see what is happening when single stepping in debuggers
56 * and so on. The exception (in my book at least) is for generated code, where you are
57 * not maintaining it, but may wish to read and understand it. If you single step it, you know that input()
58 * hides some indirect calls, but is always referring to the input stream. This is
59 * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig
60 * the runtime interfaces without changing the generated code too often, without
61 * confusing the reader of the generated output, who may not wish to know the gory
62 * details of the interface inheritance.
63 */
64
65#define		CTX	ctx
66
67/* Aids in accessing scopes for grammar programmers
68 */
69#undef	SCOPE_TYPE
70#undef	SCOPE_STACK
71#undef	SCOPE_TOP
72#define	SCOPE_TYPE(scope)   pDAAPParser_##scope##_SCOPE
73#define SCOPE_STACK(scope)  pDAAPParser_##scope##Stack
74#define	SCOPE_TOP(scope)    ctx->pDAAPParser_##scope##Top
75#define	SCOPE_SIZE(scope)		ctx->pDAAPParser_##scope##Stack_limit
76#define SCOPE_INSTANCE(scope, i)	(ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
77
78/* Macros for accessing things in the parser
79 */
80
81#undef	    PARSER
82#undef	    RECOGNIZER
83#undef	    HAVEPARSEDRULE
84#undef		MEMOIZE
85#undef	    INPUT
86#undef	    STRSTREAM
87#undef	    HASEXCEPTION
88#undef	    EXCEPTION
89#undef	    MATCHT
90#undef	    MATCHANYT
91#undef	    FOLLOWSTACK
92#undef	    FOLLOWPUSH
93#undef	    FOLLOWPOP
94#undef	    PRECOVER
95#undef	    PREPORTERROR
96#undef	    LA
97#undef	    LT
98#undef	    CONSTRUCTEX
99#undef	    CONSUME
100#undef	    MARK
101#undef	    REWIND
102#undef	    REWINDLAST
103#undef	    PERRORRECOVERY
104#undef	    HASFAILED
105#undef	    FAILEDFLAG
106#undef	    RECOVERFROMMISMATCHEDSET
107#undef	    RECOVERFROMMISMATCHEDELEMENT
108#undef		INDEX
109#undef      ADAPTOR
110#undef		SEEK
111#undef	    RULEMEMO
112#undef		DBG
113
114#define	    PARSER							ctx->pParser
115#define	    RECOGNIZER						PARSER->rec
116#define		PSRSTATE						RECOGNIZER->state
117#define	    HAVEPARSEDRULE(r)				RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
118#define		MEMOIZE(ri,si)					RECOGNIZER->memoize(RECOGNIZER, ri, si)
119#define	    INPUT							PARSER->tstream
120#define	    STRSTREAM						INPUT
121#define		ISTREAM							INPUT->istream
122#define		INDEX()							ISTREAM->index(INPUT->istream)
123#define	    HASEXCEPTION()					(PSRSTATE->error == ANTLR3_TRUE)
124#define	    EXCEPTION						PSRSTATE->exception
125#define	    MATCHT(t, fs)					RECOGNIZER->match(RECOGNIZER, t, fs)
126#define	    MATCHANYT()						RECOGNIZER->matchAny(RECOGNIZER)
127#define	    FOLLOWSTACK					    PSRSTATE->following
128#define	    FOLLOWPUSH(x)					FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL)
129#define	    FOLLOWPOP()						FOLLOWSTACK->pop(FOLLOWSTACK)
130#define	    PRECOVER()						RECOGNIZER->recover(RECOGNIZER)
131#define	    PREPORTERROR()					RECOGNIZER->reportError(RECOGNIZER)
132#define	    LA(n)							INPUT->istream->_LA(ISTREAM, n)
133#define	    LT(n)							INPUT->_LT(INPUT, n)
134#define	    CONSTRUCTEX()					RECOGNIZER->exConstruct(RECOGNIZER)
135#define	    CONSUME()						ISTREAM->consume(ISTREAM)
136#define	    MARK()							ISTREAM->mark(ISTREAM)
137#define	    REWIND(m)						ISTREAM->rewind(ISTREAM, m)
138#define	    REWINDLAST()					ISTREAM->rewindLast(ISTREAM)
139#define		SEEK(n)							ISTREAM->seek(ISTREAM, n)
140#define	    PERRORRECOVERY					PSRSTATE->errorRecovery
141#define	    FAILEDFLAG						PSRSTATE->failed
142#define	    HASFAILED()						(FAILEDFLAG == ANTLR3_TRUE)
143#define	    BACKTRACKING					PSRSTATE->backtracking
144#define	    RECOVERFROMMISMATCHEDSET(s)		RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s)
145#define	    RECOVERFROMMISMATCHEDELEMENT(e)	RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s)
146#define     ADAPTOR                         ctx->adaptor
147#define		RULEMEMO						PSRSTATE->ruleMemo
148#define		DBG								RECOGNIZER->debugger
149
150#define		TOKTEXT(tok, txt)				tok, (pANTLR3_UINT8)txt
151
152/* The 4 tokens defined below may well clash with your own #defines or token types. If so
153 * then for the present you must use different names for your defines as these are hard coded
154 * in the code generator. It would be better not to use such names internally, and maybe
155 * we can change this in a forthcoming release. I deliberately do not #undef these
156 * here as this will at least give you a redefined error somewhere if they clash.
157 */
158#define	    UP	    ANTLR3_TOKEN_UP
159#define	    DOWN    ANTLR3_TOKEN_DOWN
160#define	    EOR	    ANTLR3_TOKEN_EOR
161#define	    INVALID ANTLR3_TOKEN_INVALID
162
163
164/* =============================================================================
165 * Functions to create and destroy scopes. First come the rule scopes, followed
166 * by the global declared scopes.
167 */
168
169
170
171/* ============================================================================= */
172
173/* =============================================================================
174 * Start of recognizer
175 */
176
177
178
179/** \brief Table of all token names in symbolic order, mainly used for
180 *         error reporting.
181 */
182pANTLR3_UINT8   DAAPParserTokenNames[8+4]
183     = {
184        (pANTLR3_UINT8) "<invalid>",       /* String to print to indicate an invalid token */
185        (pANTLR3_UINT8) "<EOR>",
186        (pANTLR3_UINT8) "<DOWN>",
187        (pANTLR3_UINT8) "<UP>",
188        (pANTLR3_UINT8) "NEWLINE",
189        (pANTLR3_UINT8) "OPOR",
190        (pANTLR3_UINT8) "OPAND",
191        (pANTLR3_UINT8) "LPAR",
192        (pANTLR3_UINT8) "RPAR",
193        (pANTLR3_UINT8) "STR",
194        (pANTLR3_UINT8) "QUOTE",
195        (pANTLR3_UINT8) "ESCAPED"
196       };
197
198
199
200// Forward declare the locally static matching functions we have generated.
201//
202static DAAPParser_query_return	query    (pDAAPParser ctx);
203static DAAPParser_expr_return	expr    (pDAAPParser ctx);
204static DAAPParser_aexpr_return	aexpr    (pDAAPParser ctx);
205static DAAPParser_crit_return	crit    (pDAAPParser ctx);
206static void	DAAPParserFree(pDAAPParser ctx);
207/* For use in tree output where we are accumulating rule labels via label += ruleRef
208 * we need a function that knows how to free a return scope when the list is destroyed.
209 * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro.
210 */
211static	void ANTLR3_CDECL freeScope(void * scope)
212{
213    ANTLR3_FREE(scope);
214}
215
216/** \brief Name of the grammar file that generated this code
217 */
218static const char fileName[] = "DAAP.g";
219
220/** \brief Return the name of the grammar file that generated this code.
221 */
222static const char * getGrammarFileName()
223{
224	return fileName;
225}
226/** \brief Create a new DAAPParser parser and return a context for it.
227 *
228 * \param[in] instream Pointer to an input stream interface.
229 *
230 * \return Pointer to new parser context upon success.
231 */
232ANTLR3_API pDAAPParser
233DAAPParserNew   (pANTLR3_COMMON_TOKEN_STREAM instream)
234{
235	// See if we can create a new parser with the standard constructor
236	//
237	return DAAPParserNewSSD(instream, NULL);
238}
239
240/** \brief Create a new DAAPParser parser and return a context for it.
241 *
242 * \param[in] instream Pointer to an input stream interface.
243 *
244 * \return Pointer to new parser context upon success.
245 */
246ANTLR3_API pDAAPParser
247DAAPParserNewSSD   (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
248{
249    pDAAPParser ctx;	    /* Context structure we will build and return   */
250
251    ctx	= (pDAAPParser) ANTLR3_CALLOC(1, sizeof(DAAPParser));
252
253    if	(ctx == NULL)
254    {
255		// Failed to allocate memory for parser context
256		//
257        return  NULL;
258    }
259
260    /* -------------------------------------------------------------------
261     * Memory for basic structure is allocated, now to fill in
262     * the base ANTLR3 structures. We initialize the function pointers
263     * for the standard ANTLR3 parser function set, but upon return
264     * from here, the programmer may set the pointers to provide custom
265     * implementations of each function.
266     *
267     * We don't use the macros defined in DAAPParser.h here, in order that you can get a sense
268     * of what goes where.
269     */
270
271    /* Create a base parser/recognizer, using the supplied token stream
272     */
273    ctx->pParser	    = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state);
274    /* Install the implementation of our DAAPParser interface
275     */
276    ctx->query	= query;
277    ctx->expr	= expr;
278    ctx->aexpr	= aexpr;
279    ctx->crit	= crit;
280    ctx->free			= DAAPParserFree;
281    ctx->getGrammarFileName	= getGrammarFileName;
282
283    /* Install the scope pushing methods.
284     */
285    ADAPTOR	= ANTLR3_TREE_ADAPTORNew(instream->tstream->tokenSource->strFactory);
286    ctx->vectors	= antlr3VectorFactoryNew(0);
287
288
289
290    /* Install the token table
291     */
292    PSRSTATE->tokenNames   = DAAPParserTokenNames;
293
294
295    /* Return the newly built parser to the caller
296     */
297    return  ctx;
298}
299
300/** Free the parser resources
301 */
302 static void
303 DAAPParserFree(pDAAPParser ctx)
304 {
305    /* Free any scope memory
306     */
307
308    ctx->vectors->close(ctx->vectors);
309    /* We created the adaptor so we must free it
310     */
311    ADAPTOR->free(ADAPTOR);
312	// Free this parser
313	//
314    ctx->pParser->free(ctx->pParser);
315    ANTLR3_FREE(ctx);
316
317    /* Everything is released, so we can return
318     */
319    return;
320 }
321
322/** Return token names used by this parser
323 *
324 * The returned pointer is used as an index into the token names table (using the token
325 * number as the index).
326 *
327 * \return Pointer to first char * in the table.
328 */
329static pANTLR3_UINT8    *getTokenNames()
330{
331        return DAAPParserTokenNames;
332}
333
334
335/* Declare the bitsets
336 */
337
338/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query42  */
339static	ANTLR3_BITWORD FOLLOW_expr_in_query42_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000010) };
340static  ANTLR3_BITSET_LIST FOLLOW_expr_in_query42	= { FOLLOW_expr_in_query42_bits, 1	};
341/** Bitset defining follow set for error recovery in rule state: FOLLOW_NEWLINE_in_query44  */
342static	ANTLR3_BITWORD FOLLOW_NEWLINE_in_query44_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000000) };
343static  ANTLR3_BITSET_LIST FOLLOW_NEWLINE_in_query44	= { FOLLOW_NEWLINE_in_query44_bits, 1	};
344/** Bitset defining follow set for error recovery in rule state: FOLLOW_EOF_in_query47  */
345static	ANTLR3_BITWORD FOLLOW_EOF_in_query47_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
346static  ANTLR3_BITSET_LIST FOLLOW_EOF_in_query47	= { FOLLOW_EOF_in_query47_bits, 1	};
347/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr62  */
348static	ANTLR3_BITWORD FOLLOW_aexpr_in_expr62_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000022) };
349static  ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr62	= { FOLLOW_aexpr_in_expr62_bits, 1	};
350/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPOR_in_expr65  */
351static	ANTLR3_BITWORD FOLLOW_OPOR_in_expr65_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000280) };
352static  ANTLR3_BITSET_LIST FOLLOW_OPOR_in_expr65	= { FOLLOW_OPOR_in_expr65_bits, 1	};
353/** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr68  */
354static	ANTLR3_BITWORD FOLLOW_aexpr_in_expr68_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000022) };
355static  ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr68	= { FOLLOW_aexpr_in_expr68_bits, 1	};
356/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr80  */
357static	ANTLR3_BITWORD FOLLOW_crit_in_aexpr80_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000042) };
358static  ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr80	= { FOLLOW_crit_in_aexpr80_bits, 1	};
359/** Bitset defining follow set for error recovery in rule state: FOLLOW_OPAND_in_aexpr83  */
360static	ANTLR3_BITWORD FOLLOW_OPAND_in_aexpr83_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000280) };
361static  ANTLR3_BITSET_LIST FOLLOW_OPAND_in_aexpr83	= { FOLLOW_OPAND_in_aexpr83_bits, 1	};
362/** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr86  */
363static	ANTLR3_BITWORD FOLLOW_crit_in_aexpr86_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000042) };
364static  ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr86	= { FOLLOW_crit_in_aexpr86_bits, 1	};
365/** Bitset defining follow set for error recovery in rule state: FOLLOW_LPAR_in_crit98  */
366static	ANTLR3_BITWORD FOLLOW_LPAR_in_crit98_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000280) };
367static  ANTLR3_BITSET_LIST FOLLOW_LPAR_in_crit98	= { FOLLOW_LPAR_in_crit98_bits, 1	};
368/** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_crit100  */
369static	ANTLR3_BITWORD FOLLOW_expr_in_crit100_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000100) };
370static  ANTLR3_BITSET_LIST FOLLOW_expr_in_crit100	= { FOLLOW_expr_in_crit100_bits, 1	};
371/** Bitset defining follow set for error recovery in rule state: FOLLOW_RPAR_in_crit102  */
372static	ANTLR3_BITWORD FOLLOW_RPAR_in_crit102_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
373static  ANTLR3_BITSET_LIST FOLLOW_RPAR_in_crit102	= { FOLLOW_RPAR_in_crit102_bits, 1	};
374/** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_crit112  */
375static	ANTLR3_BITWORD FOLLOW_STR_in_crit112_bits[]	= { ANTLR3_UINT64_LIT(0x0000000000000002) };
376static  ANTLR3_BITSET_LIST FOLLOW_STR_in_crit112	= { FOLLOW_STR_in_crit112_bits, 1	};
377
378
379
380
381/* ==============================================
382 * Parsing rules
383 */
384/**
385 * $ANTLR start query
386 * DAAP.g:27:1: query : expr ( NEWLINE )? EOF -> expr ;
387 */
388static DAAPParser_query_return
389query(pDAAPParser ctx)
390{
391    DAAPParser_query_return retval;
392
393    pANTLR3_BASE_TREE root_0;
394
395    pANTLR3_COMMON_TOKEN    NEWLINE2;
396    pANTLR3_COMMON_TOKEN    EOF3;
397    DAAPParser_expr_return expr1;
398    #undef	RETURN_TYPE_expr1
399    #define	RETURN_TYPE_expr1 DAAPParser_expr_return
400
401    pANTLR3_BASE_TREE NEWLINE2_tree;
402    pANTLR3_BASE_TREE EOF3_tree;
403    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NEWLINE;
404    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_EOF;
405    pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr;
406    /* Initialize rule variables
407     */
408
409
410    root_0 = NULL;
411
412    NEWLINE2       = NULL;
413    EOF3       = NULL;
414    expr1.tree = NULL;
415
416    retval.start = LT(1); retval.stop = retval.start;
417
418    NEWLINE2_tree   = NULL;
419    EOF3_tree   = NULL;
420
421    stream_NEWLINE   = NULL;
422    #define CREATE_stream_NEWLINE  if (stream_NEWLINE == NULL) {stream_NEWLINE = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NEWLINE"); }
423    stream_EOF   = NULL;
424    #define CREATE_stream_EOF  if (stream_EOF == NULL) {stream_EOF = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token EOF"); }
425    stream_expr   = NULL;
426    #define CREATE_stream_expr  if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); }
427
428    retval.tree  = NULL;
429    {
430        // DAAP.g:27:7: ( expr ( NEWLINE )? EOF -> expr )
431        // DAAP.g:27:9: expr ( NEWLINE )? EOF
432        {
433            FOLLOWPUSH(FOLLOW_expr_in_query42);
434            expr1=expr(ctx);
435
436            FOLLOWPOP();
437            if  (HASEXCEPTION())
438            {
439                goto rulequeryEx;
440            }
441
442            CREATE_stream_expr; stream_expr->add(stream_expr, expr1.tree, NULL);
443
444            // DAAP.g:27:14: ( NEWLINE )?
445            {
446                int alt1=2;
447                switch ( LA(1) )
448                {
449                    case NEWLINE:
450                    	{
451                    		alt1=1;
452                    	}
453                        break;
454                }
455
456                switch (alt1)
457                {
458            	case 1:
459            	    // DAAP.g:27:14: NEWLINE
460            	    {
461            	        NEWLINE2 = (pANTLR3_COMMON_TOKEN) MATCHT(NEWLINE, &FOLLOW_NEWLINE_in_query44);
462            	        if  (HASEXCEPTION())
463            	        {
464            	            goto rulequeryEx;
465            	        }
466
467            	        CREATE_stream_NEWLINE; stream_NEWLINE->add(stream_NEWLINE, NEWLINE2, NULL);
468
469
470            	    }
471            	    break;
472
473                }
474            }
475            EOF3 = (pANTLR3_COMMON_TOKEN) MATCHT(EOF, &FOLLOW_EOF_in_query47);
476            if  (HASEXCEPTION())
477            {
478                goto rulequeryEx;
479            }
480
481            CREATE_stream_EOF; stream_EOF->add(stream_EOF, EOF3, NULL);
482
483
484
485            /* AST REWRITE
486             * elements          : expr
487             * token labels      :
488             * rule labels       : retval
489             * token list labels :
490             * rule list labels  :
491             */
492            {
493            	pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
494
495            	stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR,  RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
496
497            	root_0			    = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
498            	retval.tree    = root_0;
499            	// 27:27: -> expr
500            	{
501            	    ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr));
502
503            	}
504
505            	retval.tree = root_0; // set result root
506            	if (stream_retval != NULL) stream_retval->free(stream_retval);
507
508
509            }
510        }
511
512    }
513
514
515    // This is where rules clean up and exit
516    //
517    goto rulequeryEx; /* Prevent compiler warnings */
518    rulequeryEx: ;
519    retval.stop = LT(-1);
520
521    	retval.stop = LT(-1);
522    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
523    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
524        if (stream_NEWLINE != NULL) stream_NEWLINE->free(stream_NEWLINE);
525        if (stream_EOF != NULL) stream_EOF->free(stream_EOF);
526        if (stream_expr != NULL) stream_expr->free(stream_expr);
527
528            if (HASEXCEPTION())
529            {
530                PREPORTERROR();
531                PRECOVER();
532                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
533            }
534
535
536    return retval;
537}
538/* $ANTLR end query */
539
540/**
541 * $ANTLR start expr
542 * DAAP.g:30:1: expr : aexpr ( OPOR aexpr )* ;
543 */
544static DAAPParser_expr_return
545expr(pDAAPParser ctx)
546{
547    DAAPParser_expr_return retval;
548
549    pANTLR3_BASE_TREE root_0;
550
551    pANTLR3_COMMON_TOKEN    OPOR5;
552    DAAPParser_aexpr_return aexpr4;
553    #undef	RETURN_TYPE_aexpr4
554    #define	RETURN_TYPE_aexpr4 DAAPParser_aexpr_return
555
556    DAAPParser_aexpr_return aexpr6;
557    #undef	RETURN_TYPE_aexpr6
558    #define	RETURN_TYPE_aexpr6 DAAPParser_aexpr_return
559
560    pANTLR3_BASE_TREE OPOR5_tree;
561
562    /* Initialize rule variables
563     */
564
565
566    root_0 = NULL;
567
568    OPOR5       = NULL;
569    aexpr4.tree = NULL;
570
571    aexpr6.tree = NULL;
572
573    retval.start = LT(1); retval.stop = retval.start;
574
575    OPOR5_tree   = NULL;
576
577
578    retval.tree  = NULL;
579    {
580        // DAAP.g:30:6: ( aexpr ( OPOR aexpr )* )
581        // DAAP.g:30:8: aexpr ( OPOR aexpr )*
582        {
583            root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
584
585            FOLLOWPUSH(FOLLOW_aexpr_in_expr62);
586            aexpr4=aexpr(ctx);
587
588            FOLLOWPOP();
589            if  (HASEXCEPTION())
590            {
591                goto ruleexprEx;
592            }
593
594            ADAPTOR->addChild(ADAPTOR, root_0, aexpr4.tree);
595
596            // DAAP.g:30:14: ( OPOR aexpr )*
597
598            for (;;)
599            {
600                int alt2=2;
601                switch ( LA(1) )
602                {
603                case OPOR:
604                	{
605                		alt2=1;
606                	}
607                    break;
608
609                }
610
611                switch (alt2)
612                {
613            	case 1:
614            	    // DAAP.g:30:15: OPOR aexpr
615            	    {
616            	        OPOR5 = (pANTLR3_COMMON_TOKEN) MATCHT(OPOR, &FOLLOW_OPOR_in_expr65);
617            	        if  (HASEXCEPTION())
618            	        {
619            	            goto ruleexprEx;
620            	        }
621
622            	        OPOR5_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OPOR5));
623            	        root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OPOR5_tree, root_0));
624
625            	        FOLLOWPUSH(FOLLOW_aexpr_in_expr68);
626            	        aexpr6=aexpr(ctx);
627
628            	        FOLLOWPOP();
629            	        if  (HASEXCEPTION())
630            	        {
631            	            goto ruleexprEx;
632            	        }
633
634            	        ADAPTOR->addChild(ADAPTOR, root_0, aexpr6.tree);
635
636            	    }
637            	    break;
638
639            	default:
640            	    goto loop2;	/* break out of the loop */
641            	    break;
642                }
643            }
644            loop2: ; /* Jump out to here if this rule does not match */
645
646
647        }
648
649    }
650
651
652    // This is where rules clean up and exit
653    //
654    goto ruleexprEx; /* Prevent compiler warnings */
655    ruleexprEx: ;
656    retval.stop = LT(-1);
657
658    	retval.stop = LT(-1);
659    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
660    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
661
662            if (HASEXCEPTION())
663            {
664                PREPORTERROR();
665                PRECOVER();
666                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
667            }
668
669
670    return retval;
671}
672/* $ANTLR end expr */
673
674/**
675 * $ANTLR start aexpr
676 * DAAP.g:33:1: aexpr : crit ( OPAND crit )* ;
677 */
678static DAAPParser_aexpr_return
679aexpr(pDAAPParser ctx)
680{
681    DAAPParser_aexpr_return retval;
682
683    pANTLR3_BASE_TREE root_0;
684
685    pANTLR3_COMMON_TOKEN    OPAND8;
686    DAAPParser_crit_return crit7;
687    #undef	RETURN_TYPE_crit7
688    #define	RETURN_TYPE_crit7 DAAPParser_crit_return
689
690    DAAPParser_crit_return crit9;
691    #undef	RETURN_TYPE_crit9
692    #define	RETURN_TYPE_crit9 DAAPParser_crit_return
693
694    pANTLR3_BASE_TREE OPAND8_tree;
695
696    /* Initialize rule variables
697     */
698
699
700    root_0 = NULL;
701
702    OPAND8       = NULL;
703    crit7.tree = NULL;
704
705    crit9.tree = NULL;
706
707    retval.start = LT(1); retval.stop = retval.start;
708
709    OPAND8_tree   = NULL;
710
711
712    retval.tree  = NULL;
713    {
714        // DAAP.g:33:7: ( crit ( OPAND crit )* )
715        // DAAP.g:33:9: crit ( OPAND crit )*
716        {
717            root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
718
719            FOLLOWPUSH(FOLLOW_crit_in_aexpr80);
720            crit7=crit(ctx);
721
722            FOLLOWPOP();
723            if  (HASEXCEPTION())
724            {
725                goto ruleaexprEx;
726            }
727
728            ADAPTOR->addChild(ADAPTOR, root_0, crit7.tree);
729
730            // DAAP.g:33:14: ( OPAND crit )*
731
732            for (;;)
733            {
734                int alt3=2;
735                switch ( LA(1) )
736                {
737                case OPAND:
738                	{
739                		alt3=1;
740                	}
741                    break;
742
743                }
744
745                switch (alt3)
746                {
747            	case 1:
748            	    // DAAP.g:33:15: OPAND crit
749            	    {
750            	        OPAND8 = (pANTLR3_COMMON_TOKEN) MATCHT(OPAND, &FOLLOW_OPAND_in_aexpr83);
751            	        if  (HASEXCEPTION())
752            	        {
753            	            goto ruleaexprEx;
754            	        }
755
756            	        OPAND8_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OPAND8));
757            	        root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OPAND8_tree, root_0));
758
759            	        FOLLOWPUSH(FOLLOW_crit_in_aexpr86);
760            	        crit9=crit(ctx);
761
762            	        FOLLOWPOP();
763            	        if  (HASEXCEPTION())
764            	        {
765            	            goto ruleaexprEx;
766            	        }
767
768            	        ADAPTOR->addChild(ADAPTOR, root_0, crit9.tree);
769
770            	    }
771            	    break;
772
773            	default:
774            	    goto loop3;	/* break out of the loop */
775            	    break;
776                }
777            }
778            loop3: ; /* Jump out to here if this rule does not match */
779
780
781        }
782
783    }
784
785
786    // This is where rules clean up and exit
787    //
788    goto ruleaexprEx; /* Prevent compiler warnings */
789    ruleaexprEx: ;
790    retval.stop = LT(-1);
791
792    	retval.stop = LT(-1);
793    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
794    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
795
796            if (HASEXCEPTION())
797            {
798                PREPORTERROR();
799                PRECOVER();
800                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
801            }
802
803
804    return retval;
805}
806/* $ANTLR end aexpr */
807
808/**
809 * $ANTLR start crit
810 * DAAP.g:36:1: crit : ( LPAR expr RPAR -> expr | STR );
811 */
812static DAAPParser_crit_return
813crit(pDAAPParser ctx)
814{
815    DAAPParser_crit_return retval;
816
817    pANTLR3_BASE_TREE root_0;
818
819    pANTLR3_COMMON_TOKEN    LPAR10;
820    pANTLR3_COMMON_TOKEN    RPAR12;
821    pANTLR3_COMMON_TOKEN    STR13;
822    DAAPParser_expr_return expr11;
823    #undef	RETURN_TYPE_expr11
824    #define	RETURN_TYPE_expr11 DAAPParser_expr_return
825
826    pANTLR3_BASE_TREE LPAR10_tree;
827    pANTLR3_BASE_TREE RPAR12_tree;
828    pANTLR3_BASE_TREE STR13_tree;
829    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_RPAR;
830    pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_LPAR;
831    pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr;
832    /* Initialize rule variables
833     */
834
835
836    root_0 = NULL;
837
838    LPAR10       = NULL;
839    RPAR12       = NULL;
840    STR13       = NULL;
841    expr11.tree = NULL;
842
843    retval.start = LT(1); retval.stop = retval.start;
844
845    LPAR10_tree   = NULL;
846    RPAR12_tree   = NULL;
847    STR13_tree   = NULL;
848
849    stream_RPAR   = NULL;
850    #define CREATE_stream_RPAR  if (stream_RPAR == NULL) {stream_RPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token RPAR"); }
851    stream_LPAR   = NULL;
852    #define CREATE_stream_LPAR  if (stream_LPAR == NULL) {stream_LPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token LPAR"); }
853    stream_expr   = NULL;
854    #define CREATE_stream_expr  if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); }
855
856    retval.tree  = NULL;
857    {
858        {
859            //  DAAP.g:36:6: ( LPAR expr RPAR -> expr | STR )
860
861            ANTLR3_UINT32 alt4;
862
863            alt4=2;
864
865            switch ( LA(1) )
866            {
867            case LPAR:
868            	{
869            		alt4=1;
870            	}
871                break;
872            case STR:
873            	{
874            		alt4=2;
875            	}
876                break;
877
878            default:
879                CONSTRUCTEX();
880                EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
881                EXCEPTION->message      = (void *)"";
882                EXCEPTION->decisionNum  = 4;
883                EXCEPTION->state        = 0;
884
885
886                goto rulecritEx;
887            }
888
889            switch (alt4)
890            {
891        	case 1:
892        	    // DAAP.g:36:8: LPAR expr RPAR
893        	    {
894        	        LPAR10 = (pANTLR3_COMMON_TOKEN) MATCHT(LPAR, &FOLLOW_LPAR_in_crit98);
895        	        if  (HASEXCEPTION())
896        	        {
897        	            goto rulecritEx;
898        	        }
899
900        	        CREATE_stream_LPAR; stream_LPAR->add(stream_LPAR, LPAR10, NULL);
901
902        	        FOLLOWPUSH(FOLLOW_expr_in_crit100);
903        	        expr11=expr(ctx);
904
905        	        FOLLOWPOP();
906        	        if  (HASEXCEPTION())
907        	        {
908        	            goto rulecritEx;
909        	        }
910
911        	        CREATE_stream_expr; stream_expr->add(stream_expr, expr11.tree, NULL);
912        	        RPAR12 = (pANTLR3_COMMON_TOKEN) MATCHT(RPAR, &FOLLOW_RPAR_in_crit102);
913        	        if  (HASEXCEPTION())
914        	        {
915        	            goto rulecritEx;
916        	        }
917
918        	        CREATE_stream_RPAR; stream_RPAR->add(stream_RPAR, RPAR12, NULL);
919
920
921
922        	        /* AST REWRITE
923        	         * elements          : expr
924        	         * token labels      :
925        	         * rule labels       : retval
926        	         * token list labels :
927        	         * rule list labels  :
928        	         */
929        	        {
930        	        	pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval;
931
932        	        	stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR,  RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL);
933
934        	        	root_0			    = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
935        	        	retval.tree    = root_0;
936        	        	// 36:24: -> expr
937        	        	{
938        	        	    ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr));
939
940        	        	}
941
942        	        	retval.tree = root_0; // set result root
943        	        	if (stream_retval != NULL) stream_retval->free(stream_retval);
944
945
946        	        }
947        	    }
948        	    break;
949        	case 2:
950        	    // DAAP.g:37:4: STR
951        	    {
952        	        root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR));
953
954        	        STR13 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_crit112);
955        	        if  (HASEXCEPTION())
956        	        {
957        	            goto rulecritEx;
958        	        }
959
960        	        STR13_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, STR13));
961        	        ADAPTOR->addChild(ADAPTOR, root_0, STR13_tree);
962
963
964        	    }
965        	    break;
966
967            }
968        }
969    }
970
971
972    // This is where rules clean up and exit
973    //
974    goto rulecritEx; /* Prevent compiler warnings */
975    rulecritEx: ;
976    retval.stop = LT(-1);
977
978    	retval.stop = LT(-1);
979    	retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0));
980    	ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop);
981        if (stream_RPAR != NULL) stream_RPAR->free(stream_RPAR);
982        if (stream_LPAR != NULL) stream_LPAR->free(stream_LPAR);
983        if (stream_expr != NULL) stream_expr->free(stream_expr);
984
985            if (HASEXCEPTION())
986            {
987                PREPORTERROR();
988                PRECOVER();
989                retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION));
990            }
991
992
993    return retval;
994}
995/* $ANTLR end crit */
996/* End of parsing rules
997 * ==============================================
998 */
999
1000/* ==============================================
1001 * Syntactic predicates
1002 */
1003/* End of syntactic predicates
1004 * ==============================================
1005 */
1006
1007
1008
1009
1010
1011
1012/* End of code
1013 * =============================================================================
1014 */
1015