1 /* A Bison parser, made by GNU Bison 3.0.2. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2013 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 "3.0.2"
50 #define YYSKELETON_NAME "yacc.c"
64 /* Copy the first part of user declarations. */
65 #line 21 "sparql_parser.y" /* yacc.c:339 */
69 #include "sparql_parser.h"
70 #include "sparql_mapping.h"
72 #define YYMALLOC SMB_MALLOC
73 #define YYREALLOC SMB_REALLOC
75 struct yy_buffer_state
;
76 typedef struct yy_buffer_state
*YY_BUFFER_STATE
;
77 extern int yylex (void);
78 extern void yyerror (char const *);
79 extern void *yyterminate(void);
80 extern YY_BUFFER_STATE
yy_scan_string( const char *str
);
81 extern void yy_delete_buffer ( YY_BUFFER_STATE buffer
);
83 /* forward declarations */
84 static const char *map_expr(const char *attr
, char op
, const char *val
);
85 static const char *map_daterange(const char *dateattr
,
86 time_t date1
, time_t date2
);
87 static time_t isodate2unix(const char *s
);
89 /* global vars, eg needed by the lexer */
90 struct sparql_parser_state
{
95 } *global_sparql_parser_state
;
97 #line 98 "sparql_parser.c" /* yacc.c:339 */
100 # if defined __cplusplus && 201103L <= __cplusplus
101 # define YY_NULLPTR nullptr
103 # define YY_NULLPTR 0
107 /* Enabling verbose error messages. */
108 #ifdef YYERROR_VERBOSE
109 # undef YYERROR_VERBOSE
110 # define YYERROR_VERBOSE 1
112 # define YYERROR_VERBOSE 1
115 /* In a future release of Bison, this section will be replaced
116 by #include "sparql_parser.h". */
117 #ifndef YY_YY_SPARQL_PARSER_H_INCLUDED
118 # define YY_YY_SPARQL_PARSER_H_INCLUDED
150 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
151 typedef union YYSTYPE YYSTYPE
;
154 #line 61 "sparql_parser.y" /* yacc.c:355 */
161 #line 162 "sparql_parser.c" /* yacc.c:355 */
163 # define YYSTYPE_IS_TRIVIAL 1
164 # define YYSTYPE_IS_DECLARED 1
168 extern YYSTYPE yylval
;
171 /* "%code provides" blocks. */
172 #line 53 "sparql_parser.y" /* yacc.c:355 */
176 #define SPRAW_TIME_OFFSET 978307200
177 extern int yywrap(void);
178 extern bool map_spotlight_to_sparql_query(struct sl_query
*slq
);
180 #line 181 "sparql_parser.c" /* yacc.c:355 */
182 #endif /* !YY_YY_SPARQL_PARSER_H_INCLUDED */
184 /* Copy the second part of user declarations. */
186 #line 187 "sparql_parser.c" /* yacc.c:358 */
193 typedef YYTYPE_UINT8 yytype_uint8
;
195 typedef unsigned char yytype_uint8
;
199 typedef YYTYPE_INT8 yytype_int8
;
201 typedef signed char yytype_int8
;
205 typedef YYTYPE_UINT16 yytype_uint16
;
207 typedef unsigned short int yytype_uint16
;
211 typedef YYTYPE_INT16 yytype_int16
;
213 typedef short int yytype_int16
;
217 # ifdef __SIZE_TYPE__
218 # define YYSIZE_T __SIZE_TYPE__
219 # elif defined size_t
220 # define YYSIZE_T size_t
221 # elif ! defined YYSIZE_T
222 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
223 # define YYSIZE_T size_t
225 # define YYSIZE_T unsigned int
229 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
232 # if defined YYENABLE_NLS && YYENABLE_NLS
234 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
235 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
239 # define YY_(Msgid) Msgid
244 # if (defined __GNUC__ \
245 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
246 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
247 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
249 # define YY_ATTRIBUTE(Spec) /* empty */
253 #ifndef YY_ATTRIBUTE_PURE
254 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
257 #ifndef YY_ATTRIBUTE_UNUSED
258 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
261 #if !defined _Noreturn \
262 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
263 # if defined _MSC_VER && 1200 <= _MSC_VER
264 # define _Noreturn __declspec (noreturn)
266 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
270 /* Suppress unused-variable warnings by "using" E. */
271 #if ! defined lint || defined __GNUC__
272 # define YYUSE(E) ((void) (E))
274 # define YYUSE(E) /* empty */
277 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
278 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
279 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
280 _Pragma ("GCC diagnostic push") \
281 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
282 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
283 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
284 _Pragma ("GCC diagnostic pop")
286 # define YY_INITIAL_VALUE(Value) Value
288 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
289 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
290 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
292 #ifndef YY_INITIAL_VALUE
293 # define YY_INITIAL_VALUE(Value) /* Nothing. */
297 #if ! defined yyoverflow || YYERROR_VERBOSE
299 /* The parser invokes alloca or malloc; define the necessary symbols. */
301 # ifdef YYSTACK_USE_ALLOCA
302 # if YYSTACK_USE_ALLOCA
304 # define YYSTACK_ALLOC __builtin_alloca
305 # elif defined __BUILTIN_VA_ARG_INCR
306 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
308 # define YYSTACK_ALLOC __alloca
309 # elif defined _MSC_VER
310 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
311 # define alloca _alloca
313 # define YYSTACK_ALLOC alloca
314 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
315 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
316 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
317 # ifndef EXIT_SUCCESS
318 # define EXIT_SUCCESS 0
325 # ifdef YYSTACK_ALLOC
326 /* Pacify GCC's 'empty if-body' warning. */
327 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
328 # ifndef YYSTACK_ALLOC_MAXIMUM
329 /* The OS might guarantee only one guard page at the bottom of the stack,
330 and a page size can be as small as 4096 bytes. So we cannot safely
331 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
332 to allow for a few compiler-allocated temporary stack slots. */
333 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
336 # define YYSTACK_ALLOC YYMALLOC
337 # define YYSTACK_FREE YYFREE
338 # ifndef YYSTACK_ALLOC_MAXIMUM
339 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
341 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
342 && ! ((defined YYMALLOC || defined malloc) \
343 && (defined YYFREE || defined free)))
344 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
345 # ifndef EXIT_SUCCESS
346 # define EXIT_SUCCESS 0
350 # define YYMALLOC malloc
351 # if ! defined malloc && ! defined EXIT_SUCCESS
352 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
357 # if ! defined free && ! defined EXIT_SUCCESS
358 void free (void *); /* INFRINGES ON USER NAME SPACE */
362 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
365 #if (! defined yyoverflow \
366 && (! defined __cplusplus \
367 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
369 /* A type that is properly aligned for any stack member. */
372 yytype_int16 yyss_alloc
;
376 /* The size of the maximum gap between one aligned stack and the next. */
377 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
379 /* The size of an array large to enough to hold all stacks, each with
381 # define YYSTACK_BYTES(N) \
382 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
383 + YYSTACK_GAP_MAXIMUM)
385 # define YYCOPY_NEEDED 1
387 /* Relocate STACK from its old location to the new one. The
388 local variables YYSIZE and YYSTACKSIZE give the old and new number of
389 elements in the stack, and YYPTR gives the new location of the
390 stack. Advance YYPTR to a properly aligned location for the next
392 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
395 YYSIZE_T yynewbytes; \
396 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
397 Stack = &yyptr->Stack_alloc; \
398 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
399 yyptr += yynewbytes / sizeof (*yyptr); \
405 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
406 /* Copy COUNT objects from SRC to DST. The source and destination do
409 # if defined __GNUC__ && 1 < __GNUC__
410 # define YYCOPY(Dst, Src, Count) \
411 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
413 # define YYCOPY(Dst, Src, Count) \
417 for (yyi = 0; yyi < (Count); yyi++) \
418 (Dst)[yyi] = (Src)[yyi]; \
423 #endif /* !YYCOPY_NEEDED */
425 /* YYFINAL -- State number of the termination state. */
427 /* YYLAST -- Last index in YYTABLE. */
430 /* YYNTOKENS -- Number of terminals. */
432 /* YYNNTS -- Number of nonterminals. */
434 /* YYNRULES -- Number of rules. */
436 /* YYNSTATES -- Number of states. */
439 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
440 by yylex, with out-of-bounds checking. */
442 #define YYMAXUTOK 271
444 #define YYTRANSLATE(YYX) \
445 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
447 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
448 as returned by yylex, without out-of-bounds checking. */
449 static const yytype_uint8 yytranslate
[] =
451 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
454 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
455 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
456 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
457 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
458 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
459 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
460 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
461 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
462 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
463 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
464 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
465 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
466 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
467 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
468 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
469 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
470 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
471 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
472 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
473 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
474 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
475 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
476 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
477 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
482 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
483 static const yytype_uint8 yyrline
[] =
485 0, 83, 83, 85, 89, 95, 118, 125, 128, 131,
486 134, 137, 147, 151, 155, 159, 163, 167, 171, 175,
491 #if YYDEBUG || YYERROR_VERBOSE || 1
492 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
493 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
494 static const char *const yytname
[] =
496 "$end", "error", "$undefined", "WORD", "BOOL", "FUNC_INRANGE",
497 "DATE_ISO", "OBRACE", "CBRACE", "EQUAL", "UNEQUAL", "GT", "LT", "COMMA",
498 "QUOTE", "AND", "OR", "$accept", "input", "line", "expr", "match",
499 "function", "date", YY_NULLPTR
504 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
505 (internal) symbol number NUM (which must be that of a token). */
506 static const yytype_uint16 yytoknum
[] =
508 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
509 265, 266, 267, 268, 269, 270, 271
513 #define YYPACT_NINF -10
515 #define yypact_value_is_default(Yystate) \
516 (!!((Yystate) == (-10)))
518 #define YYTABLE_NINF -1
520 #define yytable_value_is_error(Yytable_value) \
523 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
525 static const yytype_int8 yypact
[] =
527 -10, 10, -10, 9, -10, -2, -1, -10, 8, -9,
528 -10, 2, 12, 13, 14, 26, -7, -1, -1, 27,
529 28, 29, 30, 31, 22, -10, 20, -10, -10, 23,
530 24, 25, 32, 19, 37, 38, 39, 40, -10, 41,
531 34, -10, -10, -10, -10, 42, 19, 36, 43, -10,
535 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
536 Performed when YYTABLE does not specify something else to do. Zero
537 means the default is an error. */
538 static const yytype_uint8 yydefact
[] =
540 2, 0, 1, 0, 5, 0, 0, 3, 4, 7,
541 8, 0, 0, 0, 0, 0, 0, 0, 0, 0,
542 0, 0, 0, 0, 0, 9, 10, 11, 6, 0,
543 0, 0, 0, 0, 12, 13, 15, 14, 22, 0,
544 0, 16, 17, 19, 18, 0, 0, 0, 0, 21,
548 /* YYPGOTO[NTERM-NUM]. */
549 static const yytype_int8 yypgoto
[] =
551 -10, -10, -10, -6, 33, -10, 3
554 /* YYDEFGOTO[NTERM-NUM]. */
555 static const yytype_int8 yydefgoto
[] =
557 -1, 1, 7, 8, 9, 10, 40
560 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
561 positive, shift that token. If negative, reduce the rule whose
562 number is the opposite. If YYTABLE_NINF, syntax error. */
563 static const yytype_uint8 yytable
[] =
565 16, 25, 3, 4, 5, 15, 6, 19, 17, 18,
566 2, 26, 27, 3, 4, 5, 20, 6, 11, 12,
567 13, 14, 38, 17, 18, 39, 21, 22, 23, 24,
568 3, 29, 30, 31, 32, 33, 18, 34, 35, 36,
569 41, 42, 43, 44, 49, 47, 37, 46, 45, 48,
573 static const yytype_int8 yycheck
[] =
575 6, 8, 3, 4, 5, 7, 7, 16, 15, 16,
576 0, 17, 18, 3, 4, 5, 14, 7, 9, 10,
577 11, 12, 3, 15, 16, 6, 14, 14, 14, 3,
578 3, 3, 3, 3, 3, 13, 16, 14, 14, 14,
579 3, 3, 3, 3, 8, 3, 14, 13, 7, 46,
583 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
584 symbol of state STATE-NUM. */
585 static const yytype_uint8 yystos
[] =
587 0, 18, 0, 3, 4, 5, 7, 19, 20, 21,
588 22, 9, 10, 11, 12, 7, 20, 15, 16, 16,
589 14, 14, 14, 14, 3, 8, 20, 20, 21, 3,
590 3, 3, 3, 13, 14, 14, 14, 14, 3, 6,
591 23, 3, 3, 3, 3, 7, 13, 3, 23, 8,
595 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
596 static const yytype_uint8 yyr1
[] =
598 0, 17, 18, 18, 19, 20, 20, 20, 20, 20,
599 20, 20, 21, 21, 21, 21, 21, 21, 21, 21,
603 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
604 static const yytype_uint8 yyr2
[] =
606 0, 2, 0, 2, 1, 1, 3, 1, 1, 3,
607 3, 3, 5, 5, 5, 5, 6, 6, 6, 6,
612 #define yyerrok (yyerrstatus = 0)
613 #define yyclearin (yychar = YYEMPTY)
617 #define YYACCEPT goto yyacceptlab
618 #define YYABORT goto yyabortlab
619 #define YYERROR goto yyerrorlab
622 #define YYRECOVERING() (!!yyerrstatus)
624 #define YYBACKUP(Token, Value) \
626 if (yychar == YYEMPTY) \
630 YYPOPSTACK (yylen); \
636 yyerror (YY_("syntax error: cannot back up")); \
641 /* Error token number */
643 #define YYERRCODE 256
647 /* Enable debugging if requested. */
651 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
652 # define YYFPRINTF fprintf
655 # define YYDPRINTF(Args) \
661 /* This macro is provided for backward compatibility. */
662 #ifndef YY_LOCATION_PRINT
663 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
667 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
671 YYFPRINTF (stderr, "%s ", Title); \
672 yy_symbol_print (stderr, \
674 YYFPRINTF (stderr, "\n"); \
679 /*----------------------------------------.
680 | Print this symbol's value on YYOUTPUT. |
681 `----------------------------------------*/
684 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
686 FILE *yyo
= yyoutput
;
691 if (yytype
< YYNTOKENS
)
692 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
698 /*--------------------------------.
699 | Print this symbol on YYOUTPUT. |
700 `--------------------------------*/
703 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
705 YYFPRINTF (yyoutput
, "%s %s (",
706 yytype
< YYNTOKENS
? "token" : "nterm", yytname
[yytype
]);
708 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
);
709 YYFPRINTF (yyoutput
, ")");
712 /*------------------------------------------------------------------.
713 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
715 `------------------------------------------------------------------*/
718 yy_stack_print (yytype_int16
*yybottom
, yytype_int16
*yytop
)
720 YYFPRINTF (stderr
, "Stack now");
721 for (; yybottom
<= yytop
; yybottom
++)
723 int yybot
= *yybottom
;
724 YYFPRINTF (stderr
, " %d", yybot
);
726 YYFPRINTF (stderr
, "\n");
729 # define YY_STACK_PRINT(Bottom, Top) \
732 yy_stack_print ((Bottom), (Top)); \
736 /*------------------------------------------------.
737 | Report that the YYRULE is going to be reduced. |
738 `------------------------------------------------*/
741 yy_reduce_print (yytype_int16
*yyssp
, YYSTYPE
*yyvsp
, int yyrule
)
743 unsigned long int yylno
= yyrline
[yyrule
];
744 int yynrhs
= yyr2
[yyrule
];
746 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
748 /* The symbols being reduced. */
749 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
751 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
752 yy_symbol_print (stderr
,
753 yystos
[yyssp
[yyi
+ 1 - yynrhs
]],
754 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
756 YYFPRINTF (stderr
, "\n");
760 # define YY_REDUCE_PRINT(Rule) \
763 yy_reduce_print (yyssp, yyvsp, Rule); \
766 /* Nonzero means print parse trace. It is left uninitialized so that
767 multiple parsers can coexist. */
770 # define YYDPRINTF(Args)
771 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
772 # define YY_STACK_PRINT(Bottom, Top)
773 # define YY_REDUCE_PRINT(Rule)
774 #endif /* !YYDEBUG */
777 /* YYINITDEPTH -- initial size of the parser's stacks. */
779 # define YYINITDEPTH 200
782 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
783 if the built-in stack extension method is used).
785 Do not make this value too large; the results are undefined if
786 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
787 evaluated with infinite-precision integer arithmetic. */
790 # define YYMAXDEPTH 10000
797 # if defined __GLIBC__ && defined _STRING_H
798 # define yystrlen strlen
800 /* Return the length of YYSTR. */
802 yystrlen (const char *yystr
)
805 for (yylen
= 0; yystr
[yylen
]; yylen
++)
813 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
814 # define yystpcpy stpcpy
816 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
819 yystpcpy (char *yydest
, const char *yysrc
)
822 const char *yys
= yysrc
;
824 while ((*yyd
++ = *yys
++) != '\0')
833 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
834 quotes and backslashes, so that it's suitable for yyerror. The
835 heuristic is that double-quoting is unnecessary unless the string
836 contains an apostrophe, a comma, or backslash (other than
837 backslash-backslash). YYSTR is taken from yytname. If YYRES is
838 null, do not copy; instead, return the length of what the result
841 yytnamerr (char *yyres
, const char *yystr
)
846 char const *yyp
= yystr
;
853 goto do_not_strip_quotes
;
857 goto do_not_strip_quotes
;
870 do_not_strip_quotes
: ;
874 return yystrlen (yystr
);
876 return yystpcpy (yyres
, yystr
) - yyres
;
880 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
881 about the unexpected token YYTOKEN for the state stack whose top is
884 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
885 not large enough to hold the message. In that case, also set
886 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
887 required number of bytes is too large to store. */
889 yysyntax_error (YYSIZE_T
*yymsg_alloc
, char **yymsg
,
890 yytype_int16
*yyssp
, int yytoken
)
892 YYSIZE_T yysize0
= yytnamerr (YY_NULLPTR
, yytname
[yytoken
]);
893 YYSIZE_T yysize
= yysize0
;
894 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
895 /* Internationalized format string. */
896 const char *yyformat
= YY_NULLPTR
;
897 /* Arguments of yyformat. */
898 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
899 /* Number of reported tokens (one for the "unexpected", one per
903 /* There are many possibilities here to consider:
904 - If this state is a consistent state with a default action, then
905 the only way this function was invoked is if the default action
906 is an error action. In that case, don't check for expected
907 tokens because there are none.
908 - The only way there can be no lookahead present (in yychar) is if
909 this state is a consistent state with a default action. Thus,
910 detecting the absence of a lookahead is sufficient to determine
911 that there is no unexpected or expected token to report. In that
912 case, just report a simple "syntax error".
913 - Don't assume there isn't a lookahead just because this state is a
914 consistent state with a default action. There might have been a
915 previous inconsistent state, consistent state with a non-default
916 action, or user semantic action that manipulated yychar.
917 - Of course, the expected token list depends on states to have
918 correct lookahead information, and it depends on the parser not
919 to perform extra reductions after fetching a lookahead from the
920 scanner and before detecting a syntax error. Thus, state merging
921 (from LALR or IELR) and default reductions corrupt the expected
922 token list. However, the list is correct for canonical LR with
923 one exception: it will still contain any token that will not be
924 accepted due to an error action in a later state.
926 if (yytoken
!= YYEMPTY
)
928 int yyn
= yypact
[*yyssp
];
929 yyarg
[yycount
++] = yytname
[yytoken
];
930 if (!yypact_value_is_default (yyn
))
932 /* Start YYX at -YYN if negative to avoid negative indexes in
933 YYCHECK. In other words, skip the first -YYN actions for
934 this state because they are default actions. */
935 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
936 /* Stay within bounds of both yycheck and yytname. */
937 int yychecklim
= YYLAST
- yyn
+ 1;
938 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
941 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
942 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
943 && !yytable_value_is_error (yytable
[yyx
+ yyn
]))
945 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
951 yyarg
[yycount
++] = yytname
[yyx
];
953 YYSIZE_T yysize1
= yysize
+ yytnamerr (YY_NULLPTR
, yytname
[yyx
]);
954 if (! (yysize
<= yysize1
955 && yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
965 # define YYCASE_(N, S) \
969 YYCASE_(0, YY_("syntax error"));
970 YYCASE_(1, YY_("syntax error, unexpected %s"));
971 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
972 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
973 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
974 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
979 YYSIZE_T yysize1
= yysize
+ yystrlen (yyformat
);
980 if (! (yysize
<= yysize1
&& yysize1
<= YYSTACK_ALLOC_MAXIMUM
))
985 if (*yymsg_alloc
< yysize
)
987 *yymsg_alloc
= 2 * yysize
;
988 if (! (yysize
<= *yymsg_alloc
989 && *yymsg_alloc
<= YYSTACK_ALLOC_MAXIMUM
))
990 *yymsg_alloc
= YYSTACK_ALLOC_MAXIMUM
;
994 /* Avoid sprintf, as that infringes on the user's name space.
995 Don't have undefined behavior even if the translation
996 produced a string with the wrong number of "%s"s. */
1000 while ((*yyp
= *yyformat
) != '\0')
1001 if (*yyp
== '%' && yyformat
[1] == 's' && yyi
< yycount
)
1003 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1014 #endif /* YYERROR_VERBOSE */
1016 /*-----------------------------------------------.
1017 | Release the memory associated to this symbol. |
1018 `-----------------------------------------------*/
1021 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
)
1026 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1028 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1030 YY_IGNORE_MAYBE_UNINITIALIZED_END
1036 /* The lookahead symbol. */
1039 /* The semantic value of the lookahead symbol. */
1041 /* Number of syntax errors so far. */
1053 /* Number of tokens to shift before error messages enabled. */
1056 /* The stacks and their tools:
1057 'yyss': related to states.
1058 'yyvs': related to semantic values.
1060 Refer to the stacks through separate pointers, to allow yyoverflow
1061 to reallocate them elsewhere. */
1063 /* The state stack. */
1064 yytype_int16 yyssa
[YYINITDEPTH
];
1066 yytype_int16
*yyssp
;
1068 /* The semantic value stack. */
1069 YYSTYPE yyvsa
[YYINITDEPTH
];
1073 YYSIZE_T yystacksize
;
1077 /* Lookahead token as an internal (translated) token number. */
1079 /* The variables used to return semantic value and location from the
1084 /* Buffer for error messages, and its allocated size. */
1086 char *yymsg
= yymsgbuf
;
1087 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1090 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1092 /* The number of symbols on the RHS of the reduced rule.
1093 Keep to zero when no symbol should be popped. */
1096 yyssp
= yyss
= yyssa
;
1097 yyvsp
= yyvs
= yyvsa
;
1098 yystacksize
= YYINITDEPTH
;
1100 YYDPRINTF ((stderr
, "Starting parse\n"));
1105 yychar
= YYEMPTY
; /* Cause a token to be read. */
1108 /*------------------------------------------------------------.
1109 | yynewstate -- Push a new state, which is found in yystate. |
1110 `------------------------------------------------------------*/
1112 /* In all cases, when you get here, the value and location stacks
1113 have just been pushed. So pushing a state here evens the stacks. */
1119 if (yyss
+ yystacksize
- 1 <= yyssp
)
1121 /* Get the current used size of the three stacks, in elements. */
1122 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1126 /* Give user a chance to reallocate the stack. Use copies of
1127 these so that the &'s don't force the real ones into
1129 YYSTYPE
*yyvs1
= yyvs
;
1130 yytype_int16
*yyss1
= yyss
;
1132 /* Each stack pointer address is followed by the size of the
1133 data in use in that stack, in bytes. This used to be a
1134 conditional around just the two extra args, but that might
1135 be undefined if yyoverflow is a macro. */
1136 yyoverflow (YY_("memory exhausted"),
1137 &yyss1
, yysize
* sizeof (*yyssp
),
1138 &yyvs1
, yysize
* sizeof (*yyvsp
),
1144 #else /* no yyoverflow */
1145 # ifndef YYSTACK_RELOCATE
1146 goto yyexhaustedlab
;
1148 /* Extend the stack our own way. */
1149 if (YYMAXDEPTH
<= yystacksize
)
1150 goto yyexhaustedlab
;
1152 if (YYMAXDEPTH
< yystacksize
)
1153 yystacksize
= YYMAXDEPTH
;
1156 yytype_int16
*yyss1
= yyss
;
1157 union yyalloc
*yyptr
=
1158 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1160 goto yyexhaustedlab
;
1161 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1162 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);
1163 # undef YYSTACK_RELOCATE
1165 YYSTACK_FREE (yyss1
);
1168 #endif /* no yyoverflow */
1170 yyssp
= yyss
+ yysize
- 1;
1171 yyvsp
= yyvs
+ yysize
- 1;
1173 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1174 (unsigned long int) yystacksize
));
1176 if (yyss
+ yystacksize
- 1 <= yyssp
)
1180 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1182 if (yystate
== YYFINAL
)
1192 /* Do appropriate processing given the current state. Read a
1193 lookahead token if we need one and don't already have one. */
1195 /* First try to decide what to do without reference to lookahead token. */
1196 yyn
= yypact
[yystate
];
1197 if (yypact_value_is_default (yyn
))
1200 /* Not known => get a lookahead token if don't already have one. */
1202 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1203 if (yychar
== YYEMPTY
)
1205 YYDPRINTF ((stderr
, "Reading a token: "));
1209 if (yychar
<= YYEOF
)
1211 yychar
= yytoken
= YYEOF
;
1212 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1216 yytoken
= YYTRANSLATE (yychar
);
1217 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1220 /* If the proper action on seeing token YYTOKEN is to reduce or to
1221 detect an error, take that action. */
1223 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1228 if (yytable_value_is_error (yyn
))
1234 /* Count tokens shifted since error; after three, turn off error
1239 /* Shift the lookahead token. */
1240 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1242 /* Discard the shifted token. */
1246 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1248 YY_IGNORE_MAYBE_UNINITIALIZED_END
1253 /*-----------------------------------------------------------.
1254 | yydefault -- do the default action for the current state. |
1255 `-----------------------------------------------------------*/
1257 yyn
= yydefact
[yystate
];
1263 /*-----------------------------.
1264 | yyreduce -- Do a reduction. |
1265 `-----------------------------*/
1267 /* yyn is the number of a rule to reduce with. */
1270 /* If YYLEN is nonzero, implement the default value of the action:
1273 Otherwise, the following line sets YYVAL to garbage.
1274 This behavior is undocumented and Bison
1275 users should not rely upon it. Assigning to YYVAL
1276 unconditionally makes the parser a bit smaller, and it avoids a
1277 GCC warning that YYVAL may be used uninitialized. */
1278 yyval
= yyvsp
[1-yylen
];
1281 YY_REDUCE_PRINT (yyn
);
1285 #line 89 "sparql_parser.y" /* yacc.c:1646 */
1287 global_sparql_parser_state
->result
= (yyvsp
[0].sval
);
1289 #line 1290 "sparql_parser.c" /* yacc.c:1646 */
1293 #line 95 "sparql_parser.y" /* yacc.c:1646 */
1296 * We can't properly handle these in expressions, fortunately this
1297 * is probably only ever used by OS X as sole element in an
1298 * expression ie "False" (when Finder window selected our share
1299 * but no search string entered yet). Packet traces showed that OS
1300 * X Spotlight server then returns a failure (ie -1) which is what
1301 * we do here too by calling YYABORT.
1305 #line 1306 "sparql_parser.c" /* yacc.c:1646 */
1309 #line 118 "sparql_parser.y" /* yacc.c:1646 */
1311 if (strcmp((yyvsp
[-2].sval
), (yyvsp
[0].sval
)) != 0) {
1312 (yyval
.sval
) = talloc_asprintf(talloc_tos(), "{ %s } UNION { %s }", (yyvsp
[-2].sval
), (yyvsp
[0].sval
));
1314 (yyval
.sval
) = talloc_asprintf(talloc_tos(), "%s", (yyvsp
[-2].sval
));
1317 #line 1318 "sparql_parser.c" /* yacc.c:1646 */
1321 #line 125 "sparql_parser.y" /* yacc.c:1646 */
1323 (yyval
.sval
) = (yyvsp
[0].sval
);
1325 #line 1326 "sparql_parser.c" /* yacc.c:1646 */
1329 #line 128 "sparql_parser.y" /* yacc.c:1646 */
1331 (yyval
.sval
) = (yyvsp
[0].sval
);
1333 #line 1334 "sparql_parser.c" /* yacc.c:1646 */
1337 #line 131 "sparql_parser.y" /* yacc.c:1646 */
1339 (yyval
.sval
) = talloc_asprintf(talloc_tos(), "%s", (yyvsp
[-1].sval
));
1341 #line 1342 "sparql_parser.c" /* yacc.c:1646 */
1345 #line 134 "sparql_parser.y" /* yacc.c:1646 */
1347 (yyval
.sval
) = talloc_asprintf(talloc_tos(), "%s . %s", (yyvsp
[-2].sval
), (yyvsp
[0].sval
));
1349 #line 1350 "sparql_parser.c" /* yacc.c:1646 */
1353 #line 137 "sparql_parser.y" /* yacc.c:1646 */
1355 if (strcmp((yyvsp
[-2].sval
), (yyvsp
[0].sval
)) != 0) {
1356 (yyval
.sval
) = talloc_asprintf(talloc_tos(), "{ %s } UNION { %s }", (yyvsp
[-2].sval
), (yyvsp
[0].sval
));
1358 (yyval
.sval
) = talloc_asprintf(talloc_tos(), "%s", (yyvsp
[-2].sval
));
1361 #line 1362 "sparql_parser.c" /* yacc.c:1646 */
1365 #line 147 "sparql_parser.y" /* yacc.c:1646 */
1367 (yyval
.sval
) = map_expr((yyvsp
[-4].sval
), '=', (yyvsp
[-1].sval
));
1368 if ((yyval
.sval
) == NULL
) YYABORT
;
1370 #line 1371 "sparql_parser.c" /* yacc.c:1646 */
1374 #line 151 "sparql_parser.y" /* yacc.c:1646 */
1376 (yyval
.sval
) = map_expr((yyvsp
[-4].sval
), '!', (yyvsp
[-1].sval
));
1377 if ((yyval
.sval
) == NULL
) YYABORT
;
1379 #line 1380 "sparql_parser.c" /* yacc.c:1646 */
1383 #line 155 "sparql_parser.y" /* yacc.c:1646 */
1385 (yyval
.sval
) = map_expr((yyvsp
[-4].sval
), '<', (yyvsp
[-1].sval
));
1386 if ((yyval
.sval
) == NULL
) YYABORT
;
1388 #line 1389 "sparql_parser.c" /* yacc.c:1646 */
1392 #line 159 "sparql_parser.y" /* yacc.c:1646 */
1394 (yyval
.sval
) = map_expr((yyvsp
[-4].sval
), '>', (yyvsp
[-1].sval
));
1395 if ((yyval
.sval
) == NULL
) YYABORT
;
1397 #line 1398 "sparql_parser.c" /* yacc.c:1646 */
1401 #line 163 "sparql_parser.y" /* yacc.c:1646 */
1403 (yyval
.sval
) = map_expr((yyvsp
[-5].sval
), '=', (yyvsp
[-2].sval
));
1404 if ((yyval
.sval
) == NULL
) YYABORT
;
1406 #line 1407 "sparql_parser.c" /* yacc.c:1646 */
1410 #line 167 "sparql_parser.y" /* yacc.c:1646 */
1412 (yyval
.sval
) = map_expr((yyvsp
[-5].sval
), '!', (yyvsp
[-2].sval
));
1413 if ((yyval
.sval
) == NULL
) YYABORT
;
1415 #line 1416 "sparql_parser.c" /* yacc.c:1646 */
1419 #line 171 "sparql_parser.y" /* yacc.c:1646 */
1421 (yyval
.sval
) = map_expr((yyvsp
[-5].sval
), '<', (yyvsp
[-2].sval
));
1422 if ((yyval
.sval
) == NULL
) YYABORT
;
1424 #line 1425 "sparql_parser.c" /* yacc.c:1646 */
1428 #line 175 "sparql_parser.y" /* yacc.c:1646 */
1430 (yyval
.sval
) = map_expr((yyvsp
[-5].sval
), '>', (yyvsp
[-2].sval
));
1431 if ((yyval
.sval
) == NULL
) YYABORT
;
1433 #line 1434 "sparql_parser.c" /* yacc.c:1646 */
1437 #line 182 "sparql_parser.y" /* yacc.c:1646 */
1439 (yyval
.sval
) = map_daterange((yyvsp
[-5].sval
), (yyvsp
[-3].tval
), (yyvsp
[-1].tval
));
1440 if ((yyval
.sval
) == NULL
) YYABORT
;
1442 #line 1443 "sparql_parser.c" /* yacc.c:1646 */
1446 #line 189 "sparql_parser.y" /* yacc.c:1646 */
1447 {(yyval
.tval
) = isodate2unix((yyvsp
[-1].sval
));}
1448 #line 1449 "sparql_parser.c" /* yacc.c:1646 */
1452 #line 190 "sparql_parser.y" /* yacc.c:1646 */
1453 {(yyval
.tval
) = atoi((yyvsp
[0].sval
)) + SPRAW_TIME_OFFSET
;}
1454 #line 1455 "sparql_parser.c" /* yacc.c:1646 */
1458 #line 1459 "sparql_parser.c" /* yacc.c:1646 */
1461 /* User semantic actions sometimes alter yychar, and that requires
1462 that yytoken be updated with the new translation. We take the
1463 approach of translating immediately before every use of yytoken.
1464 One alternative is translating here after every semantic action,
1465 but that translation would be missed if the semantic action invokes
1466 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1467 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1468 incorrect destructor might then be invoked immediately. In the
1469 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1470 to an incorrect destructor call or verbose syntax error message
1471 before the lookahead is translated. */
1472 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1476 YY_STACK_PRINT (yyss
, yyssp
);
1480 /* Now 'shift' the result of the reduction. Determine what state
1481 that goes to, based on the state we popped back to and the rule
1482 number reduced by. */
1486 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1487 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1488 yystate
= yytable
[yystate
];
1490 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1495 /*--------------------------------------.
1496 | yyerrlab -- here on detecting error. |
1497 `--------------------------------------*/
1499 /* Make sure we have latest lookahead translation. See comments at
1500 user semantic actions for why this is necessary. */
1501 yytoken
= yychar
== YYEMPTY
? YYEMPTY
: YYTRANSLATE (yychar
);
1503 /* If not already recovering from an error, report this error. */
1507 #if ! YYERROR_VERBOSE
1508 yyerror (YY_("syntax error"));
1510 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1513 char const *yymsgp
= YY_("syntax error");
1514 int yysyntax_error_status
;
1515 yysyntax_error_status
= YYSYNTAX_ERROR
;
1516 if (yysyntax_error_status
== 0)
1518 else if (yysyntax_error_status
== 1)
1520 if (yymsg
!= yymsgbuf
)
1521 YYSTACK_FREE (yymsg
);
1522 yymsg
= (char *) YYSTACK_ALLOC (yymsg_alloc
);
1526 yymsg_alloc
= sizeof yymsgbuf
;
1527 yysyntax_error_status
= 2;
1531 yysyntax_error_status
= YYSYNTAX_ERROR
;
1536 if (yysyntax_error_status
== 2)
1537 goto yyexhaustedlab
;
1539 # undef YYSYNTAX_ERROR
1545 if (yyerrstatus
== 3)
1547 /* If just tried and failed to reuse lookahead token after an
1548 error, discard it. */
1550 if (yychar
<= YYEOF
)
1552 /* Return failure if at end of input. */
1553 if (yychar
== YYEOF
)
1558 yydestruct ("Error: discarding",
1564 /* Else will try to reuse lookahead token after shifting the error
1569 /*---------------------------------------------------.
1570 | yyerrorlab -- error raised explicitly by YYERROR. |
1571 `---------------------------------------------------*/
1574 /* Pacify compilers like GCC when the user code never invokes
1575 YYERROR and the label yyerrorlab therefore never appears in user
1577 if (/*CONSTCOND*/ 0)
1580 /* Do not reclaim the symbols of the rule whose action triggered
1584 YY_STACK_PRINT (yyss
, yyssp
);
1589 /*-------------------------------------------------------------.
1590 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1591 `-------------------------------------------------------------*/
1593 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1597 yyn
= yypact
[yystate
];
1598 if (!yypact_value_is_default (yyn
))
1601 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1609 /* Pop the current state because it cannot handle the error token. */
1614 yydestruct ("Error: popping",
1615 yystos
[yystate
], yyvsp
);
1618 YY_STACK_PRINT (yyss
, yyssp
);
1621 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1623 YY_IGNORE_MAYBE_UNINITIALIZED_END
1626 /* Shift the error token. */
1627 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1633 /*-------------------------------------.
1634 | yyacceptlab -- YYACCEPT comes here. |
1635 `-------------------------------------*/
1640 /*-----------------------------------.
1641 | yyabortlab -- YYABORT comes here. |
1642 `-----------------------------------*/
1647 #if !defined yyoverflow || YYERROR_VERBOSE
1648 /*-------------------------------------------------.
1649 | yyexhaustedlab -- memory exhaustion comes here. |
1650 `-------------------------------------------------*/
1652 yyerror (YY_("memory exhausted"));
1658 if (yychar
!= YYEMPTY
)
1660 /* Make sure we have latest lookahead translation. See comments at
1661 user semantic actions for why this is necessary. */
1662 yytoken
= YYTRANSLATE (yychar
);
1663 yydestruct ("Cleanup: discarding lookahead",
1666 /* Do not reclaim the symbols of the rule whose action triggered
1667 this YYABORT or YYACCEPT. */
1669 YY_STACK_PRINT (yyss
, yyssp
);
1670 while (yyssp
!= yyss
)
1672 yydestruct ("Cleanup: popping",
1673 yystos
[*yyssp
], yyvsp
);
1678 YYSTACK_FREE (yyss
);
1681 if (yymsg
!= yymsgbuf
)
1682 YYSTACK_FREE (yymsg
);
1686 #line 193 "sparql_parser.y" /* yacc.c:1906 */
1689 static time_t isodate2unix(const char *s
)
1694 p
= strptime(s
, "%Y-%m-%dT%H:%M:%SZ", &tm
);
1701 static const char *map_daterange(const char *dateattr
,
1702 time_t date1
, time_t date2
)
1704 struct sparql_parser_state
*s
= global_sparql_parser_state
;
1706 char *sparql
= NULL
;
1707 const struct sl_attr_map
*p
;
1709 char buf1
[64], buf2
[64];
1711 if (s
->var
== 'z') {
1715 tmp
= localtime(&date1
);
1719 result
= strftime(buf1
, sizeof(buf1
), "%Y-%m-%dT%H:%M:%SZ", tmp
);
1724 tmp
= localtime(&date2
);
1728 result
= strftime(buf2
, sizeof(buf2
), "%Y-%m-%dT%H:%M:%SZ", tmp
);
1733 p
= sl_attr_map_by_spotlight(dateattr
);
1738 sparql
= talloc_asprintf(talloc_tos(),
1739 "?obj %s ?%c FILTER (?%c > '%s' && ?%c < '%s')",
1746 if (sparql
== NULL
) {
1754 static char *map_type_search(const char *attr
, char op
, const char *val
)
1756 char *result
= NULL
;
1757 const char *sparqlAttr
;
1758 const struct sl_type_map
*p
;
1760 p
= sl_type_map_by_spotlight(val
);
1767 sparqlAttr
= "rdf:type";
1769 case kMDTypeMapMime
:
1770 sparqlAttr
= "nie:mimeType";
1776 result
= talloc_asprintf(talloc_tos(), "?obj %s '%s'",
1779 if (result
== NULL
) {
1786 static const char *map_expr(const char *attr
, char op
, const char *val
)
1788 struct sparql_parser_state
*s
= global_sparql_parser_state
;
1790 char *sparql
= NULL
;
1791 const struct sl_attr_map
*p
;
1798 if (s
->var
== 'z') {
1802 p
= sl_attr_map_by_spotlight(attr
);
1807 if ((p
->type
!= ssmt_type
) && (p
->sparql_attr
== NULL
)) {
1808 yyerror("unsupported Spotlight attribute");
1814 sparql
= talloc_asprintf(talloc_tos(), "?obj %s '%s'",
1815 p
->sparql_attr
, val
);
1816 if (sparql
== NULL
) {
1822 sparql
= talloc_asprintf(talloc_tos(),
1823 "?obj %s ?%c FILTER(?%c %c%c '%s')",
1828 /* append '=' to '!' */
1829 op
== '!' ? '=' : ' ',
1831 if (sparql
== NULL
) {
1838 q
= talloc_strdup(talloc_tos(), "");
1849 q
= talloc_strndup_append(q
, start
, val
- start
);
1854 q
= talloc_strdup_append(q
, ".*");
1862 q
= talloc_strndup_append(q
, start
, val
- start
);
1867 sparql
= talloc_asprintf(talloc_tos(),
1869 "FILTER(regex(?%c, '^%s$', 'i'))",
1875 if (sparql
== NULL
) {
1882 sparql
= talloc_asprintf(talloc_tos(), "?obj %s '%s'",
1883 p
->sparql_attr
, val
);
1884 if (sparql
== NULL
) {
1890 t
= atoi(val
) + SPRAW_TIME_OFFSET
;
1891 tmp
= localtime(&t
);
1895 result
= strftime(buf1
, sizeof(buf1
),
1896 "%Y-%m-%dT%H:%M:%SZ", tmp
);
1900 sparql
= talloc_asprintf(talloc_tos(),
1901 "?obj %s ?%c FILTER(?%c %c '%s')",
1907 if (sparql
== NULL
) {
1914 sparql
= map_type_search(attr
, op
, val
);
1915 if (sparql
== NULL
) {
1927 void yyerror(const char *str
)
1929 DEBUG(1, ("yyerror: %s\n", str
));
1938 * Map a Spotlight RAW query string to a SPARQL query string
1940 bool map_spotlight_to_sparql_query(struct sl_query
*slq
)
1942 struct sparql_parser_state s
= {
1943 .frame
= talloc_stackframe(),
1948 s
.s
= yy_scan_string(slq
->query_string
);
1950 TALLOC_FREE(s
.frame
);
1953 global_sparql_parser_state
= &s
;
1955 global_sparql_parser_state
= NULL
;
1956 yy_delete_buffer(s
.s
);
1959 TALLOC_FREE(s
.frame
);
1963 slq
->sparql_query
= talloc_asprintf(slq
,
1964 "SELECT ?url WHERE { %s . ?obj nie:url ?url . "
1965 "FILTER(tracker:uri-is-descendant('file://%s/', ?url)) }",
1966 s
.result
, slq
->path_scope
);
1967 TALLOC_FREE(s
.frame
);
1968 if (slq
->sparql_query
== NULL
) {