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