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 *ssp_result;
103 /* Line 371 of yacc.c */
104 #line 105 "slmod_rdf_parser.c"
107 # if defined __cplusplus && 201103L <= __cplusplus
108 # define YY_NULL nullptr
114 /* Enabling verbose error messages. */
115 #ifdef YYERROR_VERBOSE
116 # undef YYERROR_VERBOSE
117 # define YYERROR_VERBOSE 1
119 # define YYERROR_VERBOSE 1
122 /* In a future release of Bison, this section will be replaced
123 by #include "y.tab.h". */
124 #ifndef YY_YY_Y_TAB_H_INCLUDED
125 # define YY_YY_Y_TAB_H_INCLUDED
126 /* Enabling traces. */
137 /* Put the tokens into the symbol table, so that GDB and other debuggers
159 #define FUNC_INRANGE 260
174 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
175 typedef union YYSTYPE
177 /* Line 387 of yacc.c */
178 #line 44 "slmod_rdf_parser.y"
186 /* Line 387 of yacc.c */
187 #line 188 "slmod_rdf_parser.c"
189 # define YYSTYPE_IS_TRIVIAL 1
190 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
191 # define YYSTYPE_IS_DECLARED 1
194 extern YYSTYPE yylval;
197 #if defined __STDC__ || defined __cplusplus
198 int yyparse (void *YYPARSE_PARAM);
202 #else /* ! YYPARSE_PARAM */
203 #if defined __STDC__ || defined __cplusplus
208 #endif /* ! YYPARSE_PARAM */
209 /* "%code provides" blocks. */
210 /* Line 387 of yacc.c */
211 #line 38 "slmod_rdf_parser.y"
213 #define SPRAW_TIME_OFFSET 978307200
214 extern int map_spotlight_to_rdf_query(slq_t *slq, gchar **sparql_result);
215 extern slq_t *srp_slq;
218 /* Line 387 of yacc.c */
219 #line 220 "slmod_rdf_parser.c"
221 #endif /* !YY_YY_Y_TAB_H_INCLUDED */
223 /* Copy the second part of user declarations. */
225 /* Line 390 of yacc.c */
226 #line 227 "slmod_rdf_parser.c"
233 typedef YYTYPE_UINT8 yytype_uint8;
235 typedef unsigned char yytype_uint8;
239 typedef YYTYPE_INT8 yytype_int8;
240 #elif (defined __STDC__ || defined __C99__FUNC__ \
241 || defined __cplusplus || defined _MSC_VER)
242 typedef signed char yytype_int8;
244 typedef short int yytype_int8;
248 typedef YYTYPE_UINT16 yytype_uint16;
250 typedef unsigned short int yytype_uint16;
254 typedef YYTYPE_INT16 yytype_int16;
256 typedef short int yytype_int16;
260 # ifdef __SIZE_TYPE__
261 # define YYSIZE_T __SIZE_TYPE__
262 # elif defined size_t
263 # define YYSIZE_T size_t
264 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
265 || defined __cplusplus || defined _MSC_VER)
266 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
267 # define YYSIZE_T size_t
269 # define YYSIZE_T unsigned int
273 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
276 # if defined YYENABLE_NLS && YYENABLE_NLS
278 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
279 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
283 # define YY_(Msgid) Msgid
287 /* Suppress unused-variable warnings by "using" E. */
288 #if ! defined lint || defined __GNUC__
289 # define YYUSE(E) ((void) (E))
291 # define YYUSE(E) /* empty */
294 /* Identity function, used to suppress warnings about constant conditions. */
298 #if (defined __STDC__ || defined __C99__FUNC__ \
299 || defined __cplusplus || defined _MSC_VER)
312 #if ! defined yyoverflow || YYERROR_VERBOSE
314 /* The parser invokes alloca or malloc; define the necessary symbols. */
316 # ifdef YYSTACK_USE_ALLOCA
317 # if YYSTACK_USE_ALLOCA
319 # define YYSTACK_ALLOC __builtin_alloca
320 # elif defined __BUILTIN_VA_ARG_INCR
321 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
323 # define YYSTACK_ALLOC __alloca
324 # elif defined _MSC_VER
325 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
326 # define alloca _alloca
328 # define YYSTACK_ALLOC alloca
329 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
330 || defined __cplusplus || defined _MSC_VER)
331 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
332 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
333 # ifndef EXIT_SUCCESS
334 # define EXIT_SUCCESS 0
341 # ifdef YYSTACK_ALLOC
342 /* Pacify GCC's `empty if-body' warning. */
343 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
344 # ifndef YYSTACK_ALLOC_MAXIMUM
345 /* The OS might guarantee only one guard page at the bottom of the stack,
346 and a page size can be as small as 4096 bytes. So we cannot safely
347 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
348 to allow for a few compiler-allocated temporary stack slots. */
349 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
352 # define YYSTACK_ALLOC YYMALLOC
353 # define YYSTACK_FREE YYFREE
354 # ifndef YYSTACK_ALLOC_MAXIMUM
355 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
357 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
358 && ! ((defined YYMALLOC || defined malloc) \
359 && (defined YYFREE || defined free)))
360 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
361 # ifndef EXIT_SUCCESS
362 # define EXIT_SUCCESS 0
366 # define YYMALLOC malloc
367 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
368 || defined __cplusplus || defined _MSC_VER)
369 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
374 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
375 || defined __cplusplus || defined _MSC_VER)
376 void free (void *); /* INFRINGES ON USER NAME SPACE */
380 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
383 #if (! defined yyoverflow \
384 && (! defined __cplusplus \
385 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
387 /* A type that is properly aligned for any stack member. */
390 yytype_int16 yyss_alloc;
394 /* The size of the maximum gap between one aligned stack and the next. */
395 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
397 /* The size of an array large to enough to hold all stacks, each with
399 # define YYSTACK_BYTES(N) \
400 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
401 + YYSTACK_GAP_MAXIMUM)
403 # define YYCOPY_NEEDED 1
405 /* Relocate STACK from its old location to the new one. The
406 local variables YYSIZE and YYSTACKSIZE give the old and new number of
407 elements in the stack, and YYPTR gives the new location of the
408 stack. Advance YYPTR to a properly aligned location for the next
410 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
413 YYSIZE_T yynewbytes; \
414 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
415 Stack = &yyptr->Stack_alloc; \
416 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
417 yyptr += yynewbytes / sizeof (*yyptr); \
423 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
424 /* Copy COUNT objects from SRC to DST. The source and destination do
427 # if defined __GNUC__ && 1 < __GNUC__
428 # define YYCOPY(Dst, Src, Count) \
429 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
431 # define YYCOPY(Dst, Src, Count) \
435 for (yyi = 0; yyi < (Count); yyi++) \
436 (Dst)[yyi] = (Src)[yyi]; \
441 #endif /* !YYCOPY_NEEDED */
443 /* YYFINAL -- State number of the termination state. */
445 /* YYLAST -- Last index in YYTABLE. */
448 /* YYNTOKENS -- Number of terminals. */
450 /* YYNNTS -- Number of nonterminals. */
452 /* YYNRULES -- Number of rules. */
454 /* YYNRULES -- Number of states. */
457 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
459 #define YYMAXUTOK 271
461 #define YYTRANSLATE(YYX) \
462 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
464 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
465 static const yytype_uint8 yytranslate[] =
467 0, 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, 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, 1, 2, 3, 4,
493 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
498 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
500 static const yytype_uint8 yyprhs[] =
502 0, 0, 3, 4, 7, 9, 11, 15, 17, 19,
503 23, 27, 31, 37, 43, 49, 55, 62, 69, 76,
507 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
508 static const yytype_int8 yyrhs[] =
510 18, 0, -1, -1, 18, 19, -1, 20, -1, 4,
511 -1, 21, 16, 21, -1, 21, -1, 22, -1, 7,
512 20, 8, -1, 20, 15, 20, -1, 20, 16, 20,
513 -1, 3, 9, 14, 3, 14, -1, 3, 10, 14,
514 3, 14, -1, 3, 12, 14, 3, 14, -1, 3,
515 11, 14, 3, 14, -1, 3, 9, 14, 3, 14,
516 3, -1, 3, 10, 14, 3, 14, 3, -1, 3,
517 12, 14, 3, 14, 3, -1, 3, 11, 14, 3,
518 14, 3, -1, 5, 7, 3, 13, 23, 13, 23,
519 8, -1, 6, 7, 3, 8, -1, 3, -1
522 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
523 static const yytype_uint8 yyrline[] =
525 0, 66, 66, 68, 72, 89, 95, 101, 102, 103,
526 104, 105, 114, 115, 116, 117, 118, 119, 120, 121,
531 #if YYDEBUG || YYERROR_VERBOSE || 1
532 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
533 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
534 static const char *const yytname[] =
536 "$end", "error", "$undefined", "WORD", "BOOL", "FUNC_INRANGE",
537 "DATE_ISO", "OBRACE", "CBRACE", "EQUAL", "UNEQUAL", "GT", "LT", "COMMA",
538 "QUOTE", "AND", "OR", "$accept", "input", "line", "expr", "match",
539 "function", "date", YY_NULL
544 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
546 static const yytype_uint16 yytoknum[] =
548 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
549 265, 266, 267, 268, 269, 270, 271
553 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
554 static const yytype_uint8 yyr1[] =
556 0, 17, 18, 18, 19, 20, 20, 20, 20, 20,
557 20, 20, 21, 21, 21, 21, 21, 21, 21, 21,
561 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
562 static const yytype_uint8 yyr2[] =
564 0, 2, 0, 2, 1, 1, 3, 1, 1, 3,
565 3, 3, 5, 5, 5, 5, 6, 6, 6, 6,
569 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
570 Performed when YYTABLE doesn't specify something else to do. Zero
571 means the default is an error. */
572 static const yytype_uint8 yydefact[] =
574 2, 0, 1, 0, 5, 0, 0, 3, 4, 7,
575 8, 0, 0, 0, 0, 0, 0, 0, 0, 0,
576 0, 0, 0, 0, 0, 9, 10, 11, 6, 0,
577 0, 0, 0, 0, 12, 13, 15, 14, 22, 0,
578 0, 16, 17, 19, 18, 0, 0, 0, 0, 21,
582 /* YYDEFGOTO[NTERM-NUM]. */
583 static const yytype_int8 yydefgoto[] =
585 -1, 1, 7, 8, 9, 10, 40
588 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
590 #define YYPACT_NINF -10
591 static const yytype_int8 yypact[] =
593 -10, 10, -10, 9, -10, -2, -1, -10, 8, -9,
594 -10, 2, 12, 13, 14, 26, -7, -1, -1, 27,
595 28, 29, 30, 31, 22, -10, 20, -10, -10, 23,
596 24, 25, 32, 19, 37, 38, 39, 40, -10, 41,
597 34, -10, -10, -10, -10, 42, 19, 36, 43, -10,
601 /* YYPGOTO[NTERM-NUM]. */
602 static const yytype_int8 yypgoto[] =
604 -10, -10, -10, -6, 33, -10, 3
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, 25, 3, 4, 5, 15, 6, 19, 17, 18,
614 2, 26, 27, 3, 4, 5, 20, 6, 11, 12,
615 13, 14, 38, 17, 18, 39, 21, 22, 23, 24,
616 3, 29, 30, 31, 32, 33, 18, 34, 35, 36,
617 41, 42, 43, 44, 49, 47, 37, 46, 45, 48,
621 #define yypact_value_is_default(Yystate) \
622 (!!((Yystate) == (-10)))
624 #define yytable_value_is_error(Yytable_value) \
627 static const yytype_int8 yycheck[] =
629 6, 8, 3, 4, 5, 7, 7, 16, 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, 3, 3, 13, 16, 14, 14, 14,
633 3, 3, 3, 3, 8, 3, 14, 13, 7, 46,
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, 16,
643 14, 14, 14, 14, 3, 8, 20, 20, 21, 3,
644 3, 3, 3, 13, 14, 14, 14, 14, 3, 6,
645 23, 3, 3, 3, 3, 7, 13, 3, 23, 8,
649 #define yyerrok (yyerrstatus = 0)
650 #define yyclearin (yychar = YYEMPTY)
654 #define YYACCEPT goto yyacceptlab
655 #define YYABORT goto yyabortlab
656 #define YYERROR goto yyerrorlab
659 /* Like YYERROR except do call yyerror. This remains here temporarily
660 to ease the transition to the new meaning of YYERROR, for GCC.
661 Once GCC version 2 has supplanted version 1, this can go. However,
662 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
663 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
666 #define YYFAIL goto yyerrlab
668 /* This is here to suppress warnings from the GCC cpp's
669 -Wunused-macros. Normally we don't worry about that warning, but
670 some users do, and we want to make it easy for users to remove
671 YYFAIL uses, which will produce warnings from Bison 2.5. */
674 #define YYRECOVERING() (!!yyerrstatus)
676 #define YYBACKUP(Token, Value) \
678 if (yychar == YYEMPTY) \
682 YYPOPSTACK (yylen); \
688 yyerror (YY_("syntax error: cannot back up")); \
693 /* Error token number */
695 #define YYERRCODE 256
698 /* This macro is provided for backward compatibility. */
699 #ifndef YY_LOCATION_PRINT
700 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
704 /* YYLEX -- calling `yylex' with the right arguments. */
706 # define YYLEX yylex (YYLEX_PARAM)
708 # define YYLEX yylex ()
711 /* Enable debugging if requested. */
715 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
716 # define YYFPRINTF fprintf
719 # define YYDPRINTF(Args) \
725 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
729 YYFPRINTF (stderr, "%s ", Title); \
730 yy_symbol_print (stderr, \
732 YYFPRINTF (stderr, "\n"); \
737 /*--------------------------------.
738 | Print this symbol on YYOUTPUT. |
739 `--------------------------------*/
742 #if (defined __STDC__ || defined __C99__FUNC__ \
743 || defined __cplusplus || defined _MSC_VER)
745 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
748 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
751 YYSTYPE const * const yyvaluep;
754 FILE *yyo = yyoutput;
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 (YY_NULL, yytname[yytoken]);
1008 YYSIZE_T yysize = yysize0;
1009 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1010 /* Internationalized format string. */
1011 const char *yyformat = YY_NULL;
1012 /* Arguments of yyformat. */
1013 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1014 /* Number of reported tokens (one for the "unexpected", one per
1018 /* There are many possibilities here to consider:
1019 - Assume YYFAIL is not used. It's too flawed to consider. See
1020 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1021 for details. YYERROR is fine as it does not invoke this
1023 - If this state is a consistent state with a default action, then
1024 the only way this function was invoked is if the default action
1025 is an error action. In that case, don't check for expected
1026 tokens because there are none.
1027 - The only way there can be no lookahead present (in yychar) is if
1028 this state is a consistent state with a default action. Thus,
1029 detecting the absence of a lookahead is sufficient to determine
1030 that there is no unexpected or expected token to report. In that
1031 case, just report a simple "syntax error".
1032 - Don't assume there isn't a lookahead just because this state is a
1033 consistent state with a default action. There might have been a
1034 previous inconsistent state, consistent state with a non-default
1035 action, or user semantic action that manipulated yychar.
1036 - Of course, the expected token list depends on states to have
1037 correct lookahead information, and it depends on the parser not
1038 to perform extra reductions after fetching a lookahead from the
1039 scanner and before detecting a syntax error. Thus, state merging
1040 (from LALR or IELR) and default reductions corrupt the expected
1041 token list. However, the list is correct for canonical LR with
1042 one exception: it will still contain any token that will not be
1043 accepted due to an error action in a later state.
1045 if (yytoken != YYEMPTY)
1047 int yyn = yypact[*yyssp];
1048 yyarg[yycount++] = yytname[yytoken];
1049 if (!yypact_value_is_default (yyn))
1051 /* Start YYX at -YYN if negative to avoid negative indexes in
1052 YYCHECK. In other words, skip the first -YYN actions for
1053 this state because they are default actions. */
1054 int yyxbegin = yyn < 0 ? -yyn : 0;
1055 /* Stay within bounds of both yycheck and yytname. */
1056 int yychecklim = YYLAST - yyn + 1;
1057 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1060 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1061 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1062 && !yytable_value_is_error (yytable[yyx + yyn]))
1064 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1070 yyarg[yycount++] = yytname[yyx];
1072 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1073 if (! (yysize <= yysize1
1074 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1084 # define YYCASE_(N, S) \
1088 YYCASE_(0, YY_("syntax error"));
1089 YYCASE_(1, YY_("syntax error, unexpected %s"));
1090 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1091 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1092 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1093 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1098 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1099 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1104 if (*yymsg_alloc < yysize)
1106 *yymsg_alloc = 2 * yysize;
1107 if (! (yysize <= *yymsg_alloc
1108 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1109 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1113 /* Avoid sprintf, as that infringes on the user's name space.
1114 Don't have undefined behavior even if the translation
1115 produced a string with the wrong number of "%s"s. */
1119 while ((*yyp = *yyformat) != '\0')
1120 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1122 yyp += yytnamerr (yyp, yyarg[yyi++]);
1133 #endif /* YYERROR_VERBOSE */
1135 /*-----------------------------------------------.
1136 | Release the memory associated to this symbol. |
1137 `-----------------------------------------------*/
1140 #if (defined __STDC__ || defined __C99__FUNC__ \
1141 || defined __cplusplus || defined _MSC_VER)
1143 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1146 yydestruct (yymsg, yytype, yyvaluep)
1156 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1169 /* The lookahead symbol. */
1173 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1174 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1175 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1177 #ifndef YY_INITIAL_VALUE
1178 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1181 /* The semantic value of the lookahead symbol. */
1182 YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
1184 /* Number of syntax errors so far. */
1192 #ifdef YYPARSE_PARAM
1193 #if (defined __STDC__ || defined __C99__FUNC__ \
1194 || defined __cplusplus || defined _MSC_VER)
1196 yyparse (void *YYPARSE_PARAM)
1199 yyparse (YYPARSE_PARAM)
1200 void *YYPARSE_PARAM;
1202 #else /* ! YYPARSE_PARAM */
1203 #if (defined __STDC__ || defined __C99__FUNC__ \
1204 || defined __cplusplus || defined _MSC_VER)
1215 /* Number of tokens to shift before error messages enabled. */
1218 /* The stacks and their tools:
1219 `yyss': related to states.
1220 `yyvs': related to semantic values.
1222 Refer to the stacks through separate pointers, to allow yyoverflow
1223 to reallocate them elsewhere. */
1225 /* The state stack. */
1226 yytype_int16 yyssa[YYINITDEPTH];
1228 yytype_int16 *yyssp;
1230 /* The semantic value stack. */
1231 YYSTYPE yyvsa[YYINITDEPTH];
1235 YYSIZE_T yystacksize;
1239 /* Lookahead token as an internal (translated) token number. */
1241 /* The variables used to return semantic value and location from the
1246 /* Buffer for error messages, and its allocated size. */
1248 char *yymsg = yymsgbuf;
1249 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1252 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1254 /* The number of symbols on the RHS of the reduced rule.
1255 Keep to zero when no symbol should be popped. */
1258 yyssp = yyss = yyssa;
1259 yyvsp = yyvs = yyvsa;
1260 yystacksize = YYINITDEPTH;
1262 YYDPRINTF ((stderr, "Starting parse\n"));
1267 yychar = YYEMPTY; /* Cause a token to be read. */
1270 /*------------------------------------------------------------.
1271 | yynewstate -- Push a new state, which is found in yystate. |
1272 `------------------------------------------------------------*/
1274 /* In all cases, when you get here, the value and location stacks
1275 have just been pushed. So pushing a state here evens the stacks. */
1281 if (yyss + yystacksize - 1 <= yyssp)
1283 /* Get the current used size of the three stacks, in elements. */
1284 YYSIZE_T yysize = yyssp - yyss + 1;
1288 /* Give user a chance to reallocate the stack. Use copies of
1289 these so that the &'s don't force the real ones into
1291 YYSTYPE *yyvs1 = yyvs;
1292 yytype_int16 *yyss1 = yyss;
1294 /* Each stack pointer address is followed by the size of the
1295 data in use in that stack, in bytes. This used to be a
1296 conditional around just the two extra args, but that might
1297 be undefined if yyoverflow is a macro. */
1298 yyoverflow (YY_("memory exhausted"),
1299 &yyss1, yysize * sizeof (*yyssp),
1300 &yyvs1, yysize * sizeof (*yyvsp),
1306 #else /* no yyoverflow */
1307 # ifndef YYSTACK_RELOCATE
1308 goto yyexhaustedlab;
1310 /* Extend the stack our own way. */
1311 if (YYMAXDEPTH <= yystacksize)
1312 goto yyexhaustedlab;
1314 if (YYMAXDEPTH < yystacksize)
1315 yystacksize = YYMAXDEPTH;
1318 yytype_int16 *yyss1 = yyss;
1319 union yyalloc *yyptr =
1320 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1322 goto yyexhaustedlab;
1323 YYSTACK_RELOCATE (yyss_alloc, yyss);
1324 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1325 # undef YYSTACK_RELOCATE
1327 YYSTACK_FREE (yyss1);
1330 #endif /* no yyoverflow */
1332 yyssp = yyss + yysize - 1;
1333 yyvsp = yyvs + yysize - 1;
1335 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1336 (unsigned long int) yystacksize));
1338 if (yyss + yystacksize - 1 <= yyssp)
1342 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1344 if (yystate == YYFINAL)
1354 /* Do appropriate processing given the current state. Read a
1355 lookahead token if we need one and don't already have one. */
1357 /* First try to decide what to do without reference to lookahead token. */
1358 yyn = yypact[yystate];
1359 if (yypact_value_is_default (yyn))
1362 /* Not known => get a lookahead token if don't already have one. */
1364 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1365 if (yychar == YYEMPTY)
1367 YYDPRINTF ((stderr, "Reading a token: "));
1371 if (yychar <= YYEOF)
1373 yychar = yytoken = YYEOF;
1374 YYDPRINTF ((stderr, "Now at end of input.\n"));
1378 yytoken = YYTRANSLATE (yychar);
1379 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1382 /* If the proper action on seeing token YYTOKEN is to reduce or to
1383 detect an error, take that action. */
1385 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1390 if (yytable_value_is_error (yyn))
1396 /* Count tokens shifted since error; after three, turn off error
1401 /* Shift the lookahead token. */
1402 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1404 /* Discard the shifted token. */
1408 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1410 YY_IGNORE_MAYBE_UNINITIALIZED_END
1415 /*-----------------------------------------------------------.
1416 | yydefault -- do the default action for the current state. |
1417 `-----------------------------------------------------------*/
1419 yyn = yydefact[yystate];
1425 /*-----------------------------.
1426 | yyreduce -- Do a reduction. |
1427 `-----------------------------*/
1429 /* yyn is the number of a rule to reduce with. */
1432 /* If YYLEN is nonzero, implement the default value of the action:
1435 Otherwise, the following line sets YYVAL to garbage.
1436 This behavior is undocumented and Bison
1437 users should not rely upon it. Assigning to YYVAL
1438 unconditionally makes the parser a bit smaller, and it avoids a
1439 GCC warning that YYVAL may be used uninitialized. */
1440 yyval = yyvsp[1-yylen];
1443 YY_REDUCE_PRINT (yyn);
1447 /* Line 1792 of yacc.c */
1448 #line 72 "slmod_rdf_parser.y"
1450 ssp_result = talloc_asprintf(srp_slq,
1453 " <rdfq:startsWith>"
1454 " <rdfq:Property name=\"File:Path\" />"
1455 " <rdf:String>%s</rdf:String>"
1456 " </rdfq:startsWith>"
1459 "</rdfq:Condition>",
1460 srp_slq->slq_vol->v_path, (yyvsp[(1) - (1)].sval));
1461 (yyval.sval) = ssp_result;
1466 /* Line 1792 of yacc.c */
1467 #line 89 "slmod_rdf_parser.y"
1469 if ((yyvsp[(1) - (1)].bval) == false)
1477 /* Line 1792 of yacc.c */
1478 #line 95 "slmod_rdf_parser.y"
1480 if (strcmp((yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval)) != 0)
1481 (yyval.sval) = talloc_asprintf(srp_slq, "{ %s } UNION { %s }", (yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval));
1483 (yyval.sval) = talloc_asprintf(srp_slq, "%s", (yyvsp[(1) - (3)].sval));
1488 /* Line 1792 of yacc.c */
1489 #line 101 "slmod_rdf_parser.y"
1490 {(yyval.sval) = (yyvsp[(1) - (1)].sval); if ((yyval.sval) == NULL) YYABORT;}
1494 /* Line 1792 of yacc.c */
1495 #line 102 "slmod_rdf_parser.y"
1496 {(yyval.sval) = (yyvsp[(1) - (1)].sval);}
1500 /* Line 1792 of yacc.c */
1501 #line 103 "slmod_rdf_parser.y"
1502 {(yyval.sval) = talloc_asprintf(srp_slq, "%s", (yyvsp[(2) - (3)].sval));}
1506 /* Line 1792 of yacc.c */
1507 #line 104 "slmod_rdf_parser.y"
1508 {(yyval.sval) = talloc_asprintf(srp_slq, "%s . %s", (yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval));}
1512 /* Line 1792 of yacc.c */
1513 #line 105 "slmod_rdf_parser.y"
1515 if (strcmp((yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval)) != 0)
1516 (yyval.sval) = talloc_asprintf(srp_slq, "{ %s } UNION { %s }", (yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval));
1518 (yyval.sval) = talloc_asprintf(srp_slq, "%s", (yyvsp[(1) - (3)].sval));
1523 /* Line 1792 of yacc.c */
1524 #line 114 "slmod_rdf_parser.y"
1525 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '=', (yyvsp[(4) - (5)].sval));}
1529 /* Line 1792 of yacc.c */
1530 #line 115 "slmod_rdf_parser.y"
1531 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '!', (yyvsp[(4) - (5)].sval));}
1535 /* Line 1792 of yacc.c */
1536 #line 116 "slmod_rdf_parser.y"
1537 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '<', (yyvsp[(4) - (5)].sval));}
1541 /* Line 1792 of yacc.c */
1542 #line 117 "slmod_rdf_parser.y"
1543 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '>', (yyvsp[(4) - (5)].sval));}
1547 /* Line 1792 of yacc.c */
1548 #line 118 "slmod_rdf_parser.y"
1549 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '=', (yyvsp[(4) - (6)].sval));}
1553 /* Line 1792 of yacc.c */
1554 #line 119 "slmod_rdf_parser.y"
1555 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '!', (yyvsp[(4) - (6)].sval));}
1559 /* Line 1792 of yacc.c */
1560 #line 120 "slmod_rdf_parser.y"
1561 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '<', (yyvsp[(4) - (6)].sval));}
1565 /* Line 1792 of yacc.c */
1566 #line 121 "slmod_rdf_parser.y"
1567 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '>', (yyvsp[(4) - (6)].sval));}
1571 /* Line 1792 of yacc.c */
1572 #line 125 "slmod_rdf_parser.y"
1573 {(yyval.sval) = map_daterange((yyvsp[(3) - (8)].sval), (yyvsp[(5) - (8)].tval), (yyvsp[(7) - (8)].tval));}
1577 /* Line 1792 of yacc.c */
1578 #line 129 "slmod_rdf_parser.y"
1579 {(yyval.tval) = isodate2unix((yyvsp[(3) - (4)].sval));}
1583 /* Line 1792 of yacc.c */
1584 #line 130 "slmod_rdf_parser.y"
1585 {(yyval.tval) = atoi((yyvsp[(1) - (1)].sval)) + SPRAW_TIME_OFFSET;}
1589 /* Line 1792 of yacc.c */
1590 #line 1591 "slmod_rdf_parser.c"
1593 /* User semantic actions sometimes alter yychar, and that requires
1594 that yytoken be updated with the new translation. We take the
1595 approach of translating immediately before every use of yytoken.
1596 One alternative is translating here after every semantic action,
1597 but that translation would be missed if the semantic action invokes
1598 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1599 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1600 incorrect destructor might then be invoked immediately. In the
1601 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1602 to an incorrect destructor call or verbose syntax error message
1603 before the lookahead is translated. */
1604 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1608 YY_STACK_PRINT (yyss, yyssp);
1612 /* Now `shift' the result of the reduction. Determine what state
1613 that goes to, based on the state we popped back to and the rule
1614 number reduced by. */
1618 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1619 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1620 yystate = yytable[yystate];
1622 yystate = yydefgoto[yyn - YYNTOKENS];
1627 /*------------------------------------.
1628 | yyerrlab -- here on detecting error |
1629 `------------------------------------*/
1631 /* Make sure we have latest lookahead translation. See comments at
1632 user semantic actions for why this is necessary. */
1633 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1635 /* If not already recovering from an error, report this error. */
1639 #if ! YYERROR_VERBOSE
1640 yyerror (YY_("syntax error"));
1642 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1645 char const *yymsgp = YY_("syntax error");
1646 int yysyntax_error_status;
1647 yysyntax_error_status = YYSYNTAX_ERROR;
1648 if (yysyntax_error_status == 0)
1650 else if (yysyntax_error_status == 1)
1652 if (yymsg != yymsgbuf)
1653 YYSTACK_FREE (yymsg);
1654 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1658 yymsg_alloc = sizeof yymsgbuf;
1659 yysyntax_error_status = 2;
1663 yysyntax_error_status = YYSYNTAX_ERROR;
1668 if (yysyntax_error_status == 2)
1669 goto yyexhaustedlab;
1671 # undef YYSYNTAX_ERROR
1677 if (yyerrstatus == 3)
1679 /* If just tried and failed to reuse lookahead token after an
1680 error, discard it. */
1682 if (yychar <= YYEOF)
1684 /* Return failure if at end of input. */
1685 if (yychar == YYEOF)
1690 yydestruct ("Error: discarding",
1696 /* Else will try to reuse lookahead token after shifting the error
1701 /*---------------------------------------------------.
1702 | yyerrorlab -- error raised explicitly by YYERROR. |
1703 `---------------------------------------------------*/
1706 /* Pacify compilers like GCC when the user code never invokes
1707 YYERROR and the label yyerrorlab therefore never appears in user
1709 if (/*CONSTCOND*/ 0)
1712 /* Do not reclaim the symbols of the rule which action triggered
1716 YY_STACK_PRINT (yyss, yyssp);
1721 /*-------------------------------------------------------------.
1722 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1723 `-------------------------------------------------------------*/
1725 yyerrstatus = 3; /* Each real token shifted decrements this. */
1729 yyn = yypact[yystate];
1730 if (!yypact_value_is_default (yyn))
1733 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1741 /* Pop the current state because it cannot handle the error token. */
1746 yydestruct ("Error: popping",
1747 yystos[yystate], yyvsp);
1750 YY_STACK_PRINT (yyss, yyssp);
1753 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1755 YY_IGNORE_MAYBE_UNINITIALIZED_END
1758 /* Shift the error token. */
1759 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1765 /*-------------------------------------.
1766 | yyacceptlab -- YYACCEPT comes here. |
1767 `-------------------------------------*/
1772 /*-----------------------------------.
1773 | yyabortlab -- YYABORT comes here. |
1774 `-----------------------------------*/
1779 #if !defined yyoverflow || YYERROR_VERBOSE
1780 /*-------------------------------------------------.
1781 | yyexhaustedlab -- memory exhaustion comes here. |
1782 `-------------------------------------------------*/
1784 yyerror (YY_("memory exhausted"));
1790 if (yychar != YYEMPTY)
1792 /* Make sure we have latest lookahead translation. See comments at
1793 user semantic actions for why this is necessary. */
1794 yytoken = YYTRANSLATE (yychar);
1795 yydestruct ("Cleanup: discarding lookahead",
1798 /* Do not reclaim the symbols of the rule which action triggered
1799 this YYABORT or YYACCEPT. */
1801 YY_STACK_PRINT (yyss, yyssp);
1802 while (yyssp != yyss)
1804 yydestruct ("Cleanup: popping",
1805 yystos[*yyssp], yyvsp);
1810 YYSTACK_FREE (yyss);
1813 if (yymsg != yymsgbuf)
1814 YYSTACK_FREE (yymsg);
1816 /* Make sure YYID is used. */
1817 return YYID (yyresult);
1821 /* Line 2055 of yacc.c */
1822 #line 133 "slmod_rdf_parser.y"
1825 static time_t isodate2unix(const char *s)
1829 if (strptime(s, "%Y-%m-%dT%H:%M:%SZ", &tm) == NULL)
1834 const char *map_daterange(const char *dateattr, time_t date1, time_t date2)
1837 char *result = NULL;
1838 struct spotlight_rdf_map *p;
1840 char buf1[64], buf2[64];
1842 EC_NULL_LOG( tmp = localtime(&date1) );
1843 strftime(buf1, sizeof(buf1), "%Y-%m-%dT%H:%M:%SZ", tmp);
1844 EC_NULL_LOG( tmp = localtime(&date2) );
1845 strftime(buf2, sizeof(buf2), "%Y-%m-%dT%H:%M:%SZ", tmp);
1847 for (p = spotlight_rdf_map; p->srm_spotlight_attr; p++) {
1848 if (strcmp(dateattr, p->srm_spotlight_attr) == 0) {
1860 const char *map_expr(const char *attr, char op, const char *val)
1863 char *result = NULL;
1864 struct spotlight_rdf_map *p;
1868 bstring q = NULL, search = NULL, replace = NULL;
1870 for (p = spotlight_rdf_map; p->srm_spotlight_attr; p++) {
1871 if (p->srm_rdf_attr && strcmp(p->srm_spotlight_attr, attr) == 0) {
1872 switch (p->srm_type) {
1880 q = bformat("^%s$", val);
1881 search = bfromcstr("*");
1882 replace = bfromcstr(".*");
1883 bfindreplace(q, search, replace, 0);
1890 t = atoi(val) + SPRAW_TIME_OFFSET;
1891 EC_NULL( tmp = localtime(&t) );
1892 strftime(buf1, sizeof(buf1), "%Y-%m-%dT%H:%M:%SZ", tmp);
1896 yyerror("unknown Spotlight attribute type");
1913 void yyerror(const char *str)
1916 printf("yyerror: %s\n", str);
1918 LOG(log_error, logtype_sl, "yyerror: %s", str);
1928 * Map a Spotlight RAW query string to a SPARQL query string
1930 * @param[in] slq Spotlight query handle
1931 * @param[out] sparql_result Mapped SPARQL query, string is allocated in
1932 * talloc context of slq
1933 * @return 0 on success, -1 on error
1935 int map_spotlight_to_sparql_query(slq_t *slq, gchar **sparql_result)
1938 YY_BUFFER_STATE s = NULL;
1942 s = yy_scan_string(slq->slq_qstring);
1944 EC_ZERO( yyparse() );
1948 yy_delete_buffer(s);
1950 *sparql_result = ssp_result;
1952 *sparql_result = NULL;
1957 int main(int argc, char **argv)
1963 printf("usage: %s QUERY\n", argv[0]);
1967 srp_slq = talloc_zero(NULL, slq_t);
1968 struct vol *vol = talloc_zero(srp_slq, struct vol);
1969 vol->v_path = "/Volumes/test";
1970 srp_slq->slq_vol = vol;
1972 s = yy_scan_string(argv[1]);
1976 yy_delete_buffer(s);
1979 printf("SPARQL: %s\n", ssp_result ? ssp_result : "(empty)");