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"
71 #include <atalk/standards.h>
80 #include <atalk/talloc.h>
81 #include <atalk/logger.h>
82 #include <atalk/errchk.h>
84 #include "spotlight_SPARQL_map.h"
85 #include "spotlight.h"
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 );
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);
100 /* global vars, eg needed by the lexer */
104 static gchar *ssp_result;
105 static char sparqlvar;
108 /* Line 268 of yacc.c */
109 #line 110 "spotlight_rawquery_parser.c"
111 /* Enabling traces. */
116 /* Enabling verbose error messages. */
117 #ifdef YYERROR_VERBOSE
118 # undef YYERROR_VERBOSE
119 # define YYERROR_VERBOSE 1
121 # define YYERROR_VERBOSE 1
124 /* Enabling the token table. */
125 #ifndef YYTOKEN_TABLE
126 # define YYTOKEN_TABLE 0
133 /* Put the tokens into the symbol table, so that GDB and other debuggers
155 #define FUNC_INRANGE 260
171 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
172 typedef union YYSTYPE
175 /* Line 293 of yacc.c */
176 #line 45 "spotlight_rawquery_parser.y"
185 /* Line 293 of yacc.c */
186 #line 187 "spotlight_rawquery_parser.c"
188 # define YYSTYPE_IS_TRIVIAL 1
189 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
190 # define YYSTYPE_IS_DECLARED 1
193 /* "%code provides" blocks. */
195 /* Line 340 of yacc.c */
196 #line 39 "spotlight_rawquery_parser.y"
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;
204 /* Line 340 of yacc.c */
205 #line 206 "spotlight_rawquery_parser.c"
207 /* Copy the second part of user declarations. */
210 /* Line 343 of yacc.c */
211 #line 212 "spotlight_rawquery_parser.c"
218 typedef YYTYPE_UINT8 yytype_uint8;
220 typedef unsigned char yytype_uint8;
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;
229 typedef short int yytype_int8;
233 typedef YYTYPE_UINT16 yytype_uint16;
235 typedef unsigned short int yytype_uint16;
239 typedef YYTYPE_INT16 yytype_int16;
241 typedef short int yytype_int16;
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
254 # define YYSIZE_T unsigned int
258 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
261 # if defined YYENABLE_NLS && YYENABLE_NLS
263 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
264 # define YY_(msgid) dgettext ("bison-runtime", msgid)
268 # define YY_(msgid) msgid
272 /* Suppress unused-variable warnings by "using" E. */
273 #if ! defined lint || defined __GNUC__
274 # define YYUSE(e) ((void) (e))
276 # define YYUSE(e) /* empty */
279 /* Identity function, used to suppress warnings about constant conditions. */
283 #if (defined __STDC__ || defined __C99__FUNC__ \
284 || defined __cplusplus || defined _MSC_VER)
297 #if ! defined yyoverflow || YYERROR_VERBOSE
299 /* The parser invokes alloca or malloc; define the necessary symbols. */
301 # ifdef YYSTACK_USE_ALLOCA
302 # if YYSTACK_USE_ALLOCA
304 # define YYSTACK_ALLOC __builtin_alloca
305 # elif defined __BUILTIN_VA_ARG_INCR
306 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
308 # define YYSTACK_ALLOC __alloca
309 # elif defined _MSC_VER
310 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
311 # define alloca _alloca
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
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 */
336 # define YYSTACK_ALLOC YYMALLOC
337 # define YYSTACK_FREE YYFREE
338 # ifndef YYSTACK_ALLOC_MAXIMUM
339 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
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
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 */
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 */
364 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
367 #if (! defined yyoverflow \
368 && (! defined __cplusplus \
369 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
371 /* A type that is properly aligned for any stack member. */
374 yytype_int16 yyss_alloc;
378 /* The size of the maximum gap between one aligned stack and the next. */
379 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
381 /* The size of an array large to enough to hold all stacks, each with
383 # define YYSTACK_BYTES(N) \
384 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
385 + YYSTACK_GAP_MAXIMUM)
387 # define YYCOPY_NEEDED 1
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
394 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
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); \
407 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
408 /* Copy COUNT objects from FROM to TO. The source and destination do
411 # if defined __GNUC__ && 1 < __GNUC__
412 # define YYCOPY(To, From, Count) \
413 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
415 # define YYCOPY(To, From, Count) \
419 for (yyi = 0; yyi < (Count); yyi++) \
420 (To)[yyi] = (From)[yyi]; \
425 #endif /* !YYCOPY_NEEDED */
427 /* YYFINAL -- State number of the termination state. */
429 /* YYLAST -- Last index in YYTABLE. */
432 /* YYNTOKENS -- Number of terminals. */
434 /* YYNNTS -- Number of nonterminals. */
436 /* YYNRULES -- Number of rules. */
438 /* YYNRULES -- Number of states. */
441 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
443 #define YYMAXUTOK 271
445 #define YYTRANSLATE(YYX) \
446 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
448 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
449 static const yytype_uint8 yytranslate[] =
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,
482 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
484 static const yytype_uint8 yyprhs[] =
486 0, 0, 3, 4, 7, 9, 11, 15, 17, 19,
487 23, 27, 31, 37, 43, 49, 55, 64, 69
490 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
491 static const yytype_int8 yyrhs[] =
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,
503 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
504 static const yytype_uint8 yyrline[] =
506 0, 67, 67, 69, 73, 83, 89, 95, 96, 97,
507 98, 99, 108, 109, 110, 111, 115, 119, 120
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[] =
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
524 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
526 static const yytype_uint16 yytoknum[] =
528 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
529 265, 266, 267, 268, 269, 270, 271
533 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
534 static const yytype_uint8 yyr1[] =
536 0, 17, 18, 18, 19, 20, 20, 20, 20, 20,
537 20, 20, 21, 21, 21, 21, 22, 23, 23
540 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
541 static const yytype_uint8 yyr2[] =
543 0, 2, 0, 2, 1, 1, 3, 1, 1, 3,
544 3, 3, 5, 5, 5, 5, 8, 4, 1
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[] =
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
559 /* YYDEFGOTO[NTERM-NUM]. */
560 static const yytype_int8 yydefgoto[] =
562 -1, 1, 7, 8, 9, 10, 40
565 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
567 #define YYPACT_NINF -10
568 static const yytype_int8 yypact[] =
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
577 /* YYPGOTO[NTERM-NUM]. */
578 static const yytype_int8 yypgoto[] =
580 -10, -10, -10, -6, 37, -10, 0
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[] =
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,
597 #define yypact_value_is_default(yystate) \
600 #define yytable_value_is_error(yytable_value) \
603 static const yytype_int8 yycheck[] =
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
613 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
614 symbol of state STATE-NUM. */
615 static const yytype_uint8 yystos[] =
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
624 #define yyerrok (yyerrstatus = 0)
625 #define yyclearin (yychar = YYEMPTY)
629 #define YYACCEPT goto yyacceptlab
630 #define YYABORT goto yyabortlab
631 #define YYERROR goto yyerrorlab
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
641 #define YYFAIL goto yyerrlab
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. */
649 #define YYRECOVERING() (!!yyerrstatus)
651 #define YYBACKUP(Token, Value) \
653 if (yychar == YYEMPTY && yylen == 1) \
662 yyerror (YY_("syntax error: cannot back up")); \
669 #define YYERRCODE 256
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). */
676 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
677 #ifndef YYLLOC_DEFAULT
678 # define YYLLOC_DEFAULT(Current, Rhs, N) \
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; \
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; \
698 /* This macro is provided for backward compatibility. */
700 #ifndef YY_LOCATION_PRINT
701 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
705 /* YYLEX -- calling `yylex' with the right arguments. */
708 # define YYLEX yylex (YYLEX_PARAM)
710 # define YYLEX yylex ()
713 /* Enable debugging if requested. */
717 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
718 # define YYFPRINTF fprintf
721 # define YYDPRINTF(Args) \
727 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
731 YYFPRINTF (stderr, "%s ", Title); \
732 yy_symbol_print (stderr, \
734 YYFPRINTF (stderr, "\n"); \
739 /*--------------------------------.
740 | Print this symbol on YYOUTPUT. |
741 `--------------------------------*/
744 #if (defined __STDC__ || defined __C99__FUNC__ \
745 || defined __cplusplus || defined _MSC_VER)
747 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
750 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
753 YYSTYPE const * const yyvaluep;
759 if (yytype < YYNTOKENS)
760 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
772 /*--------------------------------.
773 | Print this symbol on YYOUTPUT. |
774 `--------------------------------*/
776 #if (defined __STDC__ || defined __C99__FUNC__ \
777 || defined __cplusplus || defined _MSC_VER)
779 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
782 yy_symbol_print (yyoutput, yytype, yyvaluep)
785 YYSTYPE const * const yyvaluep;
788 if (yytype < YYNTOKENS)
789 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
791 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
793 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
794 YYFPRINTF (yyoutput, ")");
797 /*------------------------------------------------------------------.
798 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
800 `------------------------------------------------------------------*/
802 #if (defined __STDC__ || defined __C99__FUNC__ \
803 || defined __cplusplus || defined _MSC_VER)
805 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
808 yy_stack_print (yybottom, yytop)
809 yytype_int16 *yybottom;
813 YYFPRINTF (stderr, "Stack now");
814 for (; yybottom <= yytop; yybottom++)
816 int yybot = *yybottom;
817 YYFPRINTF (stderr, " %d", yybot);
819 YYFPRINTF (stderr, "\n");
822 # define YY_STACK_PRINT(Bottom, Top) \
825 yy_stack_print ((Bottom), (Top)); \
829 /*------------------------------------------------.
830 | Report that the YYRULE is going to be reduced. |
831 `------------------------------------------------*/
833 #if (defined __STDC__ || defined __C99__FUNC__ \
834 || defined __cplusplus || defined _MSC_VER)
836 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
839 yy_reduce_print (yyvsp, yyrule)
844 int yynrhs = yyr2[yyrule];
846 unsigned long int yylno = yyrline[yyrule];
847 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
849 /* The symbols being reduced. */
850 for (yyi = 0; yyi < yynrhs; yyi++)
852 YYFPRINTF (stderr, " $%d = ", yyi + 1);
853 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
854 &(yyvsp[(yyi + 1) - (yynrhs)])
856 YYFPRINTF (stderr, "\n");
860 # define YY_REDUCE_PRINT(Rule) \
863 yy_reduce_print (yyvsp, Rule); \
866 /* Nonzero means print parse trace. It is left uninitialized so that
867 multiple parsers can coexist. */
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 */
877 /* YYINITDEPTH -- initial size of the parser's stacks. */
879 # define YYINITDEPTH 200
882 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
883 if the built-in stack extension method is used).
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. */
890 # define YYMAXDEPTH 10000
897 # if defined __GLIBC__ && defined _STRING_H
898 # define yystrlen strlen
900 /* Return the length of YYSTR. */
901 #if (defined __STDC__ || defined __C99__FUNC__ \
902 || defined __cplusplus || defined _MSC_VER)
904 yystrlen (const char *yystr)
912 for (yylen = 0; yystr[yylen]; yylen++)
920 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
921 # define yystpcpy stpcpy
923 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
925 #if (defined __STDC__ || defined __C99__FUNC__ \
926 || defined __cplusplus || defined _MSC_VER)
928 yystpcpy (char *yydest, const char *yysrc)
931 yystpcpy (yydest, yysrc)
937 const char *yys = yysrc;
939 while ((*yyd++ = *yys++) != '\0')
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
956 yytnamerr (char *yyres, const char *yystr)
961 char const *yyp = yystr;
968 goto do_not_strip_quotes;
972 goto do_not_strip_quotes;
985 do_not_strip_quotes: ;
989 return yystrlen (yystr);
991 return yystpcpy (yyres, yystr) - yyres;
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
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. */
1004 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1005 yytype_int16 *yyssp, int yytoken)
1007 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1008 YYSIZE_T yysize = yysize0;
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
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
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.
1046 if (yytoken != YYEMPTY)
1048 int yyn = yypact[*yyssp];
1049 yyarg[yycount++] = yytname[yytoken];
1050 if (!yypact_value_is_default (yyn))
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;
1061 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1062 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1063 && !yytable_value_is_error (yytable[yyx + yyn]))
1065 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1071 yyarg[yycount++] = yytname[yyx];
1072 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1073 if (! (yysize <= yysize1
1074 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1083 # define YYCASE_(N, S) \
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"));
1096 yysize1 = yysize + yystrlen (yyformat);
1097 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1101 if (*yymsg_alloc < yysize)
1103 *yymsg_alloc = 2 * yysize;
1104 if (! (yysize <= *yymsg_alloc
1105 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1106 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
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. */
1116 while ((*yyp = *yyformat) != '\0')
1117 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1119 yyp += yytnamerr (yyp, yyarg[yyi++]);
1130 #endif /* YYERROR_VERBOSE */
1132 /*-----------------------------------------------.
1133 | Release the memory associated to this symbol. |
1134 `-----------------------------------------------*/
1137 #if (defined __STDC__ || defined __C99__FUNC__ \
1138 || defined __cplusplus || defined _MSC_VER)
1140 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1143 yydestruct (yymsg, yytype, yyvaluep)
1153 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1164 /* Prevent warnings from -Wmissing-prototypes. */
1165 #ifdef YYPARSE_PARAM
1166 #if defined __STDC__ || defined __cplusplus
1167 int yyparse (void *YYPARSE_PARAM);
1171 #else /* ! YYPARSE_PARAM */
1172 #if defined __STDC__ || defined __cplusplus
1177 #endif /* ! YYPARSE_PARAM */
1180 /* The lookahead symbol. */
1183 /* The semantic value of the lookahead symbol. */
1186 /* Number of syntax errors so far. */
1194 #ifdef YYPARSE_PARAM
1195 #if (defined __STDC__ || defined __C99__FUNC__ \
1196 || defined __cplusplus || defined _MSC_VER)
1198 yyparse (void *YYPARSE_PARAM)
1201 yyparse (YYPARSE_PARAM)
1202 void *YYPARSE_PARAM;
1204 #else /* ! YYPARSE_PARAM */
1205 #if (defined __STDC__ || defined __C99__FUNC__ \
1206 || defined __cplusplus || defined _MSC_VER)
1217 /* Number of tokens to shift before error messages enabled. */
1220 /* The stacks and their tools:
1221 `yyss': related to states.
1222 `yyvs': related to semantic values.
1224 Refer to the stacks thru separate pointers, to allow yyoverflow
1225 to reallocate them elsewhere. */
1227 /* The state stack. */
1228 yytype_int16 yyssa[YYINITDEPTH];
1230 yytype_int16 *yyssp;
1232 /* The semantic value stack. */
1233 YYSTYPE yyvsa[YYINITDEPTH];
1237 YYSIZE_T yystacksize;
1241 /* Lookahead token as an internal (translated) token number. */
1243 /* The variables used to return semantic value and location from the
1248 /* Buffer for error messages, and its allocated size. */
1250 char *yymsg = yymsgbuf;
1251 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1254 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1256 /* The number of symbols on the RHS of the reduced rule.
1257 Keep to zero when no symbol should be popped. */
1263 yystacksize = YYINITDEPTH;
1265 YYDPRINTF ((stderr, "Starting parse\n"));
1270 yychar = YYEMPTY; /* Cause a token to be read. */
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. */
1281 /*------------------------------------------------------------.
1282 | yynewstate -- Push a new state, which is found in yystate. |
1283 `------------------------------------------------------------*/
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. */
1292 if (yyss + yystacksize - 1 <= yyssp)
1294 /* Get the current used size of the three stacks, in elements. */
1295 YYSIZE_T yysize = yyssp - yyss + 1;
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
1302 YYSTYPE *yyvs1 = yyvs;
1303 yytype_int16 *yyss1 = yyss;
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),
1317 #else /* no yyoverflow */
1318 # ifndef YYSTACK_RELOCATE
1319 goto yyexhaustedlab;
1321 /* Extend the stack our own way. */
1322 if (YYMAXDEPTH <= yystacksize)
1323 goto yyexhaustedlab;
1325 if (YYMAXDEPTH < yystacksize)
1326 yystacksize = YYMAXDEPTH;
1329 yytype_int16 *yyss1 = yyss;
1330 union yyalloc *yyptr =
1331 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1333 goto yyexhaustedlab;
1334 YYSTACK_RELOCATE (yyss_alloc, yyss);
1335 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1336 # undef YYSTACK_RELOCATE
1338 YYSTACK_FREE (yyss1);
1341 #endif /* no yyoverflow */
1343 yyssp = yyss + yysize - 1;
1344 yyvsp = yyvs + yysize - 1;
1346 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1347 (unsigned long int) yystacksize));
1349 if (yyss + yystacksize - 1 <= yyssp)
1353 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1355 if (yystate == YYFINAL)
1365 /* Do appropriate processing given the current state. Read a
1366 lookahead token if we need one and don't already have one. */
1368 /* First try to decide what to do without reference to lookahead token. */
1369 yyn = yypact[yystate];
1370 if (yypact_value_is_default (yyn))
1373 /* Not known => get a lookahead token if don't already have one. */
1375 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1376 if (yychar == YYEMPTY)
1378 YYDPRINTF ((stderr, "Reading a token: "));
1382 if (yychar <= YYEOF)
1384 yychar = yytoken = YYEOF;
1385 YYDPRINTF ((stderr, "Now at end of input.\n"));
1389 yytoken = YYTRANSLATE (yychar);
1390 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1393 /* If the proper action on seeing token YYTOKEN is to reduce or to
1394 detect an error, take that action. */
1396 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1401 if (yytable_value_is_error (yyn))
1407 /* Count tokens shifted since error; after three, turn off error
1412 /* Shift the lookahead token. */
1413 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1415 /* Discard the shifted token. */
1424 /*-----------------------------------------------------------.
1425 | yydefault -- do the default action for the current state. |
1426 `-----------------------------------------------------------*/
1428 yyn = yydefact[yystate];
1434 /*-----------------------------.
1435 | yyreduce -- Do a reduction. |
1436 `-----------------------------*/
1438 /* yyn is the number of a rule to reduce with. */
1441 /* If YYLEN is nonzero, implement the default value of the action:
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];
1452 YY_REDUCE_PRINT (yyn);
1457 /* Line 1806 of yacc.c */
1458 #line 73 "spotlight_rawquery_parser.y"
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;
1470 /* Line 1806 of yacc.c */
1471 #line 83 "spotlight_rawquery_parser.y"
1473 if ((yyvsp[(1) - (1)].bval) == false)
1482 /* Line 1806 of yacc.c */
1483 #line 89 "spotlight_rawquery_parser.y"
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));
1488 (yyval.sval) = talloc_asprintf(ssp_slq, "%s", (yyvsp[(1) - (3)].sval));
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;}
1501 /* Line 1806 of yacc.c */
1502 #line 96 "spotlight_rawquery_parser.y"
1503 {(yyval.sval) = (yyvsp[(1) - (1)].sval);}
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));}
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));}
1522 /* Line 1806 of yacc.c */
1523 #line 99 "spotlight_rawquery_parser.y"
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));
1528 (yyval.sval) = talloc_asprintf(ssp_slq, "%s", (yyvsp[(1) - (3)].sval));
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));}
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));}
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));}
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));}
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));}
1569 /* Line 1806 of yacc.c */
1570 #line 119 "spotlight_rawquery_parser.y"
1571 {(yyval.tval) = isodate2unix((yyvsp[(3) - (4)].sval));}
1576 /* Line 1806 of yacc.c */
1577 #line 120 "spotlight_rawquery_parser.y"
1578 {(yyval.tval) = atoi((yyvsp[(1) - (1)].sval)) + SPRAW_TIME_OFFSET;}
1583 /* Line 1806 of yacc.c */
1584 #line 1585 "spotlight_rawquery_parser.c"
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);
1602 YY_STACK_PRINT (yyss, yyssp);
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. */
1612 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1613 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1614 yystate = yytable[yystate];
1616 yystate = yydefgoto[yyn - YYNTOKENS];
1621 /*------------------------------------.
1622 | yyerrlab -- here on detecting error |
1623 `------------------------------------*/
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);
1629 /* If not already recovering from an error, report this error. */
1633 #if ! YYERROR_VERBOSE
1634 yyerror (YY_("syntax error"));
1636 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1639 char const *yymsgp = YY_("syntax error");
1640 int yysyntax_error_status;
1641 yysyntax_error_status = YYSYNTAX_ERROR;
1642 if (yysyntax_error_status == 0)
1644 else if (yysyntax_error_status == 1)
1646 if (yymsg != yymsgbuf)
1647 YYSTACK_FREE (yymsg);
1648 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1652 yymsg_alloc = sizeof yymsgbuf;
1653 yysyntax_error_status = 2;
1657 yysyntax_error_status = YYSYNTAX_ERROR;
1662 if (yysyntax_error_status == 2)
1663 goto yyexhaustedlab;
1665 # undef YYSYNTAX_ERROR
1671 if (yyerrstatus == 3)
1673 /* If just tried and failed to reuse lookahead token after an
1674 error, discard it. */
1676 if (yychar <= YYEOF)
1678 /* Return failure if at end of input. */
1679 if (yychar == YYEOF)
1684 yydestruct ("Error: discarding",
1690 /* Else will try to reuse lookahead token after shifting the error
1695 /*---------------------------------------------------.
1696 | yyerrorlab -- error raised explicitly by YYERROR. |
1697 `---------------------------------------------------*/
1700 /* Pacify compilers like GCC when the user code never invokes
1701 YYERROR and the label yyerrorlab therefore never appears in user
1703 if (/*CONSTCOND*/ 0)
1706 /* Do not reclaim the symbols of the rule which action triggered
1710 YY_STACK_PRINT (yyss, yyssp);
1715 /*-------------------------------------------------------------.
1716 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1717 `-------------------------------------------------------------*/
1719 yyerrstatus = 3; /* Each real token shifted decrements this. */
1723 yyn = yypact[yystate];
1724 if (!yypact_value_is_default (yyn))
1727 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1735 /* Pop the current state because it cannot handle the error token. */
1740 yydestruct ("Error: popping",
1741 yystos[yystate], yyvsp);
1744 YY_STACK_PRINT (yyss, yyssp);
1750 /* Shift the error token. */
1751 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1757 /*-------------------------------------.
1758 | yyacceptlab -- YYACCEPT comes here. |
1759 `-------------------------------------*/
1764 /*-----------------------------------.
1765 | yyabortlab -- YYABORT comes here. |
1766 `-----------------------------------*/
1771 #if !defined(yyoverflow) || YYERROR_VERBOSE
1772 /*-------------------------------------------------.
1773 | yyexhaustedlab -- memory exhaustion comes here. |
1774 `-------------------------------------------------*/
1776 yyerror (YY_("memory exhausted"));
1782 if (yychar != YYEMPTY)
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",
1790 /* Do not reclaim the symbols of the rule which action triggered
1791 this YYABORT or YYACCEPT. */
1793 YY_STACK_PRINT (yyss, yyssp);
1794 while (yyssp != yyss)
1796 yydestruct ("Cleanup: popping",
1797 yystos[*yyssp], yyvsp);
1802 YYSTACK_FREE (yyss);
1805 if (yymsg != yymsgbuf)
1806 YYSTACK_FREE (yymsg);
1808 /* Make sure YYID is used. */
1809 return YYID (yyresult);
1814 /* Line 2067 of yacc.c */
1815 #line 123 "spotlight_rawquery_parser.y"
1818 static time_t isodate2unix(const char *s)
1822 if (strptime(s, "%Y-%m-%dT%H:%M:%SZ", &tm) == NULL)
1827 const char *map_daterange(const char *dateattr, time_t date1, time_t date2)
1830 char *result = NULL;
1831 struct spotlight_sparql_map *p;
1833 char buf1[64], buf2[64];
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);
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')",
1861 const char *map_expr(const char *attr, char op, const char *val)
1864 char *result = NULL;
1865 struct spotlight_sparql_map *p;
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) {
1874 result = talloc_asprintf(ssp_slq, "?obj %s '%s'", p->ssm_sparql_attr, val);
1877 result = talloc_asprintf(ssp_slq, "?obj %s ?%c FILTER(?%c %c '%s')",
1886 result = talloc_asprintf(ssp_slq, "?obj %s ?%c FILTER(regex(?%c, '%s'))",
1894 result = talloc_asprintf(ssp_slq, "?obj %s '%s'", p->ssm_sparql_attr, val);
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')",
1909 yyerror("unknown Spotlight attribute type");
1920 void yyerror(const char *str)
1923 printf("yyerror: %s\n", str);
1925 LOG(log_error, logtype_sl, "yyerror: %s", str);
1935 * Map a Spotlight RAW query string to a SPARQL query string
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
1942 int map_spotlight_to_sparql_query(slq_t *slq, gchar **sparql_result)
1945 YY_BUFFER_STATE s = NULL;
1949 s = yy_scan_string(slq->slq_qstring);
1952 EC_ZERO( yyparse() );
1956 yy_delete_buffer(s);
1958 *sparql_result = ssp_result;
1960 *sparql_result = NULL;
1965 int main(int argc, char **argv)
1971 printf("usage: %s QUERY\n", argv[0]);
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;
1981 s = yy_scan_string(argv[1]);
1985 yy_delete_buffer(s);
1988 printf("SPARQL: %s\n", ssp_result ? ssp_result : "(empty)");