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:50
6 *     -                 for the lexer : DAAPLexerLexer *
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    "DAAPLexer.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)   pDAAPLexer_##scope##_SCOPE
73#define SCOPE_STACK(scope)  pDAAPLexer_##scope##Stack
74#define	SCOPE_TOP(scope)    ctx->pDAAPLexer_##scope##Top
75#define	SCOPE_SIZE(scope)		ctx->pDAAPLexer_##scope##Stack_limit
76#define SCOPE_INSTANCE(scope, i)	(ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i))
77
78
79/* Macros for accessing things in a lexer
80 */
81#undef	    LEXER
82#undef	    RECOGNIZER
83#undef	    RULEMEMO
84#undef	    GETCHARINDEX
85#undef	    GETLINE
86#undef	    GETCHARPOSITIONINLINE
87#undef	    EMIT
88#undef	    EMITNEW
89#undef	    MATCHC
90#undef	    MATCHS
91#undef	    MATCHRANGE
92#undef	    LTOKEN
93#undef	    HASFAILED
94#undef	    FAILEDFLAG
95#undef	    INPUT
96#undef	    STRSTREAM
97#undef	    LA
98#undef	    HASEXCEPTION
99#undef	    EXCEPTION
100#undef	    CONSTRUCTEX
101#undef	    CONSUME
102#undef	    LRECOVER
103#undef	    MARK
104#undef	    REWIND
105#undef	    REWINDLAST
106#undef	    BACKTRACKING
107#undef		MATCHANY
108#undef		MEMOIZE
109#undef		HAVEPARSEDRULE
110#undef		GETTEXT
111#undef		INDEX
112#undef		SEEK
113#undef		PUSHSTREAM
114#undef		POPSTREAM
115#undef		SETTEXT
116#undef		SETTEXT8
117
118#define	    LEXER					ctx->pLexer
119#define	    RECOGNIZER			    LEXER->rec
120#define		LEXSTATE				RECOGNIZER->state
121#define		TOKSOURCE				LEXSTATE->tokSource
122#define	    GETCHARINDEX()			LEXER->getCharIndex(LEXER)
123#define	    GETLINE()				LEXER->getLine(LEXER)
124#define	    GETTEXT()				LEXER->getText(LEXER)
125#define	    GETCHARPOSITIONINLINE() LEXER->getCharPositionInLine(LEXER)
126#define	    EMIT()					LEXSTATE->type = _type; LEXER->emit(LEXER)
127#define	    EMITNEW(t)				LEXER->emitNew(LEXER, t)
128#define	    MATCHC(c)				LEXER->matchc(LEXER, c)
129#define	    MATCHS(s)				LEXER->matchs(LEXER, s)
130#define	    MATCHRANGE(c1,c2)	    LEXER->matchRange(LEXER, c1, c2)
131#define	    MATCHANY()				LEXER->matchAny(LEXER)
132#define	    LTOKEN  				LEXSTATE->token
133#define	    HASFAILED()				(LEXSTATE->failed == ANTLR3_TRUE)
134#define	    BACKTRACKING			LEXSTATE->backtracking
135#define	    FAILEDFLAG				LEXSTATE->failed
136#define	    INPUT					LEXER->input
137#define	    STRSTREAM				INPUT
138#define		ISTREAM					INPUT->istream
139#define		INDEX()					ISTREAM->index(ISTREAM)
140#define		SEEK(n)					ISTREAM->seek(ISTREAM, n)
141#define	    EOF_TOKEN				&(LEXSTATE->tokSource->eofToken)
142#define	    HASEXCEPTION()			(LEXSTATE->error == ANTLR3_TRUE)
143#define	    EXCEPTION				LEXSTATE->exception
144#define	    CONSTRUCTEX()			RECOGNIZER->exConstruct(RECOGNIZER)
145#define	    LRECOVER()				LEXER->recover(LEXER)
146#define	    MARK()					ISTREAM->mark(ISTREAM)
147#define	    REWIND(m)				ISTREAM->rewind(ISTREAM, m)
148#define	    REWINDLAST()			ISTREAM->rewindLast(ISTREAM)
149#define		MEMOIZE(ri,si)			RECOGNIZER->memoize(RECOGNIZER, ri, si)
150#define		HAVEPARSEDRULE(r)		RECOGNIZER->alreadyParsedRule(RECOGNIZER, r)
151#define		PUSHSTREAM(str)			LEXER->pushCharStream(LEXER, str)
152#define		POPSTREAM()				LEXER->popCharStream(LEXER)
153#define		SETTEXT(str)			LEXSTATE->text = str
154#define		SKIP()					LEXSTATE->token = &(TOKSOURCE->skipToken)
155#define		USER1					LEXSTATE->user1
156#define		USER2					LEXSTATE->user2
157#define		USER3					LEXSTATE->user3
158#define		CUSTOM					LEXSTATE->custom
159#define		RULEMEMO				LEXSTATE->ruleMemo
160#define		DBG						RECOGNIZER->debugger
161
162/* If we have been told we can rely on the standard 8 bit or 16 bit input
163 * stream, then we can define our macros to use the direct pointers
164 * in the input object, which is much faster than indirect calls. This
165 * is really only significant to lexers with a lot of fragment rules (which
166 * do not place LA(1) in a temporary at the moment) and even then
167 * only if there is a lot of input (order of say 1M or so).
168 */
169#if	defined(ANTLR3_INLINE_INPUT_ASCII) || defined(ANTLR3_INLINE_INPUT_UTF16)
170
171# ifdef	ANTLR3_INLINE_INPUT_ASCII
172
173/* 8 bit "ASCII" (actually any 8 bit character set) */
174
175#  define	    NEXTCHAR			((pANTLR3_UINT8)(INPUT->nextChar))
176#  define	    DATAP				((pANTLR3_UINT8)(INPUT->data))
177
178# else
179
180#  define	    NEXTCHAR			((pANTLR3_UINT16)(INPUT->nextChar))
181#  define	    DATAP				((pANTLR3_UINT16)(INPUT->data))
182
183# endif
184
185# define	    LA(n) ((NEXTCHAR + n) > (DATAP + INPUT->sizeBuf) ? ANTLR3_CHARSTREAM_EOF : (ANTLR3_UCHAR)(*(NEXTCHAR + n - 1)))
186# define	    CONSUME()											\
187{																	\
188    if	(NEXTCHAR < (DATAP + INPUT->sizeBuf))						\
189    {																\
190		INPUT->charPositionInLine++;								\
191		if  ((ANTLR3_UCHAR)(*NEXTCHAR) == INPUT->newlineChar)		\
192		{															\
193			INPUT->line++;											\
194			INPUT->charPositionInLine	= 0;						\
195			INPUT->currentLine		= (void *)(NEXTCHAR + 1);		\
196		}															\
197		INPUT->nextChar = (void *)(NEXTCHAR + 1);					\
198    }																\
199}
200
201#else
202
203// Pick up the input character by calling the input stream implementation.
204//
205#define	    CONSUME()				INPUT->istream->consume(INPUT->istream)
206#define	    LA(n)					INPUT->istream->_LA(INPUT->istream, n)
207
208#endif
209#define		TOKTEXT(tok, txt)				tok, (pANTLR3_UINT8)txt
210
211/* The 4 tokens defined below may well clash with your own #defines or token types. If so
212 * then for the present you must use different names for your defines as these are hard coded
213 * in the code generator. It would be better not to use such names internally, and maybe
214 * we can change this in a forthcoming release. I deliberately do not #undef these
215 * here as this will at least give you a redefined error somewhere if they clash.
216 */
217#define	    UP	    ANTLR3_TOKEN_UP
218#define	    DOWN    ANTLR3_TOKEN_DOWN
219#define	    EOR	    ANTLR3_TOKEN_EOR
220#define	    INVALID ANTLR3_TOKEN_INVALID
221
222
223/* =============================================================================
224 * Functions to create and destroy scopes. First come the rule scopes, followed
225 * by the global declared scopes.
226 */
227
228
229
230/* ============================================================================= */
231
232/* =============================================================================
233 * Start of recognizer
234 */
235
236
237/* Forward declare the locally static matching functions we have generated and any predicate functions.
238 */
239static ANTLR3_INLINE  void	mQUOTE    (pDAAPLexer ctx);
240static ANTLR3_INLINE  void	mLPAR    (pDAAPLexer ctx);
241static ANTLR3_INLINE  void	mRPAR    (pDAAPLexer ctx);
242static ANTLR3_INLINE  void	mOPAND    (pDAAPLexer ctx);
243static ANTLR3_INLINE  void	mOPOR    (pDAAPLexer ctx);
244static ANTLR3_INLINE  void	mNEWLINE    (pDAAPLexer ctx);
245static ANTLR3_INLINE  void	mSTR    (pDAAPLexer ctx);
246static ANTLR3_INLINE  void	mESCAPED    (pDAAPLexer ctx);
247static ANTLR3_INLINE  void	mTokens    (pDAAPLexer ctx);
248static void	DAAPLexerFree(pDAAPLexer ctx);
249
250/* =========================================================================
251 * Lexer matching rules end.
252 * =========================================================================
253 */
254
255
256
257static void
258DAAPLexerFree  (pDAAPLexer ctx)
259{
260    LEXER->free(LEXER);
261
262    ANTLR3_FREE(ctx);
263}
264
265/** \brief Name of the grammar file that generated this code
266 */
267static const char fileName[] = "DAAP.g";
268
269/** \brief Return the name of the grammar file that generated this code.
270 */
271static const char * getGrammarFileName()
272{
273	return fileName;
274}
275
276/** \brief Create a new lexer called DAAPLexer
277 *
278 * \param[in]    instream Pointer to an initialized input stream
279 * \return
280 *     - Success pDAAPLexer initialized for the lex start
281 *     - Fail NULL
282 */
283ANTLR3_API pDAAPLexer DAAPLexerNew
284(pANTLR3_INPUT_STREAM instream)
285{
286	// See if we can create a new lexer with the standard constructor
287	//
288	return DAAPLexerNewSSD(instream, NULL);
289}
290
291/** \brief Create a new lexer called DAAPLexer
292 *
293 * \param[in]    instream Pointer to an initialized input stream
294 * \param[state] state Previously created shared recognizer stat
295 * \return
296 *     - Success pDAAPLexer initialized for the lex start
297 *     - Fail NULL
298 */
299ANTLR3_API pDAAPLexer DAAPLexerNewSSD
300(pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state)
301{
302    pDAAPLexer ctx; // Context structure we will build and return
303
304    ctx = (pDAAPLexer) ANTLR3_CALLOC(1, sizeof(DAAPLexer));
305
306    if  (ctx == NULL)
307    {
308        // Failed to allocate memory for lexer context
309        return  NULL;
310    }
311
312    /* -------------------------------------------------------------------
313     * Memory for basic structure is allocated, now to fill in
314     * in base ANTLR3 structures. We initialize the function pointers
315     * for the standard ANTLR3 lexer function set, but upon return
316     * from here, the programmer may set the pointers to provide custom
317     * implementations of each function.
318     *
319     * We don't use the macros defined in DAAPLexer.h here so you can get a sense
320     * of what goes where.
321     */
322
323    /* Create a base lexer, using the supplied input stream
324     */
325    ctx->pLexer	= antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state);
326
327    /* Check that we allocated the memory correctly
328     */
329    if	(ctx->pLexer == NULL)
330    {
331		ANTLR3_FREE(ctx);
332		return  NULL;
333    }
334    /* Install the implementation of our DAAPLexer interface
335     */
336    ctx->mQUOTE	= mQUOTE;
337    ctx->mLPAR	= mLPAR;
338    ctx->mRPAR	= mRPAR;
339    ctx->mOPAND	= mOPAND;
340    ctx->mOPOR	= mOPOR;
341    ctx->mNEWLINE	= mNEWLINE;
342    ctx->mSTR	= mSTR;
343    ctx->mESCAPED	= mESCAPED;
344    ctx->mTokens	= mTokens;
345
346    /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE
347     *  it will call mTokens() in this generated code, and will pass it the ctx
348     * pointer of this lexer, not the context of the base lexer, so store that now.
349     */
350    ctx->pLexer->ctx	    = ctx;
351
352    /**Install the token matching function
353     */
354    ctx->pLexer->mTokens = (void (*) (void *))(mTokens);
355
356    ctx->getGrammarFileName	= getGrammarFileName;
357    ctx->free		= DAAPLexerFree;
358
359
360
361
362
363    /* Return the newly built lexer to the caller
364     */
365    return  ctx;
366}
367
368
369/* =========================================================================
370 * Functions to match the lexer grammar defined tokens from the input stream
371 */
372
373//   Comes from: 40:7: ( '\\'' )
374/** \brief Lexer rule generated by ANTLR3
375 *
376 * $ANTLR start QUOTE
377 *
378 * Looks to match the characters the constitute the token QUOTE
379 * from the attached input stream.
380 *
381 *
382 * \remark
383 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
384 */
385static ANTLR3_INLINE
386void mQUOTE(pDAAPLexer ctx)
387{
388	ANTLR3_UINT32	_type;
389
390    _type	    = QUOTE;
391
392
393    // DAAP.g:40:7: ( '\\'' )
394    // DAAP.g:40:9: '\\''
395    {
396        MATCHC('\'');
397        if  (HASEXCEPTION())
398        {
399            goto ruleQUOTEEx;
400        }
401
402
403    }
404
405	LEXSTATE->type = _type;
406
407    // This is where rules clean up and exit
408    //
409    goto ruleQUOTEEx; /* Prevent compiler warnings */
410    ruleQUOTEEx: ;
411
412}
413// $ANTLR end QUOTE
414
415//   Comes from: 41:6: ( '(' )
416/** \brief Lexer rule generated by ANTLR3
417 *
418 * $ANTLR start LPAR
419 *
420 * Looks to match the characters the constitute the token LPAR
421 * from the attached input stream.
422 *
423 *
424 * \remark
425 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
426 */
427static ANTLR3_INLINE
428void mLPAR(pDAAPLexer ctx)
429{
430	ANTLR3_UINT32	_type;
431
432    _type	    = LPAR;
433
434
435    // DAAP.g:41:6: ( '(' )
436    // DAAP.g:41:8: '('
437    {
438        MATCHC('(');
439        if  (HASEXCEPTION())
440        {
441            goto ruleLPAREx;
442        }
443
444
445    }
446
447	LEXSTATE->type = _type;
448
449    // This is where rules clean up and exit
450    //
451    goto ruleLPAREx; /* Prevent compiler warnings */
452    ruleLPAREx: ;
453
454}
455// $ANTLR end LPAR
456
457//   Comes from: 42:6: ( ')' )
458/** \brief Lexer rule generated by ANTLR3
459 *
460 * $ANTLR start RPAR
461 *
462 * Looks to match the characters the constitute the token RPAR
463 * from the attached input stream.
464 *
465 *
466 * \remark
467 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
468 */
469static ANTLR3_INLINE
470void mRPAR(pDAAPLexer ctx)
471{
472	ANTLR3_UINT32	_type;
473
474    _type	    = RPAR;
475
476
477    // DAAP.g:42:6: ( ')' )
478    // DAAP.g:42:8: ')'
479    {
480        MATCHC(')');
481        if  (HASEXCEPTION())
482        {
483            goto ruleRPAREx;
484        }
485
486
487    }
488
489	LEXSTATE->type = _type;
490
491    // This is where rules clean up and exit
492    //
493    goto ruleRPAREx; /* Prevent compiler warnings */
494    ruleRPAREx: ;
495
496}
497// $ANTLR end RPAR
498
499//   Comes from: 44:7: ( '+' )
500/** \brief Lexer rule generated by ANTLR3
501 *
502 * $ANTLR start OPAND
503 *
504 * Looks to match the characters the constitute the token OPAND
505 * from the attached input stream.
506 *
507 *
508 * \remark
509 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
510 */
511static ANTLR3_INLINE
512void mOPAND(pDAAPLexer ctx)
513{
514	ANTLR3_UINT32	_type;
515
516    _type	    = OPAND;
517
518
519    // DAAP.g:44:7: ( '+' )
520    // DAAP.g:44:9: '+'
521    {
522        MATCHC('+');
523        if  (HASEXCEPTION())
524        {
525            goto ruleOPANDEx;
526        }
527
528
529    }
530
531	LEXSTATE->type = _type;
532
533    // This is where rules clean up and exit
534    //
535    goto ruleOPANDEx; /* Prevent compiler warnings */
536    ruleOPANDEx: ;
537
538}
539// $ANTLR end OPAND
540
541//   Comes from: 45:6: ( ',' )
542/** \brief Lexer rule generated by ANTLR3
543 *
544 * $ANTLR start OPOR
545 *
546 * Looks to match the characters the constitute the token OPOR
547 * from the attached input stream.
548 *
549 *
550 * \remark
551 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
552 */
553static ANTLR3_INLINE
554void mOPOR(pDAAPLexer ctx)
555{
556	ANTLR3_UINT32	_type;
557
558    _type	    = OPOR;
559
560
561    // DAAP.g:45:6: ( ',' )
562    // DAAP.g:45:8: ','
563    {
564        MATCHC(',');
565        if  (HASEXCEPTION())
566        {
567            goto ruleOPOREx;
568        }
569
570
571    }
572
573	LEXSTATE->type = _type;
574
575    // This is where rules clean up and exit
576    //
577    goto ruleOPOREx; /* Prevent compiler warnings */
578    ruleOPOREx: ;
579
580}
581// $ANTLR end OPOR
582
583//   Comes from: 47:9: ( ( '\\r' )? '\\n' )
584/** \brief Lexer rule generated by ANTLR3
585 *
586 * $ANTLR start NEWLINE
587 *
588 * Looks to match the characters the constitute the token NEWLINE
589 * from the attached input stream.
590 *
591 *
592 * \remark
593 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
594 */
595static ANTLR3_INLINE
596void mNEWLINE(pDAAPLexer ctx)
597{
598	ANTLR3_UINT32	_type;
599
600    _type	    = NEWLINE;
601
602
603    // DAAP.g:47:9: ( ( '\\r' )? '\\n' )
604    // DAAP.g:47:11: ( '\\r' )? '\\n'
605    {
606
607        // DAAP.g:47:11: ( '\\r' )?
608        {
609            int alt1=2;
610            switch ( LA(1) )
611            {
612                case '\r':
613                	{
614                		alt1=1;
615                	}
616                    break;
617            }
618
619            switch (alt1)
620            {
621        	case 1:
622        	    // DAAP.g:47:11: '\\r'
623        	    {
624        	        MATCHC('\r');
625        	        if  (HASEXCEPTION())
626        	        {
627        	            goto ruleNEWLINEEx;
628        	        }
629
630
631        	    }
632        	    break;
633
634            }
635        }
636        MATCHC('\n');
637        if  (HASEXCEPTION())
638        {
639            goto ruleNEWLINEEx;
640        }
641
642
643    }
644
645	LEXSTATE->type = _type;
646
647    // This is where rules clean up and exit
648    //
649    goto ruleNEWLINEEx; /* Prevent compiler warnings */
650    ruleNEWLINEEx: ;
651
652}
653// $ANTLR end NEWLINE
654
655//   Comes from: 55:2: ( QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE )
656/** \brief Lexer rule generated by ANTLR3
657 *
658 * $ANTLR start STR
659 *
660 * Looks to match the characters the constitute the token STR
661 * from the attached input stream.
662 *
663 *
664 * \remark
665 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
666 */
667static ANTLR3_INLINE
668void mSTR(pDAAPLexer ctx)
669{
670	ANTLR3_UINT32	_type;
671    pANTLR3_COMMON_TOKEN esc;
672    ANTLR3_UINT32 reg;
673
674
675    esc = NULL;
676
677    _type	    = STR;
678
679     pANTLR3_STRING unesc = GETTEXT()->factory->newRaw(GETTEXT()->factory);
680
681    // DAAP.g:55:2: ( QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE )
682    // DAAP.g:55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE
683    {
684        /* 55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE */
685        mQUOTE(ctx );
686        if  (HASEXCEPTION())
687        {
688            goto ruleSTREx;
689        }
690
691        // DAAP.g:55:10: (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+
692        {
693            int cnt2=0;
694
695            for (;;)
696            {
697                int alt2=3;
698        	{
699        	   /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState)
700        	    */
701        	    int LA2_0 = LA(1);
702        	    if ( (((LA2_0 >= 0x0000) && (LA2_0 <= '&')) || ((LA2_0 >= '(') && (LA2_0 <= '[')) || ((LA2_0 >= ']') && (LA2_0 <= 0xFFFF))) )
703        	    {
704        	        alt2=1;
705        	    }
706        	    else if ( (LA2_0 == '\\') )
707        	    {
708        	        alt2=2;
709        	    }
710
711        	}
712        	switch (alt2)
713        	{
714        	    case 1:
715        	        // DAAP.g:55:12: reg=~ ( '\\\\' | '\\'' )
716        	        {
717        	            reg= LA(1);
718        	            if ( ((LA(1) >= 0x0000) && (LA(1) <= '&')) || ((LA(1) >= '(') && (LA(1) <= '[')) || ((LA(1) >= ']') && (LA(1) <= 0xFFFF)) )
719        	            {
720        	                CONSUME();
721
722        	            }
723        	            else
724        	            {
725        	                CONSTRUCTEX();
726        	                EXCEPTION->type         = ANTLR3_MISMATCHED_SET_EXCEPTION;
727        	                EXCEPTION->name         = (void *)ANTLR3_MISMATCHED_SET_NAME;
728
729        	                LRECOVER();    goto ruleSTREx;
730        	            }
731
732        	            {
733        	                 unesc->addc(unesc, reg);
734        	            }
735
736        	        }
737        	        break;
738        	    case 2:
739        	        // DAAP.g:56:6: esc= ESCAPED
740        	        {
741        	            /* 56:6: esc= ESCAPED */
742        	            {
743        	                ANTLR3_MARKER escStart114 = GETCHARINDEX();
744        	            mESCAPED(ctx );
745        	                if  (HASEXCEPTION())
746        	                {
747        	                    goto ruleSTREx;
748        	                }
749
750        	                esc = LEXSTATE->tokFactory->newToken(LEXSTATE->tokFactory);
751        	                esc->setType(esc, ANTLR3_TOKEN_INVALID);
752        	                esc->setStartIndex(esc, escStart114);
753        	                esc->setStopIndex(esc, GETCHARINDEX()-1);
754        	                esc->input = INPUT;
755        	            }
756        	            {
757        	                 unesc->appendS(unesc, GETTEXT());
758        	            }
759
760        	        }
761        	        break;
762
763        	    default:
764
765        		if ( cnt2 >= 1 )
766        		{
767        		    goto loop2;
768        		}
769        		/* mismatchedSetEx()
770        		 */
771        		CONSTRUCTEX();
772        		EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION;
773        		EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME;
774
775
776        		goto ruleSTREx;
777        	}
778        	cnt2++;
779            }
780            loop2: ;	/* Jump to here if this rule does not match */
781        }
782        /* 55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE */
783        mQUOTE(ctx );
784        if  (HASEXCEPTION())
785        {
786            goto ruleSTREx;
787        }
788
789        {
790             SETTEXT(unesc);
791        }
792
793    }
794
795	LEXSTATE->type = _type;
796
797    // This is where rules clean up and exit
798    //
799    goto ruleSTREx; /* Prevent compiler warnings */
800    ruleSTREx: ;
801
802    esc = NULL;
803
804}
805// $ANTLR end STR
806
807//   Comes from: 59:9: ( '\\\\' ( '\\\\' | '\\'' ) )
808/** \brief Lexer rule generated by ANTLR3
809 *
810 * $ANTLR start ESCAPED
811 *
812 * Looks to match the characters the constitute the token ESCAPED
813 * from the attached input stream.
814 *
815 *
816 * \remark
817 *  - lexer->error == ANTLR3_TRUE if an exception was thrown.
818 */
819static ANTLR3_INLINE
820void mESCAPED(pDAAPLexer ctx)
821{
822	ANTLR3_UINT32	_type;
823
824
825    // DAAP.g:59:9: ( '\\\\' ( '\\\\' | '\\'' ) )
826    // DAAP.g:59:11: '\\\\' ( '\\\\' | '\\'' )
827    {
828        MATCHC('\\');
829        if  (HASEXCEPTION())
830        {
831            goto ruleESCAPEDEx;
832        }
833
834
835        // DAAP.g:60:3: ( '\\\\' | '\\'' )
836        {
837            int alt3=2;
838            switch ( LA(1) )
839            {
840            case '\\':
841            	{
842            		alt3=1;
843            	}
844                break;
845            case '\'':
846            	{
847            		alt3=2;
848            	}
849                break;
850
851            default:
852                CONSTRUCTEX();
853                EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
854                EXCEPTION->message      = (void *)"";
855                EXCEPTION->decisionNum  = 3;
856                EXCEPTION->state        = 0;
857
858
859                goto ruleESCAPEDEx;
860            }
861
862            switch (alt3)
863            {
864        	case 1:
865        	    // DAAP.g:60:5: '\\\\'
866        	    {
867        	        MATCHC('\\');
868        	        if  (HASEXCEPTION())
869        	        {
870        	            goto ruleESCAPEDEx;
871        	        }
872
873        	        {
874        	             SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\\"));
875        	        }
876
877        	    }
878        	    break;
879        	case 2:
880        	    // DAAP.g:61:5: '\\''
881        	    {
882        	        MATCHC('\'');
883        	        if  (HASEXCEPTION())
884        	        {
885        	            goto ruleESCAPEDEx;
886        	        }
887
888        	        {
889        	             SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\'"));
890        	        }
891
892        	    }
893        	    break;
894
895            }
896        }
897
898    }
899
900
901
902    // This is where rules clean up and exit
903    //
904    goto ruleESCAPEDEx; /* Prevent compiler warnings */
905    ruleESCAPEDEx: ;
906
907}
908// $ANTLR end ESCAPED
909
910/** This is the entry point in to the lexer from an object that
911 *  wants to generate the next token, such as a pCOMMON_TOKEN_STREAM
912 */
913static void
914mTokens(pDAAPLexer ctx)
915{
916    {
917        //  DAAP.g:1:8: ( QUOTE | LPAR | RPAR | OPAND | OPOR | NEWLINE | STR )
918
919        ANTLR3_UINT32 alt4;
920
921        alt4=7;
922
923        switch ( LA(1) )
924        {
925        case '\'':
926        	{
927
928        		{
929        		    int LA4_1 = LA(2);
930        		    if ( (((LA4_1 >= 0x0000) && (LA4_1 <= '&')) || ((LA4_1 >= '(') && (LA4_1 <= 0xFFFF))) )
931        		    {
932        		        alt4=7;
933        		    }
934        		    else
935        		    {
936        		        alt4=1;    }
937        		}
938        	}
939            break;
940        case '(':
941        	{
942        		alt4=2;
943        	}
944            break;
945        case ')':
946        	{
947        		alt4=3;
948        	}
949            break;
950        case '+':
951        	{
952        		alt4=4;
953        	}
954            break;
955        case ',':
956        	{
957        		alt4=5;
958        	}
959            break;
960        case '\n':
961        case '\r':
962        	{
963        		alt4=6;
964        	}
965            break;
966
967        default:
968            CONSTRUCTEX();
969            EXCEPTION->type         = ANTLR3_NO_VIABLE_ALT_EXCEPTION;
970            EXCEPTION->message      = (void *)"";
971            EXCEPTION->decisionNum  = 4;
972            EXCEPTION->state        = 0;
973
974
975            goto ruleTokensEx;
976        }
977
978        switch (alt4)
979        {
980    	case 1:
981    	    // DAAP.g:1:10: QUOTE
982    	    {
983    	        /* 1:10: QUOTE */
984    	        mQUOTE(ctx );
985    	        if  (HASEXCEPTION())
986    	        {
987    	            goto ruleTokensEx;
988    	        }
989
990
991    	    }
992    	    break;
993    	case 2:
994    	    // DAAP.g:1:16: LPAR
995    	    {
996    	        /* 1:16: LPAR */
997    	        mLPAR(ctx );
998    	        if  (HASEXCEPTION())
999    	        {
1000    	            goto ruleTokensEx;
1001    	        }
1002
1003
1004    	    }
1005    	    break;
1006    	case 3:
1007    	    // DAAP.g:1:21: RPAR
1008    	    {
1009    	        /* 1:21: RPAR */
1010    	        mRPAR(ctx );
1011    	        if  (HASEXCEPTION())
1012    	        {
1013    	            goto ruleTokensEx;
1014    	        }
1015
1016
1017    	    }
1018    	    break;
1019    	case 4:
1020    	    // DAAP.g:1:26: OPAND
1021    	    {
1022    	        /* 1:26: OPAND */
1023    	        mOPAND(ctx );
1024    	        if  (HASEXCEPTION())
1025    	        {
1026    	            goto ruleTokensEx;
1027    	        }
1028
1029
1030    	    }
1031    	    break;
1032    	case 5:
1033    	    // DAAP.g:1:32: OPOR
1034    	    {
1035    	        /* 1:32: OPOR */
1036    	        mOPOR(ctx );
1037    	        if  (HASEXCEPTION())
1038    	        {
1039    	            goto ruleTokensEx;
1040    	        }
1041
1042
1043    	    }
1044    	    break;
1045    	case 6:
1046    	    // DAAP.g:1:37: NEWLINE
1047    	    {
1048    	        /* 1:37: NEWLINE */
1049    	        mNEWLINE(ctx );
1050    	        if  (HASEXCEPTION())
1051    	        {
1052    	            goto ruleTokensEx;
1053    	        }
1054
1055
1056    	    }
1057    	    break;
1058    	case 7:
1059    	    // DAAP.g:1:45: STR
1060    	    {
1061    	        /* 1:45: STR */
1062    	        mSTR(ctx );
1063    	        if  (HASEXCEPTION())
1064    	        {
1065    	            goto ruleTokensEx;
1066    	        }
1067
1068
1069    	    }
1070    	    break;
1071
1072        }
1073    }
1074
1075
1076    goto ruleTokensEx; /* Prevent compiler warnings */
1077ruleTokensEx: ;
1078}
1079
1080/* =========================================================================
1081 * Lexer matching rules end.
1082 * =========================================================================
1083 */
1084/* End of Lexer code
1085 * ================================================
1086 * ================================================
1087 */
1088
1089
1090/* End of code
1091 * =============================================================================
1092 */
1093