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