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>
78 #include <atalk/talloc.h>
79 #include <atalk/logger.h>
80 #include <atalk/errchk.h>
81 #include <atalk/spotlight.h>
83 #include "slmod_rdf_map.h"
85 struct yy_buffer_state;
86 typedef struct yy_buffer_state *YY_BUFFER_STATE;
87 extern int yylex (void);
88 extern void yyerror (char const *);
89 extern void *yyterminate(void);
90 extern YY_BUFFER_STATE yy_scan_string( const char *str);
91 extern void yy_delete_buffer ( YY_BUFFER_STATE buffer );
93 /* forward declarations */
94 static const char *map_expr(const char *attr, char op, const char *val);
95 static const char *map_daterange(const char *dateattr, time_t date1, time_t date2);
96 static time_t isodate2unix(const char *s);
98 /* global vars, eg needed by the lexer */
102 static gchar *srp_result;
103 static gchar *srp_fts;
105 /* Line 371 of yacc.c */
106 #line 107 "slmod_rdf_parser.c"
109 # if defined __cplusplus && 201103L <= __cplusplus
110 # define YY_NULL nullptr
116 /* Enabling verbose error messages. */
117 #ifdef YYERROR_VERBOSE
118 # undef YYERROR_VERBOSE
119 # define YYERROR_VERBOSE 1
121 # define YYERROR_VERBOSE 1
124 /* In a future release of Bison, this section will be replaced
125 by #include "y.tab.h". */
126 #ifndef YY_YY_Y_TAB_H_INCLUDED
127 # define YY_YY_Y_TAB_H_INCLUDED
128 /* Enabling traces. */
139 /* Put the tokens into the symbol table, so that GDB and other debuggers
161 #define FUNC_INRANGE 260
176 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
177 typedef union YYSTYPE
179 /* Line 387 of yacc.c */
180 #line 46 "slmod_rdf_parser.y"
188 /* Line 387 of yacc.c */
189 #line 190 "slmod_rdf_parser.c"
191 # define YYSTYPE_IS_TRIVIAL 1
192 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
193 # define YYSTYPE_IS_DECLARED 1
196 extern YYSTYPE yylval;
199 #if defined __STDC__ || defined __cplusplus
200 int yyparse (void *YYPARSE_PARAM);
204 #else /* ! YYPARSE_PARAM */
205 #if defined __STDC__ || defined __cplusplus
210 #endif /* ! YYPARSE_PARAM */
211 /* "%code provides" blocks. */
212 /* Line 387 of yacc.c */
213 #line 40 "slmod_rdf_parser.y"
215 #define SPRAW_TIME_OFFSET 978307200
216 extern int map_spotlight_to_rdf_query(slq_t *slq);
217 extern slq_t *srp_slq;
220 /* Line 387 of yacc.c */
221 #line 222 "slmod_rdf_parser.c"
223 #endif /* !YY_YY_Y_TAB_H_INCLUDED */
225 /* Copy the second part of user declarations. */
227 /* Line 390 of yacc.c */
228 #line 229 "slmod_rdf_parser.c"
235 typedef YYTYPE_UINT8 yytype_uint8;
237 typedef unsigned char yytype_uint8;
241 typedef YYTYPE_INT8 yytype_int8;
242 #elif (defined __STDC__ || defined __C99__FUNC__ \
243 || defined __cplusplus || defined _MSC_VER)
244 typedef signed char yytype_int8;
246 typedef short int yytype_int8;
250 typedef YYTYPE_UINT16 yytype_uint16;
252 typedef unsigned short int yytype_uint16;
256 typedef YYTYPE_INT16 yytype_int16;
258 typedef short int yytype_int16;
262 # ifdef __SIZE_TYPE__
263 # define YYSIZE_T __SIZE_TYPE__
264 # elif defined size_t
265 # define YYSIZE_T size_t
266 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
267 || defined __cplusplus || defined _MSC_VER)
268 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
269 # define YYSIZE_T size_t
271 # define YYSIZE_T unsigned int
275 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
278 # if defined YYENABLE_NLS && YYENABLE_NLS
280 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
281 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
285 # define YY_(Msgid) Msgid
289 /* Suppress unused-variable warnings by "using" E. */
290 #if ! defined lint || defined __GNUC__
291 # define YYUSE(E) ((void) (E))
293 # define YYUSE(E) /* empty */
296 /* Identity function, used to suppress warnings about constant conditions. */
300 #if (defined __STDC__ || defined __C99__FUNC__ \
301 || defined __cplusplus || defined _MSC_VER)
314 #if ! defined yyoverflow || YYERROR_VERBOSE
316 /* The parser invokes alloca or malloc; define the necessary symbols. */
318 # ifdef YYSTACK_USE_ALLOCA
319 # if YYSTACK_USE_ALLOCA
321 # define YYSTACK_ALLOC __builtin_alloca
322 # elif defined __BUILTIN_VA_ARG_INCR
323 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
325 # define YYSTACK_ALLOC __alloca
326 # elif defined _MSC_VER
327 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
328 # define alloca _alloca
330 # define YYSTACK_ALLOC alloca
331 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
332 || defined __cplusplus || defined _MSC_VER)
333 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
334 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
335 # ifndef EXIT_SUCCESS
336 # define EXIT_SUCCESS 0
343 # ifdef YYSTACK_ALLOC
344 /* Pacify GCC's `empty if-body' warning. */
345 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
346 # ifndef YYSTACK_ALLOC_MAXIMUM
347 /* The OS might guarantee only one guard page at the bottom of the stack,
348 and a page size can be as small as 4096 bytes. So we cannot safely
349 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
350 to allow for a few compiler-allocated temporary stack slots. */
351 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
354 # define YYSTACK_ALLOC YYMALLOC
355 # define YYSTACK_FREE YYFREE
356 # ifndef YYSTACK_ALLOC_MAXIMUM
357 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
359 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
360 && ! ((defined YYMALLOC || defined malloc) \
361 && (defined YYFREE || defined free)))
362 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
363 # ifndef EXIT_SUCCESS
364 # define EXIT_SUCCESS 0
368 # define YYMALLOC malloc
369 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
370 || defined __cplusplus || defined _MSC_VER)
371 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
376 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
377 || defined __cplusplus || defined _MSC_VER)
378 void free (void *); /* INFRINGES ON USER NAME SPACE */
382 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
385 #if (! defined yyoverflow \
386 && (! defined __cplusplus \
387 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
389 /* A type that is properly aligned for any stack member. */
392 yytype_int16 yyss_alloc;
396 /* The size of the maximum gap between one aligned stack and the next. */
397 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
399 /* The size of an array large to enough to hold all stacks, each with
401 # define YYSTACK_BYTES(N) \
402 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
403 + YYSTACK_GAP_MAXIMUM)
405 # define YYCOPY_NEEDED 1
407 /* Relocate STACK from its old location to the new one. The
408 local variables YYSIZE and YYSTACKSIZE give the old and new number of
409 elements in the stack, and YYPTR gives the new location of the
410 stack. Advance YYPTR to a properly aligned location for the next
412 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
415 YYSIZE_T yynewbytes; \
416 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
417 Stack = &yyptr->Stack_alloc; \
418 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
419 yyptr += yynewbytes / sizeof (*yyptr); \
425 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
426 /* Copy COUNT objects from SRC to DST. The source and destination do
429 # if defined __GNUC__ && 1 < __GNUC__
430 # define YYCOPY(Dst, Src, Count) \
431 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
433 # define YYCOPY(Dst, Src, Count) \
437 for (yyi = 0; yyi < (Count); yyi++) \
438 (Dst)[yyi] = (Src)[yyi]; \
443 #endif /* !YYCOPY_NEEDED */
445 /* YYFINAL -- State number of the termination state. */
447 /* YYLAST -- Last index in YYTABLE. */
450 /* YYNTOKENS -- Number of terminals. */
452 /* YYNNTS -- Number of nonterminals. */
454 /* YYNRULES -- Number of rules. */
456 /* YYNRULES -- Number of states. */
459 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
461 #define YYMAXUTOK 271
463 #define YYTRANSLATE(YYX) \
464 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
466 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
467 static const yytype_uint8 yytranslate[] =
469 0, 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, 2, 2, 2, 2,
494 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
495 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
500 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
502 static const yytype_uint8 yyprhs[] =
504 0, 0, 3, 4, 7, 9, 11, 13, 15, 19,
505 23, 27, 33, 39, 45, 51, 58, 65, 72, 79,
509 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
510 static const yytype_int8 yyrhs[] =
512 18, 0, -1, -1, 18, 19, -1, 20, -1, 4,
513 -1, 21, -1, 22, -1, 7, 20, 8, -1, 20,
514 15, 20, -1, 20, 16, 20, -1, 3, 9, 14,
515 3, 14, -1, 3, 10, 14, 3, 14, -1, 3,
516 12, 14, 3, 14, -1, 3, 11, 14, 3, 14,
517 -1, 3, 9, 14, 3, 14, 3, -1, 3, 10,
518 14, 3, 14, 3, -1, 3, 12, 14, 3, 14,
519 3, -1, 3, 11, 14, 3, 14, 3, -1, 5,
520 7, 3, 13, 23, 13, 23, 8, -1, 6, 7,
524 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
525 static const yytype_uint8 yyrline[] =
527 0, 68, 68, 70, 74, 91, 97, 98, 99, 100,
528 101, 126, 127, 128, 129, 130, 131, 132, 133, 137,
533 #if YYDEBUG || YYERROR_VERBOSE || 1
534 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
535 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
536 static const char *const yytname[] =
538 "$end", "error", "$undefined", "WORD", "BOOL", "FUNC_INRANGE",
539 "DATE_ISO", "OBRACE", "CBRACE", "EQUAL", "UNEQUAL", "GT", "LT", "COMMA",
540 "QUOTE", "AND", "OR", "$accept", "input", "line", "expr", "match",
541 "function", "date", YY_NULL
546 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
548 static const yytype_uint16 yytoknum[] =
550 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
551 265, 266, 267, 268, 269, 270, 271
555 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
556 static const yytype_uint8 yyr1[] =
558 0, 17, 18, 18, 19, 20, 20, 20, 20, 20,
559 20, 21, 21, 21, 21, 21, 21, 21, 21, 22,
563 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
564 static const yytype_uint8 yyr2[] =
566 0, 2, 0, 2, 1, 1, 1, 1, 3, 3,
567 3, 5, 5, 5, 5, 6, 6, 6, 6, 8,
571 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
572 Performed when YYTABLE doesn't specify something else to do. Zero
573 means the default is an error. */
574 static const yytype_uint8 yydefact[] =
576 2, 0, 1, 0, 5, 0, 0, 3, 4, 6,
577 7, 0, 0, 0, 0, 0, 0, 0, 0, 0,
578 0, 0, 0, 0, 8, 9, 10, 0, 0, 0,
579 0, 0, 11, 12, 14, 13, 21, 0, 0, 15,
580 16, 18, 17, 0, 0, 0, 0, 20, 19
583 /* YYDEFGOTO[NTERM-NUM]. */
584 static const yytype_int8 yydefgoto[] =
586 -1, 1, 7, 8, 9, 10, 38
589 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
591 #define YYPACT_NINF -8
592 static const yytype_int8 yypact[] =
594 -8, 10, -8, 9, -8, -2, -1, -8, 8, -8,
595 -8, 2, 12, 13, 14, 4, -7, -1, -1, 26,
596 27, 28, 29, 20, -8, 18, -8, 21, 22, 23,
597 24, 19, 36, 37, 38, 39, -8, 40, 30, -8,
598 -8, -8, -8, 41, 19, 42, 43, -8, -8
601 /* YYPGOTO[NTERM-NUM]. */
602 static const yytype_int8 yypgoto[] =
604 -8, -8, -8, -6, -8, -8, 1
607 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
608 positive, shift that token. If negative, reduce the rule which
609 number is the opposite. If YYTABLE_NINF, syntax error. */
610 #define YYTABLE_NINF -1
611 static const yytype_uint8 yytable[] =
613 16, 24, 3, 4, 5, 15, 6, 23, 17, 18,
614 2, 25, 26, 3, 4, 5, 19, 6, 11, 12,
615 13, 14, 36, 17, 18, 37, 20, 21, 22, 27,
616 28, 29, 30, 31, 18, 32, 33, 34, 35, 39,
617 40, 41, 42, 44, 45, 46, 0, 43, 0, 0,
621 #define yypact_value_is_default(Yystate) \
622 (!!((Yystate) == (-8)))
624 #define yytable_value_is_error(Yytable_value) \
627 static const yytype_int8 yycheck[] =
629 6, 8, 3, 4, 5, 7, 7, 3, 15, 16,
630 0, 17, 18, 3, 4, 5, 14, 7, 9, 10,
631 11, 12, 3, 15, 16, 6, 14, 14, 14, 3,
632 3, 3, 3, 13, 16, 14, 14, 14, 14, 3,
633 3, 3, 3, 13, 3, 44, -1, 7, -1, -1,
637 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
638 symbol of state STATE-NUM. */
639 static const yytype_uint8 yystos[] =
641 0, 18, 0, 3, 4, 5, 7, 19, 20, 21,
642 22, 9, 10, 11, 12, 7, 20, 15, 16, 14,
643 14, 14, 14, 3, 8, 20, 20, 3, 3, 3,
644 3, 13, 14, 14, 14, 14, 3, 6, 23, 3,
645 3, 3, 3, 7, 13, 3, 23, 8, 8
648 #define yyerrok (yyerrstatus = 0)
649 #define yyclearin (yychar = YYEMPTY)
653 #define YYACCEPT goto yyacceptlab
654 #define YYABORT goto yyabortlab
655 #define YYERROR goto yyerrorlab
658 /* Like YYERROR except do call yyerror. This remains here temporarily
659 to ease the transition to the new meaning of YYERROR, for GCC.
660 Once GCC version 2 has supplanted version 1, this can go. However,
661 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
662 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
665 #define YYFAIL goto yyerrlab
667 /* This is here to suppress warnings from the GCC cpp's
668 -Wunused-macros. Normally we don't worry about that warning, but
669 some users do, and we want to make it easy for users to remove
670 YYFAIL uses, which will produce warnings from Bison 2.5. */
673 #define YYRECOVERING() (!!yyerrstatus)
675 #define YYBACKUP(Token, Value) \
677 if (yychar == YYEMPTY) \
681 YYPOPSTACK (yylen); \
687 yyerror (YY_("syntax error: cannot back up")); \
692 /* Error token number */
694 #define YYERRCODE 256
697 /* This macro is provided for backward compatibility. */
698 #ifndef YY_LOCATION_PRINT
699 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
703 /* YYLEX -- calling `yylex' with the right arguments. */
705 # define YYLEX yylex (YYLEX_PARAM)
707 # define YYLEX yylex ()
710 /* Enable debugging if requested. */
714 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
715 # define YYFPRINTF fprintf
718 # define YYDPRINTF(Args) \
724 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
728 YYFPRINTF (stderr, "%s ", Title); \
729 yy_symbol_print (stderr, \
731 YYFPRINTF (stderr, "\n"); \
736 /*--------------------------------.
737 | Print this symbol on YYOUTPUT. |
738 `--------------------------------*/
741 #if (defined __STDC__ || defined __C99__FUNC__ \
742 || defined __cplusplus || defined _MSC_VER)
744 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
747 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
750 YYSTYPE const * const yyvaluep;
753 FILE *yyo = yyoutput;
758 if (yytype < YYNTOKENS)
759 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
771 /*--------------------------------.
772 | Print this symbol on YYOUTPUT. |
773 `--------------------------------*/
775 #if (defined __STDC__ || defined __C99__FUNC__ \
776 || defined __cplusplus || defined _MSC_VER)
778 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
781 yy_symbol_print (yyoutput, yytype, yyvaluep)
784 YYSTYPE const * const yyvaluep;
787 if (yytype < YYNTOKENS)
788 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
790 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
792 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
793 YYFPRINTF (yyoutput, ")");
796 /*------------------------------------------------------------------.
797 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
799 `------------------------------------------------------------------*/
801 #if (defined __STDC__ || defined __C99__FUNC__ \
802 || defined __cplusplus || defined _MSC_VER)
804 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
807 yy_stack_print (yybottom, yytop)
808 yytype_int16 *yybottom;
812 YYFPRINTF (stderr, "Stack now");
813 for (; yybottom <= yytop; yybottom++)
815 int yybot = *yybottom;
816 YYFPRINTF (stderr, " %d", yybot);
818 YYFPRINTF (stderr, "\n");
821 # define YY_STACK_PRINT(Bottom, Top) \
824 yy_stack_print ((Bottom), (Top)); \
828 /*------------------------------------------------.
829 | Report that the YYRULE is going to be reduced. |
830 `------------------------------------------------*/
832 #if (defined __STDC__ || defined __C99__FUNC__ \
833 || defined __cplusplus || defined _MSC_VER)
835 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
838 yy_reduce_print (yyvsp, yyrule)
843 int yynrhs = yyr2[yyrule];
845 unsigned long int yylno = yyrline[yyrule];
846 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
848 /* The symbols being reduced. */
849 for (yyi = 0; yyi < yynrhs; yyi++)
851 YYFPRINTF (stderr, " $%d = ", yyi + 1);
852 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
853 &(yyvsp[(yyi + 1) - (yynrhs)])
855 YYFPRINTF (stderr, "\n");
859 # define YY_REDUCE_PRINT(Rule) \
862 yy_reduce_print (yyvsp, Rule); \
865 /* Nonzero means print parse trace. It is left uninitialized so that
866 multiple parsers can coexist. */
869 # define YYDPRINTF(Args)
870 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
871 # define YY_STACK_PRINT(Bottom, Top)
872 # define YY_REDUCE_PRINT(Rule)
873 #endif /* !YYDEBUG */
876 /* YYINITDEPTH -- initial size of the parser's stacks. */
878 # define YYINITDEPTH 200
881 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
882 if the built-in stack extension method is used).
884 Do not make this value too large; the results are undefined if
885 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
886 evaluated with infinite-precision integer arithmetic. */
889 # define YYMAXDEPTH 10000
896 # if defined __GLIBC__ && defined _STRING_H
897 # define yystrlen strlen
899 /* Return the length of YYSTR. */
900 #if (defined __STDC__ || defined __C99__FUNC__ \
901 || defined __cplusplus || defined _MSC_VER)
903 yystrlen (const char *yystr)
911 for (yylen = 0; yystr[yylen]; yylen++)
919 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
920 # define yystpcpy stpcpy
922 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
924 #if (defined __STDC__ || defined __C99__FUNC__ \
925 || defined __cplusplus || defined _MSC_VER)
927 yystpcpy (char *yydest, const char *yysrc)
930 yystpcpy (yydest, yysrc)
936 const char *yys = yysrc;
938 while ((*yyd++ = *yys++) != '\0')
947 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
948 quotes and backslashes, so that it's suitable for yyerror. The
949 heuristic is that double-quoting is unnecessary unless the string
950 contains an apostrophe, a comma, or backslash (other than
951 backslash-backslash). YYSTR is taken from yytname. If YYRES is
952 null, do not copy; instead, return the length of what the result
955 yytnamerr (char *yyres, const char *yystr)
960 char const *yyp = yystr;
967 goto do_not_strip_quotes;
971 goto do_not_strip_quotes;
984 do_not_strip_quotes: ;
988 return yystrlen (yystr);
990 return yystpcpy (yyres, yystr) - yyres;
994 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
995 about the unexpected token YYTOKEN for the state stack whose top is
998 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
999 not large enough to hold the message. In that case, also set
1000 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1001 required number of bytes is too large to store. */
1003 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1004 yytype_int16 *yyssp, int yytoken)
1006 YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1007 YYSIZE_T yysize = yysize0;
1008 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1009 /* Internationalized format string. */
1010 const char *yyformat = YY_NULL;
1011 /* Arguments of yyformat. */
1012 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1013 /* Number of reported tokens (one for the "unexpected", one per
1017 /* There are many possibilities here to consider:
1018 - Assume YYFAIL is not used. It's too flawed to consider. See
1019 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1020 for details. YYERROR is fine as it does not invoke this
1022 - If this state is a consistent state with a default action, then
1023 the only way this function was invoked is if the default action
1024 is an error action. In that case, don't check for expected
1025 tokens because there are none.
1026 - The only way there can be no lookahead present (in yychar) is if
1027 this state is a consistent state with a default action. Thus,
1028 detecting the absence of a lookahead is sufficient to determine
1029 that there is no unexpected or expected token to report. In that
1030 case, just report a simple "syntax error".
1031 - Don't assume there isn't a lookahead just because this state is a
1032 consistent state with a default action. There might have been a
1033 previous inconsistent state, consistent state with a non-default
1034 action, or user semantic action that manipulated yychar.
1035 - Of course, the expected token list depends on states to have
1036 correct lookahead information, and it depends on the parser not
1037 to perform extra reductions after fetching a lookahead from the
1038 scanner and before detecting a syntax error. Thus, state merging
1039 (from LALR or IELR) and default reductions corrupt the expected
1040 token list. However, the list is correct for canonical LR with
1041 one exception: it will still contain any token that will not be
1042 accepted due to an error action in a later state.
1044 if (yytoken != YYEMPTY)
1046 int yyn = yypact[*yyssp];
1047 yyarg[yycount++] = yytname[yytoken];
1048 if (!yypact_value_is_default (yyn))
1050 /* Start YYX at -YYN if negative to avoid negative indexes in
1051 YYCHECK. In other words, skip the first -YYN actions for
1052 this state because they are default actions. */
1053 int yyxbegin = yyn < 0 ? -yyn : 0;
1054 /* Stay within bounds of both yycheck and yytname. */
1055 int yychecklim = YYLAST - yyn + 1;
1056 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1059 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1060 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1061 && !yytable_value_is_error (yytable[yyx + yyn]))
1063 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1069 yyarg[yycount++] = yytname[yyx];
1071 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1072 if (! (yysize <= yysize1
1073 && 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"));
1097 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1098 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1103 if (*yymsg_alloc < yysize)
1105 *yymsg_alloc = 2 * yysize;
1106 if (! (yysize <= *yymsg_alloc
1107 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1108 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1112 /* Avoid sprintf, as that infringes on the user's name space.
1113 Don't have undefined behavior even if the translation
1114 produced a string with the wrong number of "%s"s. */
1118 while ((*yyp = *yyformat) != '\0')
1119 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1121 yyp += yytnamerr (yyp, yyarg[yyi++]);
1132 #endif /* YYERROR_VERBOSE */
1134 /*-----------------------------------------------.
1135 | Release the memory associated to this symbol. |
1136 `-----------------------------------------------*/
1139 #if (defined __STDC__ || defined __C99__FUNC__ \
1140 || defined __cplusplus || defined _MSC_VER)
1142 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1145 yydestruct (yymsg, yytype, yyvaluep)
1155 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1168 /* The lookahead symbol. */
1172 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1173 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1174 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1176 #ifndef YY_INITIAL_VALUE
1177 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1180 /* The semantic value of the lookahead symbol. */
1181 YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
1183 /* Number of syntax errors so far. */
1191 #ifdef YYPARSE_PARAM
1192 #if (defined __STDC__ || defined __C99__FUNC__ \
1193 || defined __cplusplus || defined _MSC_VER)
1195 yyparse (void *YYPARSE_PARAM)
1198 yyparse (YYPARSE_PARAM)
1199 void *YYPARSE_PARAM;
1201 #else /* ! YYPARSE_PARAM */
1202 #if (defined __STDC__ || defined __C99__FUNC__ \
1203 || defined __cplusplus || defined _MSC_VER)
1214 /* Number of tokens to shift before error messages enabled. */
1217 /* The stacks and their tools:
1218 `yyss': related to states.
1219 `yyvs': related to semantic values.
1221 Refer to the stacks through separate pointers, to allow yyoverflow
1222 to reallocate them elsewhere. */
1224 /* The state stack. */
1225 yytype_int16 yyssa[YYINITDEPTH];
1227 yytype_int16 *yyssp;
1229 /* The semantic value stack. */
1230 YYSTYPE yyvsa[YYINITDEPTH];
1234 YYSIZE_T yystacksize;
1238 /* Lookahead token as an internal (translated) token number. */
1240 /* The variables used to return semantic value and location from the
1245 /* Buffer for error messages, and its allocated size. */
1247 char *yymsg = yymsgbuf;
1248 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1251 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1253 /* The number of symbols on the RHS of the reduced rule.
1254 Keep to zero when no symbol should be popped. */
1257 yyssp = yyss = yyssa;
1258 yyvsp = yyvs = yyvsa;
1259 yystacksize = YYINITDEPTH;
1261 YYDPRINTF ((stderr, "Starting parse\n"));
1266 yychar = YYEMPTY; /* Cause a token to be read. */
1269 /*------------------------------------------------------------.
1270 | yynewstate -- Push a new state, which is found in yystate. |
1271 `------------------------------------------------------------*/
1273 /* In all cases, when you get here, the value and location stacks
1274 have just been pushed. So pushing a state here evens the stacks. */
1280 if (yyss + yystacksize - 1 <= yyssp)
1282 /* Get the current used size of the three stacks, in elements. */
1283 YYSIZE_T yysize = yyssp - yyss + 1;
1287 /* Give user a chance to reallocate the stack. Use copies of
1288 these so that the &'s don't force the real ones into
1290 YYSTYPE *yyvs1 = yyvs;
1291 yytype_int16 *yyss1 = yyss;
1293 /* Each stack pointer address is followed by the size of the
1294 data in use in that stack, in bytes. This used to be a
1295 conditional around just the two extra args, but that might
1296 be undefined if yyoverflow is a macro. */
1297 yyoverflow (YY_("memory exhausted"),
1298 &yyss1, yysize * sizeof (*yyssp),
1299 &yyvs1, yysize * sizeof (*yyvsp),
1305 #else /* no yyoverflow */
1306 # ifndef YYSTACK_RELOCATE
1307 goto yyexhaustedlab;
1309 /* Extend the stack our own way. */
1310 if (YYMAXDEPTH <= yystacksize)
1311 goto yyexhaustedlab;
1313 if (YYMAXDEPTH < yystacksize)
1314 yystacksize = YYMAXDEPTH;
1317 yytype_int16 *yyss1 = yyss;
1318 union yyalloc *yyptr =
1319 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1321 goto yyexhaustedlab;
1322 YYSTACK_RELOCATE (yyss_alloc, yyss);
1323 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1324 # undef YYSTACK_RELOCATE
1326 YYSTACK_FREE (yyss1);
1329 #endif /* no yyoverflow */
1331 yyssp = yyss + yysize - 1;
1332 yyvsp = yyvs + yysize - 1;
1334 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1335 (unsigned long int) yystacksize));
1337 if (yyss + yystacksize - 1 <= yyssp)
1341 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1343 if (yystate == YYFINAL)
1353 /* Do appropriate processing given the current state. Read a
1354 lookahead token if we need one and don't already have one. */
1356 /* First try to decide what to do without reference to lookahead token. */
1357 yyn = yypact[yystate];
1358 if (yypact_value_is_default (yyn))
1361 /* Not known => get a lookahead token if don't already have one. */
1363 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1364 if (yychar == YYEMPTY)
1366 YYDPRINTF ((stderr, "Reading a token: "));
1370 if (yychar <= YYEOF)
1372 yychar = yytoken = YYEOF;
1373 YYDPRINTF ((stderr, "Now at end of input.\n"));
1377 yytoken = YYTRANSLATE (yychar);
1378 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1381 /* If the proper action on seeing token YYTOKEN is to reduce or to
1382 detect an error, take that action. */
1384 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1389 if (yytable_value_is_error (yyn))
1395 /* Count tokens shifted since error; after three, turn off error
1400 /* Shift the lookahead token. */
1401 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1403 /* Discard the shifted token. */
1407 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1409 YY_IGNORE_MAYBE_UNINITIALIZED_END
1414 /*-----------------------------------------------------------.
1415 | yydefault -- do the default action for the current state. |
1416 `-----------------------------------------------------------*/
1418 yyn = yydefact[yystate];
1424 /*-----------------------------.
1425 | yyreduce -- Do a reduction. |
1426 `-----------------------------*/
1428 /* yyn is the number of a rule to reduce with. */
1431 /* If YYLEN is nonzero, implement the default value of the action:
1434 Otherwise, the following line sets YYVAL to garbage.
1435 This behavior is undocumented and Bison
1436 users should not rely upon it. Assigning to YYVAL
1437 unconditionally makes the parser a bit smaller, and it avoids a
1438 GCC warning that YYVAL may be used uninitialized. */
1439 yyval = yyvsp[1-yylen];
1442 YY_REDUCE_PRINT (yyn);
1446 /* Line 1792 of yacc.c */
1447 #line 74 "slmod_rdf_parser.y"
1449 srp_result = talloc_asprintf(srp_slq,
1450 "<rdfq:Condition>\n"
1452 " <rdfq:startsWith>\n"
1453 " <rdfq:Property name=\"File:Path\" />\n"
1454 " <rdf:String>%s</rdf:String>\n"
1455 " </rdfq:startsWith>\n"
1458 "</rdfq:Condition>\n",
1459 srp_slq->slq_vol->v_path, (yyvsp[(1) - (1)].sval));
1460 (yyval.sval) = srp_result;
1465 /* Line 1792 of yacc.c */
1466 #line 91 "slmod_rdf_parser.y"
1468 if ((yyvsp[(1) - (1)].bval) == false)
1476 /* Line 1792 of yacc.c */
1477 #line 97 "slmod_rdf_parser.y"
1478 {(yyval.sval) = (yyvsp[(1) - (1)].sval); if ((yyval.sval) == NULL) YYABORT;}
1482 /* Line 1792 of yacc.c */
1483 #line 98 "slmod_rdf_parser.y"
1484 {(yyval.sval) = (yyvsp[(1) - (1)].sval);}
1488 /* Line 1792 of yacc.c */
1489 #line 99 "slmod_rdf_parser.y"
1490 {(yyval.sval) = talloc_asprintf(srp_slq, "%s\n", (yyvsp[(2) - (3)].sval));}
1494 /* Line 1792 of yacc.c */
1495 #line 100 "slmod_rdf_parser.y"
1496 {(yyval.sval) = talloc_asprintf(srp_slq, "<rdfq:and>\n%s\n%s\n</rdfq:and>\n", (yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval));}
1500 /* Line 1792 of yacc.c */
1501 #line 101 "slmod_rdf_parser.y"
1503 if (strcmp((yyvsp[(1) - (3)].sval), "") == 0 || strcmp((yyvsp[(3) - (3)].sval), "") == 0) {
1505 * The default Spotlight search term issued by the Finder (10.8) is:
1506 * '* == "searchterm" || kMDItemTextContent == "searchterm"'
1507 * As it isn't mappable to a single Tracker RDF query, we silently
1508 * map ANY FTS query expression being part of an OR compound
1509 * expression to a simple filename search.
1510 * FTS queries are thus only possible by explicitly requesting
1511 * file content FTS search in the Finder on the client (resulting
1512 * in a 'kMDItemTextContent == "searchterm"' query).
1514 if (strcmp((yyvsp[(1) - (3)].sval), "") == 0)
1515 (yyval.sval) = talloc_asprintf(srp_slq, (yyvsp[(3) - (3)].sval));
1517 (yyval.sval) = talloc_asprintf(srp_slq, (yyvsp[(1) - (3)].sval));
1518 talloc_free(srp_fts);
1521 (yyval.sval) = talloc_asprintf(srp_slq, "<rdfq:or>\n%s\n%s\n</rdfq:or>\n", (yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval));
1527 /* Line 1792 of yacc.c */
1528 #line 126 "slmod_rdf_parser.y"
1529 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '=', (yyvsp[(4) - (5)].sval));}
1533 /* Line 1792 of yacc.c */
1534 #line 127 "slmod_rdf_parser.y"
1535 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '!', (yyvsp[(4) - (5)].sval));}
1539 /* Line 1792 of yacc.c */
1540 #line 128 "slmod_rdf_parser.y"
1541 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '<', (yyvsp[(4) - (5)].sval));}
1545 /* Line 1792 of yacc.c */
1546 #line 129 "slmod_rdf_parser.y"
1547 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '>', (yyvsp[(4) - (5)].sval));}
1551 /* Line 1792 of yacc.c */
1552 #line 130 "slmod_rdf_parser.y"
1553 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '=', (yyvsp[(4) - (6)].sval));}
1557 /* Line 1792 of yacc.c */
1558 #line 131 "slmod_rdf_parser.y"
1559 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '!', (yyvsp[(4) - (6)].sval));}
1563 /* Line 1792 of yacc.c */
1564 #line 132 "slmod_rdf_parser.y"
1565 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '<', (yyvsp[(4) - (6)].sval));}
1569 /* Line 1792 of yacc.c */
1570 #line 133 "slmod_rdf_parser.y"
1571 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '>', (yyvsp[(4) - (6)].sval));}
1575 /* Line 1792 of yacc.c */
1576 #line 137 "slmod_rdf_parser.y"
1577 {(yyval.sval) = map_daterange((yyvsp[(3) - (8)].sval), (yyvsp[(5) - (8)].tval), (yyvsp[(7) - (8)].tval));}
1581 /* Line 1792 of yacc.c */
1582 #line 141 "slmod_rdf_parser.y"
1583 {(yyval.tval) = isodate2unix((yyvsp[(3) - (4)].sval));}
1587 /* Line 1792 of yacc.c */
1588 #line 142 "slmod_rdf_parser.y"
1589 {(yyval.tval) = atoi((yyvsp[(1) - (1)].sval)) + SPRAW_TIME_OFFSET;}
1593 /* Line 1792 of yacc.c */
1594 #line 1595 "slmod_rdf_parser.c"
1597 /* User semantic actions sometimes alter yychar, and that requires
1598 that yytoken be updated with the new translation. We take the
1599 approach of translating immediately before every use of yytoken.
1600 One alternative is translating here after every semantic action,
1601 but that translation would be missed if the semantic action invokes
1602 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1603 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1604 incorrect destructor might then be invoked immediately. In the
1605 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1606 to an incorrect destructor call or verbose syntax error message
1607 before the lookahead is translated. */
1608 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1612 YY_STACK_PRINT (yyss, yyssp);
1616 /* Now `shift' the result of the reduction. Determine what state
1617 that goes to, based on the state we popped back to and the rule
1618 number reduced by. */
1622 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1623 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1624 yystate = yytable[yystate];
1626 yystate = yydefgoto[yyn - YYNTOKENS];
1631 /*------------------------------------.
1632 | yyerrlab -- here on detecting error |
1633 `------------------------------------*/
1635 /* Make sure we have latest lookahead translation. See comments at
1636 user semantic actions for why this is necessary. */
1637 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1639 /* If not already recovering from an error, report this error. */
1643 #if ! YYERROR_VERBOSE
1644 yyerror (YY_("syntax error"));
1646 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1649 char const *yymsgp = YY_("syntax error");
1650 int yysyntax_error_status;
1651 yysyntax_error_status = YYSYNTAX_ERROR;
1652 if (yysyntax_error_status == 0)
1654 else if (yysyntax_error_status == 1)
1656 if (yymsg != yymsgbuf)
1657 YYSTACK_FREE (yymsg);
1658 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1662 yymsg_alloc = sizeof yymsgbuf;
1663 yysyntax_error_status = 2;
1667 yysyntax_error_status = YYSYNTAX_ERROR;
1672 if (yysyntax_error_status == 2)
1673 goto yyexhaustedlab;
1675 # undef YYSYNTAX_ERROR
1681 if (yyerrstatus == 3)
1683 /* If just tried and failed to reuse lookahead token after an
1684 error, discard it. */
1686 if (yychar <= YYEOF)
1688 /* Return failure if at end of input. */
1689 if (yychar == YYEOF)
1694 yydestruct ("Error: discarding",
1700 /* Else will try to reuse lookahead token after shifting the error
1705 /*---------------------------------------------------.
1706 | yyerrorlab -- error raised explicitly by YYERROR. |
1707 `---------------------------------------------------*/
1710 /* Pacify compilers like GCC when the user code never invokes
1711 YYERROR and the label yyerrorlab therefore never appears in user
1713 if (/*CONSTCOND*/ 0)
1716 /* Do not reclaim the symbols of the rule which action triggered
1720 YY_STACK_PRINT (yyss, yyssp);
1725 /*-------------------------------------------------------------.
1726 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1727 `-------------------------------------------------------------*/
1729 yyerrstatus = 3; /* Each real token shifted decrements this. */
1733 yyn = yypact[yystate];
1734 if (!yypact_value_is_default (yyn))
1737 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1745 /* Pop the current state because it cannot handle the error token. */
1750 yydestruct ("Error: popping",
1751 yystos[yystate], yyvsp);
1754 YY_STACK_PRINT (yyss, yyssp);
1757 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1759 YY_IGNORE_MAYBE_UNINITIALIZED_END
1762 /* Shift the error token. */
1763 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1769 /*-------------------------------------.
1770 | yyacceptlab -- YYACCEPT comes here. |
1771 `-------------------------------------*/
1776 /*-----------------------------------.
1777 | yyabortlab -- YYABORT comes here. |
1778 `-----------------------------------*/
1783 #if !defined yyoverflow || YYERROR_VERBOSE
1784 /*-------------------------------------------------.
1785 | yyexhaustedlab -- memory exhaustion comes here. |
1786 `-------------------------------------------------*/
1788 yyerror (YY_("memory exhausted"));
1794 if (yychar != YYEMPTY)
1796 /* Make sure we have latest lookahead translation. See comments at
1797 user semantic actions for why this is necessary. */
1798 yytoken = YYTRANSLATE (yychar);
1799 yydestruct ("Cleanup: discarding lookahead",
1802 /* Do not reclaim the symbols of the rule which action triggered
1803 this YYABORT or YYACCEPT. */
1805 YY_STACK_PRINT (yyss, yyssp);
1806 while (yyssp != yyss)
1808 yydestruct ("Cleanup: popping",
1809 yystos[*yyssp], yyvsp);
1814 YYSTACK_FREE (yyss);
1817 if (yymsg != yymsgbuf)
1818 YYSTACK_FREE (yymsg);
1820 /* Make sure YYID is used. */
1821 return YYID (yyresult);
1825 /* Line 2055 of yacc.c */
1826 #line 145 "slmod_rdf_parser.y"
1829 static time_t isodate2unix(const char *s)
1833 if (strptime(s, "%Y-%m-%dT%H:%M:%SZ", &tm) == NULL)
1838 static const char *map_daterange(const char *dateattr, time_t date1, time_t date2)
1841 char *result = NULL;
1842 struct spotlight_rdf_map *p;
1844 char buf1[64], buf2[64];
1846 EC_NULL_LOG( tmp = localtime(&date1) );
1847 strftime(buf1, sizeof(buf1), "%Y-%m-%dT%H:%M:%SZ", tmp);
1848 EC_NULL_LOG( tmp = localtime(&date2) );
1849 strftime(buf2, sizeof(buf2), "%Y-%m-%dT%H:%M:%SZ", tmp);
1851 for (p = spotlight_rdf_map; p->srm_spotlight_attr; p++) {
1852 if (strcmp(dateattr, p->srm_spotlight_attr) == 0) {
1853 result = talloc_asprintf(srp_slq,
1855 " <rdfq:greaterThan>\n"
1856 " <rdfq:Property name=\"%s\" />\n"
1857 " <rdf:Date>%s</rdf:Date>\n"
1858 " </rdfq:greaterThan>\n"
1859 " <rdfq:lessThan>\n"
1860 " <rdfq:Property name=\"%s\" />\n"
1861 " <rdf:Date>%s</rdf:Date>\n"
1862 " </rdfq:lessThan>\n"
1864 p->srm_rdf_attr, buf1,
1865 p->srm_rdf_attr, buf2);
1876 static char *map_type_search(const char *attr, char op, const char *val)
1878 char *result = NULL;
1880 for (struct MDTypeMap *p = MDTypeMap; p->mdtm_value; p++) {
1881 if (strcmp(p->mdtm_value, val) == 0) {
1884 if (val[0] == '9') {
1885 srp_slq->slq_service = SERVICE_FOLDERS;
1888 result = talloc_asprintf(srp_slq,
1890 " <rdfq:Property name=\"File:Mime\" />\n"
1891 " <rdf:String>%s</rdf:String>\n"
1902 static const char *map_expr(const char *attr, char op, const char *val)
1905 char *result = NULL;
1906 struct spotlight_rdf_map *p;
1910 bstring q = NULL, search = NULL, replace = NULL;
1913 for (p = spotlight_rdf_map; p->srm_spotlight_attr; p++) {
1914 if (p->srm_rdf_attr && strcmp(p->srm_spotlight_attr, attr) == 0) {
1915 switch (p->srm_type) {
1917 q = bformat("^%s$", val);
1918 search = bfromcstr("*");
1919 replace = bfromcstr(".*");
1920 bfindreplace(q, search, replace, 0);
1921 result = talloc_asprintf(srp_slq,
1923 " <rdfq:Property name=\"%s\" />\n"
1924 " <rdf:String>%s</rdf:String>\n"
1932 q = bformat("^%s$", val);
1933 search = bfromcstr("*");
1934 replace = bfromcstr(".*");
1935 bfindreplace(q, search, replace, 0);
1936 result = talloc_asprintf(srp_slq,
1938 " <rdfq:Property name=\"%s\" />\n"
1939 " <rdf:String>%s</rdf:String>\n"
1948 yyerror("only single fts query allowed");
1952 search = bfromcstr("*");
1953 replace = bfromcstr("");
1954 bfindreplace(q, search, replace, 0);
1955 srp_fts = talloc_strdup(srp_slq, bdata(q));
1960 t = atoi(val) + SPRAW_TIME_OFFSET;
1961 EC_NULL( tmp = localtime(&t) );
1962 strftime(buf1, sizeof(buf1), "%Y-%m-%dT%H:%M:%SZ", tmp);
1970 rdfop = "greaterThan";
1972 yyerror("unknown date comparison");
1975 result = talloc_asprintf(srp_slq,
1977 " <rdfq:Property name=\"%s\" />\n"
1978 " <rdf:Date>%s</rdf:Date>\n"
1988 result = map_type_search(attr, op, val);
1992 yyerror("unknown Spotlight attribute type");
2009 void yyerror(const char *str)
2012 printf("yyerror: %s\n", str);
2014 LOG(log_error, logtype_sl, "yyerror: %s", str);
2024 * Map a Spotlight RAW query string to a RDF query
2026 * @param[in] slq Spotlight query handle
2027 * @return 0 on success, -1 on error
2029 int map_spotlight_to_rdf_query(slq_t *slq)
2032 YY_BUFFER_STATE s = NULL;
2035 slq->slq_service = SERVICE_FILES;
2037 s = yy_scan_string(slq->slq_qstring);
2039 EC_ZERO( yyparse() );
2043 yy_delete_buffer(s);
2045 slq->slq_trackerquery = srp_result;
2046 slq->slq_fts = 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)");