1 /* A Bison parser, made by GNU Bison 2.5. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
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.
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.
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/>. */
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.
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
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. */
43 /* Identify Bison output. */
47 #define YYBISON_VERSION "2.5"
50 #define YYSKELETON_NAME "yacc.c"
61 /* Using locations. */
62 #define YYLSP_NEEDED 0
66 /* Copy the first part of user declarations. */
68 /* Line 268 of yacc.c */
69 #line 1 "spotlight_rawquery_parser.y"
75 #include <atalk/talloc.h>
76 #include <atalk/logger.h>
77 #include <atalk/errchk.h>
78 #include "spotlight_SPARQL_map.h"
79 #include "spotlight.h"
81 struct yy_buffer_state;
82 typedef struct yy_buffer_state *YY_BUFFER_STATE;
83 extern int yylex (void);
84 extern void yyerror (char const *);
85 extern void *yyterminate(void);
86 extern YY_BUFFER_STATE yy_scan_string( const char *str);
87 extern void yy_delete_buffer ( YY_BUFFER_STATE buffer );
89 /* forward declarations */
90 static const char *map_expr(const char *attr, char op, const char *val);
91 static const char *map_daterange(const char *dateattr, const char *date1, const char *date2);
93 /* global vars, eg needed by the lexer */
97 static gchar *ssp_result;
101 /* Line 268 of yacc.c */
102 #line 103 "spotlight_rawquery_parser.c"
104 /* Enabling traces. */
109 /* Enabling verbose error messages. */
110 #ifdef YYERROR_VERBOSE
111 # undef YYERROR_VERBOSE
112 # define YYERROR_VERBOSE 1
114 # define YYERROR_VERBOSE 1
117 /* Enabling the token table. */
118 #ifndef YYTOKEN_TABLE
119 # define YYTOKEN_TABLE 0
126 /* Put the tokens into the symbol table, so that GDB and other debuggers
150 #define FUNC_INRANGE 261
151 #define DATE_SPEC 262
166 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
167 typedef union YYSTYPE
170 /* Line 293 of yacc.c */
171 #line 37 "spotlight_rawquery_parser.y"
179 /* Line 293 of yacc.c */
180 #line 181 "spotlight_rawquery_parser.c"
182 # define YYSTYPE_IS_TRIVIAL 1
183 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
184 # define YYSTYPE_IS_DECLARED 1
187 /* "%code provides" blocks. */
189 /* Line 340 of yacc.c */
190 #line 32 "spotlight_rawquery_parser.y"
192 extern int map_spotlight_to_sparql_query(slq_t *slq, gchar **sparql_result);
193 extern slq_t *ssp_slq;
197 /* Line 340 of yacc.c */
198 #line 199 "spotlight_rawquery_parser.c"
200 /* Copy the second part of user declarations. */
203 /* Line 343 of yacc.c */
204 #line 205 "spotlight_rawquery_parser.c"
211 typedef YYTYPE_UINT8 yytype_uint8;
213 typedef unsigned char yytype_uint8;
217 typedef YYTYPE_INT8 yytype_int8;
218 #elif (defined __STDC__ || defined __C99__FUNC__ \
219 || defined __cplusplus || defined _MSC_VER)
220 typedef signed char yytype_int8;
222 typedef short int yytype_int8;
226 typedef YYTYPE_UINT16 yytype_uint16;
228 typedef unsigned short int yytype_uint16;
232 typedef YYTYPE_INT16 yytype_int16;
234 typedef short int yytype_int16;
238 # ifdef __SIZE_TYPE__
239 # define YYSIZE_T __SIZE_TYPE__
240 # elif defined size_t
241 # define YYSIZE_T size_t
242 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
243 || defined __cplusplus || defined _MSC_VER)
244 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
245 # define YYSIZE_T size_t
247 # define YYSIZE_T unsigned int
251 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
254 # if defined YYENABLE_NLS && YYENABLE_NLS
256 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
257 # define YY_(msgid) dgettext ("bison-runtime", msgid)
261 # define YY_(msgid) msgid
265 /* Suppress unused-variable warnings by "using" E. */
266 #if ! defined lint || defined __GNUC__
267 # define YYUSE(e) ((void) (e))
269 # define YYUSE(e) /* empty */
272 /* Identity function, used to suppress warnings about constant conditions. */
276 #if (defined __STDC__ || defined __C99__FUNC__ \
277 || defined __cplusplus || defined _MSC_VER)
290 #if ! defined yyoverflow || YYERROR_VERBOSE
292 /* The parser invokes alloca or malloc; define the necessary symbols. */
294 # ifdef YYSTACK_USE_ALLOCA
295 # if YYSTACK_USE_ALLOCA
297 # define YYSTACK_ALLOC __builtin_alloca
298 # elif defined __BUILTIN_VA_ARG_INCR
299 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
301 # define YYSTACK_ALLOC __alloca
302 # elif defined _MSC_VER
303 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
304 # define alloca _alloca
306 # define YYSTACK_ALLOC alloca
307 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
308 || defined __cplusplus || defined _MSC_VER)
309 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
310 # ifndef EXIT_SUCCESS
311 # define EXIT_SUCCESS 0
318 # ifdef YYSTACK_ALLOC
319 /* Pacify GCC's `empty if-body' warning. */
320 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
321 # ifndef YYSTACK_ALLOC_MAXIMUM
322 /* The OS might guarantee only one guard page at the bottom of the stack,
323 and a page size can be as small as 4096 bytes. So we cannot safely
324 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
325 to allow for a few compiler-allocated temporary stack slots. */
326 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
329 # define YYSTACK_ALLOC YYMALLOC
330 # define YYSTACK_FREE YYFREE
331 # ifndef YYSTACK_ALLOC_MAXIMUM
332 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
334 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
335 && ! ((defined YYMALLOC || defined malloc) \
336 && (defined YYFREE || defined free)))
337 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
338 # ifndef EXIT_SUCCESS
339 # define EXIT_SUCCESS 0
343 # define YYMALLOC malloc
344 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
345 || defined __cplusplus || defined _MSC_VER)
346 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
351 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
352 || defined __cplusplus || defined _MSC_VER)
353 void free (void *); /* INFRINGES ON USER NAME SPACE */
357 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
360 #if (! defined yyoverflow \
361 && (! defined __cplusplus \
362 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
364 /* A type that is properly aligned for any stack member. */
367 yytype_int16 yyss_alloc;
371 /* The size of the maximum gap between one aligned stack and the next. */
372 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
374 /* The size of an array large to enough to hold all stacks, each with
376 # define YYSTACK_BYTES(N) \
377 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
378 + YYSTACK_GAP_MAXIMUM)
380 # define YYCOPY_NEEDED 1
382 /* Relocate STACK from its old location to the new one. The
383 local variables YYSIZE and YYSTACKSIZE give the old and new number of
384 elements in the stack, and YYPTR gives the new location of the
385 stack. Advance YYPTR to a properly aligned location for the next
387 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
390 YYSIZE_T yynewbytes; \
391 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
392 Stack = &yyptr->Stack_alloc; \
393 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
394 yyptr += yynewbytes / sizeof (*yyptr); \
400 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
401 /* Copy COUNT objects from FROM to TO. The source and destination do
404 # if defined __GNUC__ && 1 < __GNUC__
405 # define YYCOPY(To, From, Count) \
406 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
408 # define YYCOPY(To, From, Count) \
412 for (yyi = 0; yyi < (Count); yyi++) \
413 (To)[yyi] = (From)[yyi]; \
418 #endif /* !YYCOPY_NEEDED */
420 /* YYFINAL -- State number of the termination state. */
422 /* YYLAST -- Last index in YYTABLE. */
425 /* YYNTOKENS -- Number of terminals. */
427 /* YYNNTS -- Number of nonterminals. */
429 /* YYNRULES -- Number of rules. */
431 /* YYNRULES -- Number of states. */
434 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
436 #define YYMAXUTOK 272
438 #define YYTRANSLATE(YYX) \
439 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
441 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
442 static const yytype_uint8 yytranslate[] =
444 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
446 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
447 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
448 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
449 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
450 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
454 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
455 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
456 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
457 2, 2, 2, 2, 2, 2, 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, 1, 2, 3, 4,
470 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
475 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
477 static const yytype_uint8 yyprhs[] =
479 0, 0, 3, 4, 7, 9, 11, 15, 17, 19,
480 23, 27, 31, 37, 43, 49, 55
483 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
484 static const yytype_int8 yyrhs[] =
486 19, 0, -1, -1, 19, 20, -1, 21, -1, 5,
487 -1, 22, 17, 22, -1, 22, -1, 23, -1, 8,
488 21, 9, -1, 21, 16, 21, -1, 21, 17, 21,
489 -1, 4, 10, 15, 4, 15, -1, 4, 11, 15,
490 4, 15, -1, 4, 13, 15, 4, 15, -1, 4,
491 12, 15, 4, 15, -1, 6, 8, 4, 14, 7,
492 8, 3, 9, 14, 7, 8, 3, 9, 9, -1
495 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
496 static const yytype_uint8 yyrline[] =
498 0, 57, 57, 59, 63, 73, 79, 85, 86, 87,
499 88, 89, 98, 99, 100, 101, 105
503 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
504 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
505 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
506 static const char *const yytname[] =
508 "$end", "error", "$undefined", "DATE", "WORD", "BOOL", "FUNC_INRANGE",
509 "DATE_SPEC", "OBRACE", "CBRACE", "EQUAL", "UNEQUAL", "GT", "LT", "COMMA",
510 "QUOTE", "AND", "OR", "$accept", "input", "line", "expr", "match",
516 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
518 static const yytype_uint16 yytoknum[] =
520 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
521 265, 266, 267, 268, 269, 270, 271, 272
525 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
526 static const yytype_uint8 yyr1[] =
528 0, 18, 19, 19, 20, 21, 21, 21, 21, 21,
529 21, 21, 22, 22, 22, 22, 23
532 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
533 static const yytype_uint8 yyr2[] =
535 0, 2, 0, 2, 1, 1, 3, 1, 1, 3,
539 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
540 Performed when YYTABLE doesn't specify something else to do. Zero
541 means the default is an error. */
542 static const yytype_uint8 yydefact[] =
544 2, 0, 1, 0, 5, 0, 0, 3, 4, 7,
545 8, 0, 0, 0, 0, 0, 0, 0, 0, 0,
546 0, 0, 0, 0, 0, 9, 10, 11, 6, 0,
547 0, 0, 0, 0, 12, 13, 15, 14, 0, 0,
548 0, 0, 0, 0, 0, 0, 0, 16
551 /* YYDEFGOTO[NTERM-NUM]. */
552 static const yytype_int8 yydefgoto[] =
557 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
559 #define YYPACT_NINF -15
560 static const yytype_int8 yypact[] =
562 -15, 1, -15, 12, -15, -4, 13, -15, -14, -7,
563 -15, -2, 5, 11, 14, 10, -1, 13, 13, 23,
564 24, 26, 27, 28, 19, -15, 17, -15, -15, 20,
565 21, 22, 25, 31, -15, -15, -15, -15, 33, 36,
566 34, 30, 35, 37, 43, 38, 39, -15
569 /* YYPGOTO[NTERM-NUM]. */
570 static const yytype_int8 yypgoto[] =
572 -15, -15, -15, -6, 32, -15
575 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
576 positive, shift that token. If negative, reduce the rule which
577 number is the opposite. If YYTABLE_NINF, syntax error. */
578 #define YYTABLE_NINF -1
579 static const yytype_uint8 yytable[] =
581 16, 2, 17, 18, 15, 3, 4, 5, 25, 6,
582 19, 26, 27, 20, 24, 17, 18, 3, 4, 5,
583 21, 6, 11, 12, 13, 14, 22, 3, 29, 23,
584 30, 31, 32, 33, 18, 34, 35, 36, 38, 40,
585 37, 39, 43, 41, 42, 44, 45, 46, 47, 0,
589 #define yypact_value_is_default(yystate) \
592 #define yytable_value_is_error(yytable_value) \
595 static const yytype_int8 yycheck[] =
597 6, 0, 16, 17, 8, 4, 5, 6, 9, 8,
598 17, 17, 18, 15, 4, 16, 17, 4, 5, 6,
599 15, 8, 10, 11, 12, 13, 15, 4, 4, 15,
600 4, 4, 4, 14, 17, 15, 15, 15, 7, 3,
601 15, 8, 7, 9, 14, 8, 3, 9, 9, -1,
605 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
606 symbol of state STATE-NUM. */
607 static const yytype_uint8 yystos[] =
609 0, 19, 0, 4, 5, 6, 8, 20, 21, 22,
610 23, 10, 11, 12, 13, 8, 21, 16, 17, 17,
611 15, 15, 15, 15, 4, 9, 21, 21, 22, 4,
612 4, 4, 4, 14, 15, 15, 15, 15, 7, 8,
613 3, 9, 14, 7, 8, 3, 9, 9
616 #define yyerrok (yyerrstatus = 0)
617 #define yyclearin (yychar = YYEMPTY)
621 #define YYACCEPT goto yyacceptlab
622 #define YYABORT goto yyabortlab
623 #define YYERROR goto yyerrorlab
626 /* Like YYERROR except do call yyerror. This remains here temporarily
627 to ease the transition to the new meaning of YYERROR, for GCC.
628 Once GCC version 2 has supplanted version 1, this can go. However,
629 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
630 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
633 #define YYFAIL goto yyerrlab
635 /* This is here to suppress warnings from the GCC cpp's
636 -Wunused-macros. Normally we don't worry about that warning, but
637 some users do, and we want to make it easy for users to remove
638 YYFAIL uses, which will produce warnings from Bison 2.5. */
641 #define YYRECOVERING() (!!yyerrstatus)
643 #define YYBACKUP(Token, Value) \
645 if (yychar == YYEMPTY && yylen == 1) \
654 yyerror (YY_("syntax error: cannot back up")); \
661 #define YYERRCODE 256
664 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
665 If N is 0, then set CURRENT to the empty location which ends
666 the previous symbol: RHS[0] (always defined). */
668 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
669 #ifndef YYLLOC_DEFAULT
670 # define YYLLOC_DEFAULT(Current, Rhs, N) \
674 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
675 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
676 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
677 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
681 (Current).first_line = (Current).last_line = \
682 YYRHSLOC (Rhs, 0).last_line; \
683 (Current).first_column = (Current).last_column = \
684 YYRHSLOC (Rhs, 0).last_column; \
690 /* This macro is provided for backward compatibility. */
692 #ifndef YY_LOCATION_PRINT
693 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
697 /* YYLEX -- calling `yylex' with the right arguments. */
700 # define YYLEX yylex (YYLEX_PARAM)
702 # define YYLEX yylex ()
705 /* Enable debugging if requested. */
709 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
710 # define YYFPRINTF fprintf
713 # define YYDPRINTF(Args) \
719 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
723 YYFPRINTF (stderr, "%s ", Title); \
724 yy_symbol_print (stderr, \
726 YYFPRINTF (stderr, "\n"); \
731 /*--------------------------------.
732 | Print this symbol on YYOUTPUT. |
733 `--------------------------------*/
736 #if (defined __STDC__ || defined __C99__FUNC__ \
737 || defined __cplusplus || defined _MSC_VER)
739 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
742 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
745 YYSTYPE const * const yyvaluep;
751 if (yytype < YYNTOKENS)
752 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
764 /*--------------------------------.
765 | Print this symbol on YYOUTPUT. |
766 `--------------------------------*/
768 #if (defined __STDC__ || defined __C99__FUNC__ \
769 || defined __cplusplus || defined _MSC_VER)
771 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
774 yy_symbol_print (yyoutput, yytype, yyvaluep)
777 YYSTYPE const * const yyvaluep;
780 if (yytype < YYNTOKENS)
781 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
783 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
785 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
786 YYFPRINTF (yyoutput, ")");
789 /*------------------------------------------------------------------.
790 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
792 `------------------------------------------------------------------*/
794 #if (defined __STDC__ || defined __C99__FUNC__ \
795 || defined __cplusplus || defined _MSC_VER)
797 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
800 yy_stack_print (yybottom, yytop)
801 yytype_int16 *yybottom;
805 YYFPRINTF (stderr, "Stack now");
806 for (; yybottom <= yytop; yybottom++)
808 int yybot = *yybottom;
809 YYFPRINTF (stderr, " %d", yybot);
811 YYFPRINTF (stderr, "\n");
814 # define YY_STACK_PRINT(Bottom, Top) \
817 yy_stack_print ((Bottom), (Top)); \
821 /*------------------------------------------------.
822 | Report that the YYRULE is going to be reduced. |
823 `------------------------------------------------*/
825 #if (defined __STDC__ || defined __C99__FUNC__ \
826 || defined __cplusplus || defined _MSC_VER)
828 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
831 yy_reduce_print (yyvsp, yyrule)
836 int yynrhs = yyr2[yyrule];
838 unsigned long int yylno = yyrline[yyrule];
839 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
841 /* The symbols being reduced. */
842 for (yyi = 0; yyi < yynrhs; yyi++)
844 YYFPRINTF (stderr, " $%d = ", yyi + 1);
845 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
846 &(yyvsp[(yyi + 1) - (yynrhs)])
848 YYFPRINTF (stderr, "\n");
852 # define YY_REDUCE_PRINT(Rule) \
855 yy_reduce_print (yyvsp, Rule); \
858 /* Nonzero means print parse trace. It is left uninitialized so that
859 multiple parsers can coexist. */
862 # define YYDPRINTF(Args)
863 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
864 # define YY_STACK_PRINT(Bottom, Top)
865 # define YY_REDUCE_PRINT(Rule)
866 #endif /* !YYDEBUG */
869 /* YYINITDEPTH -- initial size of the parser's stacks. */
871 # define YYINITDEPTH 200
874 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
875 if the built-in stack extension method is used).
877 Do not make this value too large; the results are undefined if
878 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
879 evaluated with infinite-precision integer arithmetic. */
882 # define YYMAXDEPTH 10000
889 # if defined __GLIBC__ && defined _STRING_H
890 # define yystrlen strlen
892 /* Return the length of YYSTR. */
893 #if (defined __STDC__ || defined __C99__FUNC__ \
894 || defined __cplusplus || defined _MSC_VER)
896 yystrlen (const char *yystr)
904 for (yylen = 0; yystr[yylen]; yylen++)
912 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
913 # define yystpcpy stpcpy
915 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
917 #if (defined __STDC__ || defined __C99__FUNC__ \
918 || defined __cplusplus || defined _MSC_VER)
920 yystpcpy (char *yydest, const char *yysrc)
923 yystpcpy (yydest, yysrc)
929 const char *yys = yysrc;
931 while ((*yyd++ = *yys++) != '\0')
940 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
941 quotes and backslashes, so that it's suitable for yyerror. The
942 heuristic is that double-quoting is unnecessary unless the string
943 contains an apostrophe, a comma, or backslash (other than
944 backslash-backslash). YYSTR is taken from yytname. If YYRES is
945 null, do not copy; instead, return the length of what the result
948 yytnamerr (char *yyres, const char *yystr)
953 char const *yyp = yystr;
960 goto do_not_strip_quotes;
964 goto do_not_strip_quotes;
977 do_not_strip_quotes: ;
981 return yystrlen (yystr);
983 return yystpcpy (yyres, yystr) - yyres;
987 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
988 about the unexpected token YYTOKEN for the state stack whose top is
991 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
992 not large enough to hold the message. In that case, also set
993 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
994 required number of bytes is too large to store. */
996 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
997 yytype_int16 *yyssp, int yytoken)
999 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1000 YYSIZE_T yysize = yysize0;
1002 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1003 /* Internationalized format string. */
1004 const char *yyformat = 0;
1005 /* Arguments of yyformat. */
1006 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1007 /* Number of reported tokens (one for the "unexpected", one per
1011 /* There are many possibilities here to consider:
1012 - Assume YYFAIL is not used. It's too flawed to consider. See
1013 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1014 for details. YYERROR is fine as it does not invoke this
1016 - If this state is a consistent state with a default action, then
1017 the only way this function was invoked is if the default action
1018 is an error action. In that case, don't check for expected
1019 tokens because there are none.
1020 - The only way there can be no lookahead present (in yychar) is if
1021 this state is a consistent state with a default action. Thus,
1022 detecting the absence of a lookahead is sufficient to determine
1023 that there is no unexpected or expected token to report. In that
1024 case, just report a simple "syntax error".
1025 - Don't assume there isn't a lookahead just because this state is a
1026 consistent state with a default action. There might have been a
1027 previous inconsistent state, consistent state with a non-default
1028 action, or user semantic action that manipulated yychar.
1029 - Of course, the expected token list depends on states to have
1030 correct lookahead information, and it depends on the parser not
1031 to perform extra reductions after fetching a lookahead from the
1032 scanner and before detecting a syntax error. Thus, state merging
1033 (from LALR or IELR) and default reductions corrupt the expected
1034 token list. However, the list is correct for canonical LR with
1035 one exception: it will still contain any token that will not be
1036 accepted due to an error action in a later state.
1038 if (yytoken != YYEMPTY)
1040 int yyn = yypact[*yyssp];
1041 yyarg[yycount++] = yytname[yytoken];
1042 if (!yypact_value_is_default (yyn))
1044 /* Start YYX at -YYN if negative to avoid negative indexes in
1045 YYCHECK. In other words, skip the first -YYN actions for
1046 this state because they are default actions. */
1047 int yyxbegin = yyn < 0 ? -yyn : 0;
1048 /* Stay within bounds of both yycheck and yytname. */
1049 int yychecklim = YYLAST - yyn + 1;
1050 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1053 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1054 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1055 && !yytable_value_is_error (yytable[yyx + yyn]))
1057 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1063 yyarg[yycount++] = yytname[yyx];
1064 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1065 if (! (yysize <= yysize1
1066 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1075 # define YYCASE_(N, S) \
1079 YYCASE_(0, YY_("syntax error"));
1080 YYCASE_(1, YY_("syntax error, unexpected %s"));
1081 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1082 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1083 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1084 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1088 yysize1 = yysize + yystrlen (yyformat);
1089 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1093 if (*yymsg_alloc < yysize)
1095 *yymsg_alloc = 2 * yysize;
1096 if (! (yysize <= *yymsg_alloc
1097 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1098 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1102 /* Avoid sprintf, as that infringes on the user's name space.
1103 Don't have undefined behavior even if the translation
1104 produced a string with the wrong number of "%s"s. */
1108 while ((*yyp = *yyformat) != '\0')
1109 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1111 yyp += yytnamerr (yyp, yyarg[yyi++]);
1122 #endif /* YYERROR_VERBOSE */
1124 /*-----------------------------------------------.
1125 | Release the memory associated to this symbol. |
1126 `-----------------------------------------------*/
1129 #if (defined __STDC__ || defined __C99__FUNC__ \
1130 || defined __cplusplus || defined _MSC_VER)
1132 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1135 yydestruct (yymsg, yytype, yyvaluep)
1145 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1156 /* Prevent warnings from -Wmissing-prototypes. */
1157 #ifdef YYPARSE_PARAM
1158 #if defined __STDC__ || defined __cplusplus
1159 int yyparse (void *YYPARSE_PARAM);
1163 #else /* ! YYPARSE_PARAM */
1164 #if defined __STDC__ || defined __cplusplus
1169 #endif /* ! YYPARSE_PARAM */
1172 /* The lookahead symbol. */
1175 /* The semantic value of the lookahead symbol. */
1178 /* Number of syntax errors so far. */
1186 #ifdef YYPARSE_PARAM
1187 #if (defined __STDC__ || defined __C99__FUNC__ \
1188 || defined __cplusplus || defined _MSC_VER)
1190 yyparse (void *YYPARSE_PARAM)
1193 yyparse (YYPARSE_PARAM)
1194 void *YYPARSE_PARAM;
1196 #else /* ! YYPARSE_PARAM */
1197 #if (defined __STDC__ || defined __C99__FUNC__ \
1198 || defined __cplusplus || defined _MSC_VER)
1209 /* Number of tokens to shift before error messages enabled. */
1212 /* The stacks and their tools:
1213 `yyss': related to states.
1214 `yyvs': related to semantic values.
1216 Refer to the stacks thru separate pointers, to allow yyoverflow
1217 to reallocate them elsewhere. */
1219 /* The state stack. */
1220 yytype_int16 yyssa[YYINITDEPTH];
1222 yytype_int16 *yyssp;
1224 /* The semantic value stack. */
1225 YYSTYPE yyvsa[YYINITDEPTH];
1229 YYSIZE_T yystacksize;
1233 /* Lookahead token as an internal (translated) token number. */
1235 /* The variables used to return semantic value and location from the
1240 /* Buffer for error messages, and its allocated size. */
1242 char *yymsg = yymsgbuf;
1243 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1246 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1248 /* The number of symbols on the RHS of the reduced rule.
1249 Keep to zero when no symbol should be popped. */
1255 yystacksize = YYINITDEPTH;
1257 YYDPRINTF ((stderr, "Starting parse\n"));
1262 yychar = YYEMPTY; /* Cause a token to be read. */
1264 /* Initialize stack pointers.
1265 Waste one element of value and location stack
1266 so that they stay on the same level as the state stack.
1267 The wasted elements are never initialized. */
1273 /*------------------------------------------------------------.
1274 | yynewstate -- Push a new state, which is found in yystate. |
1275 `------------------------------------------------------------*/
1277 /* In all cases, when you get here, the value and location stacks
1278 have just been pushed. So pushing a state here evens the stacks. */
1284 if (yyss + yystacksize - 1 <= yyssp)
1286 /* Get the current used size of the three stacks, in elements. */
1287 YYSIZE_T yysize = yyssp - yyss + 1;
1291 /* Give user a chance to reallocate the stack. Use copies of
1292 these so that the &'s don't force the real ones into
1294 YYSTYPE *yyvs1 = yyvs;
1295 yytype_int16 *yyss1 = yyss;
1297 /* Each stack pointer address is followed by the size of the
1298 data in use in that stack, in bytes. This used to be a
1299 conditional around just the two extra args, but that might
1300 be undefined if yyoverflow is a macro. */
1301 yyoverflow (YY_("memory exhausted"),
1302 &yyss1, yysize * sizeof (*yyssp),
1303 &yyvs1, yysize * sizeof (*yyvsp),
1309 #else /* no yyoverflow */
1310 # ifndef YYSTACK_RELOCATE
1311 goto yyexhaustedlab;
1313 /* Extend the stack our own way. */
1314 if (YYMAXDEPTH <= yystacksize)
1315 goto yyexhaustedlab;
1317 if (YYMAXDEPTH < yystacksize)
1318 yystacksize = YYMAXDEPTH;
1321 yytype_int16 *yyss1 = yyss;
1322 union yyalloc *yyptr =
1323 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1325 goto yyexhaustedlab;
1326 YYSTACK_RELOCATE (yyss_alloc, yyss);
1327 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1328 # undef YYSTACK_RELOCATE
1330 YYSTACK_FREE (yyss1);
1333 #endif /* no yyoverflow */
1335 yyssp = yyss + yysize - 1;
1336 yyvsp = yyvs + yysize - 1;
1338 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1339 (unsigned long int) yystacksize));
1341 if (yyss + yystacksize - 1 <= yyssp)
1345 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1347 if (yystate == YYFINAL)
1357 /* Do appropriate processing given the current state. Read a
1358 lookahead token if we need one and don't already have one. */
1360 /* First try to decide what to do without reference to lookahead token. */
1361 yyn = yypact[yystate];
1362 if (yypact_value_is_default (yyn))
1365 /* Not known => get a lookahead token if don't already have one. */
1367 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1368 if (yychar == YYEMPTY)
1370 YYDPRINTF ((stderr, "Reading a token: "));
1374 if (yychar <= YYEOF)
1376 yychar = yytoken = YYEOF;
1377 YYDPRINTF ((stderr, "Now at end of input.\n"));
1381 yytoken = YYTRANSLATE (yychar);
1382 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1385 /* If the proper action on seeing token YYTOKEN is to reduce or to
1386 detect an error, take that action. */
1388 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1393 if (yytable_value_is_error (yyn))
1399 /* Count tokens shifted since error; after three, turn off error
1404 /* Shift the lookahead token. */
1405 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1407 /* Discard the shifted token. */
1416 /*-----------------------------------------------------------.
1417 | yydefault -- do the default action for the current state. |
1418 `-----------------------------------------------------------*/
1420 yyn = yydefact[yystate];
1426 /*-----------------------------.
1427 | yyreduce -- Do a reduction. |
1428 `-----------------------------*/
1430 /* yyn is the number of a rule to reduce with. */
1433 /* If YYLEN is nonzero, implement the default value of the action:
1436 Otherwise, the following line sets YYVAL to garbage.
1437 This behavior is undocumented and Bison
1438 users should not rely upon it. Assigning to YYVAL
1439 unconditionally makes the parser a bit smaller, and it avoids a
1440 GCC warning that YYVAL may be used uninitialized. */
1441 yyval = yyvsp[1-yylen];
1444 YY_REDUCE_PRINT (yyn);
1449 /* Line 1806 of yacc.c */
1450 #line 63 "spotlight_rawquery_parser.y"
1452 ssp_result = talloc_asprintf(ssp_slq,
1453 "SELECT DISTINCT ?url WHERE "
1454 "{ ?x nie:url ?url FILTER(fn:starts-with(?url, 'file://%s/')) . %s}",
1455 ssp_slq->slq_vol->v_path, (yyvsp[(1) - (1)].sval));
1456 (yyval.sval) = ssp_result;
1462 /* Line 1806 of yacc.c */
1463 #line 73 "spotlight_rawquery_parser.y"
1465 if ((yyvsp[(1) - (1)].bval) == false)
1474 /* Line 1806 of yacc.c */
1475 #line 79 "spotlight_rawquery_parser.y"
1477 if (strcmp((yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval)) != 0)
1478 (yyval.sval) = talloc_asprintf(ssp_slq, "{ %s } UNION { %s }", (yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval));
1480 (yyval.sval) = talloc_asprintf(ssp_slq, "%s", (yyvsp[(1) - (3)].sval));
1486 /* Line 1806 of yacc.c */
1487 #line 85 "spotlight_rawquery_parser.y"
1488 {(yyval.sval) = (yyvsp[(1) - (1)].sval);}
1493 /* Line 1806 of yacc.c */
1494 #line 86 "spotlight_rawquery_parser.y"
1495 {(yyval.sval) = (yyvsp[(1) - (1)].sval);}
1500 /* Line 1806 of yacc.c */
1501 #line 87 "spotlight_rawquery_parser.y"
1502 {(yyval.sval) = talloc_asprintf(ssp_slq, "%s", (yyvsp[(2) - (3)].sval));}
1507 /* Line 1806 of yacc.c */
1508 #line 88 "spotlight_rawquery_parser.y"
1509 {(yyval.sval) = talloc_asprintf(ssp_slq, "%s . %s", (yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval));}
1514 /* Line 1806 of yacc.c */
1515 #line 89 "spotlight_rawquery_parser.y"
1517 if (strcmp((yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval)) != 0)
1518 (yyval.sval) = talloc_asprintf(ssp_slq, "{ %s } UNION { %s }", (yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval));
1520 (yyval.sval) = talloc_asprintf(ssp_slq, "%s", (yyvsp[(1) - (3)].sval));
1526 /* Line 1806 of yacc.c */
1527 #line 98 "spotlight_rawquery_parser.y"
1528 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '=', (yyvsp[(4) - (5)].sval));}
1533 /* Line 1806 of yacc.c */
1534 #line 99 "spotlight_rawquery_parser.y"
1535 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '!', (yyvsp[(4) - (5)].sval));}
1540 /* Line 1806 of yacc.c */
1541 #line 100 "spotlight_rawquery_parser.y"
1542 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '<', (yyvsp[(4) - (5)].sval));}
1547 /* Line 1806 of yacc.c */
1548 #line 101 "spotlight_rawquery_parser.y"
1549 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '>', (yyvsp[(4) - (5)].sval));}
1554 /* Line 1806 of yacc.c */
1555 #line 105 "spotlight_rawquery_parser.y"
1556 {(yyval.sval) = map_daterange((yyvsp[(3) - (14)].sval), (yyvsp[(7) - (14)].sval), (yyvsp[(12) - (14)].sval));}
1561 /* Line 1806 of yacc.c */
1562 #line 1563 "spotlight_rawquery_parser.c"
1565 /* User semantic actions sometimes alter yychar, and that requires
1566 that yytoken be updated with the new translation. We take the
1567 approach of translating immediately before every use of yytoken.
1568 One alternative is translating here after every semantic action,
1569 but that translation would be missed if the semantic action invokes
1570 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1571 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1572 incorrect destructor might then be invoked immediately. In the
1573 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1574 to an incorrect destructor call or verbose syntax error message
1575 before the lookahead is translated. */
1576 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1580 YY_STACK_PRINT (yyss, yyssp);
1584 /* Now `shift' the result of the reduction. Determine what state
1585 that goes to, based on the state we popped back to and the rule
1586 number reduced by. */
1590 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1591 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1592 yystate = yytable[yystate];
1594 yystate = yydefgoto[yyn - YYNTOKENS];
1599 /*------------------------------------.
1600 | yyerrlab -- here on detecting error |
1601 `------------------------------------*/
1603 /* Make sure we have latest lookahead translation. See comments at
1604 user semantic actions for why this is necessary. */
1605 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1607 /* If not already recovering from an error, report this error. */
1611 #if ! YYERROR_VERBOSE
1612 yyerror (YY_("syntax error"));
1614 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1617 char const *yymsgp = YY_("syntax error");
1618 int yysyntax_error_status;
1619 yysyntax_error_status = YYSYNTAX_ERROR;
1620 if (yysyntax_error_status == 0)
1622 else if (yysyntax_error_status == 1)
1624 if (yymsg != yymsgbuf)
1625 YYSTACK_FREE (yymsg);
1626 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1630 yymsg_alloc = sizeof yymsgbuf;
1631 yysyntax_error_status = 2;
1635 yysyntax_error_status = YYSYNTAX_ERROR;
1640 if (yysyntax_error_status == 2)
1641 goto yyexhaustedlab;
1643 # undef YYSYNTAX_ERROR
1649 if (yyerrstatus == 3)
1651 /* If just tried and failed to reuse lookahead token after an
1652 error, discard it. */
1654 if (yychar <= YYEOF)
1656 /* Return failure if at end of input. */
1657 if (yychar == YYEOF)
1662 yydestruct ("Error: discarding",
1668 /* Else will try to reuse lookahead token after shifting the error
1673 /*---------------------------------------------------.
1674 | yyerrorlab -- error raised explicitly by YYERROR. |
1675 `---------------------------------------------------*/
1678 /* Pacify compilers like GCC when the user code never invokes
1679 YYERROR and the label yyerrorlab therefore never appears in user
1681 if (/*CONSTCOND*/ 0)
1684 /* Do not reclaim the symbols of the rule which action triggered
1688 YY_STACK_PRINT (yyss, yyssp);
1693 /*-------------------------------------------------------------.
1694 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1695 `-------------------------------------------------------------*/
1697 yyerrstatus = 3; /* Each real token shifted decrements this. */
1701 yyn = yypact[yystate];
1702 if (!yypact_value_is_default (yyn))
1705 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1713 /* Pop the current state because it cannot handle the error token. */
1718 yydestruct ("Error: popping",
1719 yystos[yystate], yyvsp);
1722 YY_STACK_PRINT (yyss, yyssp);
1728 /* Shift the error token. */
1729 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1735 /*-------------------------------------.
1736 | yyacceptlab -- YYACCEPT comes here. |
1737 `-------------------------------------*/
1742 /*-----------------------------------.
1743 | yyabortlab -- YYABORT comes here. |
1744 `-----------------------------------*/
1749 #if !defined(yyoverflow) || YYERROR_VERBOSE
1750 /*-------------------------------------------------.
1751 | yyexhaustedlab -- memory exhaustion comes here. |
1752 `-------------------------------------------------*/
1754 yyerror (YY_("memory exhausted"));
1760 if (yychar != YYEMPTY)
1762 /* Make sure we have latest lookahead translation. See comments at
1763 user semantic actions for why this is necessary. */
1764 yytoken = YYTRANSLATE (yychar);
1765 yydestruct ("Cleanup: discarding lookahead",
1768 /* Do not reclaim the symbols of the rule which action triggered
1769 this YYABORT or YYACCEPT. */
1771 YY_STACK_PRINT (yyss, yyssp);
1772 while (yyssp != yyss)
1774 yydestruct ("Cleanup: popping",
1775 yystos[*yyssp], yyvsp);
1780 YYSTACK_FREE (yyss);
1783 if (yymsg != yymsgbuf)
1784 YYSTACK_FREE (yymsg);
1786 /* Make sure YYID is used. */
1787 return YYID (yyresult);
1792 /* Line 2067 of yacc.c */
1793 #line 108 "spotlight_rawquery_parser.y"
1796 const char *map_daterange(const char *dateattr, const char *date1, const char *date2)
1798 char *result = NULL;
1799 struct spotlight_sparql_map *p;
1801 for (p = spotlight_sparql_map; p->ssm_spotlight_attr; p++) {
1802 if (strcmp(dateattr, p->ssm_spotlight_attr) == 0) {
1803 result = talloc_asprintf(ssp_slq,
1804 "?x %s ?d FILTER (?d > '%s' && ?d < '%s')",
1815 const char *map_expr(const char *attr, char op, const char *val)
1817 char *result = NULL;
1818 struct spotlight_sparql_map *p;
1820 for (p = spotlight_sparql_map; p->ssm_spotlight_attr; p++) {
1821 if (strcmp(p->ssm_spotlight_attr, attr) == 0) {
1822 result = talloc_asprintf(ssp_slq, p->ssm_sparql_query_fmtstr, val);
1830 void yyerror(const char *str)
1833 printf("yyerror: %s\n", str);
1835 LOG(log_error, logtype_sl, "yyerror: %s", str);
1845 * Map a Spotlight RAW query string to a SPARQL query string
1847 * @param[in] slq Spotlight query handle
1848 * @param[out] sparql_result Mapped SPARQL query, string is allocated in
1849 * talloc context of slq
1850 * @return 0 on success, -1 on error
1852 int map_spotlight_to_sparql_query(slq_t *slq, gchar **sparql_result)
1855 YY_BUFFER_STATE s = NULL;
1858 s = yy_scan_string(slq->slq_qstring);
1860 EC_ZERO( yyparse() );
1864 yy_delete_buffer(s);
1866 *sparql_result = NULL;
1868 *sparql_result = ssp_result;
1873 int main(int argc, char **argv)
1879 printf("usage: %s QUERY\n", argv[0]);
1883 ssp_slq = talloc_zero(NULL, slq_t);
1884 struct vol *vol = talloc_zero(ssp_slq, struct vol);
1885 vol->v_path = "/Volumes/test";
1886 ssp_slq->slq_vol = vol;
1888 s = yy_scan_string(argv[1]);
1892 yy_delete_buffer(s);
1895 printf("SPARQL: %s\n", ssp_result ? ssp_result : "(empty)");