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_sparql_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_sparql_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;
102 static char sparqlvar;
104 /* Line 371 of yacc.c */
105 #line 106 "slmod_sparql_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_sparql_parser.y"
187 /* Line 387 of yacc.c */
188 #line 189 "slmod_sparql_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_sparql_parser.y"
214 #define SPRAW_TIME_OFFSET 978307200
215 extern int map_spotlight_to_sparql_query(slq_t *slq, gchar **sparql_result);
216 extern slq_t *ssp_slq;
219 /* Line 387 of yacc.c */
220 #line 221 "slmod_sparql_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_sparql_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, 15, 17, 19,
504 23, 27, 31, 37, 43, 49, 55, 62, 69, 76,
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, 16, 21, -1, 21, -1, 22, -1, 7,
513 20, 8, -1, 20, 15, 20, -1, 20, 16, 20,
514 -1, 3, 9, 14, 3, 14, -1, 3, 10, 14,
515 3, 14, -1, 3, 12, 14, 3, 14, -1, 3,
516 11, 14, 3, 14, -1, 3, 9, 14, 3, 14,
517 3, -1, 3, 10, 14, 3, 14, 3, -1, 3,
518 12, 14, 3, 14, 3, -1, 3, 11, 14, 3,
519 14, 3, -1, 5, 7, 3, 13, 23, 13, 23,
520 8, -1, 6, 7, 3, 8, -1, 3, -1
523 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
524 static const yytype_uint8 yyrline[] =
526 0, 67, 67, 69, 73, 83, 89, 95, 96, 97,
527 98, 99, 108, 109, 110, 111, 112, 113, 114, 115,
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, 20, 21, 21, 21, 21, 21, 21, 21, 21,
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, 3, 1, 1, 3,
566 3, 3, 5, 5, 5, 5, 6, 6, 6, 6,
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, 7,
576 8, 0, 0, 0, 0, 0, 0, 0, 0, 0,
577 0, 0, 0, 0, 0, 9, 10, 11, 6, 0,
578 0, 0, 0, 0, 12, 13, 15, 14, 22, 0,
579 0, 16, 17, 19, 18, 0, 0, 0, 0, 21,
583 /* YYDEFGOTO[NTERM-NUM]. */
584 static const yytype_int8 yydefgoto[] =
586 -1, 1, 7, 8, 9, 10, 40
589 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
591 #define YYPACT_NINF -10
592 static const yytype_int8 yypact[] =
594 -10, 10, -10, 9, -10, -2, -1, -10, 8, -9,
595 -10, 2, 12, 13, 14, 26, -7, -1, -1, 27,
596 28, 29, 30, 31, 22, -10, 20, -10, -10, 23,
597 24, 25, 32, 19, 37, 38, 39, 40, -10, 41,
598 34, -10, -10, -10, -10, 42, 19, 36, 43, -10,
602 /* YYPGOTO[NTERM-NUM]. */
603 static const yytype_int8 yypgoto[] =
605 -10, -10, -10, -6, 33, -10, 3
608 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
609 positive, shift that token. If negative, reduce the rule which
610 number is the opposite. If YYTABLE_NINF, syntax error. */
611 #define YYTABLE_NINF -1
612 static const yytype_uint8 yytable[] =
614 16, 25, 3, 4, 5, 15, 6, 19, 17, 18,
615 2, 26, 27, 3, 4, 5, 20, 6, 11, 12,
616 13, 14, 38, 17, 18, 39, 21, 22, 23, 24,
617 3, 29, 30, 31, 32, 33, 18, 34, 35, 36,
618 41, 42, 43, 44, 49, 47, 37, 46, 45, 48,
622 #define yypact_value_is_default(Yystate) \
623 (!!((Yystate) == (-10)))
625 #define yytable_value_is_error(Yytable_value) \
628 static const yytype_int8 yycheck[] =
630 6, 8, 3, 4, 5, 7, 7, 16, 15, 16,
631 0, 17, 18, 3, 4, 5, 14, 7, 9, 10,
632 11, 12, 3, 15, 16, 6, 14, 14, 14, 3,
633 3, 3, 3, 3, 3, 13, 16, 14, 14, 14,
634 3, 3, 3, 3, 8, 3, 14, 13, 7, 46,
638 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
639 symbol of state STATE-NUM. */
640 static const yytype_uint8 yystos[] =
642 0, 18, 0, 3, 4, 5, 7, 19, 20, 21,
643 22, 9, 10, 11, 12, 7, 20, 15, 16, 16,
644 14, 14, 14, 14, 3, 8, 20, 20, 21, 3,
645 3, 3, 3, 13, 14, 14, 14, 14, 3, 6,
646 23, 3, 3, 3, 3, 7, 13, 3, 23, 8,
650 #define yyerrok (yyerrstatus = 0)
651 #define yyclearin (yychar = YYEMPTY)
655 #define YYACCEPT goto yyacceptlab
656 #define YYABORT goto yyabortlab
657 #define YYERROR goto yyerrorlab
660 /* Like YYERROR except do call yyerror. This remains here temporarily
661 to ease the transition to the new meaning of YYERROR, for GCC.
662 Once GCC version 2 has supplanted version 1, this can go. However,
663 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
664 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
667 #define YYFAIL goto yyerrlab
669 /* This is here to suppress warnings from the GCC cpp's
670 -Wunused-macros. Normally we don't worry about that warning, but
671 some users do, and we want to make it easy for users to remove
672 YYFAIL uses, which will produce warnings from Bison 2.5. */
675 #define YYRECOVERING() (!!yyerrstatus)
677 #define YYBACKUP(Token, Value) \
679 if (yychar == YYEMPTY) \
683 YYPOPSTACK (yylen); \
689 yyerror (YY_("syntax error: cannot back up")); \
694 /* Error token number */
696 #define YYERRCODE 256
699 /* This macro is provided for backward compatibility. */
700 #ifndef YY_LOCATION_PRINT
701 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
705 /* YYLEX -- calling `yylex' with the right arguments. */
707 # define YYLEX yylex (YYLEX_PARAM)
709 # define YYLEX yylex ()
712 /* Enable debugging if requested. */
716 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
717 # define YYFPRINTF fprintf
720 # define YYDPRINTF(Args) \
726 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
730 YYFPRINTF (stderr, "%s ", Title); \
731 yy_symbol_print (stderr, \
733 YYFPRINTF (stderr, "\n"); \
738 /*--------------------------------.
739 | Print this symbol on YYOUTPUT. |
740 `--------------------------------*/
743 #if (defined __STDC__ || defined __C99__FUNC__ \
744 || defined __cplusplus || defined _MSC_VER)
746 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
749 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
752 YYSTYPE const * const yyvaluep;
755 FILE *yyo = yyoutput;
760 if (yytype < YYNTOKENS)
761 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
773 /*--------------------------------.
774 | Print this symbol on YYOUTPUT. |
775 `--------------------------------*/
777 #if (defined __STDC__ || defined __C99__FUNC__ \
778 || defined __cplusplus || defined _MSC_VER)
780 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
783 yy_symbol_print (yyoutput, yytype, yyvaluep)
786 YYSTYPE const * const yyvaluep;
789 if (yytype < YYNTOKENS)
790 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
792 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
794 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
795 YYFPRINTF (yyoutput, ")");
798 /*------------------------------------------------------------------.
799 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
801 `------------------------------------------------------------------*/
803 #if (defined __STDC__ || defined __C99__FUNC__ \
804 || defined __cplusplus || defined _MSC_VER)
806 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
809 yy_stack_print (yybottom, yytop)
810 yytype_int16 *yybottom;
814 YYFPRINTF (stderr, "Stack now");
815 for (; yybottom <= yytop; yybottom++)
817 int yybot = *yybottom;
818 YYFPRINTF (stderr, " %d", yybot);
820 YYFPRINTF (stderr, "\n");
823 # define YY_STACK_PRINT(Bottom, Top) \
826 yy_stack_print ((Bottom), (Top)); \
830 /*------------------------------------------------.
831 | Report that the YYRULE is going to be reduced. |
832 `------------------------------------------------*/
834 #if (defined __STDC__ || defined __C99__FUNC__ \
835 || defined __cplusplus || defined _MSC_VER)
837 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
840 yy_reduce_print (yyvsp, yyrule)
845 int yynrhs = yyr2[yyrule];
847 unsigned long int yylno = yyrline[yyrule];
848 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
850 /* The symbols being reduced. */
851 for (yyi = 0; yyi < yynrhs; yyi++)
853 YYFPRINTF (stderr, " $%d = ", yyi + 1);
854 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
855 &(yyvsp[(yyi + 1) - (yynrhs)])
857 YYFPRINTF (stderr, "\n");
861 # define YY_REDUCE_PRINT(Rule) \
864 yy_reduce_print (yyvsp, Rule); \
867 /* Nonzero means print parse trace. It is left uninitialized so that
868 multiple parsers can coexist. */
871 # define YYDPRINTF(Args)
872 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
873 # define YY_STACK_PRINT(Bottom, Top)
874 # define YY_REDUCE_PRINT(Rule)
875 #endif /* !YYDEBUG */
878 /* YYINITDEPTH -- initial size of the parser's stacks. */
880 # define YYINITDEPTH 200
883 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
884 if the built-in stack extension method is used).
886 Do not make this value too large; the results are undefined if
887 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
888 evaluated with infinite-precision integer arithmetic. */
891 # define YYMAXDEPTH 10000
898 # if defined __GLIBC__ && defined _STRING_H
899 # define yystrlen strlen
901 /* Return the length of YYSTR. */
902 #if (defined __STDC__ || defined __C99__FUNC__ \
903 || defined __cplusplus || defined _MSC_VER)
905 yystrlen (const char *yystr)
913 for (yylen = 0; yystr[yylen]; yylen++)
921 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
922 # define yystpcpy stpcpy
924 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
926 #if (defined __STDC__ || defined __C99__FUNC__ \
927 || defined __cplusplus || defined _MSC_VER)
929 yystpcpy (char *yydest, const char *yysrc)
932 yystpcpy (yydest, yysrc)
938 const char *yys = yysrc;
940 while ((*yyd++ = *yys++) != '\0')
949 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
950 quotes and backslashes, so that it's suitable for yyerror. The
951 heuristic is that double-quoting is unnecessary unless the string
952 contains an apostrophe, a comma, or backslash (other than
953 backslash-backslash). YYSTR is taken from yytname. If YYRES is
954 null, do not copy; instead, return the length of what the result
957 yytnamerr (char *yyres, const char *yystr)
962 char const *yyp = yystr;
969 goto do_not_strip_quotes;
973 goto do_not_strip_quotes;
986 do_not_strip_quotes: ;
990 return yystrlen (yystr);
992 return yystpcpy (yyres, yystr) - yyres;
996 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
997 about the unexpected token YYTOKEN for the state stack whose top is
1000 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1001 not large enough to hold the message. In that case, also set
1002 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1003 required number of bytes is too large to store. */
1005 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1006 yytype_int16 *yyssp, int yytoken)
1008 YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
1009 YYSIZE_T yysize = yysize0;
1010 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1011 /* Internationalized format string. */
1012 const char *yyformat = YY_NULL;
1013 /* Arguments of yyformat. */
1014 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1015 /* Number of reported tokens (one for the "unexpected", one per
1019 /* There are many possibilities here to consider:
1020 - Assume YYFAIL is not used. It's too flawed to consider. See
1021 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1022 for details. YYERROR is fine as it does not invoke this
1024 - If this state is a consistent state with a default action, then
1025 the only way this function was invoked is if the default action
1026 is an error action. In that case, don't check for expected
1027 tokens because there are none.
1028 - The only way there can be no lookahead present (in yychar) is if
1029 this state is a consistent state with a default action. Thus,
1030 detecting the absence of a lookahead is sufficient to determine
1031 that there is no unexpected or expected token to report. In that
1032 case, just report a simple "syntax error".
1033 - Don't assume there isn't a lookahead just because this state is a
1034 consistent state with a default action. There might have been a
1035 previous inconsistent state, consistent state with a non-default
1036 action, or user semantic action that manipulated yychar.
1037 - Of course, the expected token list depends on states to have
1038 correct lookahead information, and it depends on the parser not
1039 to perform extra reductions after fetching a lookahead from the
1040 scanner and before detecting a syntax error. Thus, state merging
1041 (from LALR or IELR) and default reductions corrupt the expected
1042 token list. However, the list is correct for canonical LR with
1043 one exception: it will still contain any token that will not be
1044 accepted due to an error action in a later state.
1046 if (yytoken != YYEMPTY)
1048 int yyn = yypact[*yyssp];
1049 yyarg[yycount++] = yytname[yytoken];
1050 if (!yypact_value_is_default (yyn))
1052 /* Start YYX at -YYN if negative to avoid negative indexes in
1053 YYCHECK. In other words, skip the first -YYN actions for
1054 this state because they are default actions. */
1055 int yyxbegin = yyn < 0 ? -yyn : 0;
1056 /* Stay within bounds of both yycheck and yytname. */
1057 int yychecklim = YYLAST - yyn + 1;
1058 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1061 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1062 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1063 && !yytable_value_is_error (yytable[yyx + yyn]))
1065 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1071 yyarg[yycount++] = yytname[yyx];
1073 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
1074 if (! (yysize <= yysize1
1075 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1085 # define YYCASE_(N, S) \
1089 YYCASE_(0, YY_("syntax error"));
1090 YYCASE_(1, YY_("syntax error, unexpected %s"));
1091 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1092 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1093 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1094 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1099 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1100 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1105 if (*yymsg_alloc < yysize)
1107 *yymsg_alloc = 2 * yysize;
1108 if (! (yysize <= *yymsg_alloc
1109 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1110 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1114 /* Avoid sprintf, as that infringes on the user's name space.
1115 Don't have undefined behavior even if the translation
1116 produced a string with the wrong number of "%s"s. */
1120 while ((*yyp = *yyformat) != '\0')
1121 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1123 yyp += yytnamerr (yyp, yyarg[yyi++]);
1134 #endif /* YYERROR_VERBOSE */
1136 /*-----------------------------------------------.
1137 | Release the memory associated to this symbol. |
1138 `-----------------------------------------------*/
1141 #if (defined __STDC__ || defined __C99__FUNC__ \
1142 || defined __cplusplus || defined _MSC_VER)
1144 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1147 yydestruct (yymsg, yytype, yyvaluep)
1157 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1170 /* The lookahead symbol. */
1174 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1175 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1176 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
1178 #ifndef YY_INITIAL_VALUE
1179 # define YY_INITIAL_VALUE(Value) /* Nothing. */
1182 /* The semantic value of the lookahead symbol. */
1183 YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
1185 /* Number of syntax errors so far. */
1193 #ifdef YYPARSE_PARAM
1194 #if (defined __STDC__ || defined __C99__FUNC__ \
1195 || defined __cplusplus || defined _MSC_VER)
1197 yyparse (void *YYPARSE_PARAM)
1200 yyparse (YYPARSE_PARAM)
1201 void *YYPARSE_PARAM;
1203 #else /* ! YYPARSE_PARAM */
1204 #if (defined __STDC__ || defined __C99__FUNC__ \
1205 || defined __cplusplus || defined _MSC_VER)
1216 /* Number of tokens to shift before error messages enabled. */
1219 /* The stacks and their tools:
1220 `yyss': related to states.
1221 `yyvs': related to semantic values.
1223 Refer to the stacks through separate pointers, to allow yyoverflow
1224 to reallocate them elsewhere. */
1226 /* The state stack. */
1227 yytype_int16 yyssa[YYINITDEPTH];
1229 yytype_int16 *yyssp;
1231 /* The semantic value stack. */
1232 YYSTYPE yyvsa[YYINITDEPTH];
1236 YYSIZE_T yystacksize;
1240 /* Lookahead token as an internal (translated) token number. */
1242 /* The variables used to return semantic value and location from the
1247 /* Buffer for error messages, and its allocated size. */
1249 char *yymsg = yymsgbuf;
1250 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1253 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1255 /* The number of symbols on the RHS of the reduced rule.
1256 Keep to zero when no symbol should be popped. */
1259 yyssp = yyss = yyssa;
1260 yyvsp = yyvs = yyvsa;
1261 yystacksize = YYINITDEPTH;
1263 YYDPRINTF ((stderr, "Starting parse\n"));
1268 yychar = YYEMPTY; /* Cause a token to be read. */
1271 /*------------------------------------------------------------.
1272 | yynewstate -- Push a new state, which is found in yystate. |
1273 `------------------------------------------------------------*/
1275 /* In all cases, when you get here, the value and location stacks
1276 have just been pushed. So pushing a state here evens the stacks. */
1282 if (yyss + yystacksize - 1 <= yyssp)
1284 /* Get the current used size of the three stacks, in elements. */
1285 YYSIZE_T yysize = yyssp - yyss + 1;
1289 /* Give user a chance to reallocate the stack. Use copies of
1290 these so that the &'s don't force the real ones into
1292 YYSTYPE *yyvs1 = yyvs;
1293 yytype_int16 *yyss1 = yyss;
1295 /* Each stack pointer address is followed by the size of the
1296 data in use in that stack, in bytes. This used to be a
1297 conditional around just the two extra args, but that might
1298 be undefined if yyoverflow is a macro. */
1299 yyoverflow (YY_("memory exhausted"),
1300 &yyss1, yysize * sizeof (*yyssp),
1301 &yyvs1, yysize * sizeof (*yyvsp),
1307 #else /* no yyoverflow */
1308 # ifndef YYSTACK_RELOCATE
1309 goto yyexhaustedlab;
1311 /* Extend the stack our own way. */
1312 if (YYMAXDEPTH <= yystacksize)
1313 goto yyexhaustedlab;
1315 if (YYMAXDEPTH < yystacksize)
1316 yystacksize = YYMAXDEPTH;
1319 yytype_int16 *yyss1 = yyss;
1320 union yyalloc *yyptr =
1321 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1323 goto yyexhaustedlab;
1324 YYSTACK_RELOCATE (yyss_alloc, yyss);
1325 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1326 # undef YYSTACK_RELOCATE
1328 YYSTACK_FREE (yyss1);
1331 #endif /* no yyoverflow */
1333 yyssp = yyss + yysize - 1;
1334 yyvsp = yyvs + yysize - 1;
1336 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1337 (unsigned long int) yystacksize));
1339 if (yyss + yystacksize - 1 <= yyssp)
1343 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1345 if (yystate == YYFINAL)
1355 /* Do appropriate processing given the current state. Read a
1356 lookahead token if we need one and don't already have one. */
1358 /* First try to decide what to do without reference to lookahead token. */
1359 yyn = yypact[yystate];
1360 if (yypact_value_is_default (yyn))
1363 /* Not known => get a lookahead token if don't already have one. */
1365 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1366 if (yychar == YYEMPTY)
1368 YYDPRINTF ((stderr, "Reading a token: "));
1372 if (yychar <= YYEOF)
1374 yychar = yytoken = YYEOF;
1375 YYDPRINTF ((stderr, "Now at end of input.\n"));
1379 yytoken = YYTRANSLATE (yychar);
1380 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1383 /* If the proper action on seeing token YYTOKEN is to reduce or to
1384 detect an error, take that action. */
1386 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1391 if (yytable_value_is_error (yyn))
1397 /* Count tokens shifted since error; after three, turn off error
1402 /* Shift the lookahead token. */
1403 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1405 /* Discard the shifted token. */
1409 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1411 YY_IGNORE_MAYBE_UNINITIALIZED_END
1416 /*-----------------------------------------------------------.
1417 | yydefault -- do the default action for the current state. |
1418 `-----------------------------------------------------------*/
1420 yyn = yydefact[yystate];
1426 /*-----------------------------.
1427 | yyreduce -- Do a reduction. |
1428 `-----------------------------*/
1430 /* yyn is the number of a rule to reduce with. */
1433 /* If YYLEN is nonzero, implement the default value of the action:
1436 Otherwise, the following line sets YYVAL to garbage.
1437 This behavior is undocumented and Bison
1438 users should not rely upon it. Assigning to YYVAL
1439 unconditionally makes the parser a bit smaller, and it avoids a
1440 GCC warning that YYVAL may be used uninitialized. */
1441 yyval = yyvsp[1-yylen];
1444 YY_REDUCE_PRINT (yyn);
1448 /* Line 1792 of yacc.c */
1449 #line 73 "slmod_sparql_parser.y"
1451 ssp_result = talloc_asprintf(ssp_slq,
1452 "SELECT DISTINCT ?url WHERE "
1453 "{ ?obj nie:url ?url FILTER(regex(?url, '^file://%s/')) . %s}",
1454 ssp_slq->slq_vol->v_path, (yyvsp[(1) - (1)].sval));
1455 (yyval.sval) = ssp_result;
1460 /* Line 1792 of yacc.c */
1461 #line 83 "slmod_sparql_parser.y"
1463 if ((yyvsp[(1) - (1)].bval) == false)
1471 /* Line 1792 of yacc.c */
1472 #line 89 "slmod_sparql_parser.y"
1474 if (strcmp((yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval)) != 0)
1475 (yyval.sval) = talloc_asprintf(ssp_slq, "{ %s } UNION { %s }", (yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval));
1477 (yyval.sval) = talloc_asprintf(ssp_slq, "%s", (yyvsp[(1) - (3)].sval));
1482 /* Line 1792 of yacc.c */
1483 #line 95 "slmod_sparql_parser.y"
1484 {(yyval.sval) = (yyvsp[(1) - (1)].sval); if ((yyval.sval) == NULL) YYABORT;}
1488 /* Line 1792 of yacc.c */
1489 #line 96 "slmod_sparql_parser.y"
1490 {(yyval.sval) = (yyvsp[(1) - (1)].sval);}
1494 /* Line 1792 of yacc.c */
1495 #line 97 "slmod_sparql_parser.y"
1496 {(yyval.sval) = talloc_asprintf(ssp_slq, "%s", (yyvsp[(2) - (3)].sval));}
1500 /* Line 1792 of yacc.c */
1501 #line 98 "slmod_sparql_parser.y"
1502 {(yyval.sval) = talloc_asprintf(ssp_slq, "%s . %s", (yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval));}
1506 /* Line 1792 of yacc.c */
1507 #line 99 "slmod_sparql_parser.y"
1509 if (strcmp((yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval)) != 0)
1510 (yyval.sval) = talloc_asprintf(ssp_slq, "{ %s } UNION { %s }", (yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].sval));
1512 (yyval.sval) = talloc_asprintf(ssp_slq, "%s", (yyvsp[(1) - (3)].sval));
1517 /* Line 1792 of yacc.c */
1518 #line 108 "slmod_sparql_parser.y"
1519 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '=', (yyvsp[(4) - (5)].sval));}
1523 /* Line 1792 of yacc.c */
1524 #line 109 "slmod_sparql_parser.y"
1525 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '!', (yyvsp[(4) - (5)].sval));}
1529 /* Line 1792 of yacc.c */
1530 #line 110 "slmod_sparql_parser.y"
1531 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '<', (yyvsp[(4) - (5)].sval));}
1535 /* Line 1792 of yacc.c */
1536 #line 111 "slmod_sparql_parser.y"
1537 {(yyval.sval) = map_expr((yyvsp[(1) - (5)].sval), '>', (yyvsp[(4) - (5)].sval));}
1541 /* Line 1792 of yacc.c */
1542 #line 112 "slmod_sparql_parser.y"
1543 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '=', (yyvsp[(4) - (6)].sval));}
1547 /* Line 1792 of yacc.c */
1548 #line 113 "slmod_sparql_parser.y"
1549 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '!', (yyvsp[(4) - (6)].sval));}
1553 /* Line 1792 of yacc.c */
1554 #line 114 "slmod_sparql_parser.y"
1555 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '<', (yyvsp[(4) - (6)].sval));}
1559 /* Line 1792 of yacc.c */
1560 #line 115 "slmod_sparql_parser.y"
1561 {(yyval.sval) = map_expr((yyvsp[(1) - (6)].sval), '>', (yyvsp[(4) - (6)].sval));}
1565 /* Line 1792 of yacc.c */
1566 #line 119 "slmod_sparql_parser.y"
1567 {(yyval.sval) = map_daterange((yyvsp[(3) - (8)].sval), (yyvsp[(5) - (8)].tval), (yyvsp[(7) - (8)].tval));}
1571 /* Line 1792 of yacc.c */
1572 #line 123 "slmod_sparql_parser.y"
1573 {(yyval.tval) = isodate2unix((yyvsp[(3) - (4)].sval));}
1577 /* Line 1792 of yacc.c */
1578 #line 124 "slmod_sparql_parser.y"
1579 {(yyval.tval) = atoi((yyvsp[(1) - (1)].sval)) + SPRAW_TIME_OFFSET;}
1583 /* Line 1792 of yacc.c */
1584 #line 1585 "slmod_sparql_parser.c"
1587 /* User semantic actions sometimes alter yychar, and that requires
1588 that yytoken be updated with the new translation. We take the
1589 approach of translating immediately before every use of yytoken.
1590 One alternative is translating here after every semantic action,
1591 but that translation would be missed if the semantic action invokes
1592 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1593 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1594 incorrect destructor might then be invoked immediately. In the
1595 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1596 to an incorrect destructor call or verbose syntax error message
1597 before the lookahead is translated. */
1598 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1602 YY_STACK_PRINT (yyss, yyssp);
1606 /* Now `shift' the result of the reduction. Determine what state
1607 that goes to, based on the state we popped back to and the rule
1608 number reduced by. */
1612 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1613 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1614 yystate = yytable[yystate];
1616 yystate = yydefgoto[yyn - YYNTOKENS];
1621 /*------------------------------------.
1622 | yyerrlab -- here on detecting error |
1623 `------------------------------------*/
1625 /* Make sure we have latest lookahead translation. See comments at
1626 user semantic actions for why this is necessary. */
1627 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1629 /* If not already recovering from an error, report this error. */
1633 #if ! YYERROR_VERBOSE
1634 yyerror (YY_("syntax error"));
1636 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1639 char const *yymsgp = YY_("syntax error");
1640 int yysyntax_error_status;
1641 yysyntax_error_status = YYSYNTAX_ERROR;
1642 if (yysyntax_error_status == 0)
1644 else if (yysyntax_error_status == 1)
1646 if (yymsg != yymsgbuf)
1647 YYSTACK_FREE (yymsg);
1648 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1652 yymsg_alloc = sizeof yymsgbuf;
1653 yysyntax_error_status = 2;
1657 yysyntax_error_status = YYSYNTAX_ERROR;
1662 if (yysyntax_error_status == 2)
1663 goto yyexhaustedlab;
1665 # undef YYSYNTAX_ERROR
1671 if (yyerrstatus == 3)
1673 /* If just tried and failed to reuse lookahead token after an
1674 error, discard it. */
1676 if (yychar <= YYEOF)
1678 /* Return failure if at end of input. */
1679 if (yychar == YYEOF)
1684 yydestruct ("Error: discarding",
1690 /* Else will try to reuse lookahead token after shifting the error
1695 /*---------------------------------------------------.
1696 | yyerrorlab -- error raised explicitly by YYERROR. |
1697 `---------------------------------------------------*/
1700 /* Pacify compilers like GCC when the user code never invokes
1701 YYERROR and the label yyerrorlab therefore never appears in user
1703 if (/*CONSTCOND*/ 0)
1706 /* Do not reclaim the symbols of the rule which action triggered
1710 YY_STACK_PRINT (yyss, yyssp);
1715 /*-------------------------------------------------------------.
1716 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1717 `-------------------------------------------------------------*/
1719 yyerrstatus = 3; /* Each real token shifted decrements this. */
1723 yyn = yypact[yystate];
1724 if (!yypact_value_is_default (yyn))
1727 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1735 /* Pop the current state because it cannot handle the error token. */
1740 yydestruct ("Error: popping",
1741 yystos[yystate], yyvsp);
1744 YY_STACK_PRINT (yyss, yyssp);
1747 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1749 YY_IGNORE_MAYBE_UNINITIALIZED_END
1752 /* Shift the error token. */
1753 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1759 /*-------------------------------------.
1760 | yyacceptlab -- YYACCEPT comes here. |
1761 `-------------------------------------*/
1766 /*-----------------------------------.
1767 | yyabortlab -- YYABORT comes here. |
1768 `-----------------------------------*/
1773 #if !defined yyoverflow || YYERROR_VERBOSE
1774 /*-------------------------------------------------.
1775 | yyexhaustedlab -- memory exhaustion comes here. |
1776 `-------------------------------------------------*/
1778 yyerror (YY_("memory exhausted"));
1784 if (yychar != YYEMPTY)
1786 /* Make sure we have latest lookahead translation. See comments at
1787 user semantic actions for why this is necessary. */
1788 yytoken = YYTRANSLATE (yychar);
1789 yydestruct ("Cleanup: discarding lookahead",
1792 /* Do not reclaim the symbols of the rule which action triggered
1793 this YYABORT or YYACCEPT. */
1795 YY_STACK_PRINT (yyss, yyssp);
1796 while (yyssp != yyss)
1798 yydestruct ("Cleanup: popping",
1799 yystos[*yyssp], yyvsp);
1804 YYSTACK_FREE (yyss);
1807 if (yymsg != yymsgbuf)
1808 YYSTACK_FREE (yymsg);
1810 /* Make sure YYID is used. */
1811 return YYID (yyresult);
1815 /* Line 2055 of yacc.c */
1816 #line 127 "slmod_sparql_parser.y"
1819 static time_t isodate2unix(const char *s)
1823 if (strptime(s, "%Y-%m-%dT%H:%M:%SZ", &tm) == NULL)
1828 static const char *map_daterange(const char *dateattr, time_t date1, time_t date2)
1831 char *result = NULL;
1832 struct spotlight_sparql_map *p;
1834 char buf1[64], buf2[64];
1836 EC_NULL_LOG( tmp = localtime(&date1) );
1837 strftime(buf1, sizeof(buf1), "%Y-%m-%dT%H:%M:%SZ", tmp);
1838 EC_NULL_LOG( tmp = localtime(&date2) );
1839 strftime(buf2, sizeof(buf2), "%Y-%m-%dT%H:%M:%SZ", tmp);
1841 for (p = spotlight_sparql_map; p->ssm_spotlight_attr; p++) {
1842 if (strcmp(dateattr, p->ssm_spotlight_attr) == 0) {
1843 result = talloc_asprintf(ssp_slq,
1844 "?obj %s ?%c FILTER (?%c > '%s' && ?%c < '%s')",
1862 static char *map_type_search(const char *attr, char op, const char *val)
1864 char *result = NULL;
1865 const char *sparqlAttr;
1867 for (struct MDTypeMap *p = MDTypeMap; p->mdtm_value; p++) {
1868 if (strcmp(p->mdtm_value, val) == 0) {
1869 switch (p->mdtm_type) {
1871 sparqlAttr = "rdf:type";
1873 case kMDTypeMapMime:
1874 sparqlAttr = "nie:mimeType";
1879 result = talloc_asprintf(ssp_slq, "?obj %s '%s'",
1888 static const char *map_expr(const char *attr, char op, const char *val)
1891 char *result = NULL;
1892 struct spotlight_sparql_map *p;
1896 bstring q = NULL, search = NULL, replace = NULL;
1898 for (p = spotlight_sparql_map; p->ssm_spotlight_attr; p++) {
1899 if (strcmp(p->ssm_spotlight_attr, attr) == 0) {
1900 if (p->ssm_type != ssmt_type && p->ssm_sparql_attr == NULL) {
1901 yyerror("unsupported Spotlight attribute");
1904 switch (p->ssm_type) {
1906 result = talloc_asprintf(ssp_slq, "?obj %s '%s'", p->ssm_sparql_attr, val);
1909 result = talloc_asprintf(ssp_slq, "?obj %s ?%c FILTER(?%c %c%c '%s')",
1914 op == '!' ? '=' : ' ', /* append '=' to '!' */
1919 q = bformat("^%s$", val);
1920 search = bfromcstr("*");
1921 replace = bfromcstr(".*");
1922 bfindreplace(q, search, replace, 0);
1923 result = talloc_asprintf(ssp_slq, "?obj %s ?%c FILTER(regex(?%c, '%s'))",
1931 result = talloc_asprintf(ssp_slq, "?obj %s '%s'", p->ssm_sparql_attr, val);
1934 t = atoi(val) + SPRAW_TIME_OFFSET;
1935 EC_NULL( tmp = localtime(&t) );
1936 strftime(buf1, sizeof(buf1), "%Y-%m-%dT%H:%M:%SZ", tmp);
1937 result = talloc_asprintf(ssp_slq, "?obj %s ?%c FILTER(?%c %c '%s')",
1946 result = map_type_search(attr, op, val);
1965 void yyerror(const char *str)
1968 printf("yyerror: %s\n", str);
1970 LOG(log_error, logtype_sl, "yyerror: %s", str);
1980 * Map a Spotlight RAW query string to a SPARQL query string
1982 * @param[in] slq Spotlight query handle
1983 * @param[out] sparql_result Mapped SPARQL query, string is allocated in
1984 * talloc context of slq
1985 * @return 0 on success, -1 on error
1987 int map_spotlight_to_sparql_query(slq_t *slq, gchar **sparql_result)
1990 YY_BUFFER_STATE s = NULL;
1994 s = yy_scan_string(slq->slq_qstring);
1997 EC_ZERO( yyparse() );
2001 yy_delete_buffer(s);
2003 *sparql_result = ssp_result;
2005 *sparql_result = NULL;
2010 int main(int argc, char **argv)
2016 printf("usage: %s QUERY\n", argv[0]);
2020 ssp_slq = talloc_zero(NULL, slq_t);
2021 struct vol *vol = talloc_zero(ssp_slq, struct vol);
2022 vol->v_path = "/Volumes/test";
2023 ssp_slq->slq_vol = vol;
2026 s = yy_scan_string(argv[1]);
2030 yy_delete_buffer(s);
2033 printf("SPARQL: %s\n", ssp_result ? ssp_result : "(empty)");