]> arthur.barton.de Git - netatalk.git/blob - etc/spotlight/slmod_tracker_0_6_parser.c
Add support for Tracker 0.67 on Solaris
[netatalk.git] / etc / spotlight / slmod_tracker_0_6_parser.c
1 /* A Bison parser, made by GNU Bison 2.7.  */
2
3 /* Bison implementation for Yacc-like parsers in C
4    
5       Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
6    
7    This program is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20 /* As a special exception, you may create a larger work that contains
21    part or all of the Bison parser skeleton and distribute that work
22    under terms of your choice, so long as that work isn't itself a
23    parser generator using the skeleton or a modified version thereof
24    as a parser skeleton.  Alternatively, if you modify or redistribute
25    the parser skeleton itself, you may (at your option) remove this
26    special exception, which will cause the skeleton and the resulting
27    Bison output files to be licensed under the GNU General Public
28    License without this special exception.
29    
30    This special exception was added by the Free Software Foundation in
31    version 2.2 of Bison.  */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34    simplifying the original so-called "semantic" parser.  */
35
36 /* All symbols defined below should begin with yy or YY, to avoid
37    infringing on user name space.  This should be done even for local
38    variables, as they might otherwise be expanded by user macros.
39    There are some unavoidable exceptions within include files to
40    define necessary library symbols; they are noted "INFRINGES ON
41    USER NAME SPACE" below.  */
42
43 /* Identify Bison output.  */
44 #define YYBISON 1
45
46 /* Bison version.  */
47 #define YYBISON_VERSION "2.7"
48
49 /* Skeleton name.  */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers.  */
53 #define YYPURE 0
54
55 /* Push parsers.  */
56 #define YYPUSH 0
57
58 /* Pull parsers.  */
59 #define YYPULL 1
60
61 /* "%code top" blocks.  */
62 /* Line 349 of yacc.c  */
63 #line 1 "slmod_tracker_0_6_parser.y"
64
65   #include <atalk/standards.h>
66
67   #include <stdbool.h>
68   #include <stdio.h>
69   #include <string.h>
70   #include <time.h>
71
72   #include <gio/gio.h>
73   #include <tracker.h>
74
75   #include <atalk/talloc.h>
76   #include <atalk/logger.h>
77   #include <atalk/errchk.h>
78   #include <atalk/spotlight.h>
79
80   #include "slmod_tracker_0_6_map.h"
81
82   struct yy_buffer_state;
83   typedef struct yy_buffer_state *YY_BUFFER_STATE;
84   extern int yylex (void);
85   extern void yyerror (char const *);
86   extern void *yyterminate(void);
87   extern YY_BUFFER_STATE yy_scan_string( const char *str);
88   extern void yy_delete_buffer ( YY_BUFFER_STATE buffer );
89
90   /* forward declarations */
91   static char *map_expr(const char *attr, char op, const char *val);
92   static time_t isodate2unix(const char *s);
93  
94  /* global vars, eg needed by the lexer */
95   slq_t *ts_slq;
96
97   /* local vars */
98   static ServiceType ts_type;   /* Tracker query object type */
99   static gchar *ts_search;      /* Tracker query search term */
100
101
102 /* Line 349 of yacc.c  */
103 #line 104 "slmod_tracker_0_6_parser.c"
104
105
106
107 /* Copy the first part of user declarations.  */
108
109 /* Line 371 of yacc.c  */
110 #line 111 "slmod_tracker_0_6_parser.c"
111
112 # ifndef YY_NULL
113 #  if defined __cplusplus && 201103L <= __cplusplus
114 #   define YY_NULL nullptr
115 #  else
116 #   define YY_NULL 0
117 #  endif
118 # endif
119
120 /* Enabling verbose error messages.  */
121 #ifdef YYERROR_VERBOSE
122 # undef YYERROR_VERBOSE
123 # define YYERROR_VERBOSE 1
124 #else
125 # define YYERROR_VERBOSE 1
126 #endif
127
128 /* In a future release of Bison, this section will be replaced
129    by #include "y.tab.h".  */
130 #ifndef YY_YY_Y_TAB_H_INCLUDED
131 # define YY_YY_Y_TAB_H_INCLUDED
132 /* Enabling traces.  */
133 #ifndef YYDEBUG
134 # define YYDEBUG 0
135 #endif
136 #if YYDEBUG
137 extern int yydebug;
138 #endif
139
140 /* Tokens.  */
141 #ifndef YYTOKENTYPE
142 # define YYTOKENTYPE
143    /* Put the tokens into the symbol table, so that GDB and other debuggers
144       know about them.  */
145    enum yytokentype {
146      WORD = 258,
147      BOOL = 259,
148      FUNC_INRANGE = 260,
149      DATE_ISO = 261,
150      OBRACE = 262,
151      CBRACE = 263,
152      EQUAL = 264,
153      UNEQUAL = 265,
154      GT = 266,
155      LT = 267,
156      COMMA = 268,
157      QUOTE = 269,
158      AND = 270,
159      OR = 271
160    };
161 #endif
162 /* Tokens.  */
163 #define WORD 258
164 #define BOOL 259
165 #define FUNC_INRANGE 260
166 #define DATE_ISO 261
167 #define OBRACE 262
168 #define CBRACE 263
169 #define EQUAL 264
170 #define UNEQUAL 265
171 #define GT 266
172 #define LT 267
173 #define COMMA 268
174 #define QUOTE 269
175 #define AND 270
176 #define OR 271
177
178
179
180 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
181 typedef union YYSTYPE
182 {
183 /* Line 387 of yacc.c  */
184 #line 45 "slmod_tracker_0_6_parser.y"
185
186     int ival;
187     char *sval;
188     bool bval;
189     time_t tval;
190
191
192 /* Line 387 of yacc.c  */
193 #line 194 "slmod_tracker_0_6_parser.c"
194 } YYSTYPE;
195 # define YYSTYPE_IS_TRIVIAL 1
196 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
197 # define YYSTYPE_IS_DECLARED 1
198 #endif
199
200 extern YYSTYPE yylval;
201
202 #ifdef YYPARSE_PARAM
203 #if defined __STDC__ || defined __cplusplus
204 int yyparse (void *YYPARSE_PARAM);
205 #else
206 int yyparse ();
207 #endif
208 #else /* ! YYPARSE_PARAM */
209 #if defined __STDC__ || defined __cplusplus
210 int yyparse (void);
211 #else
212 int yyparse ();
213 #endif
214 #endif /* ! YYPARSE_PARAM */
215 /* "%code provides" blocks.  */
216 /* Line 387 of yacc.c  */
217 #line 39 "slmod_tracker_0_6_parser.y"
218
219   #define SPRAW_TIME_OFFSET 978307200
220   extern int map_spotlight_to_tracker_0_6_query(slq_t *slq, ServiceType *type, gchar **search);
221   extern slq_t *ts_slq;
222
223
224 /* Line 387 of yacc.c  */
225 #line 226 "slmod_tracker_0_6_parser.c"
226
227 #endif /* !YY_YY_Y_TAB_H_INCLUDED  */
228
229 /* Copy the second part of user declarations.  */
230
231 /* Line 390 of yacc.c  */
232 #line 233 "slmod_tracker_0_6_parser.c"
233
234 #ifdef short
235 # undef short
236 #endif
237
238 #ifdef YYTYPE_UINT8
239 typedef YYTYPE_UINT8 yytype_uint8;
240 #else
241 typedef unsigned char yytype_uint8;
242 #endif
243
244 #ifdef YYTYPE_INT8
245 typedef YYTYPE_INT8 yytype_int8;
246 #elif (defined __STDC__ || defined __C99__FUNC__ \
247      || defined __cplusplus || defined _MSC_VER)
248 typedef signed char yytype_int8;
249 #else
250 typedef short int yytype_int8;
251 #endif
252
253 #ifdef YYTYPE_UINT16
254 typedef YYTYPE_UINT16 yytype_uint16;
255 #else
256 typedef unsigned short int yytype_uint16;
257 #endif
258
259 #ifdef YYTYPE_INT16
260 typedef YYTYPE_INT16 yytype_int16;
261 #else
262 typedef short int yytype_int16;
263 #endif
264
265 #ifndef YYSIZE_T
266 # ifdef __SIZE_TYPE__
267 #  define YYSIZE_T __SIZE_TYPE__
268 # elif defined size_t
269 #  define YYSIZE_T size_t
270 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
271      || defined __cplusplus || defined _MSC_VER)
272 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
273 #  define YYSIZE_T size_t
274 # else
275 #  define YYSIZE_T unsigned int
276 # endif
277 #endif
278
279 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
280
281 #ifndef YY_
282 # if defined YYENABLE_NLS && YYENABLE_NLS
283 #  if ENABLE_NLS
284 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
285 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
286 #  endif
287 # endif
288 # ifndef YY_
289 #  define YY_(Msgid) Msgid
290 # endif
291 #endif
292
293 /* Suppress unused-variable warnings by "using" E.  */
294 #if ! defined lint || defined __GNUC__
295 # define YYUSE(E) ((void) (E))
296 #else
297 # define YYUSE(E) /* empty */
298 #endif
299
300 /* Identity function, used to suppress warnings about constant conditions.  */
301 #ifndef lint
302 # define YYID(N) (N)
303 #else
304 #if (defined __STDC__ || defined __C99__FUNC__ \
305      || defined __cplusplus || defined _MSC_VER)
306 static int
307 YYID (int yyi)
308 #else
309 static int
310 YYID (yyi)
311     int yyi;
312 #endif
313 {
314   return yyi;
315 }
316 #endif
317
318 #if ! defined yyoverflow || YYERROR_VERBOSE
319
320 /* The parser invokes alloca or malloc; define the necessary symbols.  */
321
322 # ifdef YYSTACK_USE_ALLOCA
323 #  if YYSTACK_USE_ALLOCA
324 #   ifdef __GNUC__
325 #    define YYSTACK_ALLOC __builtin_alloca
326 #   elif defined __BUILTIN_VA_ARG_INCR
327 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
328 #   elif defined _AIX
329 #    define YYSTACK_ALLOC __alloca
330 #   elif defined _MSC_VER
331 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
332 #    define alloca _alloca
333 #   else
334 #    define YYSTACK_ALLOC alloca
335 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
336      || defined __cplusplus || defined _MSC_VER)
337 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
338       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
339 #     ifndef EXIT_SUCCESS
340 #      define EXIT_SUCCESS 0
341 #     endif
342 #    endif
343 #   endif
344 #  endif
345 # endif
346
347 # ifdef YYSTACK_ALLOC
348    /* Pacify GCC's `empty if-body' warning.  */
349 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
350 #  ifndef YYSTACK_ALLOC_MAXIMUM
351     /* The OS might guarantee only one guard page at the bottom of the stack,
352        and a page size can be as small as 4096 bytes.  So we cannot safely
353        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
354        to allow for a few compiler-allocated temporary stack slots.  */
355 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
356 #  endif
357 # else
358 #  define YYSTACK_ALLOC YYMALLOC
359 #  define YYSTACK_FREE YYFREE
360 #  ifndef YYSTACK_ALLOC_MAXIMUM
361 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
362 #  endif
363 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
364        && ! ((defined YYMALLOC || defined malloc) \
365              && (defined YYFREE || defined free)))
366 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
367 #   ifndef EXIT_SUCCESS
368 #    define EXIT_SUCCESS 0
369 #   endif
370 #  endif
371 #  ifndef YYMALLOC
372 #   define YYMALLOC malloc
373 #   if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
374      || defined __cplusplus || defined _MSC_VER)
375 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
376 #   endif
377 #  endif
378 #  ifndef YYFREE
379 #   define YYFREE free
380 #   if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
381      || defined __cplusplus || defined _MSC_VER)
382 void free (void *); /* INFRINGES ON USER NAME SPACE */
383 #   endif
384 #  endif
385 # endif
386 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
387
388
389 #if (! defined yyoverflow \
390      && (! defined __cplusplus \
391          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
392
393 /* A type that is properly aligned for any stack member.  */
394 union yyalloc
395 {
396   yytype_int16 yyss_alloc;
397   YYSTYPE yyvs_alloc;
398 };
399
400 /* The size of the maximum gap between one aligned stack and the next.  */
401 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
402
403 /* The size of an array large to enough to hold all stacks, each with
404    N elements.  */
405 # define YYSTACK_BYTES(N) \
406      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
407       + YYSTACK_GAP_MAXIMUM)
408
409 # define YYCOPY_NEEDED 1
410
411 /* Relocate STACK from its old location to the new one.  The
412    local variables YYSIZE and YYSTACKSIZE give the old and new number of
413    elements in the stack, and YYPTR gives the new location of the
414    stack.  Advance YYPTR to a properly aligned location for the next
415    stack.  */
416 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
417     do                                                                  \
418       {                                                                 \
419         YYSIZE_T yynewbytes;                                            \
420         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
421         Stack = &yyptr->Stack_alloc;                                    \
422         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
423         yyptr += yynewbytes / sizeof (*yyptr);                          \
424       }                                                                 \
425     while (YYID (0))
426
427 #endif
428
429 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
430 /* Copy COUNT objects from SRC to DST.  The source and destination do
431    not overlap.  */
432 # ifndef YYCOPY
433 #  if defined __GNUC__ && 1 < __GNUC__
434 #   define YYCOPY(Dst, Src, Count) \
435       __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
436 #  else
437 #   define YYCOPY(Dst, Src, Count)              \
438       do                                        \
439         {                                       \
440           YYSIZE_T yyi;                         \
441           for (yyi = 0; yyi < (Count); yyi++)   \
442             (Dst)[yyi] = (Src)[yyi];            \
443         }                                       \
444       while (YYID (0))
445 #  endif
446 # endif
447 #endif /* !YYCOPY_NEEDED */
448
449 /* YYFINAL -- State number of the termination state.  */
450 #define YYFINAL  2
451 /* YYLAST -- Last index in YYTABLE.  */
452 #define YYLAST   52
453
454 /* YYNTOKENS -- Number of terminals.  */
455 #define YYNTOKENS  17
456 /* YYNNTS -- Number of nonterminals.  */
457 #define YYNNTS  7
458 /* YYNRULES -- Number of rules.  */
459 #define YYNRULES  22
460 /* YYNRULES -- Number of states.  */
461 #define YYNSTATES  51
462
463 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
464 #define YYUNDEFTOK  2
465 #define YYMAXUTOK   271
466
467 #define YYTRANSLATE(YYX)                                                \
468   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
469
470 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
471 static const yytype_uint8 yytranslate[] =
472 {
473        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
474        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
475        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
476        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
477        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
478        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
479        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
480        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
481        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
482        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
483        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
484        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
485        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
486        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
487        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
488        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
489        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
490        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
491        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
492        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
493        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
494        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
495        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
496        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
497        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
498        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
499        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
500       15,    16
501 };
502
503 #if YYDEBUG
504 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
505    YYRHS.  */
506 static const yytype_uint8 yyprhs[] =
507 {
508        0,     0,     3,     4,     7,     9,    11,    15,    17,    19,
509       23,    27,    31,    37,    43,    49,    55,    62,    69,    76,
510       83,    92,    97
511 };
512
513 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
514 static const yytype_int8 yyrhs[] =
515 {
516       18,     0,    -1,    -1,    18,    19,    -1,    20,    -1,     4,
517       -1,    21,    16,    21,    -1,    21,    -1,    22,    -1,     7,
518       20,     8,    -1,    20,    15,    20,    -1,    20,    16,    20,
519       -1,     3,     9,    14,     3,    14,    -1,     3,    10,    14,
520        3,    14,    -1,     3,    12,    14,     3,    14,    -1,     3,
521       11,    14,     3,    14,    -1,     3,     9,    14,     3,    14,
522        3,    -1,     3,    10,    14,     3,    14,     3,    -1,     3,
523       12,    14,     3,    14,     3,    -1,     3,    11,    14,     3,
524       14,     3,    -1,     5,     7,     3,    13,    23,    13,    23,
525        8,    -1,     6,     7,     3,     8,    -1,     3,    -1
526 };
527
528 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
529 static const yytype_uint8 yyrline[] =
530 {
531        0,    67,    67,    69,    73,    80,    86,    92,    93,    94,
532       95,   103,   107,   108,   109,   110,   111,   112,   113,   114,
533      118,   122,   123
534 };
535 #endif
536
537 #if YYDEBUG || YYERROR_VERBOSE || 1
538 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
539    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
540 static const char *const yytname[] =
541 {
542   "$end", "error", "$undefined", "WORD", "BOOL", "FUNC_INRANGE",
543   "DATE_ISO", "OBRACE", "CBRACE", "EQUAL", "UNEQUAL", "GT", "LT", "COMMA",
544   "QUOTE", "AND", "OR", "$accept", "input", "line", "expr", "match",
545   "function", "date", YY_NULL
546 };
547 #endif
548
549 # ifdef YYPRINT
550 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
551    token YYLEX-NUM.  */
552 static const yytype_uint16 yytoknum[] =
553 {
554        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
555      265,   266,   267,   268,   269,   270,   271
556 };
557 # endif
558
559 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
560 static const yytype_uint8 yyr1[] =
561 {
562        0,    17,    18,    18,    19,    20,    20,    20,    20,    20,
563       20,    20,    21,    21,    21,    21,    21,    21,    21,    21,
564       22,    23,    23
565 };
566
567 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
568 static const yytype_uint8 yyr2[] =
569 {
570        0,     2,     0,     2,     1,     1,     3,     1,     1,     3,
571        3,     3,     5,     5,     5,     5,     6,     6,     6,     6,
572        8,     4,     1
573 };
574
575 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
576    Performed when YYTABLE doesn't specify something else to do.  Zero
577    means the default is an error.  */
578 static const yytype_uint8 yydefact[] =
579 {
580        2,     0,     1,     0,     5,     0,     0,     3,     4,     7,
581        8,     0,     0,     0,     0,     0,     0,     0,     0,     0,
582        0,     0,     0,     0,     0,     9,    10,    11,     6,     0,
583        0,     0,     0,     0,    12,    13,    15,    14,    22,     0,
584        0,    16,    17,    19,    18,     0,     0,     0,     0,    21,
585       20
586 };
587
588 /* YYDEFGOTO[NTERM-NUM].  */
589 static const yytype_int8 yydefgoto[] =
590 {
591       -1,     1,     7,     8,     9,    10,    40
592 };
593
594 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
595    STATE-NUM.  */
596 #define YYPACT_NINF -10
597 static const yytype_int8 yypact[] =
598 {
599      -10,    10,   -10,     9,   -10,    -2,    -1,   -10,     8,    -9,
600      -10,     2,    12,    13,    14,    26,    -7,    -1,    -1,    27,
601       28,    29,    30,    31,    22,   -10,    20,   -10,   -10,    23,
602       24,    25,    32,    19,    37,    38,    39,    40,   -10,    41,
603       34,   -10,   -10,   -10,   -10,    42,    19,    36,    43,   -10,
604      -10
605 };
606
607 /* YYPGOTO[NTERM-NUM].  */
608 static const yytype_int8 yypgoto[] =
609 {
610      -10,   -10,   -10,    -6,    33,   -10,     3
611 };
612
613 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
614    positive, shift that token.  If negative, reduce the rule which
615    number is the opposite.  If YYTABLE_NINF, syntax error.  */
616 #define YYTABLE_NINF -1
617 static const yytype_uint8 yytable[] =
618 {
619       16,    25,     3,     4,     5,    15,     6,    19,    17,    18,
620        2,    26,    27,     3,     4,     5,    20,     6,    11,    12,
621       13,    14,    38,    17,    18,    39,    21,    22,    23,    24,
622        3,    29,    30,    31,    32,    33,    18,    34,    35,    36,
623       41,    42,    43,    44,    49,    47,    37,    46,    45,    48,
624        0,    50,    28
625 };
626
627 #define yypact_value_is_default(Yystate) \
628   (!!((Yystate) == (-10)))
629
630 #define yytable_value_is_error(Yytable_value) \
631   YYID (0)
632
633 static const yytype_int8 yycheck[] =
634 {
635        6,     8,     3,     4,     5,     7,     7,    16,    15,    16,
636        0,    17,    18,     3,     4,     5,    14,     7,     9,    10,
637       11,    12,     3,    15,    16,     6,    14,    14,    14,     3,
638        3,     3,     3,     3,     3,    13,    16,    14,    14,    14,
639        3,     3,     3,     3,     8,     3,    14,    13,     7,    46,
640       -1,     8,    19
641 };
642
643 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
644    symbol of state STATE-NUM.  */
645 static const yytype_uint8 yystos[] =
646 {
647        0,    18,     0,     3,     4,     5,     7,    19,    20,    21,
648       22,     9,    10,    11,    12,     7,    20,    15,    16,    16,
649       14,    14,    14,    14,     3,     8,    20,    20,    21,     3,
650        3,     3,     3,    13,    14,    14,    14,    14,     3,     6,
651       23,     3,     3,     3,     3,     7,    13,     3,    23,     8,
652        8
653 };
654
655 #define yyerrok         (yyerrstatus = 0)
656 #define yyclearin       (yychar = YYEMPTY)
657 #define YYEMPTY         (-2)
658 #define YYEOF           0
659
660 #define YYACCEPT        goto yyacceptlab
661 #define YYABORT         goto yyabortlab
662 #define YYERROR         goto yyerrorlab
663
664
665 /* Like YYERROR except do call yyerror.  This remains here temporarily
666    to ease the transition to the new meaning of YYERROR, for GCC.
667    Once GCC version 2 has supplanted version 1, this can go.  However,
668    YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
669    in Bison 2.4.2's NEWS entry, where a plan to phase it out is
670    discussed.  */
671
672 #define YYFAIL          goto yyerrlab
673 #if defined YYFAIL
674   /* This is here to suppress warnings from the GCC cpp's
675      -Wunused-macros.  Normally we don't worry about that warning, but
676      some users do, and we want to make it easy for users to remove
677      YYFAIL uses, which will produce warnings from Bison 2.5.  */
678 #endif
679
680 #define YYRECOVERING()  (!!yyerrstatus)
681
682 #define YYBACKUP(Token, Value)                                  \
683 do                                                              \
684   if (yychar == YYEMPTY)                                        \
685     {                                                           \
686       yychar = (Token);                                         \
687       yylval = (Value);                                         \
688       YYPOPSTACK (yylen);                                       \
689       yystate = *yyssp;                                         \
690       goto yybackup;                                            \
691     }                                                           \
692   else                                                          \
693     {                                                           \
694       yyerror (YY_("syntax error: cannot back up")); \
695       YYERROR;                                                  \
696     }                                                           \
697 while (YYID (0))
698
699 /* Error token number */
700 #define YYTERROR        1
701 #define YYERRCODE       256
702
703
704 /* This macro is provided for backward compatibility. */
705 #ifndef YY_LOCATION_PRINT
706 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
707 #endif
708
709
710 /* YYLEX -- calling `yylex' with the right arguments.  */
711 #ifdef YYLEX_PARAM
712 # define YYLEX yylex (YYLEX_PARAM)
713 #else
714 # define YYLEX yylex ()
715 #endif
716
717 /* Enable debugging if requested.  */
718 #if YYDEBUG
719
720 # ifndef YYFPRINTF
721 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
722 #  define YYFPRINTF fprintf
723 # endif
724
725 # define YYDPRINTF(Args)                        \
726 do {                                            \
727   if (yydebug)                                  \
728     YYFPRINTF Args;                             \
729 } while (YYID (0))
730
731 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
732 do {                                                                      \
733   if (yydebug)                                                            \
734     {                                                                     \
735       YYFPRINTF (stderr, "%s ", Title);                                   \
736       yy_symbol_print (stderr,                                            \
737                   Type, Value); \
738       YYFPRINTF (stderr, "\n");                                           \
739     }                                                                     \
740 } while (YYID (0))
741
742
743 /*--------------------------------.
744 | Print this symbol on YYOUTPUT.  |
745 `--------------------------------*/
746
747 /*ARGSUSED*/
748 #if (defined __STDC__ || defined __C99__FUNC__ \
749      || defined __cplusplus || defined _MSC_VER)
750 static void
751 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
752 #else
753 static void
754 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
755     FILE *yyoutput;
756     int yytype;
757     YYSTYPE const * const yyvaluep;
758 #endif
759 {
760   FILE *yyo = yyoutput;
761   YYUSE (yyo);
762   if (!yyvaluep)
763     return;
764 # ifdef YYPRINT
765   if (yytype < YYNTOKENS)
766     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
767 # else
768   YYUSE (yyoutput);
769 # endif
770   switch (yytype)
771     {
772       default:
773         break;
774     }
775 }
776
777
778 /*--------------------------------.
779 | Print this symbol on YYOUTPUT.  |
780 `--------------------------------*/
781
782 #if (defined __STDC__ || defined __C99__FUNC__ \
783      || defined __cplusplus || defined _MSC_VER)
784 static void
785 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
786 #else
787 static void
788 yy_symbol_print (yyoutput, yytype, yyvaluep)
789     FILE *yyoutput;
790     int yytype;
791     YYSTYPE const * const yyvaluep;
792 #endif
793 {
794   if (yytype < YYNTOKENS)
795     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
796   else
797     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
798
799   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
800   YYFPRINTF (yyoutput, ")");
801 }
802
803 /*------------------------------------------------------------------.
804 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
805 | TOP (included).                                                   |
806 `------------------------------------------------------------------*/
807
808 #if (defined __STDC__ || defined __C99__FUNC__ \
809      || defined __cplusplus || defined _MSC_VER)
810 static void
811 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
812 #else
813 static void
814 yy_stack_print (yybottom, yytop)
815     yytype_int16 *yybottom;
816     yytype_int16 *yytop;
817 #endif
818 {
819   YYFPRINTF (stderr, "Stack now");
820   for (; yybottom <= yytop; yybottom++)
821     {
822       int yybot = *yybottom;
823       YYFPRINTF (stderr, " %d", yybot);
824     }
825   YYFPRINTF (stderr, "\n");
826 }
827
828 # define YY_STACK_PRINT(Bottom, Top)                            \
829 do {                                                            \
830   if (yydebug)                                                  \
831     yy_stack_print ((Bottom), (Top));                           \
832 } while (YYID (0))
833
834
835 /*------------------------------------------------.
836 | Report that the YYRULE is going to be reduced.  |
837 `------------------------------------------------*/
838
839 #if (defined __STDC__ || defined __C99__FUNC__ \
840      || defined __cplusplus || defined _MSC_VER)
841 static void
842 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
843 #else
844 static void
845 yy_reduce_print (yyvsp, yyrule)
846     YYSTYPE *yyvsp;
847     int yyrule;
848 #endif
849 {
850   int yynrhs = yyr2[yyrule];
851   int yyi;
852   unsigned long int yylno = yyrline[yyrule];
853   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
854              yyrule - 1, yylno);
855   /* The symbols being reduced.  */
856   for (yyi = 0; yyi < yynrhs; yyi++)
857     {
858       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
859       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
860                        &(yyvsp[(yyi + 1) - (yynrhs)])
861                                        );
862       YYFPRINTF (stderr, "\n");
863     }
864 }
865
866 # define YY_REDUCE_PRINT(Rule)          \
867 do {                                    \
868   if (yydebug)                          \
869     yy_reduce_print (yyvsp, Rule); \
870 } while (YYID (0))
871
872 /* Nonzero means print parse trace.  It is left uninitialized so that
873    multiple parsers can coexist.  */
874 int yydebug;
875 #else /* !YYDEBUG */
876 # define YYDPRINTF(Args)
877 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
878 # define YY_STACK_PRINT(Bottom, Top)
879 # define YY_REDUCE_PRINT(Rule)
880 #endif /* !YYDEBUG */
881
882
883 /* YYINITDEPTH -- initial size of the parser's stacks.  */
884 #ifndef YYINITDEPTH
885 # define YYINITDEPTH 200
886 #endif
887
888 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
889    if the built-in stack extension method is used).
890
891    Do not make this value too large; the results are undefined if
892    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
893    evaluated with infinite-precision integer arithmetic.  */
894
895 #ifndef YYMAXDEPTH
896 # define YYMAXDEPTH 10000
897 #endif
898
899
900 #if YYERROR_VERBOSE
901
902 # ifndef yystrlen
903 #  if defined __GLIBC__ && defined _STRING_H
904 #   define yystrlen strlen
905 #  else
906 /* Return the length of YYSTR.  */
907 #if (defined __STDC__ || defined __C99__FUNC__ \
908      || defined __cplusplus || defined _MSC_VER)
909 static YYSIZE_T
910 yystrlen (const char *yystr)
911 #else
912 static YYSIZE_T
913 yystrlen (yystr)
914     const char *yystr;
915 #endif
916 {
917   YYSIZE_T yylen;
918   for (yylen = 0; yystr[yylen]; yylen++)
919     continue;
920   return yylen;
921 }
922 #  endif
923 # endif
924
925 # ifndef yystpcpy
926 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
927 #   define yystpcpy stpcpy
928 #  else
929 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
930    YYDEST.  */
931 #if (defined __STDC__ || defined __C99__FUNC__ \
932      || defined __cplusplus || defined _MSC_VER)
933 static char *
934 yystpcpy (char *yydest, const char *yysrc)
935 #else
936 static char *
937 yystpcpy (yydest, yysrc)
938     char *yydest;
939     const char *yysrc;
940 #endif
941 {
942   char *yyd = yydest;
943   const char *yys = yysrc;
944
945   while ((*yyd++ = *yys++) != '\0')
946     continue;
947
948   return yyd - 1;
949 }
950 #  endif
951 # endif
952
953 # ifndef yytnamerr
954 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
955    quotes and backslashes, so that it's suitable for yyerror.  The
956    heuristic is that double-quoting is unnecessary unless the string
957    contains an apostrophe, a comma, or backslash (other than
958    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
959    null, do not copy; instead, return the length of what the result
960    would have been.  */
961 static YYSIZE_T
962 yytnamerr (char *yyres, const char *yystr)
963 {
964   if (*yystr == '"')
965     {
966       YYSIZE_T yyn = 0;
967       char const *yyp = yystr;
968
969       for (;;)
970         switch (*++yyp)
971           {
972           case '\'':
973           case ',':
974             goto do_not_strip_quotes;
975
976           case '\\':
977             if (*++yyp != '\\')
978               goto do_not_strip_quotes;
979             /* Fall through.  */
980           default:
981             if (yyres)
982               yyres[yyn] = *yyp;
983             yyn++;
984             break;
985
986           case '"':
987             if (yyres)
988               yyres[yyn] = '\0';
989             return yyn;
990           }
991     do_not_strip_quotes: ;
992     }
993
994   if (! yyres)
995     return yystrlen (yystr);
996
997   return yystpcpy (yyres, yystr) - yyres;
998 }
999 # endif
1000
1001 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1002    about the unexpected token YYTOKEN for the state stack whose top is
1003    YYSSP.
1004
1005    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1006    not large enough to hold the message.  In that case, also set
1007    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1008    required number of bytes is too large to store.  */
1009 static int
1010 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1011                 yytype_int16 *yyssp, int yytoken)
1012 {
1013   YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1014   YYSIZE_T yysize = yysize0;
1015   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1016   /* Internationalized format string. */
1017   const char *yyformat = YY_NULL;
1018   /* Arguments of yyformat. */
1019   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1020   /* Number of reported tokens (one for the "unexpected", one per
1021      "expected"). */
1022   int yycount = 0;
1023
1024   /* There are many possibilities here to consider:
1025      - Assume YYFAIL is not used.  It's too flawed to consider.  See
1026        <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1027        for details.  YYERROR is fine as it does not invoke this
1028        function.
1029      - If this state is a consistent state with a default action, then
1030        the only way this function was invoked is if the default action
1031        is an error action.  In that case, don't check for expected
1032        tokens because there are none.
1033      - The only way there can be no lookahead present (in yychar) is if
1034        this state is a consistent state with a default action.  Thus,
1035        detecting the absence of a lookahead is sufficient to determine
1036        that there is no unexpected or expected token to report.  In that
1037        case, just report a simple "syntax error".
1038      - Don't assume there isn't a lookahead just because this state is a
1039        consistent state with a default action.  There might have been a
1040        previous inconsistent state, consistent state with a non-default
1041        action, or user semantic action that manipulated yychar.
1042      - Of course, the expected token list depends on states to have
1043        correct lookahead information, and it depends on the parser not
1044        to perform extra reductions after fetching a lookahead from the
1045        scanner and before detecting a syntax error.  Thus, state merging
1046        (from LALR or IELR) and default reductions corrupt the expected
1047        token list.  However, the list is correct for canonical LR with
1048        one exception: it will still contain any token that will not be
1049        accepted due to an error action in a later state.
1050   */
1051   if (yytoken != YYEMPTY)
1052     {
1053       int yyn = yypact[*yyssp];
1054       yyarg[yycount++] = yytname[yytoken];
1055       if (!yypact_value_is_default (yyn))
1056         {
1057           /* Start YYX at -YYN if negative to avoid negative indexes in
1058              YYCHECK.  In other words, skip the first -YYN actions for
1059              this state because they are default actions.  */
1060           int yyxbegin = yyn < 0 ? -yyn : 0;
1061           /* Stay within bounds of both yycheck and yytname.  */
1062           int yychecklim = YYLAST - yyn + 1;
1063           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1064           int yyx;
1065
1066           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1067             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1068                 && !yytable_value_is_error (yytable[yyx + yyn]))
1069               {
1070                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1071                   {
1072                     yycount = 1;
1073                     yysize = yysize0;
1074                     break;
1075                   }
1076                 yyarg[yycount++] = yytname[yyx];
1077                 {
1078                   YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1079                   if (! (yysize <= yysize1
1080                          && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1081                     return 2;
1082                   yysize = yysize1;
1083                 }
1084               }
1085         }
1086     }
1087
1088   switch (yycount)
1089     {
1090 # define YYCASE_(N, S)                      \
1091       case N:                               \
1092         yyformat = S;                       \
1093       break
1094       YYCASE_(0, YY_("syntax error"));
1095       YYCASE_(1, YY_("syntax error, unexpected %s"));
1096       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1097       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1098       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1099       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1100 # undef YYCASE_
1101     }
1102
1103   {
1104     YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1105     if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1106       return 2;
1107     yysize = yysize1;
1108   }
1109
1110   if (*yymsg_alloc < yysize)
1111     {
1112       *yymsg_alloc = 2 * yysize;
1113       if (! (yysize <= *yymsg_alloc
1114              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1115         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1116       return 1;
1117     }
1118
1119   /* Avoid sprintf, as that infringes on the user's name space.
1120      Don't have undefined behavior even if the translation
1121      produced a string with the wrong number of "%s"s.  */
1122   {
1123     char *yyp = *yymsg;
1124     int yyi = 0;
1125     while ((*yyp = *yyformat) != '\0')
1126       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1127         {
1128           yyp += yytnamerr (yyp, yyarg[yyi++]);
1129           yyformat += 2;
1130         }
1131       else
1132         {
1133           yyp++;
1134           yyformat++;
1135         }
1136   }
1137   return 0;
1138 }
1139 #endif /* YYERROR_VERBOSE */
1140
1141 /*-----------------------------------------------.
1142 | Release the memory associated to this symbol.  |
1143 `-----------------------------------------------*/
1144
1145 /*ARGSUSED*/
1146 #if (defined __STDC__ || defined __C99__FUNC__ \
1147      || defined __cplusplus || defined _MSC_VER)
1148 static void
1149 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1150 #else
1151 static void
1152 yydestruct (yymsg, yytype, yyvaluep)
1153     const char *yymsg;
1154     int yytype;
1155     YYSTYPE *yyvaluep;
1156 #endif
1157 {
1158   YYUSE (yyvaluep);
1159
1160   if (!yymsg)
1161     yymsg = "Deleting";
1162   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1163
1164   switch (yytype)
1165     {
1166
1167       default:
1168         break;
1169     }
1170 }
1171
1172
1173
1174
1175 /* The lookahead symbol.  */
1176 int yychar;
1177
1178
1179 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1180 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1181 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1182 #endif
1183 #ifndef YY_INITIAL_VALUE
1184 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1185 #endif
1186
1187 /* The semantic value of the lookahead symbol.  */
1188 YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
1189
1190 /* Number of syntax errors so far.  */
1191 int yynerrs;
1192
1193
1194 /*----------.
1195 | yyparse.  |
1196 `----------*/
1197
1198 #ifdef YYPARSE_PARAM
1199 #if (defined __STDC__ || defined __C99__FUNC__ \
1200      || defined __cplusplus || defined _MSC_VER)
1201 int
1202 yyparse (void *YYPARSE_PARAM)
1203 #else
1204 int
1205 yyparse (YYPARSE_PARAM)
1206     void *YYPARSE_PARAM;
1207 #endif
1208 #else /* ! YYPARSE_PARAM */
1209 #if (defined __STDC__ || defined __C99__FUNC__ \
1210      || defined __cplusplus || defined _MSC_VER)
1211 int
1212 yyparse (void)
1213 #else
1214 int
1215 yyparse ()
1216
1217 #endif
1218 #endif
1219 {
1220     int yystate;
1221     /* Number of tokens to shift before error messages enabled.  */
1222     int yyerrstatus;
1223
1224     /* The stacks and their tools:
1225        `yyss': related to states.
1226        `yyvs': related to semantic values.
1227
1228        Refer to the stacks through separate pointers, to allow yyoverflow
1229        to reallocate them elsewhere.  */
1230
1231     /* The state stack.  */
1232     yytype_int16 yyssa[YYINITDEPTH];
1233     yytype_int16 *yyss;
1234     yytype_int16 *yyssp;
1235
1236     /* The semantic value stack.  */
1237     YYSTYPE yyvsa[YYINITDEPTH];
1238     YYSTYPE *yyvs;
1239     YYSTYPE *yyvsp;
1240
1241     YYSIZE_T yystacksize;
1242
1243   int yyn;
1244   int yyresult;
1245   /* Lookahead token as an internal (translated) token number.  */
1246   int yytoken = 0;
1247   /* The variables used to return semantic value and location from the
1248      action routines.  */
1249   YYSTYPE yyval;
1250
1251 #if YYERROR_VERBOSE
1252   /* Buffer for error messages, and its allocated size.  */
1253   char yymsgbuf[128];
1254   char *yymsg = yymsgbuf;
1255   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1256 #endif
1257
1258 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1259
1260   /* The number of symbols on the RHS of the reduced rule.
1261      Keep to zero when no symbol should be popped.  */
1262   int yylen = 0;
1263
1264   yyssp = yyss = yyssa;
1265   yyvsp = yyvs = yyvsa;
1266   yystacksize = YYINITDEPTH;
1267
1268   YYDPRINTF ((stderr, "Starting parse\n"));
1269
1270   yystate = 0;
1271   yyerrstatus = 0;
1272   yynerrs = 0;
1273   yychar = YYEMPTY; /* Cause a token to be read.  */
1274   goto yysetstate;
1275
1276 /*------------------------------------------------------------.
1277 | yynewstate -- Push a new state, which is found in yystate.  |
1278 `------------------------------------------------------------*/
1279  yynewstate:
1280   /* In all cases, when you get here, the value and location stacks
1281      have just been pushed.  So pushing a state here evens the stacks.  */
1282   yyssp++;
1283
1284  yysetstate:
1285   *yyssp = yystate;
1286
1287   if (yyss + yystacksize - 1 <= yyssp)
1288     {
1289       /* Get the current used size of the three stacks, in elements.  */
1290       YYSIZE_T yysize = yyssp - yyss + 1;
1291
1292 #ifdef yyoverflow
1293       {
1294         /* Give user a chance to reallocate the stack.  Use copies of
1295            these so that the &'s don't force the real ones into
1296            memory.  */
1297         YYSTYPE *yyvs1 = yyvs;
1298         yytype_int16 *yyss1 = yyss;
1299
1300         /* Each stack pointer address is followed by the size of the
1301            data in use in that stack, in bytes.  This used to be a
1302            conditional around just the two extra args, but that might
1303            be undefined if yyoverflow is a macro.  */
1304         yyoverflow (YY_("memory exhausted"),
1305                     &yyss1, yysize * sizeof (*yyssp),
1306                     &yyvs1, yysize * sizeof (*yyvsp),
1307                     &yystacksize);
1308
1309         yyss = yyss1;
1310         yyvs = yyvs1;
1311       }
1312 #else /* no yyoverflow */
1313 # ifndef YYSTACK_RELOCATE
1314       goto yyexhaustedlab;
1315 # else
1316       /* Extend the stack our own way.  */
1317       if (YYMAXDEPTH <= yystacksize)
1318         goto yyexhaustedlab;
1319       yystacksize *= 2;
1320       if (YYMAXDEPTH < yystacksize)
1321         yystacksize = YYMAXDEPTH;
1322
1323       {
1324         yytype_int16 *yyss1 = yyss;
1325         union yyalloc *yyptr =
1326           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1327         if (! yyptr)
1328           goto yyexhaustedlab;
1329         YYSTACK_RELOCATE (yyss_alloc, yyss);
1330         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1331 #  undef YYSTACK_RELOCATE
1332         if (yyss1 != yyssa)
1333           YYSTACK_FREE (yyss1);
1334       }
1335 # endif
1336 #endif /* no yyoverflow */
1337
1338       yyssp = yyss + yysize - 1;
1339       yyvsp = yyvs + yysize - 1;
1340
1341       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1342                   (unsigned long int) yystacksize));
1343
1344       if (yyss + yystacksize - 1 <= yyssp)
1345         YYABORT;
1346     }
1347
1348   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1349
1350   if (yystate == YYFINAL)
1351     YYACCEPT;
1352
1353   goto yybackup;
1354
1355 /*-----------.
1356 | yybackup.  |
1357 `-----------*/
1358 yybackup:
1359
1360   /* Do appropriate processing given the current state.  Read a
1361      lookahead token if we need one and don't already have one.  */
1362
1363   /* First try to decide what to do without reference to lookahead token.  */
1364   yyn = yypact[yystate];
1365   if (yypact_value_is_default (yyn))
1366     goto yydefault;
1367
1368   /* Not known => get a lookahead token if don't already have one.  */
1369
1370   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1371   if (yychar == YYEMPTY)
1372     {
1373       YYDPRINTF ((stderr, "Reading a token: "));
1374       yychar = YYLEX;
1375     }
1376
1377   if (yychar <= YYEOF)
1378     {
1379       yychar = yytoken = YYEOF;
1380       YYDPRINTF ((stderr, "Now at end of input.\n"));
1381     }
1382   else
1383     {
1384       yytoken = YYTRANSLATE (yychar);
1385       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1386     }
1387
1388   /* If the proper action on seeing token YYTOKEN is to reduce or to
1389      detect an error, take that action.  */
1390   yyn += yytoken;
1391   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1392     goto yydefault;
1393   yyn = yytable[yyn];
1394   if (yyn <= 0)
1395     {
1396       if (yytable_value_is_error (yyn))
1397         goto yyerrlab;
1398       yyn = -yyn;
1399       goto yyreduce;
1400     }
1401
1402   /* Count tokens shifted since error; after three, turn off error
1403      status.  */
1404   if (yyerrstatus)
1405     yyerrstatus--;
1406
1407   /* Shift the lookahead token.  */
1408   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1409
1410   /* Discard the shifted token.  */
1411   yychar = YYEMPTY;
1412
1413   yystate = yyn;
1414   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1415   *++yyvsp = yylval;
1416   YY_IGNORE_MAYBE_UNINITIALIZED_END
1417
1418   goto yynewstate;
1419
1420
1421 /*-----------------------------------------------------------.
1422 | yydefault -- do the default action for the current state.  |
1423 `-----------------------------------------------------------*/
1424 yydefault:
1425   yyn = yydefact[yystate];
1426   if (yyn == 0)
1427     goto yyerrlab;
1428   goto yyreduce;
1429
1430
1431 /*-----------------------------.
1432 | yyreduce -- Do a reduction.  |
1433 `-----------------------------*/
1434 yyreduce:
1435   /* yyn is the number of a rule to reduce with.  */
1436   yylen = yyr2[yyn];
1437
1438   /* If YYLEN is nonzero, implement the default value of the action:
1439      `$$ = $1'.
1440
1441      Otherwise, the following line sets YYVAL to garbage.
1442      This behavior is undocumented and Bison
1443      users should not rely upon it.  Assigning to YYVAL
1444      unconditionally makes the parser a bit smaller, and it avoids a
1445      GCC warning that YYVAL may be used uninitialized.  */
1446   yyval = yyvsp[1-yylen];
1447
1448
1449   YY_REDUCE_PRINT (yyn);
1450   switch (yyn)
1451     {
1452         case 4:
1453 /* Line 1792 of yacc.c  */
1454 #line 73 "slmod_tracker_0_6_parser.y"
1455     {
1456     ts_search = (yyvsp[(1) - (1)].sval);
1457     (yyval.sval) = (yyvsp[(1) - (1)].sval);
1458 }
1459     break;
1460
1461   case 5:
1462 /* Line 1792 of yacc.c  */
1463 #line 80 "slmod_tracker_0_6_parser.y"
1464     {
1465     if ((yyvsp[(1) - (1)].bval) == false)
1466         YYACCEPT;
1467     else
1468         YYABORT;
1469 }
1470     break;
1471
1472   case 6:
1473 /* Line 1792 of yacc.c  */
1474 #line 86 "slmod_tracker_0_6_parser.y"
1475     {
1476     if (strcmp((yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval)) != 0)
1477         YYABORT;
1478     else
1479         (yyval.sval) = (yyvsp[(1) - (3)].sval);
1480 }
1481     break;
1482
1483   case 7:
1484 /* Line 1792 of yacc.c  */
1485 #line 92 "slmod_tracker_0_6_parser.y"
1486     {(yyval.sval) = (yyvsp[(1) - (1)].sval);}
1487     break;
1488
1489   case 8:
1490 /* Line 1792 of yacc.c  */
1491 #line 93 "slmod_tracker_0_6_parser.y"
1492     {(yyval.sval) = (yyvsp[(1) - (1)].sval);}
1493     break;
1494
1495   case 9:
1496 /* Line 1792 of yacc.c  */
1497 #line 94 "slmod_tracker_0_6_parser.y"
1498     {(yyval.sval) = (yyvsp[(2) - (3)].sval);}
1499     break;
1500
1501   case 10:
1502 /* Line 1792 of yacc.c  */
1503 #line 95 "slmod_tracker_0_6_parser.y"
1504     {
1505     if ((yyvsp[(1) - (3)].sval))
1506         (yyval.sval) = (yyvsp[(1) - (3)].sval);
1507     else if ((yyvsp[(3) - (3)].sval))
1508         (yyval.sval) = (yyvsp[(3) - (3)].sval);
1509     else
1510         YYABORT;
1511 }
1512     break;
1513
1514   case 11:
1515 /* Line 1792 of yacc.c  */
1516 #line 103 "slmod_tracker_0_6_parser.y"
1517     {YYABORT;}
1518     break;
1519
1520   case 12:
1521 /* Line 1792 of yacc.c  */
1522 #line 107 "slmod_tracker_0_6_parser.y"
1523     {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '=', (yyvsp[(4) - (5)].sval));}
1524     break;
1525
1526   case 13:
1527 /* Line 1792 of yacc.c  */
1528 #line 108 "slmod_tracker_0_6_parser.y"
1529     {YYABORT;}
1530     break;
1531
1532   case 14:
1533 /* Line 1792 of yacc.c  */
1534 #line 109 "slmod_tracker_0_6_parser.y"
1535     {YYABORT;}
1536     break;
1537
1538   case 15:
1539 /* Line 1792 of yacc.c  */
1540 #line 110 "slmod_tracker_0_6_parser.y"
1541     {YYABORT;}
1542     break;
1543
1544   case 16:
1545 /* Line 1792 of yacc.c  */
1546 #line 111 "slmod_tracker_0_6_parser.y"
1547     {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '=', (yyvsp[(4) - (6)].sval));}
1548     break;
1549
1550   case 17:
1551 /* Line 1792 of yacc.c  */
1552 #line 112 "slmod_tracker_0_6_parser.y"
1553     {YYABORT;}
1554     break;
1555
1556   case 18:
1557 /* Line 1792 of yacc.c  */
1558 #line 113 "slmod_tracker_0_6_parser.y"
1559     {YYABORT;}
1560     break;
1561
1562   case 19:
1563 /* Line 1792 of yacc.c  */
1564 #line 114 "slmod_tracker_0_6_parser.y"
1565     {YYABORT;}
1566     break;
1567
1568   case 20:
1569 /* Line 1792 of yacc.c  */
1570 #line 118 "slmod_tracker_0_6_parser.y"
1571     {YYABORT;}
1572     break;
1573
1574   case 21:
1575 /* Line 1792 of yacc.c  */
1576 #line 122 "slmod_tracker_0_6_parser.y"
1577     {(yyval.tval) = isodate2unix((yyvsp[(3) - (4)].sval));}
1578     break;
1579
1580   case 22:
1581 /* Line 1792 of yacc.c  */
1582 #line 123 "slmod_tracker_0_6_parser.y"
1583     {(yyval.tval) = atoi((yyvsp[(1) - (1)].sval)) + SPRAW_TIME_OFFSET;}
1584     break;
1585
1586
1587 /* Line 1792 of yacc.c  */
1588 #line 1589 "slmod_tracker_0_6_parser.c"
1589       default: break;
1590     }
1591   /* User semantic actions sometimes alter yychar, and that requires
1592      that yytoken be updated with the new translation.  We take the
1593      approach of translating immediately before every use of yytoken.
1594      One alternative is translating here after every semantic action,
1595      but that translation would be missed if the semantic action invokes
1596      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1597      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1598      incorrect destructor might then be invoked immediately.  In the
1599      case of YYERROR or YYBACKUP, subsequent parser actions might lead
1600      to an incorrect destructor call or verbose syntax error message
1601      before the lookahead is translated.  */
1602   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1603
1604   YYPOPSTACK (yylen);
1605   yylen = 0;
1606   YY_STACK_PRINT (yyss, yyssp);
1607
1608   *++yyvsp = yyval;
1609
1610   /* Now `shift' the result of the reduction.  Determine what state
1611      that goes to, based on the state we popped back to and the rule
1612      number reduced by.  */
1613
1614   yyn = yyr1[yyn];
1615
1616   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1617   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1618     yystate = yytable[yystate];
1619   else
1620     yystate = yydefgoto[yyn - YYNTOKENS];
1621
1622   goto yynewstate;
1623
1624
1625 /*------------------------------------.
1626 | yyerrlab -- here on detecting error |
1627 `------------------------------------*/
1628 yyerrlab:
1629   /* Make sure we have latest lookahead translation.  See comments at
1630      user semantic actions for why this is necessary.  */
1631   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1632
1633   /* If not already recovering from an error, report this error.  */
1634   if (!yyerrstatus)
1635     {
1636       ++yynerrs;
1637 #if ! YYERROR_VERBOSE
1638       yyerror (YY_("syntax error"));
1639 #else
1640 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1641                                         yyssp, yytoken)
1642       {
1643         char const *yymsgp = YY_("syntax error");
1644         int yysyntax_error_status;
1645         yysyntax_error_status = YYSYNTAX_ERROR;
1646         if (yysyntax_error_status == 0)
1647           yymsgp = yymsg;
1648         else if (yysyntax_error_status == 1)
1649           {
1650             if (yymsg != yymsgbuf)
1651               YYSTACK_FREE (yymsg);
1652             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1653             if (!yymsg)
1654               {
1655                 yymsg = yymsgbuf;
1656                 yymsg_alloc = sizeof yymsgbuf;
1657                 yysyntax_error_status = 2;
1658               }
1659             else
1660               {
1661                 yysyntax_error_status = YYSYNTAX_ERROR;
1662                 yymsgp = yymsg;
1663               }
1664           }
1665         yyerror (yymsgp);
1666         if (yysyntax_error_status == 2)
1667           goto yyexhaustedlab;
1668       }
1669 # undef YYSYNTAX_ERROR
1670 #endif
1671     }
1672
1673
1674
1675   if (yyerrstatus == 3)
1676     {
1677       /* If just tried and failed to reuse lookahead token after an
1678          error, discard it.  */
1679
1680       if (yychar <= YYEOF)
1681         {
1682           /* Return failure if at end of input.  */
1683           if (yychar == YYEOF)
1684             YYABORT;
1685         }
1686       else
1687         {
1688           yydestruct ("Error: discarding",
1689                       yytoken, &yylval);
1690           yychar = YYEMPTY;
1691         }
1692     }
1693
1694   /* Else will try to reuse lookahead token after shifting the error
1695      token.  */
1696   goto yyerrlab1;
1697
1698
1699 /*---------------------------------------------------.
1700 | yyerrorlab -- error raised explicitly by YYERROR.  |
1701 `---------------------------------------------------*/
1702 yyerrorlab:
1703
1704   /* Pacify compilers like GCC when the user code never invokes
1705      YYERROR and the label yyerrorlab therefore never appears in user
1706      code.  */
1707   if (/*CONSTCOND*/ 0)
1708      goto yyerrorlab;
1709
1710   /* Do not reclaim the symbols of the rule which action triggered
1711      this YYERROR.  */
1712   YYPOPSTACK (yylen);
1713   yylen = 0;
1714   YY_STACK_PRINT (yyss, yyssp);
1715   yystate = *yyssp;
1716   goto yyerrlab1;
1717
1718
1719 /*-------------------------------------------------------------.
1720 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1721 `-------------------------------------------------------------*/
1722 yyerrlab1:
1723   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1724
1725   for (;;)
1726     {
1727       yyn = yypact[yystate];
1728       if (!yypact_value_is_default (yyn))
1729         {
1730           yyn += YYTERROR;
1731           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1732             {
1733               yyn = yytable[yyn];
1734               if (0 < yyn)
1735                 break;
1736             }
1737         }
1738
1739       /* Pop the current state because it cannot handle the error token.  */
1740       if (yyssp == yyss)
1741         YYABORT;
1742
1743
1744       yydestruct ("Error: popping",
1745                   yystos[yystate], yyvsp);
1746       YYPOPSTACK (1);
1747       yystate = *yyssp;
1748       YY_STACK_PRINT (yyss, yyssp);
1749     }
1750
1751   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1752   *++yyvsp = yylval;
1753   YY_IGNORE_MAYBE_UNINITIALIZED_END
1754
1755
1756   /* Shift the error token.  */
1757   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1758
1759   yystate = yyn;
1760   goto yynewstate;
1761
1762
1763 /*-------------------------------------.
1764 | yyacceptlab -- YYACCEPT comes here.  |
1765 `-------------------------------------*/
1766 yyacceptlab:
1767   yyresult = 0;
1768   goto yyreturn;
1769
1770 /*-----------------------------------.
1771 | yyabortlab -- YYABORT comes here.  |
1772 `-----------------------------------*/
1773 yyabortlab:
1774   yyresult = 1;
1775   goto yyreturn;
1776
1777 #if !defined yyoverflow || YYERROR_VERBOSE
1778 /*-------------------------------------------------.
1779 | yyexhaustedlab -- memory exhaustion comes here.  |
1780 `-------------------------------------------------*/
1781 yyexhaustedlab:
1782   yyerror (YY_("memory exhausted"));
1783   yyresult = 2;
1784   /* Fall through.  */
1785 #endif
1786
1787 yyreturn:
1788   if (yychar != YYEMPTY)
1789     {
1790       /* Make sure we have latest lookahead translation.  See comments at
1791          user semantic actions for why this is necessary.  */
1792       yytoken = YYTRANSLATE (yychar);
1793       yydestruct ("Cleanup: discarding lookahead",
1794                   yytoken, &yylval);
1795     }
1796   /* Do not reclaim the symbols of the rule which action triggered
1797      this YYABORT or YYACCEPT.  */
1798   YYPOPSTACK (yylen);
1799   YY_STACK_PRINT (yyss, yyssp);
1800   while (yyssp != yyss)
1801     {
1802       yydestruct ("Cleanup: popping",
1803                   yystos[*yyssp], yyvsp);
1804       YYPOPSTACK (1);
1805     }
1806 #ifndef yyoverflow
1807   if (yyss != yyssa)
1808     YYSTACK_FREE (yyss);
1809 #endif
1810 #if YYERROR_VERBOSE
1811   if (yymsg != yymsgbuf)
1812     YYSTACK_FREE (yymsg);
1813 #endif
1814   /* Make sure YYID is used.  */
1815   return YYID (yyresult);
1816 }
1817
1818
1819 /* Line 2055 of yacc.c  */
1820 #line 126 "slmod_tracker_0_6_parser.y"
1821
1822
1823 static time_t isodate2unix(const char *s)
1824 {
1825     struct tm tm;
1826
1827     if (strptime(s, "%Y-%m-%dT%H:%M:%SZ", &tm) == NULL)
1828         return (time_t)-1;
1829     return mktime(&tm);
1830 }
1831
1832 static void map_type_search(const char *val)
1833 {
1834     for (struct MDTypeMap *p = MDTypeMap; p->mdtm_value; p++) {
1835         if (strcmp(p->mdtm_value, val) == 0) {
1836             if (p->mdtm_type == -1)
1837                 ts_type = SERVICE_OTHER_FILES;
1838             else
1839                 ts_type = p->mdtm_type;
1840             return;
1841         }
1842     }
1843     ts_type = SERVICE_OTHER_FILES;
1844 }
1845
1846 static char *map_expr(const char *attr, char op, const char *val)
1847 {
1848     EC_INIT;
1849     bstring q, search, replace;
1850     char *result = NULL;
1851
1852     for (struct spotlight_tracker_map *p = spotlight_tracker_map; p->stm_spotlight_attr; p++) {
1853         if (strcmp(p->stm_spotlight_attr, attr) == 0) {
1854             switch (p->stm_type) {
1855             case stmt_name:
1856             case stmt_fts:
1857                 q = bfromcstr(val);
1858                 search = bfromcstr("*");
1859                 replace = bfromcstr("");
1860                 bfindreplace(q, search, replace, 0);
1861                 result = talloc_strdup(ts_slq, bdata(q));
1862                 bdestroy(q);
1863                 bdestroy(search);
1864                 bdestroy(replace);
1865                 break;
1866
1867             case stmt_type:
1868                 map_type_search(val);
1869                 return NULL;
1870
1871             default:
1872                 yyerror("unknown Spotlight attribute type");
1873                 EC_FAIL;
1874             }
1875             break;
1876         }
1877     }
1878
1879
1880
1881 EC_CLEANUP:
1882     return result;
1883 }
1884
1885 void yyerror(const char *str)
1886 {
1887 #ifdef MAIN
1888     printf("yyerror: %s\n", str);
1889 #else
1890     LOG(log_error, logtype_sl, "yyerror: %s", str);
1891 #endif
1892 }
1893  
1894 int yywrap()
1895 {
1896     return 1;
1897
1898
1899 /**
1900  * Map a Spotlight RAW query string to a Tracker 0.6 query
1901  *
1902  * @param[in]     slq      Spotlight query handle
1903  * @param[out]    type     mapped file type
1904  * @param[out]    search   mapped search term
1905  * @return        0 on success, -1 on error
1906  **/
1907 int map_spotlight_to_tracker_0_6_query(slq_t *slq_in,
1908                                        ServiceType *type,
1909                                        gchar **search)
1910 {
1911     EC_INIT;
1912     YY_BUFFER_STATE s = NULL;
1913
1914     ts_slq = slq_in;
1915     s = yy_scan_string(ts_slq->slq_qstring);
1916
1917     /* Default object type is file */
1918     *type = SERVICE_FILES;
1919     *search = NULL;
1920
1921     EC_ZERO( yyparse() );
1922     *type = ts_type;
1923     *search = ts_search;
1924
1925 EC_CLEANUP:
1926     if (s)
1927         yy_delete_buffer(s);
1928     EC_EXIT;
1929 }
1930
1931 #ifdef MAIN
1932 int main(int argc, char **argv)
1933 {
1934     int ret;
1935     YY_BUFFER_STATE s;
1936
1937     if (argc != 2) {
1938         printf("usage: %s QUERY\n", argv[0]);
1939         return 1;
1940     }
1941
1942     ts_slq = talloc_zero(NULL, slq_t);
1943     struct vol *vol = talloc_zero(ts_slq, struct vol);
1944     vol->v_path = "/Volumes/test";
1945     ts_slq->slq_vol = vol;
1946
1947     s = yy_scan_string(argv[1]);
1948
1949     ret = yyparse();
1950
1951     yy_delete_buffer(s);
1952
1953     if (ret == 0) {
1954         printf("Tracker 0.6 query: service: %s, searchterm: %s\n",
1955                tracker_type_to_service_name(ts_type), ts_search);
1956     }
1957
1958     return 0;
1959
1960 #endif