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