1 /* A Bison parser, made by GNU Bison 2.7. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2012 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.7"
50 #define YYSKELETON_NAME "yacc.c"
64 /* Copy the first part of user declarations. */
65 /* Line 371 of yacc.c */
66 #line 1 "slmod_rdf_parser.y"
68 #include <atalk/standards.h>
77 #include <atalk/talloc.h>
78 #include <atalk/logger.h>
79 #include <atalk/errchk.h>
80 #include <atalk/spotlight.h>
82 #include "slmod_rdf_map.h"
84 struct yy_buffer_state;
85 typedef struct yy_buffer_state *YY_BUFFER_STATE;
86 extern int yylex (void);
87 extern void yyerror (char const *);
88 extern void *yyterminate(void);
89 extern YY_BUFFER_STATE yy_scan_string( const char *str);
90 extern void yy_delete_buffer ( YY_BUFFER_STATE buffer );
92 /* forward declarations */
93 static const char *map_expr(const char *attr, char op, const char *val);
94 static const char *map_daterange(const char *dateattr, time_t date1, time_t date2);
95 static time_t isodate2unix(const char *s);
97 /* global vars, eg needed by the lexer */
101 static gchar *srp_result;
102 static gchar *srp_fts;
104 /* Line 371 of yacc.c */
105 #line 106 "slmod_rdf_parser.c"
108 # if defined __cplusplus && 201103L <= __cplusplus
109 # define YY_NULL nullptr
115 /* Enabling verbose error messages. */
116 #ifdef YYERROR_VERBOSE
117 # undef YYERROR_VERBOSE
118 # define YYERROR_VERBOSE 1
120 # define YYERROR_VERBOSE 1
123 /* In a future release of Bison, this section will be replaced
124 by #include "y.tab.h". */
125 #ifndef YY_YY_Y_TAB_H_INCLUDED
126 # define YY_YY_Y_TAB_H_INCLUDED
127 /* Enabling traces. */
138 /* Put the tokens into the symbol table, so that GDB and other debuggers
160 #define FUNC_INRANGE 260
175 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
176 typedef union YYSTYPE
178 /* Line 387 of yacc.c */
179 #line 45 "slmod_rdf_parser.y"
187 /* Line 387 of yacc.c */
188 #line 189 "slmod_rdf_parser.c"
190 # define YYSTYPE_IS_TRIVIAL 1
191 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
192 # define YYSTYPE_IS_DECLARED 1
195 extern YYSTYPE yylval;
198 #if defined __STDC__ || defined __cplusplus
199 int yyparse (void *YYPARSE_PARAM);
203 #else /* ! YYPARSE_PARAM */
204 #if defined __STDC__ || defined __cplusplus
209 #endif /* ! YYPARSE_PARAM */
210 /* "%code provides" blocks. */
211 /* Line 387 of yacc.c */
212 #line 39 "slmod_rdf_parser.y"
214 #define SPRAW_TIME_OFFSET 978307200
215 extern int map_spotlight_to_rdf_query(slq_t *slq, gchar **rdf_result, gchar **fts_result);
216 extern slq_t *srp_slq;
219 /* Line 387 of yacc.c */
220 #line 221 "slmod_rdf_parser.c"
222 #endif /* !YY_YY_Y_TAB_H_INCLUDED */
224 /* Copy the second part of user declarations. */
226 /* Line 390 of yacc.c */
227 #line 228 "slmod_rdf_parser.c"
234 typedef YYTYPE_UINT8 yytype_uint8;
236 typedef unsigned char yytype_uint8;
240 typedef YYTYPE_INT8 yytype_int8;
241 #elif (defined __STDC__ || defined __C99__FUNC__ \
242 || defined __cplusplus || defined _MSC_VER)
243 typedef signed char yytype_int8;
245 typedef short int yytype_int8;
249 typedef YYTYPE_UINT16 yytype_uint16;
251 typedef unsigned short int yytype_uint16;
255 typedef YYTYPE_INT16 yytype_int16;
257 typedef short int yytype_int16;
261 # ifdef __SIZE_TYPE__
262 # define YYSIZE_T __SIZE_TYPE__
263 # elif defined size_t
264 # define YYSIZE_T size_t
265 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
266 || defined __cplusplus || defined _MSC_VER)
267 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
268 # define YYSIZE_T size_t
270 # define YYSIZE_T unsigned int
274 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
277 # if defined YYENABLE_NLS && YYENABLE_NLS
279 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
280 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
284 # define YY_(Msgid) Msgid
288 /* Suppress unused-variable warnings by "using" E. */
289 #if ! defined lint || defined __GNUC__
290 # define YYUSE(E) ((void) (E))
292 # define YYUSE(E) /* empty */
295 /* Identity function, used to suppress warnings about constant conditions. */
299 #if (defined __STDC__ || defined __C99__FUNC__ \
300 || defined __cplusplus || defined _MSC_VER)
313 #if ! defined yyoverflow || YYERROR_VERBOSE
315 /* The parser invokes alloca or malloc; define the necessary symbols. */
317 # ifdef YYSTACK_USE_ALLOCA
318 # if YYSTACK_USE_ALLOCA
320 # define YYSTACK_ALLOC __builtin_alloca
321 # elif defined __BUILTIN_VA_ARG_INCR
322 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
324 # define YYSTACK_ALLOC __alloca
325 # elif defined _MSC_VER
326 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
327 # define alloca _alloca
329 # define YYSTACK_ALLOC alloca
330 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
331 || defined __cplusplus || defined _MSC_VER)
332 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
333 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
334 # ifndef EXIT_SUCCESS
335 # define EXIT_SUCCESS 0
342 # ifdef YYSTACK_ALLOC
343 /* Pacify GCC's `empty if-body' warning. */
344 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
345 # ifndef YYSTACK_ALLOC_MAXIMUM
346 /* The OS might guarantee only one guard page at the bottom of the stack,
347 and a page size can be as small as 4096 bytes. So we cannot safely
348 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
349 to allow for a few compiler-allocated temporary stack slots. */
350 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
353 # define YYSTACK_ALLOC YYMALLOC
354 # define YYSTACK_FREE YYFREE
355 # ifndef YYSTACK_ALLOC_MAXIMUM
356 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
358 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
359 && ! ((defined YYMALLOC || defined malloc) \
360 && (defined YYFREE || defined free)))
361 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
362 # ifndef EXIT_SUCCESS
363 # define EXIT_SUCCESS 0
367 # define YYMALLOC malloc
368 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
369 || defined __cplusplus || defined _MSC_VER)
370 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
375 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
376 || defined __cplusplus || defined _MSC_VER)
377 void free (void *); /* INFRINGES ON USER NAME SPACE */
381 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
384 #if (! defined yyoverflow \
385 && (! defined __cplusplus \
386 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
388 /* A type that is properly aligned for any stack member. */
391 yytype_int16 yyss_alloc;
395 /* The size of the maximum gap between one aligned stack and the next. */
396 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
398 /* The size of an array large to enough to hold all stacks, each with
400 # define YYSTACK_BYTES(N) \
401 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
402 + YYSTACK_GAP_MAXIMUM)
404 # define YYCOPY_NEEDED 1
406 /* Relocate STACK from its old location to the new one. The
407 local variables YYSIZE and YYSTACKSIZE give the old and new number of
408 elements in the stack, and YYPTR gives the new location of the
409 stack. Advance YYPTR to a properly aligned location for the next
411 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
414 YYSIZE_T yynewbytes; \
415 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
416 Stack = &yyptr->Stack_alloc; \
417 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
418 yyptr += yynewbytes / sizeof (*yyptr); \
424 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
425 /* Copy COUNT objects from SRC to DST. The source and destination do
428 # if defined __GNUC__ && 1 < __GNUC__
429 # define YYCOPY(Dst, Src, Count) \
430 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
432 # define YYCOPY(Dst, Src, Count) \
436 for (yyi = 0; yyi < (Count); yyi++) \
437 (Dst)[yyi] = (Src)[yyi]; \
442 #endif /* !YYCOPY_NEEDED */
444 /* YYFINAL -- State number of the termination state. */
446 /* YYLAST -- Last index in YYTABLE. */
449 /* YYNTOKENS -- Number of terminals. */
451 /* YYNNTS -- Number of nonterminals. */
453 /* YYNRULES -- Number of rules. */
455 /* YYNRULES -- Number of states. */
458 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
460 #define YYMAXUTOK 271
462 #define YYTRANSLATE(YYX) \
463 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
465 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
466 static const yytype_uint8 yytranslate[] =
468 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
469 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
470 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
471 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
472 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
473 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
474 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
475 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
476 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
477 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
478 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
479 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
480 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
481 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
482 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
483 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
484 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
485 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
486 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
487 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
488 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
489 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
490 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
491 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
492 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
493 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
494 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
499 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
501 static const yytype_uint8 yyprhs[] =
503 0, 0, 3, 4, 7, 9, 11, 13, 15, 19,
504 23, 27, 33, 39, 45, 51, 58, 65, 72, 79,
508 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
509 static const yytype_int8 yyrhs[] =
511 18, 0, -1, -1, 18, 19, -1, 20, -1, 4,
512 -1, 21, -1, 22, -1, 7, 20, 8, -1, 20,
513 15, 20, -1, 20, 16, 20, -1, 3, 9, 14,
514 3, 14, -1, 3, 10, 14, 3, 14, -1, 3,
515 12, 14, 3, 14, -1, 3, 11, 14, 3, 14,
516 -1, 3, 9, 14, 3, 14, 3, -1, 3, 10,
517 14, 3, 14, 3, -1, 3, 12, 14, 3, 14,
518 3, -1, 3, 11, 14, 3, 14, 3, -1, 5,
519 7, 3, 13, 23, 13, 23, 8, -1, 6, 7,
523 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
524 static const yytype_uint8 yyrline[] =
526 0, 67, 67, 69, 73, 90, 96, 97, 98, 99,
527 100, 125, 126, 127, 128, 129, 130, 131, 132, 136,
532 #if YYDEBUG || YYERROR_VERBOSE || 1
533 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
534 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
535 static const char *const yytname[] =
537 "$end", "error", "$undefined", "WORD", "BOOL", "FUNC_INRANGE",
538 "DATE_ISO", "OBRACE", "CBRACE", "EQUAL", "UNEQUAL", "GT", "LT", "COMMA",
539 "QUOTE", "AND", "OR", "$accept", "input", "line", "expr", "match",
540 "function", "date", YY_NULL
545 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
547 static const yytype_uint16 yytoknum[] =
549 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
550 265, 266, 267, 268, 269, 270, 271
554 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
555 static const yytype_uint8 yyr1[] =
557 0, 17, 18, 18, 19, 20, 20, 20, 20, 20,
558 20, 21, 21, 21, 21, 21, 21, 21, 21, 22,
562 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
563 static const yytype_uint8 yyr2[] =
565 0, 2, 0, 2, 1, 1, 1, 1, 3, 3,
566 3, 5, 5, 5, 5, 6, 6, 6, 6, 8,
570 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
571 Performed when YYTABLE doesn't specify something else to do. Zero
572 means the default is an error. */
573 static const yytype_uint8 yydefact[] =
575 2, 0, 1, 0, 5, 0, 0, 3, 4, 6,
576 7, 0, 0, 0, 0, 0, 0, 0, 0, 0,
577 0, 0, 0, 0, 8, 9, 10, 0, 0, 0,
578 0, 0, 11, 12, 14, 13, 21, 0, 0, 15,
579 16, 18, 17, 0, 0, 0, 0, 20, 19
582 /* YYDEFGOTO[NTERM-NUM]. */
583 static const yytype_int8 yydefgoto[] =
585 -1, 1, 7, 8, 9, 10, 38
588 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
590 #define YYPACT_NINF -8
591 static const yytype_int8 yypact[] =
593 -8, 10, -8, 9, -8, -2, -1, -8, 8, -8,
594 -8, 2, 12, 13, 14, 4, -7, -1, -1, 26,
595 27, 28, 29, 20, -8, 18, -8, 21, 22, 23,
596 24, 19, 36, 37, 38, 39, -8, 40, 30, -8,
597 -8, -8, -8, 41, 19, 42, 43, -8, -8
600 /* YYPGOTO[NTERM-NUM]. */
601 static const yytype_int8 yypgoto[] =
603 -8, -8, -8, -6, -8, -8, 1
606 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
607 positive, shift that token. If negative, reduce the rule which
608 number is the opposite. If YYTABLE_NINF, syntax error. */
609 #define YYTABLE_NINF -1
610 static const yytype_uint8 yytable[] =
612 16, 24, 3, 4, 5, 15, 6, 23, 17, 18,
613 2, 25, 26, 3, 4, 5, 19, 6, 11, 12,
614 13, 14, 36, 17, 18, 37, 20, 21, 22, 27,
615 28, 29, 30, 31, 18, 32, 33, 34, 35, 39,
616 40, 41, 42, 44, 45, 46, 0, 43, 0, 0,
620 #define yypact_value_is_default(Yystate) \
621 (!!((Yystate) == (-8)))
623 #define yytable_value_is_error(Yytable_value) \
626 static const yytype_int8 yycheck[] =
628 6, 8, 3, 4, 5, 7, 7, 3, 15, 16,
629 0, 17, 18, 3, 4, 5, 14, 7, 9, 10,
630 11, 12, 3, 15, 16, 6, 14, 14, 14, 3,
631 3, 3, 3, 13, 16, 14, 14, 14, 14, 3,
632 3, 3, 3, 13, 3, 44, -1, 7, -1, -1,
636 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
637 symbol of state STATE-NUM. */
638 static const yytype_uint8 yystos[] =
640 0, 18, 0, 3, 4, 5, 7, 19, 20, 21,
641 22, 9, 10, 11, 12, 7, 20, 15, 16, 14,
642 14, 14, 14, 3, 8, 20, 20, 3, 3, 3,
643 3, 13, 14, 14, 14, 14, 3, 6, 23, 3,
644 3, 3, 3, 7, 13, 3, 23, 8, 8
647 #define yyerrok (yyerrstatus = 0)
648 #define yyclearin (yychar = YYEMPTY)
652 #define YYACCEPT goto yyacceptlab
653 #define YYABORT goto yyabortlab
654 #define YYERROR goto yyerrorlab
657 /* Like YYERROR except do call yyerror. This remains here temporarily
658 to ease the transition to the new meaning of YYERROR, for GCC.
659 Once GCC version 2 has supplanted version 1, this can go. However,
660 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
661 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
664 #define YYFAIL goto yyerrlab
666 /* This is here to suppress warnings from the GCC cpp's
667 -Wunused-macros. Normally we don't worry about that warning, but
668 some users do, and we want to make it easy for users to remove
669 YYFAIL uses, which will produce warnings from Bison 2.5. */
672 #define YYRECOVERING() (!!yyerrstatus)
674 #define YYBACKUP(Token, Value) \
676 if (yychar == YYEMPTY) \
680 YYPOPSTACK (yylen); \
686 yyerror (YY_("syntax error: cannot back up")); \
691 /* Error token number */
693 #define YYERRCODE 256
696 /* This macro is provided for backward compatibility. */
697 #ifndef YY_LOCATION_PRINT
698 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
702 /* YYLEX -- calling `yylex' with the right arguments. */
704 # define YYLEX yylex (YYLEX_PARAM)
706 # define YYLEX yylex ()
709 /* Enable debugging if requested. */
713 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
714 # define YYFPRINTF fprintf
717 # define YYDPRINTF(Args) \
723 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
727 YYFPRINTF (stderr, "%s ", Title); \
728 yy_symbol_print (stderr, \
730 YYFPRINTF (stderr, "\n"); \
735 /*--------------------------------.
736 | Print this symbol on YYOUTPUT. |
737 `--------------------------------*/
740 #if (defined __STDC__ || defined __C99__FUNC__ \
741 || defined __cplusplus || defined _MSC_VER)
743 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
746 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
749 YYSTYPE const * const yyvaluep;
752 FILE *yyo = yyoutput;
757 if (yytype < YYNTOKENS)
758 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
770 /*--------------------------------.
771 | Print this symbol on YYOUTPUT. |
772 `--------------------------------*/
774 #if (defined __STDC__ || defined __C99__FUNC__ \
775 || defined __cplusplus || defined _MSC_VER)
777 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
780 yy_symbol_print (yyoutput, yytype, yyvaluep)
783 YYSTYPE const * const yyvaluep;
786 if (yytype < YYNTOKENS)
787 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
789 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
791 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
792 YYFPRINTF (yyoutput, ")");
795 /*------------------------------------------------------------------.
796 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
798 `------------------------------------------------------------------*/
800 #if (defined __STDC__ || defined __C99__FUNC__ \
801 || defined __cplusplus || defined _MSC_VER)
803 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
806 yy_stack_print (yybottom, yytop)
807 yytype_int16 *yybottom;
811 YYFPRINTF (stderr, "Stack now");
812 for (; yybottom <= yytop; yybottom++)
814 int yybot = *yybottom;
815 YYFPRINTF (stderr, " %d", yybot);
817 YYFPRINTF (stderr, "\n");
820 # define YY_STACK_PRINT(Bottom, Top) \
823 yy_stack_print ((Bottom), (Top)); \
827 /*------------------------------------------------.
828 | Report that the YYRULE is going to be reduced. |
829 `------------------------------------------------*/
831 #if (defined __STDC__ || defined __C99__FUNC__ \
832 || defined __cplusplus || defined _MSC_VER)
834 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
837 yy_reduce_print (yyvsp, yyrule)
842 int yynrhs = yyr2[yyrule];
844 unsigned long int yylno = yyrline[yyrule];
845 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
847 /* The symbols being reduced. */
848 for (yyi = 0; yyi < yynrhs; yyi++)
850 YYFPRINTF (stderr, " $%d = ", yyi + 1);
851 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
852 &(yyvsp[(yyi + 1) - (yynrhs)])
854 YYFPRINTF (stderr, "\n");
858 # define YY_REDUCE_PRINT(Rule) \
861 yy_reduce_print (yyvsp, Rule); \
864 /* Nonzero means print parse trace. It is left uninitialized so that
865 multiple parsers can coexist. */
868 # define YYDPRINTF(Args)
869 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
870 # define YY_STACK_PRINT(Bottom, Top)
871 # define YY_REDUCE_PRINT(Rule)
872 #endif /* !YYDEBUG */
875 /* YYINITDEPTH -- initial size of the parser's stacks. */
877 # define YYINITDEPTH 200
880 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
881 if the built-in stack extension method is used).
883 Do not make this value too large; the results are undefined if
884 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
885 evaluated with infinite-precision integer arithmetic. */
888 # define YYMAXDEPTH 10000
895 # if defined __GLIBC__ && defined _STRING_H
896 # define yystrlen strlen
898 /* Return the length of YYSTR. */
899 #if (defined __STDC__ || defined __C99__FUNC__ \
900 || defined __cplusplus || defined _MSC_VER)
902 yystrlen (const char *yystr)
910 for (yylen = 0; yystr[yylen]; yylen++)
918 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
919 # define yystpcpy stpcpy
921 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
923 #if (defined __STDC__ || defined __C99__FUNC__ \
924 || defined __cplusplus || defined _MSC_VER)
926 yystpcpy (char *yydest, const char *yysrc)
929 yystpcpy (yydest, yysrc)
935 const char *yys = yysrc;
937 while ((*yyd++ = *yys++) != '\0')
946 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
947 quotes and backslashes, so that it's suitable for yyerror. The
948 heuristic is that double-quoting is unnecessary unless the string
949 contains an apostrophe, a comma, or backslash (other than
950 backslash-backslash). YYSTR is taken from yytname. If YYRES is
951 null, do not copy; instead, return the length of what the result
954 yytnamerr (char *yyres, const char *yystr)
959 char const *yyp = yystr;
966 goto do_not_strip_quotes;
970 goto do_not_strip_quotes;
983 do_not_strip_quotes: ;
987 return yystrlen (yystr);
989 return yystpcpy (yyres, yystr) - yyres;
993 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
994 about the unexpected token YYTOKEN for the state stack whose top is
997 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
998 not large enough to hold the message. In that case, also set
999 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1000 required number of bytes is too large to store. */
1002 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1003 yytype_int16 *yyssp, int yytoken)
1005 YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1006 YYSIZE_T yysize = yysize0;
1007 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1008 /* Internationalized format string. */
1009 const char *yyformat = YY_NULL;
1010 /* Arguments of yyformat. */
1011 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1012 /* Number of reported tokens (one for the "unexpected", one per
1016 /* There are many possibilities here to consider:
1017 - Assume YYFAIL is not used. It's too flawed to consider. See
1018 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1019 for details. YYERROR is fine as it does not invoke this
1021 - If this state is a consistent state with a default action, then
1022 the only way this function was invoked is if the default action
1023 is an error action. In that case, don't check for expected
1024 tokens because there are none.
1025 - The only way there can be no lookahead present (in yychar) is if
1026 this state is a consistent state with a default action. Thus,
1027 detecting the absence of a lookahead is sufficient to determine
1028 that there is no unexpected or expected token to report. In that
1029 case, just report a simple "syntax error".
1030 - Don't assume there isn't a lookahead just because this state is a
1031 consistent state with a default action. There might have been a
1032 previous inconsistent state, consistent state with a non-default
1033 action, or user semantic action that manipulated yychar.
1034 - Of course, the expected token list depends on states to have
1035 correct lookahead information, and it depends on the parser not
1036 to perform extra reductions after fetching a lookahead from the
1037 scanner and before detecting a syntax error. Thus, state merging
1038 (from LALR or IELR) and default reductions corrupt the expected
1039 token list. However, the list is correct for canonical LR with
1040 one exception: it will still contain any token that will not be
1041 accepted due to an error action in a later state.
1043 if (yytoken != YYEMPTY)
1045 int yyn = yypact[*yyssp];
1046 yyarg[yycount++] = yytname[yytoken];
1047 if (!yypact_value_is_default (yyn))
1049 /* Start YYX at -YYN if negative to avoid negative indexes in
1050 YYCHECK. In other words, skip the first -YYN actions for
1051 this state because they are default actions. */
1052 int yyxbegin = yyn < 0 ? -yyn : 0;
1053 /* Stay within bounds of both yycheck and yytname. */
1054 int yychecklim = YYLAST - yyn + 1;
1055 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1058 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1059 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1060 && !yytable_value_is_error (yytable[yyx + yyn]))
1062 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1068 yyarg[yycount++] = yytname[yyx];
1070 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1071 if (! (yysize <= yysize1
1072 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1082 # define YYCASE_(N, S) \
1086 YYCASE_(0, YY_("syntax error"));
1087 YYCASE_(1, YY_("syntax error, unexpected %s"));
1088 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1089 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1090 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1091 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1096 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1097 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1102 if (*yymsg_alloc < yysize)
1104 *yymsg_alloc = 2 * yysize;
1105 if (! (yysize <= *yymsg_alloc
1106 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1107 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1111 /* Avoid sprintf, as that infringes on the user's name space.
1112 Don't have undefined behavior even if the translation
1113 produced a string with the wrong number of "%s"s. */
1117 while ((*yyp = *yyformat) != '\0')
1118 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1120 yyp += yytnamerr (yyp, yyarg[yyi++]);
1131 #endif /* YYERROR_VERBOSE */
1133 /*-----------------------------------------------.
1134 | Release the memory associated to this symbol. |
1135 `-----------------------------------------------*/
1138 #if (defined __STDC__ || defined __C99__FUNC__ \
1139 || defined __cplusplus || defined _MSC_VER)
1141 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1144 yydestruct (yymsg, yytype, yyvaluep)
1154 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1167 /* The lookahead symbol. */
1171 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1172 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1173 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1175 #ifndef YY_INITIAL_VALUE
1176 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1179 /* The semantic value of the lookahead symbol. */
1180 YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
1182 /* Number of syntax errors so far. */
1190 #ifdef YYPARSE_PARAM
1191 #if (defined __STDC__ || defined __C99__FUNC__ \
1192 || defined __cplusplus || defined _MSC_VER)
1194 yyparse (void *YYPARSE_PARAM)
1197 yyparse (YYPARSE_PARAM)
1198 void *YYPARSE_PARAM;
1200 #else /* ! YYPARSE_PARAM */
1201 #if (defined __STDC__ || defined __C99__FUNC__ \
1202 || defined __cplusplus || defined _MSC_VER)
1213 /* Number of tokens to shift before error messages enabled. */
1216 /* The stacks and their tools:
1217 `yyss': related to states.
1218 `yyvs': related to semantic values.
1220 Refer to the stacks through separate pointers, to allow yyoverflow
1221 to reallocate them elsewhere. */
1223 /* The state stack. */
1224 yytype_int16 yyssa[YYINITDEPTH];
1226 yytype_int16 *yyssp;
1228 /* The semantic value stack. */
1229 YYSTYPE yyvsa[YYINITDEPTH];
1233 YYSIZE_T yystacksize;
1237 /* Lookahead token as an internal (translated) token number. */
1239 /* The variables used to return semantic value and location from the
1244 /* Buffer for error messages, and its allocated size. */
1246 char *yymsg = yymsgbuf;
1247 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1250 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1252 /* The number of symbols on the RHS of the reduced rule.
1253 Keep to zero when no symbol should be popped. */
1256 yyssp = yyss = yyssa;
1257 yyvsp = yyvs = yyvsa;
1258 yystacksize = YYINITDEPTH;
1260 YYDPRINTF ((stderr, "Starting parse\n"));
1265 yychar = YYEMPTY; /* Cause a token to be read. */
1268 /*------------------------------------------------------------.
1269 | yynewstate -- Push a new state, which is found in yystate. |
1270 `------------------------------------------------------------*/
1272 /* In all cases, when you get here, the value and location stacks
1273 have just been pushed. So pushing a state here evens the stacks. */
1279 if (yyss + yystacksize - 1 <= yyssp)
1281 /* Get the current used size of the three stacks, in elements. */
1282 YYSIZE_T yysize = yyssp - yyss + 1;
1286 /* Give user a chance to reallocate the stack. Use copies of
1287 these so that the &'s don't force the real ones into
1289 YYSTYPE *yyvs1 = yyvs;
1290 yytype_int16 *yyss1 = yyss;
1292 /* Each stack pointer address is followed by the size of the
1293 data in use in that stack, in bytes. This used to be a
1294 conditional around just the two extra args, but that might
1295 be undefined if yyoverflow is a macro. */
1296 yyoverflow (YY_("memory exhausted"),
1297 &yyss1, yysize * sizeof (*yyssp),
1298 &yyvs1, yysize * sizeof (*yyvsp),
1304 #else /* no yyoverflow */
1305 # ifndef YYSTACK_RELOCATE
1306 goto yyexhaustedlab;
1308 /* Extend the stack our own way. */
1309 if (YYMAXDEPTH <= yystacksize)
1310 goto yyexhaustedlab;
1312 if (YYMAXDEPTH < yystacksize)
1313 yystacksize = YYMAXDEPTH;
1316 yytype_int16 *yyss1 = yyss;
1317 union yyalloc *yyptr =
1318 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1320 goto yyexhaustedlab;
1321 YYSTACK_RELOCATE (yyss_alloc, yyss);
1322 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1323 # undef YYSTACK_RELOCATE
1325 YYSTACK_FREE (yyss1);
1328 #endif /* no yyoverflow */
1330 yyssp = yyss + yysize - 1;
1331 yyvsp = yyvs + yysize - 1;
1333 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1334 (unsigned long int) yystacksize));
1336 if (yyss + yystacksize - 1 <= yyssp)
1340 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1342 if (yystate == YYFINAL)
1352 /* Do appropriate processing given the current state. Read a
1353 lookahead token if we need one and don't already have one. */
1355 /* First try to decide what to do without reference to lookahead token. */
1356 yyn = yypact[yystate];
1357 if (yypact_value_is_default (yyn))
1360 /* Not known => get a lookahead token if don't already have one. */
1362 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1363 if (yychar == YYEMPTY)
1365 YYDPRINTF ((stderr, "Reading a token: "));
1369 if (yychar <= YYEOF)
1371 yychar = yytoken = YYEOF;
1372 YYDPRINTF ((stderr, "Now at end of input.\n"));
1376 yytoken = YYTRANSLATE (yychar);
1377 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1380 /* If the proper action on seeing token YYTOKEN is to reduce or to
1381 detect an error, take that action. */
1383 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1388 if (yytable_value_is_error (yyn))
1394 /* Count tokens shifted since error; after three, turn off error
1399 /* Shift the lookahead token. */
1400 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1402 /* Discard the shifted token. */
1406 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1408 YY_IGNORE_MAYBE_UNINITIALIZED_END
1413 /*-----------------------------------------------------------.
1414 | yydefault -- do the default action for the current state. |
1415 `-----------------------------------------------------------*/
1417 yyn = yydefact[yystate];
1423 /*-----------------------------.
1424 | yyreduce -- Do a reduction. |
1425 `-----------------------------*/
1427 /* yyn is the number of a rule to reduce with. */
1430 /* If YYLEN is nonzero, implement the default value of the action:
1433 Otherwise, the following line sets YYVAL to garbage.
1434 This behavior is undocumented and Bison
1435 users should not rely upon it. Assigning to YYVAL
1436 unconditionally makes the parser a bit smaller, and it avoids a
1437 GCC warning that YYVAL may be used uninitialized. */
1438 yyval = yyvsp[1-yylen];
1441 YY_REDUCE_PRINT (yyn);
1445 /* Line 1792 of yacc.c */
1446 #line 73 "slmod_rdf_parser.y"
1448 srp_result = talloc_asprintf(srp_slq,
1449 "<rdfq:Condition>\n"
1451 " <rdfq:startsWith>\n"
1452 " <rdfq:Property name=\"File:Path\" />\n"
1453 " <rdf:String>%s</rdf:String>\n"
1454 " </rdfq:startsWith>\n"
1457 "</rdfq:Condition>\n",
1458 srp_slq->slq_vol->v_path, (yyvsp[(1) - (1)].sval));
1459 (yyval.sval) = srp_result;
1464 /* Line 1792 of yacc.c */
1465 #line 90 "slmod_rdf_parser.y"
1467 if ((yyvsp[(1) - (1)].bval) == false)
1475 /* Line 1792 of yacc.c */
1476 #line 96 "slmod_rdf_parser.y"
1477 {(yyval.sval) = (yyvsp[(1) - (1)].sval); if ((yyval.sval) == NULL) YYABORT;}
1481 /* Line 1792 of yacc.c */
1482 #line 97 "slmod_rdf_parser.y"
1483 {(yyval.sval) = (yyvsp[(1) - (1)].sval);}
1487 /* Line 1792 of yacc.c */
1488 #line 98 "slmod_rdf_parser.y"
1489 {(yyval.sval) = talloc_asprintf(srp_slq, "%s\n", (yyvsp[(2) - (3)].sval));}
1493 /* Line 1792 of yacc.c */
1494 #line 99 "slmod_rdf_parser.y"
1495 {(yyval.sval) = talloc_asprintf(srp_slq, "<rdfq:and>\n%s\n%s\n</rdfq:and>\n", (yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval));}
1499 /* Line 1792 of yacc.c */
1500 #line 100 "slmod_rdf_parser.y"
1502 if (strcmp((yyvsp[(1) - (3)].sval), "") == 0 || strcmp((yyvsp[(3) - (3)].sval), "") == 0) {
1504 * The default Spotlight search term issued by the Finder (10.8) is:
1505 * '* == "searchterm" || kMDItemTextContent == "searchterm"'
1506 * As it isn't mappable to a single Tracker RDF query, we silently
1507 * map ANY FTS query expression being part of an OR compound
1508 * expression to a simple filename search.
1509 * FTS queries are thus only possible by explicitly requesting
1510 * file content FTS search in the Finder on the client (resulting
1511 * in a 'kMDItemTextContent == "searchterm"' query).
1513 if (strcmp((yyvsp[(1) - (3)].sval), "") == 0)
1514 (yyval.sval) = talloc_asprintf(srp_slq, (yyvsp[(3) - (3)].sval));
1516 (yyval.sval) = talloc_asprintf(srp_slq, (yyvsp[(1) - (3)].sval));
1517 talloc_free(srp_fts);
1520 (yyval.sval) = talloc_asprintf(srp_slq, "<rdfq:or>\n%s\n%s\n</rdfq:or>\n", (yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval));
1526 /* Line 1792 of yacc.c */
1527 #line 125 "slmod_rdf_parser.y"
1528 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '=', (yyvsp[(4) - (5)].sval));}
1532 /* Line 1792 of yacc.c */
1533 #line 126 "slmod_rdf_parser.y"
1534 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '!', (yyvsp[(4) - (5)].sval));}
1538 /* Line 1792 of yacc.c */
1539 #line 127 "slmod_rdf_parser.y"
1540 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '<', (yyvsp[(4) - (5)].sval));}
1544 /* Line 1792 of yacc.c */
1545 #line 128 "slmod_rdf_parser.y"
1546 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '>', (yyvsp[(4) - (5)].sval));}
1550 /* Line 1792 of yacc.c */
1551 #line 129 "slmod_rdf_parser.y"
1552 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '=', (yyvsp[(4) - (6)].sval));}
1556 /* Line 1792 of yacc.c */
1557 #line 130 "slmod_rdf_parser.y"
1558 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '!', (yyvsp[(4) - (6)].sval));}
1562 /* Line 1792 of yacc.c */
1563 #line 131 "slmod_rdf_parser.y"
1564 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '<', (yyvsp[(4) - (6)].sval));}
1568 /* Line 1792 of yacc.c */
1569 #line 132 "slmod_rdf_parser.y"
1570 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '>', (yyvsp[(4) - (6)].sval));}
1574 /* Line 1792 of yacc.c */
1575 #line 136 "slmod_rdf_parser.y"
1576 {(yyval.sval) = map_daterange((yyvsp[(3) - (8)].sval), (yyvsp[(5) - (8)].tval), (yyvsp[(7) - (8)].tval));}
1580 /* Line 1792 of yacc.c */
1581 #line 140 "slmod_rdf_parser.y"
1582 {(yyval.tval) = isodate2unix((yyvsp[(3) - (4)].sval));}
1586 /* Line 1792 of yacc.c */
1587 #line 141 "slmod_rdf_parser.y"
1588 {(yyval.tval) = atoi((yyvsp[(1) - (1)].sval)) + SPRAW_TIME_OFFSET;}
1592 /* Line 1792 of yacc.c */
1593 #line 1594 "slmod_rdf_parser.c"
1596 /* User semantic actions sometimes alter yychar, and that requires
1597 that yytoken be updated with the new translation. We take the
1598 approach of translating immediately before every use of yytoken.
1599 One alternative is translating here after every semantic action,
1600 but that translation would be missed if the semantic action invokes
1601 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1602 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1603 incorrect destructor might then be invoked immediately. In the
1604 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1605 to an incorrect destructor call or verbose syntax error message
1606 before the lookahead is translated. */
1607 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1611 YY_STACK_PRINT (yyss, yyssp);
1615 /* Now `shift' the result of the reduction. Determine what state
1616 that goes to, based on the state we popped back to and the rule
1617 number reduced by. */
1621 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1622 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1623 yystate = yytable[yystate];
1625 yystate = yydefgoto[yyn - YYNTOKENS];
1630 /*------------------------------------.
1631 | yyerrlab -- here on detecting error |
1632 `------------------------------------*/
1634 /* Make sure we have latest lookahead translation. See comments at
1635 user semantic actions for why this is necessary. */
1636 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1638 /* If not already recovering from an error, report this error. */
1642 #if ! YYERROR_VERBOSE
1643 yyerror (YY_("syntax error"));
1645 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1648 char const *yymsgp = YY_("syntax error");
1649 int yysyntax_error_status;
1650 yysyntax_error_status = YYSYNTAX_ERROR;
1651 if (yysyntax_error_status == 0)
1653 else if (yysyntax_error_status == 1)
1655 if (yymsg != yymsgbuf)
1656 YYSTACK_FREE (yymsg);
1657 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1661 yymsg_alloc = sizeof yymsgbuf;
1662 yysyntax_error_status = 2;
1666 yysyntax_error_status = YYSYNTAX_ERROR;
1671 if (yysyntax_error_status == 2)
1672 goto yyexhaustedlab;
1674 # undef YYSYNTAX_ERROR
1680 if (yyerrstatus == 3)
1682 /* If just tried and failed to reuse lookahead token after an
1683 error, discard it. */
1685 if (yychar <= YYEOF)
1687 /* Return failure if at end of input. */
1688 if (yychar == YYEOF)
1693 yydestruct ("Error: discarding",
1699 /* Else will try to reuse lookahead token after shifting the error
1704 /*---------------------------------------------------.
1705 | yyerrorlab -- error raised explicitly by YYERROR. |
1706 `---------------------------------------------------*/
1709 /* Pacify compilers like GCC when the user code never invokes
1710 YYERROR and the label yyerrorlab therefore never appears in user
1712 if (/*CONSTCOND*/ 0)
1715 /* Do not reclaim the symbols of the rule which action triggered
1719 YY_STACK_PRINT (yyss, yyssp);
1724 /*-------------------------------------------------------------.
1725 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1726 `-------------------------------------------------------------*/
1728 yyerrstatus = 3; /* Each real token shifted decrements this. */
1732 yyn = yypact[yystate];
1733 if (!yypact_value_is_default (yyn))
1736 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1744 /* Pop the current state because it cannot handle the error token. */
1749 yydestruct ("Error: popping",
1750 yystos[yystate], yyvsp);
1753 YY_STACK_PRINT (yyss, yyssp);
1756 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1758 YY_IGNORE_MAYBE_UNINITIALIZED_END
1761 /* Shift the error token. */
1762 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1768 /*-------------------------------------.
1769 | yyacceptlab -- YYACCEPT comes here. |
1770 `-------------------------------------*/
1775 /*-----------------------------------.
1776 | yyabortlab -- YYABORT comes here. |
1777 `-----------------------------------*/
1782 #if !defined yyoverflow || YYERROR_VERBOSE
1783 /*-------------------------------------------------.
1784 | yyexhaustedlab -- memory exhaustion comes here. |
1785 `-------------------------------------------------*/
1787 yyerror (YY_("memory exhausted"));
1793 if (yychar != YYEMPTY)
1795 /* Make sure we have latest lookahead translation. See comments at
1796 user semantic actions for why this is necessary. */
1797 yytoken = YYTRANSLATE (yychar);
1798 yydestruct ("Cleanup: discarding lookahead",
1801 /* Do not reclaim the symbols of the rule which action triggered
1802 this YYABORT or YYACCEPT. */
1804 YY_STACK_PRINT (yyss, yyssp);
1805 while (yyssp != yyss)
1807 yydestruct ("Cleanup: popping",
1808 yystos[*yyssp], yyvsp);
1813 YYSTACK_FREE (yyss);
1816 if (yymsg != yymsgbuf)
1817 YYSTACK_FREE (yymsg);
1819 /* Make sure YYID is used. */
1820 return YYID (yyresult);
1824 /* Line 2055 of yacc.c */
1825 #line 144 "slmod_rdf_parser.y"
1828 static time_t isodate2unix(const char *s)
1832 if (strptime(s, "%Y-%m-%dT%H:%M:%SZ", &tm) == NULL)
1837 static const char *map_daterange(const char *dateattr, time_t date1, time_t date2)
1840 char *result = NULL;
1841 struct spotlight_rdf_map *p;
1843 char buf1[64], buf2[64];
1845 EC_NULL_LOG( tmp = localtime(&date1) );
1846 strftime(buf1, sizeof(buf1), "%Y-%m-%dT%H:%M:%SZ", tmp);
1847 EC_NULL_LOG( tmp = localtime(&date2) );
1848 strftime(buf2, sizeof(buf2), "%Y-%m-%dT%H:%M:%SZ", tmp);
1850 for (p = spotlight_rdf_map; p->srm_spotlight_attr; p++) {
1851 if (strcmp(dateattr, p->srm_spotlight_attr) == 0) {
1852 result = talloc_asprintf(srp_slq,
1854 " <rdfq:greaterThan>\n"
1855 " <rdfq:Property name=\"%s\" />\n"
1856 " <rdf:Date>%s</rdf:Date>\n"
1857 " </rdfq:greaterThan>\n"
1858 " <rdfq:lessThan>\n"
1859 " <rdfq:Property name=\"%s\" />\n"
1860 " <rdf:Date>%s</rdf:Date>\n"
1861 " </rdfq:lessThan>\n"
1863 p->srm_rdf_attr, buf1,
1864 p->srm_rdf_attr, buf2);
1875 static char *map_type_search(const char *attr, char op, const char *val)
1877 char *result = NULL;
1879 for (struct MDTypeMap *p = MDTypeMap; p->mdtm_value; p++) {
1880 if (strcmp(p->mdtm_value, val) == 0) {
1883 result = talloc_asprintf(srp_slq,
1885 " <rdfq:Property name=\"File:Mime\" />\n"
1886 " <rdf:String>%s</rdf:String>\n"
1897 static const char *map_expr(const char *attr, char op, const char *val)
1900 char *result = NULL;
1901 struct spotlight_rdf_map *p;
1905 bstring q = NULL, search = NULL, replace = NULL;
1908 for (p = spotlight_rdf_map; p->srm_spotlight_attr; p++) {
1909 if (p->srm_rdf_attr && strcmp(p->srm_spotlight_attr, attr) == 0) {
1910 switch (p->srm_type) {
1912 q = bformat("^%s$", val);
1913 search = bfromcstr("*");
1914 replace = bfromcstr(".*");
1915 bfindreplace(q, search, replace, 0);
1916 result = talloc_asprintf(srp_slq,
1918 " <rdfq:Property name=\"%s\" />\n"
1919 " <rdf:String>%s</rdf:String>\n"
1927 q = bformat("^%s$", val);
1928 search = bfromcstr("*");
1929 replace = bfromcstr(".*");
1930 bfindreplace(q, search, replace, 0);
1931 result = talloc_asprintf(srp_slq,
1933 " <rdfq:Property name=\"%s\" />\n"
1934 " <rdf:String>%s</rdf:String>\n"
1943 yyerror("only single fts query allowed");
1947 search = bfromcstr("*");
1948 replace = bfromcstr("");
1949 bfindreplace(q, search, replace, 0);
1950 srp_fts = talloc_strdup(srp_slq, bdata(q));
1955 t = atoi(val) + SPRAW_TIME_OFFSET;
1956 EC_NULL( tmp = localtime(&t) );
1957 strftime(buf1, sizeof(buf1), "%Y-%m-%dT%H:%M:%SZ", tmp);
1965 rdfop = "greaterThan";
1967 yyerror("unknown date comparison");
1970 result = talloc_asprintf(srp_slq,
1972 " <rdfq:Property name=\"%s\" />\n"
1973 " <rdf:Date>%s</rdf:Date>\n"
1983 result = map_type_search(attr, op, val);
1987 yyerror("unknown Spotlight attribute type");
2004 void yyerror(const char *str)
2007 printf("yyerror: %s\n", str);
2009 LOG(log_error, logtype_sl, "yyerror: %s", str);
2019 * Map a Spotlight RAW query string to a RDF query
2021 * @param[in] slq Spotlight query handle
2022 * @param[out] sparql_result Mapped RDF query, string is allocated in
2023 * talloc context of slq
2024 * @return 0 on success, -1 on error
2026 int map_spotlight_to_rdf_query(slq_t *slq, gchar **rdf_result, gchar **fts_result)
2029 YY_BUFFER_STATE s = NULL;
2034 s = yy_scan_string(slq->slq_qstring);
2036 EC_ZERO( yyparse() );
2040 yy_delete_buffer(s);
2042 *rdf_result = srp_result;
2043 *fts_result = srp_fts;
2052 int main(int argc, char **argv)
2058 printf("usage: %s QUERY\n", argv[0]);
2062 srp_slq = talloc_zero(NULL, slq_t);
2063 struct vol *vol = talloc_zero(srp_slq, struct vol);
2064 vol->v_path = "/Volumes/test";
2065 srp_slq->slq_vol = vol;
2067 s = yy_scan_string(argv[1]);
2071 yy_delete_buffer(s);
2074 printf("RDF:\n%s\nFTS: %s\n",
2075 srp_result ? srp_result : "(empty)",
2076 srp_fts ? srp_fts : "(none)");