Line data Source code
1 : /* A Bison parser, made by GNU Bison 3.7.5. */
2 :
3 : /* Bison implementation for Yacc-like parsers in C
4 :
5 : Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6 : Inc.
7 :
8 : This program is free software: you can redistribute it and/or modify
9 : it under the terms of the GNU General Public License as published by
10 : the Free Software Foundation, either version 3 of the License, or
11 : (at your option) any later version.
12 :
13 : This program is distributed in the hope that it will be useful,
14 : but WITHOUT ANY WARRANTY; without even the implied warranty of
15 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 : GNU General Public License for more details.
17 :
18 : You should have received a copy of the GNU General Public License
19 : along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 :
21 : /* As a special exception, you may create a larger work that contains
22 : part or all of the Bison parser skeleton and distribute that work
23 : under terms of your choice, so long as that work isn't itself a
24 : parser generator using the skeleton or a modified version thereof
25 : as a parser skeleton. Alternatively, if you modify or redistribute
26 : the parser skeleton itself, you may (at your option) remove this
27 : special exception, which will cause the skeleton and the resulting
28 : Bison output files to be licensed under the GNU General Public
29 : License without this special exception.
30 :
31 : This special exception was added by the Free Software Foundation in
32 : version 2.2 of Bison. */
33 :
34 : /* C LALR(1) parser skeleton written by Richard Stallman, by
35 : simplifying the original so-called "semantic" parser. */
36 :
37 : /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 : especially those whose name start with YY_ or yy_. They are
39 : private implementation details that can be changed or removed. */
40 :
41 : /* All symbols defined below should begin with yy or YY, to avoid
42 : infringing on user name space. This should be done even for local
43 : variables, as they might otherwise be expanded by user macros.
44 : There are some unavoidable exceptions within include files to
45 : define necessary library symbols; they are noted "INFRINGES ON
46 : USER NAME SPACE" below. */
47 :
48 : /* Identify Bison output, and Bison version. */
49 : #define YYBISON 30705
50 :
51 : /* Bison version string. */
52 : #define YYBISON_VERSION "3.7.5"
53 :
54 : /* Skeleton name. */
55 : #define YYSKELETON_NAME "yacc.c"
56 :
57 : /* Pure parsers. */
58 : #define YYPURE 1
59 :
60 : /* Push parsers. */
61 : #define YYPUSH 0
62 :
63 : /* Pull parsers. */
64 : #define YYPULL 1
65 :
66 :
67 : /* Substitute the variable and function names. */
68 : #define yyparse jsonpath_yyparse
69 : #define yylex jsonpath_yylex
70 : #define yyerror jsonpath_yyerror
71 : #define yydebug jsonpath_yydebug
72 : #define yynerrs jsonpath_yynerrs
73 :
74 : /* First part of user prologue. */
75 : #line 1 "jsonpath_gram.y"
76 :
77 : /*-------------------------------------------------------------------------
78 : *
79 : * jsonpath_gram.y
80 : * Grammar definitions for jsonpath datatype
81 : *
82 : * Transforms tokenized jsonpath into tree of JsonPathParseItem structs.
83 : *
84 : * Copyright (c) 2019-2025, PostgreSQL Global Development Group
85 : *
86 : * IDENTIFICATION
87 : * src/backend/utils/adt/jsonpath_gram.y
88 : *
89 : *-------------------------------------------------------------------------
90 : */
91 :
92 : #include "postgres.h"
93 :
94 : #include "catalog/pg_collation.h"
95 : #include "fmgr.h"
96 : #include "jsonpath_internal.h"
97 : #include "miscadmin.h"
98 : #include "nodes/pg_list.h"
99 : #include "regex/regex.h"
100 : #include "utils/builtins.h"
101 :
102 : static JsonPathParseItem *makeItemType(JsonPathItemType type);
103 : static JsonPathParseItem *makeItemString(JsonPathString *s);
104 : static JsonPathParseItem *makeItemVariable(JsonPathString *s);
105 : static JsonPathParseItem *makeItemKey(JsonPathString *s);
106 : static JsonPathParseItem *makeItemNumeric(JsonPathString *s);
107 : static JsonPathParseItem *makeItemBool(bool val);
108 : static JsonPathParseItem *makeItemBinary(JsonPathItemType type,
109 : JsonPathParseItem *la,
110 : JsonPathParseItem *ra);
111 : static JsonPathParseItem *makeItemUnary(JsonPathItemType type,
112 : JsonPathParseItem *a);
113 : static JsonPathParseItem *makeItemList(List *list);
114 : static JsonPathParseItem *makeIndexArray(List *list);
115 : static JsonPathParseItem *makeAny(int first, int last);
116 : static bool makeItemLikeRegex(JsonPathParseItem *expr,
117 : JsonPathString *pattern,
118 : JsonPathString *flags,
119 : JsonPathParseItem ** result,
120 : struct Node *escontext);
121 :
122 : /*
123 : * Bison doesn't allocate anything that needs to live across parser calls,
124 : * so we can easily have it use palloc instead of malloc. This prevents
125 : * memory leaks if we error out during parsing.
126 : */
127 : #define YYMALLOC palloc
128 : #define YYFREE pfree
129 :
130 :
131 : #line 132 "jsonpath_gram.c"
132 :
133 : # ifndef YY_CAST
134 : # ifdef __cplusplus
135 : # define YY_CAST(Type, Val) static_cast<Type> (Val)
136 : # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
137 : # else
138 : # define YY_CAST(Type, Val) ((Type) (Val))
139 : # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
140 : # endif
141 : # endif
142 : # ifndef YY_NULLPTR
143 : # if defined __cplusplus
144 : # if 201103L <= __cplusplus
145 : # define YY_NULLPTR nullptr
146 : # else
147 : # define YY_NULLPTR 0
148 : # endif
149 : # else
150 : # define YY_NULLPTR ((void*)0)
151 : # endif
152 : # endif
153 :
154 : #include "jsonpath_gram.h"
155 : /* Symbol kind. */
156 : enum yysymbol_kind_t
157 : {
158 : YYSYMBOL_YYEMPTY = -2,
159 : YYSYMBOL_YYEOF = 0, /* "end of file" */
160 : YYSYMBOL_YYerror = 1, /* error */
161 : YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
162 : YYSYMBOL_TO_P = 3, /* TO_P */
163 : YYSYMBOL_NULL_P = 4, /* NULL_P */
164 : YYSYMBOL_TRUE_P = 5, /* TRUE_P */
165 : YYSYMBOL_FALSE_P = 6, /* FALSE_P */
166 : YYSYMBOL_IS_P = 7, /* IS_P */
167 : YYSYMBOL_UNKNOWN_P = 8, /* UNKNOWN_P */
168 : YYSYMBOL_EXISTS_P = 9, /* EXISTS_P */
169 : YYSYMBOL_IDENT_P = 10, /* IDENT_P */
170 : YYSYMBOL_STRING_P = 11, /* STRING_P */
171 : YYSYMBOL_NUMERIC_P = 12, /* NUMERIC_P */
172 : YYSYMBOL_INT_P = 13, /* INT_P */
173 : YYSYMBOL_VARIABLE_P = 14, /* VARIABLE_P */
174 : YYSYMBOL_OR_P = 15, /* OR_P */
175 : YYSYMBOL_AND_P = 16, /* AND_P */
176 : YYSYMBOL_NOT_P = 17, /* NOT_P */
177 : YYSYMBOL_LESS_P = 18, /* LESS_P */
178 : YYSYMBOL_LESSEQUAL_P = 19, /* LESSEQUAL_P */
179 : YYSYMBOL_EQUAL_P = 20, /* EQUAL_P */
180 : YYSYMBOL_NOTEQUAL_P = 21, /* NOTEQUAL_P */
181 : YYSYMBOL_GREATEREQUAL_P = 22, /* GREATEREQUAL_P */
182 : YYSYMBOL_GREATER_P = 23, /* GREATER_P */
183 : YYSYMBOL_ANY_P = 24, /* ANY_P */
184 : YYSYMBOL_STRICT_P = 25, /* STRICT_P */
185 : YYSYMBOL_LAX_P = 26, /* LAX_P */
186 : YYSYMBOL_LAST_P = 27, /* LAST_P */
187 : YYSYMBOL_STARTS_P = 28, /* STARTS_P */
188 : YYSYMBOL_WITH_P = 29, /* WITH_P */
189 : YYSYMBOL_LIKE_REGEX_P = 30, /* LIKE_REGEX_P */
190 : YYSYMBOL_FLAG_P = 31, /* FLAG_P */
191 : YYSYMBOL_ABS_P = 32, /* ABS_P */
192 : YYSYMBOL_SIZE_P = 33, /* SIZE_P */
193 : YYSYMBOL_TYPE_P = 34, /* TYPE_P */
194 : YYSYMBOL_FLOOR_P = 35, /* FLOOR_P */
195 : YYSYMBOL_DOUBLE_P = 36, /* DOUBLE_P */
196 : YYSYMBOL_CEILING_P = 37, /* CEILING_P */
197 : YYSYMBOL_KEYVALUE_P = 38, /* KEYVALUE_P */
198 : YYSYMBOL_DATETIME_P = 39, /* DATETIME_P */
199 : YYSYMBOL_BIGINT_P = 40, /* BIGINT_P */
200 : YYSYMBOL_BOOLEAN_P = 41, /* BOOLEAN_P */
201 : YYSYMBOL_DATE_P = 42, /* DATE_P */
202 : YYSYMBOL_DECIMAL_P = 43, /* DECIMAL_P */
203 : YYSYMBOL_INTEGER_P = 44, /* INTEGER_P */
204 : YYSYMBOL_NUMBER_P = 45, /* NUMBER_P */
205 : YYSYMBOL_STRINGFUNC_P = 46, /* STRINGFUNC_P */
206 : YYSYMBOL_TIME_P = 47, /* TIME_P */
207 : YYSYMBOL_TIME_TZ_P = 48, /* TIME_TZ_P */
208 : YYSYMBOL_TIMESTAMP_P = 49, /* TIMESTAMP_P */
209 : YYSYMBOL_TIMESTAMP_TZ_P = 50, /* TIMESTAMP_TZ_P */
210 : YYSYMBOL_51_ = 51, /* '+' */
211 : YYSYMBOL_52_ = 52, /* '-' */
212 : YYSYMBOL_53_ = 53, /* '*' */
213 : YYSYMBOL_54_ = 54, /* '/' */
214 : YYSYMBOL_55_ = 55, /* '%' */
215 : YYSYMBOL_UMINUS = 56, /* UMINUS */
216 : YYSYMBOL_57_ = 57, /* '(' */
217 : YYSYMBOL_58_ = 58, /* ')' */
218 : YYSYMBOL_59_ = 59, /* '$' */
219 : YYSYMBOL_60_ = 60, /* '@' */
220 : YYSYMBOL_61_ = 61, /* ',' */
221 : YYSYMBOL_62_ = 62, /* '[' */
222 : YYSYMBOL_63_ = 63, /* ']' */
223 : YYSYMBOL_64_ = 64, /* '{' */
224 : YYSYMBOL_65_ = 65, /* '}' */
225 : YYSYMBOL_66_ = 66, /* '.' */
226 : YYSYMBOL_67_ = 67, /* '?' */
227 : YYSYMBOL_YYACCEPT = 68, /* $accept */
228 : YYSYMBOL_result = 69, /* result */
229 : YYSYMBOL_expr_or_predicate = 70, /* expr_or_predicate */
230 : YYSYMBOL_mode = 71, /* mode */
231 : YYSYMBOL_scalar_value = 72, /* scalar_value */
232 : YYSYMBOL_comp_op = 73, /* comp_op */
233 : YYSYMBOL_delimited_predicate = 74, /* delimited_predicate */
234 : YYSYMBOL_predicate = 75, /* predicate */
235 : YYSYMBOL_starts_with_initial = 76, /* starts_with_initial */
236 : YYSYMBOL_path_primary = 77, /* path_primary */
237 : YYSYMBOL_accessor_expr = 78, /* accessor_expr */
238 : YYSYMBOL_expr = 79, /* expr */
239 : YYSYMBOL_index_elem = 80, /* index_elem */
240 : YYSYMBOL_index_list = 81, /* index_list */
241 : YYSYMBOL_array_accessor = 82, /* array_accessor */
242 : YYSYMBOL_any_level = 83, /* any_level */
243 : YYSYMBOL_any_path = 84, /* any_path */
244 : YYSYMBOL_accessor_op = 85, /* accessor_op */
245 : YYSYMBOL_csv_elem = 86, /* csv_elem */
246 : YYSYMBOL_csv_list = 87, /* csv_list */
247 : YYSYMBOL_opt_csv_list = 88, /* opt_csv_list */
248 : YYSYMBOL_datetime_precision = 89, /* datetime_precision */
249 : YYSYMBOL_opt_datetime_precision = 90, /* opt_datetime_precision */
250 : YYSYMBOL_datetime_template = 91, /* datetime_template */
251 : YYSYMBOL_opt_datetime_template = 92, /* opt_datetime_template */
252 : YYSYMBOL_key = 93, /* key */
253 : YYSYMBOL_key_name = 94, /* key_name */
254 : YYSYMBOL_method = 95 /* method */
255 : };
256 : typedef enum yysymbol_kind_t yysymbol_kind_t;
257 :
258 :
259 :
260 :
261 : #ifdef short
262 : # undef short
263 : #endif
264 :
265 : /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
266 : <limits.h> and (if available) <stdint.h> are included
267 : so that the code can choose integer types of a good width. */
268 :
269 : #ifndef __PTRDIFF_MAX__
270 : # include <limits.h> /* INFRINGES ON USER NAME SPACE */
271 : # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
272 : # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
273 : # define YY_STDINT_H
274 : # endif
275 : #endif
276 :
277 : /* Narrow types that promote to a signed type and that can represent a
278 : signed or unsigned integer of at least N bits. In tables they can
279 : save space and decrease cache pressure. Promoting to a signed type
280 : helps avoid bugs in integer arithmetic. */
281 :
282 : #ifdef __INT_LEAST8_MAX__
283 : typedef __INT_LEAST8_TYPE__ yytype_int8;
284 : #elif defined YY_STDINT_H
285 : typedef int_least8_t yytype_int8;
286 : #else
287 : typedef signed char yytype_int8;
288 : #endif
289 :
290 : #ifdef __INT_LEAST16_MAX__
291 : typedef __INT_LEAST16_TYPE__ yytype_int16;
292 : #elif defined YY_STDINT_H
293 : typedef int_least16_t yytype_int16;
294 : #else
295 : typedef short yytype_int16;
296 : #endif
297 :
298 : /* Work around bug in HP-UX 11.23, which defines these macros
299 : incorrectly for preprocessor constants. This workaround can likely
300 : be removed in 2023, as HPE has promised support for HP-UX 11.23
301 : (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
302 : <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
303 : #ifdef __hpux
304 : # undef UINT_LEAST8_MAX
305 : # undef UINT_LEAST16_MAX
306 : # define UINT_LEAST8_MAX 255
307 : # define UINT_LEAST16_MAX 65535
308 : #endif
309 :
310 : #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
311 : typedef __UINT_LEAST8_TYPE__ yytype_uint8;
312 : #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
313 : && UINT_LEAST8_MAX <= INT_MAX)
314 : typedef uint_least8_t yytype_uint8;
315 : #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
316 : typedef unsigned char yytype_uint8;
317 : #else
318 : typedef short yytype_uint8;
319 : #endif
320 :
321 : #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
322 : typedef __UINT_LEAST16_TYPE__ yytype_uint16;
323 : #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
324 : && UINT_LEAST16_MAX <= INT_MAX)
325 : typedef uint_least16_t yytype_uint16;
326 : #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
327 : typedef unsigned short yytype_uint16;
328 : #else
329 : typedef int yytype_uint16;
330 : #endif
331 :
332 : #ifndef YYPTRDIFF_T
333 : # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
334 : # define YYPTRDIFF_T __PTRDIFF_TYPE__
335 : # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
336 : # elif defined PTRDIFF_MAX
337 : # ifndef ptrdiff_t
338 : # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
339 : # endif
340 : # define YYPTRDIFF_T ptrdiff_t
341 : # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
342 : # else
343 : # define YYPTRDIFF_T long
344 : # define YYPTRDIFF_MAXIMUM LONG_MAX
345 : # endif
346 : #endif
347 :
348 : #ifndef YYSIZE_T
349 : # ifdef __SIZE_TYPE__
350 : # define YYSIZE_T __SIZE_TYPE__
351 : # elif defined size_t
352 : # define YYSIZE_T size_t
353 : # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
354 : # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
355 : # define YYSIZE_T size_t
356 : # else
357 : # define YYSIZE_T unsigned
358 : # endif
359 : #endif
360 :
361 : #define YYSIZE_MAXIMUM \
362 : YY_CAST (YYPTRDIFF_T, \
363 : (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
364 : ? YYPTRDIFF_MAXIMUM \
365 : : YY_CAST (YYSIZE_T, -1)))
366 :
367 : #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
368 :
369 :
370 : /* Stored state numbers (used for stacks). */
371 : typedef yytype_uint8 yy_state_t;
372 :
373 : /* State numbers in computations. */
374 : typedef int yy_state_fast_t;
375 :
376 : #ifndef YY_
377 : # if defined YYENABLE_NLS && YYENABLE_NLS
378 : # if ENABLE_NLS
379 : # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
380 : # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
381 : # endif
382 : # endif
383 : # ifndef YY_
384 : # define YY_(Msgid) Msgid
385 : # endif
386 : #endif
387 :
388 :
389 : #ifndef YY_ATTRIBUTE_PURE
390 : # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
391 : # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
392 : # else
393 : # define YY_ATTRIBUTE_PURE
394 : # endif
395 : #endif
396 :
397 : #ifndef YY_ATTRIBUTE_UNUSED
398 : # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
399 : # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
400 : # else
401 : # define YY_ATTRIBUTE_UNUSED
402 : # endif
403 : #endif
404 :
405 : /* Suppress unused-variable warnings by "using" E. */
406 : #if ! defined lint || defined __GNUC__
407 : # define YY_USE(E) ((void) (E))
408 : #else
409 : # define YY_USE(E) /* empty */
410 : #endif
411 :
412 : #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
413 : /* Suppress an incorrect diagnostic about yylval being uninitialized. */
414 : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
415 : _Pragma ("GCC diagnostic push") \
416 : _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
417 : _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
418 : # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
419 : _Pragma ("GCC diagnostic pop")
420 : #else
421 : # define YY_INITIAL_VALUE(Value) Value
422 : #endif
423 : #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
424 : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
425 : # define YY_IGNORE_MAYBE_UNINITIALIZED_END
426 : #endif
427 : #ifndef YY_INITIAL_VALUE
428 : # define YY_INITIAL_VALUE(Value) /* Nothing. */
429 : #endif
430 :
431 : #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
432 : # define YY_IGNORE_USELESS_CAST_BEGIN \
433 : _Pragma ("GCC diagnostic push") \
434 : _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
435 : # define YY_IGNORE_USELESS_CAST_END \
436 : _Pragma ("GCC diagnostic pop")
437 : #endif
438 : #ifndef YY_IGNORE_USELESS_CAST_BEGIN
439 : # define YY_IGNORE_USELESS_CAST_BEGIN
440 : # define YY_IGNORE_USELESS_CAST_END
441 : #endif
442 :
443 :
444 : #define YY_ASSERT(E) ((void) (0 && (E)))
445 :
446 : #if !defined yyoverflow
447 :
448 : /* The parser invokes alloca or malloc; define the necessary symbols. */
449 :
450 : # ifdef YYSTACK_USE_ALLOCA
451 : # if YYSTACK_USE_ALLOCA
452 : # ifdef __GNUC__
453 : # define YYSTACK_ALLOC __builtin_alloca
454 : # elif defined __BUILTIN_VA_ARG_INCR
455 : # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
456 : # elif defined _AIX
457 : # define YYSTACK_ALLOC __alloca
458 : # elif defined _MSC_VER
459 : # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
460 : # define alloca _alloca
461 : # else
462 : # define YYSTACK_ALLOC alloca
463 : # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
464 : # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
465 : /* Use EXIT_SUCCESS as a witness for stdlib.h. */
466 : # ifndef EXIT_SUCCESS
467 : # define EXIT_SUCCESS 0
468 : # endif
469 : # endif
470 : # endif
471 : # endif
472 : # endif
473 :
474 : # ifdef YYSTACK_ALLOC
475 : /* Pacify GCC's 'empty if-body' warning. */
476 : # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
477 : # ifndef YYSTACK_ALLOC_MAXIMUM
478 : /* The OS might guarantee only one guard page at the bottom of the stack,
479 : and a page size can be as small as 4096 bytes. So we cannot safely
480 : invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
481 : to allow for a few compiler-allocated temporary stack slots. */
482 : # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
483 : # endif
484 : # else
485 : # define YYSTACK_ALLOC YYMALLOC
486 : # define YYSTACK_FREE YYFREE
487 : # ifndef YYSTACK_ALLOC_MAXIMUM
488 : # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
489 : # endif
490 : # if (defined __cplusplus && ! defined EXIT_SUCCESS \
491 : && ! ((defined YYMALLOC || defined malloc) \
492 : && (defined YYFREE || defined free)))
493 : # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
494 : # ifndef EXIT_SUCCESS
495 : # define EXIT_SUCCESS 0
496 : # endif
497 : # endif
498 : # ifndef YYMALLOC
499 : # define YYMALLOC malloc
500 : # if ! defined malloc && ! defined EXIT_SUCCESS
501 : void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
502 : # endif
503 : # endif
504 : # ifndef YYFREE
505 : # define YYFREE free
506 : # if ! defined free && ! defined EXIT_SUCCESS
507 : void free (void *); /* INFRINGES ON USER NAME SPACE */
508 : # endif
509 : # endif
510 : # endif
511 : #endif /* !defined yyoverflow */
512 :
513 : #if (! defined yyoverflow \
514 : && (! defined __cplusplus \
515 : || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
516 :
517 : /* A type that is properly aligned for any stack member. */
518 : union yyalloc
519 : {
520 : yy_state_t yyss_alloc;
521 : YYSTYPE yyvs_alloc;
522 : };
523 :
524 : /* The size of the maximum gap between one aligned stack and the next. */
525 : # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
526 :
527 : /* The size of an array large to enough to hold all stacks, each with
528 : N elements. */
529 : # define YYSTACK_BYTES(N) \
530 : ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
531 : + YYSTACK_GAP_MAXIMUM)
532 :
533 : # define YYCOPY_NEEDED 1
534 :
535 : /* Relocate STACK from its old location to the new one. The
536 : local variables YYSIZE and YYSTACKSIZE give the old and new number of
537 : elements in the stack, and YYPTR gives the new location of the
538 : stack. Advance YYPTR to a properly aligned location for the next
539 : stack. */
540 : # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
541 : do \
542 : { \
543 : YYPTRDIFF_T yynewbytes; \
544 : YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
545 : Stack = &yyptr->Stack_alloc; \
546 : yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
547 : yyptr += yynewbytes / YYSIZEOF (*yyptr); \
548 : } \
549 : while (0)
550 :
551 : #endif
552 :
553 : #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
554 : /* Copy COUNT objects from SRC to DST. The source and destination do
555 : not overlap. */
556 : # ifndef YYCOPY
557 : # if defined __GNUC__ && 1 < __GNUC__
558 : # define YYCOPY(Dst, Src, Count) \
559 : __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
560 : # else
561 : # define YYCOPY(Dst, Src, Count) \
562 : do \
563 : { \
564 : YYPTRDIFF_T yyi; \
565 : for (yyi = 0; yyi < (Count); yyi++) \
566 : (Dst)[yyi] = (Src)[yyi]; \
567 : } \
568 : while (0)
569 : # endif
570 : # endif
571 : #endif /* !YYCOPY_NEEDED */
572 :
573 : /* YYFINAL -- State number of the termination state. */
574 : #define YYFINAL 5
575 : /* YYLAST -- Last index in YYTABLE. */
576 : #define YYLAST 239
577 :
578 : /* YYNTOKENS -- Number of terminals. */
579 : #define YYNTOKENS 68
580 : /* YYNNTS -- Number of nonterminals. */
581 : #define YYNNTS 28
582 : /* YYNRULES -- Number of rules. */
583 : #define YYNRULES 136
584 : /* YYNSTATES -- Number of states. */
585 : #define YYNSTATES 180
586 :
587 : /* YYMAXUTOK -- Last valid token kind. */
588 : #define YYMAXUTOK 306
589 :
590 :
591 : /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
592 : as returned by yylex, with out-of-bounds checking. */
593 : #define YYTRANSLATE(YYX) \
594 : (0 <= (YYX) && (YYX) <= YYMAXUTOK \
595 : ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
596 : : YYSYMBOL_YYUNDEF)
597 :
598 : /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
599 : as returned by yylex. */
600 : static const yytype_int8 yytranslate[] =
601 : {
602 : 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
603 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
604 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
605 : 2, 2, 2, 2, 2, 2, 59, 55, 2, 2,
606 : 57, 58, 53, 51, 61, 52, 66, 54, 2, 2,
607 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
608 : 2, 2, 2, 67, 60, 2, 2, 2, 2, 2,
609 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
610 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
611 : 2, 62, 2, 63, 2, 2, 2, 2, 2, 2,
612 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
613 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
614 : 2, 2, 2, 64, 2, 65, 2, 2, 2, 2,
615 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
616 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
617 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
618 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
619 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
620 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
621 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
622 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
623 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
624 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
625 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
626 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
627 : 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
628 : 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
629 : 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
630 : 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
631 : 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
632 : 45, 46, 47, 48, 49, 50, 56
633 : };
634 :
635 : #if YYDEBUG
636 : /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
637 : static const yytype_int16 yyrline[] =
638 : {
639 : 0, 122, 122, 128, 132, 133, 137, 138, 139, 143,
640 : 144, 145, 146, 147, 148, 149, 153, 154, 155, 156,
641 : 157, 158, 162, 163, 167, 168, 169, 170, 171, 172,
642 : 174, 176, 183, 193, 194, 198, 199, 200, 201, 205,
643 : 206, 207, 208, 212, 213, 214, 215, 216, 217, 218,
644 : 219, 220, 224, 225, 229, 230, 234, 235, 239, 240,
645 : 244, 245, 246, 251, 252, 253, 254, 255, 256, 257,
646 : 271, 273, 275, 277, 279, 284, 286, 288, 293, 294,
647 : 298, 299, 303, 307, 308, 312, 316, 317, 321, 325,
648 : 326, 327, 328, 329, 330, 331, 332, 333, 334, 335,
649 : 336, 337, 338, 339, 340, 341, 342, 343, 344, 345,
650 : 346, 347, 348, 349, 350, 351, 352, 353, 354, 355,
651 : 356, 357, 358, 359, 363, 364, 365, 366, 367, 368,
652 : 369, 370, 371, 372, 373, 374, 375
653 : };
654 : #endif
655 :
656 : /** Accessing symbol of state STATE. */
657 : #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
658 :
659 : #if YYDEBUG || 0
660 : /* The user-facing name of the symbol whose (internal) number is
661 : YYSYMBOL. No bounds checking. */
662 : static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
663 :
664 : /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
665 : First, the terminals, then, starting at YYNTOKENS, nonterminals. */
666 : static const char *const yytname[] =
667 : {
668 : "\"end of file\"", "error", "\"invalid token\"", "TO_P", "NULL_P",
669 : "TRUE_P", "FALSE_P", "IS_P", "UNKNOWN_P", "EXISTS_P", "IDENT_P",
670 : "STRING_P", "NUMERIC_P", "INT_P", "VARIABLE_P", "OR_P", "AND_P", "NOT_P",
671 : "LESS_P", "LESSEQUAL_P", "EQUAL_P", "NOTEQUAL_P", "GREATEREQUAL_P",
672 : "GREATER_P", "ANY_P", "STRICT_P", "LAX_P", "LAST_P", "STARTS_P",
673 : "WITH_P", "LIKE_REGEX_P", "FLAG_P", "ABS_P", "SIZE_P", "TYPE_P",
674 : "FLOOR_P", "DOUBLE_P", "CEILING_P", "KEYVALUE_P", "DATETIME_P",
675 : "BIGINT_P", "BOOLEAN_P", "DATE_P", "DECIMAL_P", "INTEGER_P", "NUMBER_P",
676 : "STRINGFUNC_P", "TIME_P", "TIME_TZ_P", "TIMESTAMP_P", "TIMESTAMP_TZ_P",
677 : "'+'", "'-'", "'*'", "'/'", "'%'", "UMINUS", "'('", "')'", "'$'", "'@'",
678 : "','", "'['", "']'", "'{'", "'}'", "'.'", "'?'", "$accept", "result",
679 : "expr_or_predicate", "mode", "scalar_value", "comp_op",
680 : "delimited_predicate", "predicate", "starts_with_initial",
681 : "path_primary", "accessor_expr", "expr", "index_elem", "index_list",
682 : "array_accessor", "any_level", "any_path", "accessor_op", "csv_elem",
683 : "csv_list", "opt_csv_list", "datetime_precision",
684 : "opt_datetime_precision", "datetime_template", "opt_datetime_template",
685 : "key", "key_name", "method", YY_NULLPTR
686 : };
687 :
688 : static const char *
689 : yysymbol_name (yysymbol_kind_t yysymbol)
690 : {
691 : return yytname[yysymbol];
692 : }
693 : #endif
694 :
695 : #ifdef YYPRINT
696 : /* YYTOKNUM[NUM] -- (External) token number corresponding to the
697 : (internal) symbol number NUM (which must be that of a token). */
698 : static const yytype_int16 yytoknum[] =
699 : {
700 : 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
701 : 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
702 : 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
703 : 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
704 : 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
705 : 305, 43, 45, 42, 47, 37, 306, 40, 41, 36,
706 : 64, 44, 91, 93, 123, 125, 46, 63
707 : };
708 : #endif
709 :
710 : #define YYPACT_NINF (-47)
711 :
712 : #define yypact_value_is_default(Yyn) \
713 : ((Yyn) == YYPACT_NINF)
714 :
715 : #define YYTABLE_NINF (-137)
716 :
717 : #define yytable_value_is_error(Yyn) \
718 : 0
719 :
720 : /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
721 : STATE-NUM. */
722 : static const yytype_int16 yypact[] =
723 : {
724 : 64, -47, -47, 11, 26, -47, -47, -47, -47, -37,
725 : -47, -47, -47, -47, -3, -47, 88, 88, 26, -47,
726 : -47, -47, -47, -47, 109, -47, 42, 176, 88, 26,
727 : -47, 26, -47, -47, 29, 163, 26, 26, 54, 125,
728 : -31, -47, -47, -47, -47, -47, -47, -47, -47, 0,
729 : 22, 88, 88, 88, 88, 88, 88, 181, 40, 176,
730 : 59, -5, 42, 20, -47, 13, 18, -47, -45, -47,
731 : -47, -47, -47, -47, -47, -47, -47, -47, 15, -47,
732 : -47, -47, -47, -47, -47, -47, 23, 25, 27, 31,
733 : 34, 38, 46, 53, 55, 69, 70, 84, 85, 86,
734 : 87, 89, 119, 120, 130, -47, -47, -47, -47, 131,
735 : 26, 14, 66, -46, -46, -47, -47, -47, 156, -47,
736 : -47, 42, 108, -47, -47, -47, 88, 88, -47, -8,
737 : 110, -10, 166, 166, 166, 166, 132, 122, -47, -47,
738 : -47, 178, -47, 156, -47, -47, -47, -2, -47, -47,
739 : 134, -47, 187, 188, -47, 141, 145, -47, -47, 147,
740 : 154, 155, 161, -47, -47, -47, -8, -47, -47, -47,
741 : -47, -10, -47, -47, -47, -47, -47, 157, -47, -47
742 : };
743 :
744 : /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
745 : Performed when YYTABLE does not specify something else to do. Zero
746 : means the default is an error. */
747 : static const yytype_int8 yydefact[] =
748 : {
749 : 8, 6, 7, 0, 0, 1, 10, 11, 12, 0,
750 : 9, 13, 14, 15, 0, 38, 0, 0, 0, 36,
751 : 37, 2, 35, 24, 5, 39, 43, 4, 0, 0,
752 : 28, 0, 45, 46, 0, 0, 0, 0, 0, 0,
753 : 0, 65, 42, 18, 20, 16, 17, 21, 19, 0,
754 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
755 : 0, 22, 44, 27, 26, 0, 52, 54, 0, 91,
756 : 92, 93, 94, 95, 96, 97, 89, 90, 60, 98,
757 : 99, 108, 109, 110, 111, 112, 100, 101, 102, 103,
758 : 104, 105, 107, 106, 113, 114, 115, 116, 117, 118,
759 : 119, 120, 121, 122, 123, 64, 66, 63, 88, 0,
760 : 0, 0, 31, 47, 48, 49, 50, 51, 25, 23,
761 : 22, 0, 0, 41, 40, 56, 0, 0, 57, 0,
762 : 87, 81, 84, 84, 84, 84, 0, 0, 33, 34,
763 : 30, 0, 29, 53, 55, 58, 59, 0, 85, 86,
764 : 0, 75, 0, 0, 78, 80, 0, 82, 83, 0,
765 : 0, 0, 0, 67, 68, 32, 0, 61, 70, 76,
766 : 77, 0, 69, 71, 72, 73, 74, 0, 79, 62
767 : };
768 :
769 : /* YYPGOTO[NTERM-NUM]. */
770 : static const yytype_int16 yypgoto[] =
771 : {
772 : -47, -47, -47, -47, -47, -47, 206, -14, -47, -47,
773 : -47, -4, 96, -47, -47, 58, -47, -16, 67, -47,
774 : -47, -47, -15, -47, -47, -47, -47, -47
775 : };
776 :
777 : /* YYDEFGOTO[NTERM-NUM]. */
778 : static const yytype_uint8 yydefgoto[] =
779 : {
780 : 0, 3, 21, 4, 22, 56, 23, 24, 140, 25,
781 : 26, 59, 67, 68, 41, 147, 106, 123, 154, 155,
782 : 156, 158, 159, 149, 150, 107, 108, 109
783 : };
784 :
785 : /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
786 : positive, shift that token. If negative, reduce the rule whose
787 : number is the opposite. If YYTABLE_NINF, syntax error. */
788 : static const yytype_int16 yytable[] =
789 : {
790 : 27, 166, 122, 151, 34, 145, 9, 53, 54, 55,
791 : 42, 5, 32, 33, 35, 58, 127, 60, 128, 146,
792 : 28, 126, 63, 64, 57, 138, 110, 35, 139, 111,
793 : 6, 7, 8, 112, 66, 9, 37, 10, 11, 12,
794 : 13, 152, 153, 14, 36, 37, 124, 113, 114, 115,
795 : 116, 117, 118, 15, 29, 36, 37, 38, 6, 7,
796 : 8, 39, 40, 167, -3, 10, 11, 12, 13, 51,
797 : 52, 53, 54, 55, 36, 37, 125, 16, 17, 129,
798 : -124, 15, -125, 18, -126, 19, 20, 61, -127, 1,
799 : 2, -128, 6, 7, 8, -129, 137, 141, 120, 10,
800 : 11, 12, 13, -130, 38, 16, 17, 65, 39, 40,
801 : 130, 31, -131, 19, 20, 15, 142, 121, 160, 161,
802 : 162, 148, 143, 66, 36, 37, -132, -133, 69, 70,
803 : 71, 72, 73, 74, 75, 76, 77, 36, 37, 16,
804 : 17, 131, -134, -135, -136, 31, 132, 19, 20, 78,
805 : 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
806 : 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
807 : 99, 100, 101, 102, 103, 104, 133, 134, 105, 157,
808 : 164, 43, 44, 45, 46, 47, 48, 135, 136, 165,
809 : 163, 49, 168, 50, 43, 44, 45, 46, 47, 48,
810 : 169, 170, 171, 172, 49, 173, 50, 51, 52, 53,
811 : 54, 55, 174, 175, 51, 52, 53, 54, 55, 176,
812 : 30, 62, 179, 144, 177, 0, 0, 51, 52, 53,
813 : 54, 55, 51, 52, 53, 54, 55, 0, 178, 119
814 : };
815 :
816 : static const yytype_int16 yycheck[] =
817 : {
818 : 4, 3, 7, 13, 18, 13, 9, 53, 54, 55,
819 : 26, 0, 16, 17, 18, 29, 61, 31, 63, 27,
820 : 57, 3, 36, 37, 28, 11, 57, 31, 14, 29,
821 : 4, 5, 6, 11, 38, 9, 16, 11, 12, 13,
822 : 14, 51, 52, 17, 15, 16, 62, 51, 52, 53,
823 : 54, 55, 56, 27, 57, 15, 16, 62, 4, 5,
824 : 6, 66, 67, 65, 0, 11, 12, 13, 14, 51,
825 : 52, 53, 54, 55, 15, 16, 63, 51, 52, 64,
826 : 57, 27, 57, 57, 57, 59, 60, 58, 57, 25,
827 : 26, 57, 4, 5, 6, 57, 110, 31, 58, 11,
828 : 12, 13, 14, 57, 62, 51, 52, 53, 66, 67,
829 : 57, 57, 57, 59, 60, 27, 8, 58, 133, 134,
830 : 135, 11, 126, 127, 15, 16, 57, 57, 3, 4,
831 : 5, 6, 7, 8, 9, 10, 11, 15, 16, 51,
832 : 52, 57, 57, 57, 57, 57, 57, 59, 60, 24,
833 : 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
834 : 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
835 : 45, 46, 47, 48, 49, 50, 57, 57, 53, 13,
836 : 58, 18, 19, 20, 21, 22, 23, 57, 57, 11,
837 : 58, 28, 58, 30, 18, 19, 20, 21, 22, 23,
838 : 13, 13, 61, 58, 28, 58, 30, 51, 52, 53,
839 : 54, 55, 58, 58, 51, 52, 53, 54, 55, 58,
840 : 14, 58, 65, 127, 166, -1, -1, 51, 52, 53,
841 : 54, 55, 51, 52, 53, 54, 55, -1, 171, 58
842 : };
843 :
844 : /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
845 : symbol of state STATE-NUM. */
846 : static const yytype_int8 yystos[] =
847 : {
848 : 0, 25, 26, 69, 71, 0, 4, 5, 6, 9,
849 : 11, 12, 13, 14, 17, 27, 51, 52, 57, 59,
850 : 60, 70, 72, 74, 75, 77, 78, 79, 57, 57,
851 : 74, 57, 79, 79, 75, 79, 15, 16, 62, 66,
852 : 67, 82, 85, 18, 19, 20, 21, 22, 23, 28,
853 : 30, 51, 52, 53, 54, 55, 73, 79, 75, 79,
854 : 75, 58, 58, 75, 75, 53, 79, 80, 81, 3,
855 : 4, 5, 6, 7, 8, 9, 10, 11, 24, 25,
856 : 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
857 : 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
858 : 46, 47, 48, 49, 50, 53, 84, 93, 94, 95,
859 : 57, 29, 11, 79, 79, 79, 79, 79, 79, 58,
860 : 58, 58, 7, 85, 85, 63, 3, 61, 63, 64,
861 : 57, 57, 57, 57, 57, 57, 57, 75, 11, 14,
862 : 76, 31, 8, 79, 80, 13, 27, 83, 11, 91,
863 : 92, 13, 51, 52, 86, 87, 88, 13, 89, 90,
864 : 90, 90, 90, 58, 58, 11, 3, 65, 58, 13,
865 : 13, 61, 58, 58, 58, 58, 58, 83, 86, 65
866 : };
867 :
868 : /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
869 : static const yytype_int8 yyr1[] =
870 : {
871 : 0, 68, 69, 69, 70, 70, 71, 71, 71, 72,
872 : 72, 72, 72, 72, 72, 72, 73, 73, 73, 73,
873 : 73, 73, 74, 74, 75, 75, 75, 75, 75, 75,
874 : 75, 75, 75, 76, 76, 77, 77, 77, 77, 78,
875 : 78, 78, 78, 79, 79, 79, 79, 79, 79, 79,
876 : 79, 79, 80, 80, 81, 81, 82, 82, 83, 83,
877 : 84, 84, 84, 85, 85, 85, 85, 85, 85, 85,
878 : 85, 85, 85, 85, 85, 86, 86, 86, 87, 87,
879 : 88, 88, 89, 90, 90, 91, 92, 92, 93, 94,
880 : 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
881 : 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
882 : 94, 94, 94, 94, 94, 94, 94, 94, 94, 94,
883 : 94, 94, 94, 94, 95, 95, 95, 95, 95, 95,
884 : 95, 95, 95, 95, 95, 95, 95
885 : };
886 :
887 : /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
888 : static const yytype_int8 yyr2[] =
889 : {
890 : 0, 2, 2, 0, 1, 1, 1, 1, 0, 1,
891 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
892 : 1, 1, 3, 4, 1, 3, 3, 3, 2, 5,
893 : 4, 3, 5, 1, 1, 1, 1, 1, 1, 1,
894 : 4, 4, 2, 1, 3, 2, 2, 3, 3, 3,
895 : 3, 3, 1, 3, 1, 3, 3, 3, 1, 1,
896 : 1, 4, 6, 2, 2, 1, 2, 4, 4, 5,
897 : 5, 5, 5, 5, 5, 1, 2, 2, 1, 3,
898 : 1, 0, 1, 1, 0, 1, 1, 0, 1, 1,
899 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
900 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
901 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
902 : 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
903 : 1, 1, 1, 1, 1, 1, 1
904 : };
905 :
906 :
907 : enum { YYENOMEM = -2 };
908 :
909 : #define yyerrok (yyerrstatus = 0)
910 : #define yyclearin (yychar = YYEMPTY)
911 :
912 : #define YYACCEPT goto yyacceptlab
913 : #define YYABORT goto yyabortlab
914 : #define YYERROR goto yyerrorlab
915 :
916 :
917 : #define YYRECOVERING() (!!yyerrstatus)
918 :
919 : #define YYBACKUP(Token, Value) \
920 : do \
921 : if (yychar == YYEMPTY) \
922 : { \
923 : yychar = (Token); \
924 : yylval = (Value); \
925 : YYPOPSTACK (yylen); \
926 : yystate = *yyssp; \
927 : goto yybackup; \
928 : } \
929 : else \
930 : { \
931 : yyerror (result, escontext, yyscanner, YY_("syntax error: cannot back up")); \
932 : YYERROR; \
933 : } \
934 : while (0)
935 :
936 : /* Backward compatibility with an undocumented macro.
937 : Use YYerror or YYUNDEF. */
938 : #define YYERRCODE YYUNDEF
939 :
940 :
941 : /* Enable debugging if requested. */
942 : #if YYDEBUG
943 :
944 : # ifndef YYFPRINTF
945 : # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
946 : # define YYFPRINTF fprintf
947 : # endif
948 :
949 : # define YYDPRINTF(Args) \
950 : do { \
951 : if (yydebug) \
952 : YYFPRINTF Args; \
953 : } while (0)
954 :
955 : /* This macro is provided for backward compatibility. */
956 : # ifndef YY_LOCATION_PRINT
957 : # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
958 : # endif
959 :
960 :
961 : # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
962 : do { \
963 : if (yydebug) \
964 : { \
965 : YYFPRINTF (stderr, "%s ", Title); \
966 : yy_symbol_print (stderr, \
967 : Kind, Value, result, escontext, yyscanner); \
968 : YYFPRINTF (stderr, "\n"); \
969 : } \
970 : } while (0)
971 :
972 :
973 : /*-----------------------------------.
974 : | Print this symbol's value on YYO. |
975 : `-----------------------------------*/
976 :
977 : static void
978 : yy_symbol_value_print (FILE *yyo,
979 : yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, JsonPathParseResult **result, struct Node *escontext, yyscan_t yyscanner)
980 : {
981 : FILE *yyoutput = yyo;
982 : YY_USE (yyoutput);
983 : YY_USE (result);
984 : YY_USE (escontext);
985 : YY_USE (yyscanner);
986 : if (!yyvaluep)
987 : return;
988 : # ifdef YYPRINT
989 : if (yykind < YYNTOKENS)
990 : YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
991 : # endif
992 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
993 : YY_USE (yykind);
994 : YY_IGNORE_MAYBE_UNINITIALIZED_END
995 : }
996 :
997 :
998 : /*---------------------------.
999 : | Print this symbol on YYO. |
1000 : `---------------------------*/
1001 :
1002 : static void
1003 : yy_symbol_print (FILE *yyo,
1004 : yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, JsonPathParseResult **result, struct Node *escontext, yyscan_t yyscanner)
1005 : {
1006 : YYFPRINTF (yyo, "%s %s (",
1007 : yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
1008 :
1009 : yy_symbol_value_print (yyo, yykind, yyvaluep, result, escontext, yyscanner);
1010 : YYFPRINTF (yyo, ")");
1011 : }
1012 :
1013 : /*------------------------------------------------------------------.
1014 : | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1015 : | TOP (included). |
1016 : `------------------------------------------------------------------*/
1017 :
1018 : static void
1019 : yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
1020 : {
1021 : YYFPRINTF (stderr, "Stack now");
1022 : for (; yybottom <= yytop; yybottom++)
1023 : {
1024 : int yybot = *yybottom;
1025 : YYFPRINTF (stderr, " %d", yybot);
1026 : }
1027 : YYFPRINTF (stderr, "\n");
1028 : }
1029 :
1030 : # define YY_STACK_PRINT(Bottom, Top) \
1031 : do { \
1032 : if (yydebug) \
1033 : yy_stack_print ((Bottom), (Top)); \
1034 : } while (0)
1035 :
1036 :
1037 : /*------------------------------------------------.
1038 : | Report that the YYRULE is going to be reduced. |
1039 : `------------------------------------------------*/
1040 :
1041 : static void
1042 : yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
1043 : int yyrule, JsonPathParseResult **result, struct Node *escontext, yyscan_t yyscanner)
1044 : {
1045 : int yylno = yyrline[yyrule];
1046 : int yynrhs = yyr2[yyrule];
1047 : int yyi;
1048 : YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
1049 : yyrule - 1, yylno);
1050 : /* The symbols being reduced. */
1051 : for (yyi = 0; yyi < yynrhs; yyi++)
1052 : {
1053 : YYFPRINTF (stderr, " $%d = ", yyi + 1);
1054 : yy_symbol_print (stderr,
1055 : YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
1056 : &yyvsp[(yyi + 1) - (yynrhs)], result, escontext, yyscanner);
1057 : YYFPRINTF (stderr, "\n");
1058 : }
1059 : }
1060 :
1061 : # define YY_REDUCE_PRINT(Rule) \
1062 : do { \
1063 : if (yydebug) \
1064 : yy_reduce_print (yyssp, yyvsp, Rule, result, escontext, yyscanner); \
1065 : } while (0)
1066 :
1067 : /* Nonzero means print parse trace. It is left uninitialized so that
1068 : multiple parsers can coexist. */
1069 : int yydebug;
1070 : #else /* !YYDEBUG */
1071 : # define YYDPRINTF(Args) ((void) 0)
1072 : # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
1073 : # define YY_STACK_PRINT(Bottom, Top)
1074 : # define YY_REDUCE_PRINT(Rule)
1075 : #endif /* !YYDEBUG */
1076 :
1077 :
1078 : /* YYINITDEPTH -- initial size of the parser's stacks. */
1079 : #ifndef YYINITDEPTH
1080 : # define YYINITDEPTH 200
1081 : #endif
1082 :
1083 : /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1084 : if the built-in stack extension method is used).
1085 :
1086 : Do not make this value too large; the results are undefined if
1087 : YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1088 : evaluated with infinite-precision integer arithmetic. */
1089 :
1090 : #ifndef YYMAXDEPTH
1091 : # define YYMAXDEPTH 10000
1092 : #endif
1093 :
1094 :
1095 :
1096 :
1097 :
1098 :
1099 : /*-----------------------------------------------.
1100 : | Release the memory associated to this symbol. |
1101 : `-----------------------------------------------*/
1102 :
1103 : static void
1104 20728 : yydestruct (const char *yymsg,
1105 : yysymbol_kind_t yykind, YYSTYPE *yyvaluep, JsonPathParseResult **result, struct Node *escontext, yyscan_t yyscanner)
1106 : {
1107 : YY_USE (yyvaluep);
1108 : YY_USE (result);
1109 : YY_USE (escontext);
1110 : YY_USE (yyscanner);
1111 20728 : if (!yymsg)
1112 0 : yymsg = "Deleting";
1113 : YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1114 :
1115 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1116 : YY_USE (yykind);
1117 : YY_IGNORE_MAYBE_UNINITIALIZED_END
1118 20728 : }
1119 :
1120 :
1121 :
1122 :
1123 :
1124 :
1125 : /*----------.
1126 : | yyparse. |
1127 : `----------*/
1128 :
1129 : int
1130 10718 : yyparse (JsonPathParseResult **result, struct Node *escontext, yyscan_t yyscanner)
1131 : {
1132 : /* Lookahead token kind. */
1133 : int yychar;
1134 :
1135 :
1136 : /* The semantic value of the lookahead symbol. */
1137 : /* Default value used for initialization, for pacifying older GCCs
1138 : or non-GCC compilers. */
1139 : YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1140 : YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1141 :
1142 : /* Number of syntax errors so far. */
1143 10718 : int yynerrs = 0;
1144 :
1145 10718 : yy_state_fast_t yystate = 0;
1146 : /* Number of tokens to shift before error messages enabled. */
1147 10718 : int yyerrstatus = 0;
1148 :
1149 : /* Refer to the stacks through separate pointers, to allow yyoverflow
1150 : to reallocate them elsewhere. */
1151 :
1152 : /* Their size. */
1153 10718 : YYPTRDIFF_T yystacksize = YYINITDEPTH;
1154 :
1155 : /* The state stack: array, bottom, top. */
1156 : yy_state_t yyssa[YYINITDEPTH];
1157 10718 : yy_state_t *yyss = yyssa;
1158 10718 : yy_state_t *yyssp = yyss;
1159 :
1160 : /* The semantic value stack: array, bottom, top. */
1161 : YYSTYPE yyvsa[YYINITDEPTH];
1162 10718 : YYSTYPE *yyvs = yyvsa;
1163 10718 : YYSTYPE *yyvsp = yyvs;
1164 :
1165 : int yyn;
1166 : /* The return value of yyparse. */
1167 : int yyresult;
1168 : /* Lookahead symbol kind. */
1169 10718 : yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1170 : /* The variables used to return semantic value and location from the
1171 : action routines. */
1172 : YYSTYPE yyval;
1173 :
1174 :
1175 :
1176 : #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1177 :
1178 : /* The number of symbols on the RHS of the reduced rule.
1179 : Keep to zero when no symbol should be popped. */
1180 10718 : int yylen = 0;
1181 :
1182 : YYDPRINTF ((stderr, "Starting parse\n"));
1183 :
1184 10718 : yychar = YYEMPTY; /* Cause a token to be read. */
1185 10718 : goto yysetstate;
1186 :
1187 :
1188 : /*------------------------------------------------------------.
1189 : | yynewstate -- push a new state, which is found in yystate. |
1190 : `------------------------------------------------------------*/
1191 214516 : yynewstate:
1192 : /* In all cases, when you get here, the value and location stacks
1193 : have just been pushed. So pushing a state here evens the stacks. */
1194 214516 : yyssp++;
1195 :
1196 :
1197 : /*--------------------------------------------------------------------.
1198 : | yysetstate -- set current state (the top of the stack) to yystate. |
1199 : `--------------------------------------------------------------------*/
1200 225234 : yysetstate:
1201 : YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1202 : YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1203 : YY_IGNORE_USELESS_CAST_BEGIN
1204 225234 : *yyssp = YY_CAST (yy_state_t, yystate);
1205 : YY_IGNORE_USELESS_CAST_END
1206 : YY_STACK_PRINT (yyss, yyssp);
1207 :
1208 225234 : if (yyss + yystacksize - 1 <= yyssp)
1209 : #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1210 : goto yyexhaustedlab;
1211 : #else
1212 : {
1213 : /* Get the current used size of the three stacks, in elements. */
1214 0 : YYPTRDIFF_T yysize = yyssp - yyss + 1;
1215 :
1216 : # if defined yyoverflow
1217 : {
1218 : /* Give user a chance to reallocate the stack. Use copies of
1219 : these so that the &'s don't force the real ones into
1220 : memory. */
1221 : yy_state_t *yyss1 = yyss;
1222 : YYSTYPE *yyvs1 = yyvs;
1223 :
1224 : /* Each stack pointer address is followed by the size of the
1225 : data in use in that stack, in bytes. This used to be a
1226 : conditional around just the two extra args, but that might
1227 : be undefined if yyoverflow is a macro. */
1228 : yyoverflow (YY_("memory exhausted"),
1229 : &yyss1, yysize * YYSIZEOF (*yyssp),
1230 : &yyvs1, yysize * YYSIZEOF (*yyvsp),
1231 : &yystacksize);
1232 : yyss = yyss1;
1233 : yyvs = yyvs1;
1234 : }
1235 : # else /* defined YYSTACK_RELOCATE */
1236 : /* Extend the stack our own way. */
1237 0 : if (YYMAXDEPTH <= yystacksize)
1238 0 : goto yyexhaustedlab;
1239 0 : yystacksize *= 2;
1240 0 : if (YYMAXDEPTH < yystacksize)
1241 0 : yystacksize = YYMAXDEPTH;
1242 :
1243 : {
1244 0 : yy_state_t *yyss1 = yyss;
1245 : union yyalloc *yyptr =
1246 0 : YY_CAST (union yyalloc *,
1247 : YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1248 0 : if (! yyptr)
1249 0 : goto yyexhaustedlab;
1250 0 : YYSTACK_RELOCATE (yyss_alloc, yyss);
1251 0 : YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1252 : # undef YYSTACK_RELOCATE
1253 0 : if (yyss1 != yyssa)
1254 0 : YYSTACK_FREE (yyss1);
1255 : }
1256 : # endif
1257 :
1258 0 : yyssp = yyss + yysize - 1;
1259 0 : yyvsp = yyvs + yysize - 1;
1260 :
1261 : YY_IGNORE_USELESS_CAST_BEGIN
1262 : YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1263 : YY_CAST (long, yystacksize)));
1264 : YY_IGNORE_USELESS_CAST_END
1265 :
1266 0 : if (yyss + yystacksize - 1 <= yyssp)
1267 0 : YYABORT;
1268 : }
1269 : #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1270 :
1271 225234 : if (yystate == YYFINAL)
1272 10334 : YYACCEPT;
1273 :
1274 214900 : goto yybackup;
1275 :
1276 :
1277 : /*-----------.
1278 : | yybackup. |
1279 : `-----------*/
1280 214900 : yybackup:
1281 : /* Do appropriate processing given the current state. Read a
1282 : lookahead token if we need one and don't already have one. */
1283 :
1284 : /* First try to decide what to do without reference to lookahead token. */
1285 214900 : yyn = yypact[yystate];
1286 214900 : if (yypact_value_is_default (yyn))
1287 93602 : goto yydefault;
1288 :
1289 : /* Not known => get a lookahead token if don't already have one. */
1290 :
1291 : /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1292 121298 : if (yychar == YYEMPTY)
1293 : {
1294 : YYDPRINTF ((stderr, "Reading a token\n"));
1295 77594 : yychar = yylex (&yylval, result, escontext, yyscanner);
1296 : }
1297 :
1298 121076 : if (yychar <= YYEOF)
1299 : {
1300 31218 : yychar = YYEOF;
1301 31218 : yytoken = YYSYMBOL_YYEOF;
1302 : YYDPRINTF ((stderr, "Now at end of input.\n"));
1303 : }
1304 89858 : else if (yychar == YYerror)
1305 : {
1306 : /* The scanner already issued an error message, process directly
1307 : to error recovery. But do not keep the error token as
1308 : lookahead, it is too special and may lead us to an endless
1309 : loop in error recovery. */
1310 0 : yychar = YYUNDEF;
1311 0 : yytoken = YYSYMBOL_YYerror;
1312 0 : goto yyerrlab1;
1313 : }
1314 : else
1315 : {
1316 89858 : yytoken = YYTRANSLATE (yychar);
1317 : YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1318 : }
1319 :
1320 : /* If the proper action on seeing token YYTOKEN is to reduce or to
1321 : detect an error, take that action. */
1322 121076 : yyn += yytoken;
1323 121076 : if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1324 42054 : goto yydefault;
1325 79022 : yyn = yytable[yyn];
1326 79022 : if (yyn <= 0)
1327 : {
1328 : if (yytable_value_is_error (yyn))
1329 : goto yyerrlab;
1330 1788 : yyn = -yyn;
1331 1788 : goto yyreduce;
1332 : }
1333 :
1334 : /* Count tokens shifted since error; after three, turn off error
1335 : status. */
1336 77234 : if (yyerrstatus)
1337 0 : yyerrstatus--;
1338 :
1339 : /* Shift the lookahead token. */
1340 : YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1341 77234 : yystate = yyn;
1342 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1343 77234 : *++yyvsp = yylval;
1344 : YY_IGNORE_MAYBE_UNINITIALIZED_END
1345 :
1346 : /* Discard the shifted token. */
1347 77234 : yychar = YYEMPTY;
1348 77234 : goto yynewstate;
1349 :
1350 :
1351 : /*-----------------------------------------------------------.
1352 : | yydefault -- do the default action for the current state. |
1353 : `-----------------------------------------------------------*/
1354 135656 : yydefault:
1355 135656 : yyn = yydefact[yystate];
1356 135656 : if (yyn == 0)
1357 132 : goto yyerrlab;
1358 135524 : goto yyreduce;
1359 :
1360 :
1361 : /*-----------------------------.
1362 : | yyreduce -- do a reduction. |
1363 : `-----------------------------*/
1364 137312 : yyreduce:
1365 : /* yyn is the number of a rule to reduce with. */
1366 137312 : yylen = yyr2[yyn];
1367 :
1368 : /* If YYLEN is nonzero, implement the default value of the action:
1369 : '$$ = $1'.
1370 :
1371 : Otherwise, the following line sets YYVAL to garbage.
1372 : This behavior is undocumented and Bison
1373 : users should not rely upon it. Assigning to YYVAL
1374 : unconditionally makes the parser a bit smaller, and it avoids a
1375 : GCC warning that YYVAL may be used uninitialized. */
1376 137312 : yyval = yyvsp[1-yylen];
1377 :
1378 :
1379 : YY_REDUCE_PRINT (yyn);
1380 137312 : switch (yyn)
1381 : {
1382 10304 : case 2: /* result: mode expr_or_predicate */
1383 : #line 122 "jsonpath_gram.y"
1384 : {
1385 : *result = palloc(sizeof(JsonPathParseResult));
1386 : (*result)->expr = (yyvsp[0].value);
1387 : (*result)->lax = (yyvsp[-1].boolean);
1388 : (void) yynerrs;
1389 : }
1390 : #line 1391 "jsonpath_gram.c"
1391 10304 : break;
1392 :
1393 30 : case 3: /* result: %empty */
1394 : #line 128 "jsonpath_gram.y"
1395 : { *result = NULL; }
1396 : #line 1397 "jsonpath_gram.c"
1397 30 : break;
1398 :
1399 9872 : case 4: /* expr_or_predicate: expr */
1400 : #line 132 "jsonpath_gram.y"
1401 : { (yyval.value) = (yyvsp[0].value); }
1402 : #line 1403 "jsonpath_gram.c"
1403 9872 : break;
1404 :
1405 432 : case 5: /* expr_or_predicate: predicate */
1406 : #line 133 "jsonpath_gram.y"
1407 : { (yyval.value) = (yyvsp[0].value); }
1408 : #line 1409 "jsonpath_gram.c"
1409 432 : break;
1410 :
1411 648 : case 6: /* mode: STRICT_P */
1412 : #line 137 "jsonpath_gram.y"
1413 : { (yyval.boolean) = false; }
1414 : #line 1415 "jsonpath_gram.c"
1415 648 : break;
1416 :
1417 690 : case 7: /* mode: LAX_P */
1418 : #line 138 "jsonpath_gram.y"
1419 : { (yyval.boolean) = true; }
1420 : #line 1421 "jsonpath_gram.c"
1421 690 : break;
1422 :
1423 9182 : case 8: /* mode: %empty */
1424 : #line 139 "jsonpath_gram.y"
1425 : { (yyval.boolean) = true; }
1426 : #line 1427 "jsonpath_gram.c"
1427 9182 : break;
1428 :
1429 834 : case 9: /* scalar_value: STRING_P */
1430 : #line 143 "jsonpath_gram.y"
1431 : { (yyval.value) = makeItemString(&(yyvsp[0].str)); }
1432 : #line 1433 "jsonpath_gram.c"
1433 834 : break;
1434 :
1435 114 : case 10: /* scalar_value: NULL_P */
1436 : #line 144 "jsonpath_gram.y"
1437 : { (yyval.value) = makeItemString(NULL); }
1438 : #line 1439 "jsonpath_gram.c"
1439 114 : break;
1440 :
1441 138 : case 11: /* scalar_value: TRUE_P */
1442 : #line 145 "jsonpath_gram.y"
1443 : { (yyval.value) = makeItemBool(true); }
1444 : #line 1445 "jsonpath_gram.c"
1445 138 : break;
1446 :
1447 42 : case 12: /* scalar_value: FALSE_P */
1448 : #line 146 "jsonpath_gram.y"
1449 : { (yyval.value) = makeItemBool(false); }
1450 : #line 1451 "jsonpath_gram.c"
1451 42 : break;
1452 :
1453 534 : case 13: /* scalar_value: NUMERIC_P */
1454 : #line 147 "jsonpath_gram.y"
1455 : { (yyval.value) = makeItemNumeric(&(yyvsp[0].str)); }
1456 : #line 1457 "jsonpath_gram.c"
1457 534 : break;
1458 :
1459 1536 : case 14: /* scalar_value: INT_P */
1460 : #line 148 "jsonpath_gram.y"
1461 : { (yyval.value) = makeItemNumeric(&(yyvsp[0].str)); }
1462 : #line 1463 "jsonpath_gram.c"
1463 1536 : break;
1464 :
1465 708 : case 15: /* scalar_value: VARIABLE_P */
1466 : #line 149 "jsonpath_gram.y"
1467 : { (yyval.value) = makeItemVariable(&(yyvsp[0].str)); }
1468 : #line 1469 "jsonpath_gram.c"
1469 708 : break;
1470 :
1471 1002 : case 16: /* comp_op: EQUAL_P */
1472 : #line 153 "jsonpath_gram.y"
1473 : { (yyval.optype) = jpiEqual; }
1474 : #line 1475 "jsonpath_gram.c"
1475 1002 : break;
1476 :
1477 12 : case 17: /* comp_op: NOTEQUAL_P */
1478 : #line 154 "jsonpath_gram.y"
1479 : { (yyval.optype) = jpiNotEqual; }
1480 : #line 1481 "jsonpath_gram.c"
1481 12 : break;
1482 :
1483 756 : case 18: /* comp_op: LESS_P */
1484 : #line 155 "jsonpath_gram.y"
1485 : { (yyval.optype) = jpiLess; }
1486 : #line 1487 "jsonpath_gram.c"
1487 756 : break;
1488 :
1489 444 : case 19: /* comp_op: GREATER_P */
1490 : #line 156 "jsonpath_gram.y"
1491 : { (yyval.optype) = jpiGreater; }
1492 : #line 1493 "jsonpath_gram.c"
1493 444 : break;
1494 :
1495 42 : case 20: /* comp_op: LESSEQUAL_P */
1496 : #line 157 "jsonpath_gram.y"
1497 : { (yyval.optype) = jpiLessOrEqual; }
1498 : #line 1499 "jsonpath_gram.c"
1499 42 : break;
1500 :
1501 336 : case 21: /* comp_op: GREATEREQUAL_P */
1502 : #line 158 "jsonpath_gram.y"
1503 : { (yyval.optype) = jpiGreaterOrEqual; }
1504 : #line 1505 "jsonpath_gram.c"
1505 336 : break;
1506 :
1507 72 : case 22: /* delimited_predicate: '(' predicate ')' */
1508 : #line 162 "jsonpath_gram.y"
1509 : { (yyval.value) = (yyvsp[-1].value); }
1510 : #line 1511 "jsonpath_gram.c"
1511 72 : break;
1512 :
1513 264 : case 23: /* delimited_predicate: EXISTS_P '(' expr ')' */
1514 : #line 163 "jsonpath_gram.y"
1515 : { (yyval.value) = makeItemUnary(jpiExists, (yyvsp[-1].value)); }
1516 : #line 1517 "jsonpath_gram.c"
1517 264 : break;
1518 :
1519 312 : case 24: /* predicate: delimited_predicate */
1520 : #line 167 "jsonpath_gram.y"
1521 : { (yyval.value) = (yyvsp[0].value); }
1522 : #line 1523 "jsonpath_gram.c"
1523 312 : break;
1524 :
1525 2592 : case 25: /* predicate: expr comp_op expr */
1526 : #line 168 "jsonpath_gram.y"
1527 : { (yyval.value) = makeItemBinary((yyvsp[-1].optype), (yyvsp[-2].value), (yyvsp[0].value)); }
1528 : #line 1529 "jsonpath_gram.c"
1529 2592 : break;
1530 :
1531 186 : case 26: /* predicate: predicate AND_P predicate */
1532 : #line 169 "jsonpath_gram.y"
1533 : { (yyval.value) = makeItemBinary(jpiAnd, (yyvsp[-2].value), (yyvsp[0].value)); }
1534 : #line 1535 "jsonpath_gram.c"
1535 186 : break;
1536 :
1537 108 : case 27: /* predicate: predicate OR_P predicate */
1538 : #line 170 "jsonpath_gram.y"
1539 : { (yyval.value) = makeItemBinary(jpiOr, (yyvsp[-2].value), (yyvsp[0].value)); }
1540 : #line 1541 "jsonpath_gram.c"
1541 108 : break;
1542 :
1543 24 : case 28: /* predicate: NOT_P delimited_predicate */
1544 : #line 171 "jsonpath_gram.y"
1545 : { (yyval.value) = makeItemUnary(jpiNot, (yyvsp[0].value)); }
1546 : #line 1547 "jsonpath_gram.c"
1547 24 : break;
1548 :
1549 72 : case 29: /* predicate: '(' predicate ')' IS_P UNKNOWN_P */
1550 : #line 173 "jsonpath_gram.y"
1551 : { (yyval.value) = makeItemUnary(jpiIsUnknown, (yyvsp[-3].value)); }
1552 : #line 1553 "jsonpath_gram.c"
1553 72 : break;
1554 :
1555 60 : case 30: /* predicate: expr STARTS_P WITH_P starts_with_initial */
1556 : #line 175 "jsonpath_gram.y"
1557 : { (yyval.value) = makeItemBinary(jpiStartsWith, (yyvsp[-3].value), (yyvsp[0].value)); }
1558 : #line 1559 "jsonpath_gram.c"
1559 60 : break;
1560 :
1561 18 : case 31: /* predicate: expr LIKE_REGEX_P STRING_P */
1562 : #line 177 "jsonpath_gram.y"
1563 : {
1564 : JsonPathParseItem *jppitem;
1565 : if (! makeItemLikeRegex((yyvsp[-2].value), &(yyvsp[0].str), NULL, &jppitem, escontext))
1566 : YYABORT;
1567 : (yyval.value) = jppitem;
1568 : }
1569 : #line 1570 "jsonpath_gram.c"
1570 12 : break;
1571 :
1572 132 : case 32: /* predicate: expr LIKE_REGEX_P STRING_P FLAG_P STRING_P */
1573 : #line 184 "jsonpath_gram.y"
1574 : {
1575 : JsonPathParseItem *jppitem;
1576 : if (! makeItemLikeRegex((yyvsp[-4].value), &(yyvsp[-2].str), &(yyvsp[0].str), &jppitem, escontext))
1577 : YYABORT;
1578 : (yyval.value) = jppitem;
1579 : }
1580 : #line 1581 "jsonpath_gram.c"
1581 108 : break;
1582 :
1583 54 : case 33: /* starts_with_initial: STRING_P */
1584 : #line 193 "jsonpath_gram.y"
1585 : { (yyval.value) = makeItemString(&(yyvsp[0].str)); }
1586 : #line 1587 "jsonpath_gram.c"
1587 54 : break;
1588 :
1589 6 : case 34: /* starts_with_initial: VARIABLE_P */
1590 : #line 194 "jsonpath_gram.y"
1591 : { (yyval.value) = makeItemVariable(&(yyvsp[0].str)); }
1592 : #line 1593 "jsonpath_gram.c"
1593 6 : break;
1594 :
1595 3906 : case 35: /* path_primary: scalar_value */
1596 : #line 198 "jsonpath_gram.y"
1597 : { (yyval.value) = (yyvsp[0].value); }
1598 : #line 1599 "jsonpath_gram.c"
1599 3906 : break;
1600 :
1601 10088 : case 36: /* path_primary: '$' */
1602 : #line 199 "jsonpath_gram.y"
1603 : { (yyval.value) = makeItemType(jpiRoot); }
1604 : #line 1605 "jsonpath_gram.c"
1605 10088 : break;
1606 :
1607 2598 : case 37: /* path_primary: '@' */
1608 : #line 200 "jsonpath_gram.y"
1609 : { (yyval.value) = makeItemType(jpiCurrent); }
1610 : #line 1611 "jsonpath_gram.c"
1611 2598 : break;
1612 :
1613 90 : case 38: /* path_primary: LAST_P */
1614 : #line 201 "jsonpath_gram.y"
1615 : { (yyval.value) = makeItemType(jpiLast); }
1616 : #line 1617 "jsonpath_gram.c"
1617 90 : break;
1618 :
1619 16682 : case 39: /* accessor_expr: path_primary */
1620 : #line 205 "jsonpath_gram.y"
1621 : { (yyval.elems) = list_make1((yyvsp[0].value)); }
1622 : #line 1623 "jsonpath_gram.c"
1623 16682 : break;
1624 :
1625 90 : case 40: /* accessor_expr: '(' expr ')' accessor_op */
1626 : #line 206 "jsonpath_gram.y"
1627 : { (yyval.elems) = list_make2((yyvsp[-2].value), (yyvsp[0].value)); }
1628 : #line 1629 "jsonpath_gram.c"
1629 90 : break;
1630 :
1631 30 : case 41: /* accessor_expr: '(' predicate ')' accessor_op */
1632 : #line 207 "jsonpath_gram.y"
1633 : { (yyval.elems) = list_make2((yyvsp[-2].value), (yyvsp[0].value)); }
1634 : #line 1635 "jsonpath_gram.c"
1635 30 : break;
1636 :
1637 13398 : case 42: /* accessor_expr: accessor_expr accessor_op */
1638 : #line 208 "jsonpath_gram.y"
1639 : { (yyval.elems) = lappend((yyvsp[-1].elems), (yyvsp[0].value)); }
1640 : #line 1641 "jsonpath_gram.c"
1641 13398 : break;
1642 :
1643 16664 : case 43: /* expr: accessor_expr */
1644 : #line 212 "jsonpath_gram.y"
1645 : { (yyval.value) = makeItemList((yyvsp[0].elems)); }
1646 : #line 1647 "jsonpath_gram.c"
1647 16664 : break;
1648 :
1649 162 : case 44: /* expr: '(' expr ')' */
1650 : #line 213 "jsonpath_gram.y"
1651 : { (yyval.value) = (yyvsp[-1].value); }
1652 : #line 1653 "jsonpath_gram.c"
1653 162 : break;
1654 :
1655 174 : case 45: /* expr: '+' expr */
1656 : #line 214 "jsonpath_gram.y"
1657 : { (yyval.value) = makeItemUnary(jpiPlus, (yyvsp[0].value)); }
1658 : #line 1659 "jsonpath_gram.c"
1659 174 : break;
1660 :
1661 246 : case 46: /* expr: '-' expr */
1662 : #line 215 "jsonpath_gram.y"
1663 : { (yyval.value) = makeItemUnary(jpiMinus, (yyvsp[0].value)); }
1664 : #line 1665 "jsonpath_gram.c"
1665 246 : break;
1666 :
1667 210 : case 47: /* expr: expr '+' expr */
1668 : #line 216 "jsonpath_gram.y"
1669 : { (yyval.value) = makeItemBinary(jpiAdd, (yyvsp[-2].value), (yyvsp[0].value)); }
1670 : #line 1671 "jsonpath_gram.c"
1671 210 : break;
1672 :
1673 102 : case 48: /* expr: expr '-' expr */
1674 : #line 217 "jsonpath_gram.y"
1675 : { (yyval.value) = makeItemBinary(jpiSub, (yyvsp[-2].value), (yyvsp[0].value)); }
1676 : #line 1677 "jsonpath_gram.c"
1677 102 : break;
1678 :
1679 72 : case 49: /* expr: expr '*' expr */
1680 : #line 218 "jsonpath_gram.y"
1681 : { (yyval.value) = makeItemBinary(jpiMul, (yyvsp[-2].value), (yyvsp[0].value)); }
1682 : #line 1683 "jsonpath_gram.c"
1683 72 : break;
1684 :
1685 36 : case 50: /* expr: expr '/' expr */
1686 : #line 219 "jsonpath_gram.y"
1687 : { (yyval.value) = makeItemBinary(jpiDiv, (yyvsp[-2].value), (yyvsp[0].value)); }
1688 : #line 1689 "jsonpath_gram.c"
1689 36 : break;
1690 :
1691 18 : case 51: /* expr: expr '%' expr */
1692 : #line 220 "jsonpath_gram.y"
1693 : { (yyval.value) = makeItemBinary(jpiMod, (yyvsp[-2].value), (yyvsp[0].value)); }
1694 : #line 1695 "jsonpath_gram.c"
1695 18 : break;
1696 :
1697 510 : case 52: /* index_elem: expr */
1698 : #line 224 "jsonpath_gram.y"
1699 : { (yyval.value) = makeItemBinary(jpiSubscript, (yyvsp[0].value), NULL); }
1700 : #line 1701 "jsonpath_gram.c"
1701 510 : break;
1702 :
1703 48 : case 53: /* index_elem: expr TO_P expr */
1704 : #line 225 "jsonpath_gram.y"
1705 : { (yyval.value) = makeItemBinary(jpiSubscript, (yyvsp[-2].value), (yyvsp[0].value)); }
1706 : #line 1707 "jsonpath_gram.c"
1707 48 : break;
1708 :
1709 510 : case 54: /* index_list: index_elem */
1710 : #line 229 "jsonpath_gram.y"
1711 : { (yyval.indexs) = list_make1((yyvsp[0].value)); }
1712 : #line 1713 "jsonpath_gram.c"
1713 510 : break;
1714 :
1715 48 : case 55: /* index_list: index_list ',' index_elem */
1716 : #line 230 "jsonpath_gram.y"
1717 : { (yyval.indexs) = lappend((yyvsp[-2].indexs), (yyvsp[0].value)); }
1718 : #line 1719 "jsonpath_gram.c"
1719 48 : break;
1720 :
1721 2008 : case 56: /* array_accessor: '[' '*' ']' */
1722 : #line 234 "jsonpath_gram.y"
1723 : { (yyval.value) = makeItemType(jpiAnyArray); }
1724 : #line 1725 "jsonpath_gram.c"
1725 2008 : break;
1726 :
1727 510 : case 57: /* array_accessor: '[' index_list ']' */
1728 : #line 235 "jsonpath_gram.y"
1729 : { (yyval.value) = makeIndexArray((yyvsp[-1].indexs)); }
1730 : #line 1731 "jsonpath_gram.c"
1731 510 : break;
1732 :
1733 282 : case 58: /* any_level: INT_P */
1734 : #line 239 "jsonpath_gram.y"
1735 : { (yyval.integer) = pg_strtoint32((yyvsp[0].str).val); }
1736 : #line 1737 "jsonpath_gram.c"
1737 282 : break;
1738 :
1739 96 : case 59: /* any_level: LAST_P */
1740 : #line 240 "jsonpath_gram.y"
1741 : { (yyval.integer) = -1; }
1742 : #line 1743 "jsonpath_gram.c"
1743 96 : break;
1744 :
1745 114 : case 60: /* any_path: ANY_P */
1746 : #line 244 "jsonpath_gram.y"
1747 : { (yyval.value) = makeAny(0, -1); }
1748 : #line 1749 "jsonpath_gram.c"
1749 114 : break;
1750 :
1751 102 : case 61: /* any_path: ANY_P '{' any_level '}' */
1752 : #line 245 "jsonpath_gram.y"
1753 : { (yyval.value) = makeAny((yyvsp[-1].integer), (yyvsp[-1].integer)); }
1754 : #line 1755 "jsonpath_gram.c"
1755 102 : break;
1756 :
1757 138 : case 62: /* any_path: ANY_P '{' any_level TO_P any_level '}' */
1758 : #line 247 "jsonpath_gram.y"
1759 : { (yyval.value) = makeAny((yyvsp[-3].integer), (yyvsp[-1].integer)); }
1760 : #line 1761 "jsonpath_gram.c"
1761 138 : break;
1762 :
1763 3836 : case 63: /* accessor_op: '.' key */
1764 : #line 251 "jsonpath_gram.y"
1765 : { (yyval.value) = (yyvsp[0].value); }
1766 : #line 1767 "jsonpath_gram.c"
1767 3836 : break;
1768 :
1769 174 : case 64: /* accessor_op: '.' '*' */
1770 : #line 252 "jsonpath_gram.y"
1771 : { (yyval.value) = makeItemType(jpiAnyKey); }
1772 : #line 1773 "jsonpath_gram.c"
1773 174 : break;
1774 :
1775 2518 : case 65: /* accessor_op: array_accessor */
1776 : #line 253 "jsonpath_gram.y"
1777 : { (yyval.value) = (yyvsp[0].value); }
1778 : #line 1779 "jsonpath_gram.c"
1779 2518 : break;
1780 :
1781 354 : case 66: /* accessor_op: '.' any_path */
1782 : #line 254 "jsonpath_gram.y"
1783 : { (yyval.value) = (yyvsp[0].value); }
1784 : #line 1785 "jsonpath_gram.c"
1785 354 : break;
1786 :
1787 1752 : case 67: /* accessor_op: '.' method '(' ')' */
1788 : #line 255 "jsonpath_gram.y"
1789 : { (yyval.value) = makeItemType((yyvsp[-2].optype)); }
1790 : #line 1791 "jsonpath_gram.c"
1791 1752 : break;
1792 :
1793 2280 : case 68: /* accessor_op: '?' '(' predicate ')' */
1794 : #line 256 "jsonpath_gram.y"
1795 : { (yyval.value) = makeItemUnary(jpiFilter, (yyvsp[-1].value)); }
1796 : #line 1797 "jsonpath_gram.c"
1797 2280 : break;
1798 :
1799 276 : case 69: /* accessor_op: '.' DECIMAL_P '(' opt_csv_list ')' */
1800 : #line 258 "jsonpath_gram.y"
1801 : {
1802 : if (list_length((yyvsp[-1].elems)) == 0)
1803 : (yyval.value) = makeItemBinary(jpiDecimal, NULL, NULL);
1804 : else if (list_length((yyvsp[-1].elems)) == 1)
1805 : (yyval.value) = makeItemBinary(jpiDecimal, linitial((yyvsp[-1].elems)), NULL);
1806 : else if (list_length((yyvsp[-1].elems)) == 2)
1807 : (yyval.value) = makeItemBinary(jpiDecimal, linitial((yyvsp[-1].elems)), lsecond((yyvsp[-1].elems)));
1808 : else
1809 : ereturn(escontext, false,
1810 : (errcode(ERRCODE_SYNTAX_ERROR),
1811 : errmsg("invalid input syntax for type %s", "jsonpath"),
1812 : errdetail(".decimal() can only have an optional precision[,scale].")));
1813 : }
1814 : #line 1815 "jsonpath_gram.c"
1815 276 : break;
1816 :
1817 1032 : case 70: /* accessor_op: '.' DATETIME_P '(' opt_datetime_template ')' */
1818 : #line 272 "jsonpath_gram.y"
1819 : { (yyval.value) = makeItemUnary(jpiDatetime, (yyvsp[-1].value)); }
1820 : #line 1821 "jsonpath_gram.c"
1821 1032 : break;
1822 :
1823 324 : case 71: /* accessor_op: '.' TIME_P '(' opt_datetime_precision ')' */
1824 : #line 274 "jsonpath_gram.y"
1825 : { (yyval.value) = makeItemUnary(jpiTime, (yyvsp[-1].value)); }
1826 : #line 1827 "jsonpath_gram.c"
1827 324 : break;
1828 :
1829 294 : case 72: /* accessor_op: '.' TIME_TZ_P '(' opt_datetime_precision ')' */
1830 : #line 276 "jsonpath_gram.y"
1831 : { (yyval.value) = makeItemUnary(jpiTimeTz, (yyvsp[-1].value)); }
1832 : #line 1833 "jsonpath_gram.c"
1833 294 : break;
1834 :
1835 336 : case 73: /* accessor_op: '.' TIMESTAMP_P '(' opt_datetime_precision ')' */
1836 : #line 278 "jsonpath_gram.y"
1837 : { (yyval.value) = makeItemUnary(jpiTimestamp, (yyvsp[-1].value)); }
1838 : #line 1839 "jsonpath_gram.c"
1839 336 : break;
1840 :
1841 342 : case 74: /* accessor_op: '.' TIMESTAMP_TZ_P '(' opt_datetime_precision ')' */
1842 : #line 280 "jsonpath_gram.y"
1843 : { (yyval.value) = makeItemUnary(jpiTimestampTz, (yyvsp[-1].value)); }
1844 : #line 1845 "jsonpath_gram.c"
1845 342 : break;
1846 :
1847 156 : case 75: /* csv_elem: INT_P */
1848 : #line 285 "jsonpath_gram.y"
1849 : { (yyval.value) = makeItemNumeric(&(yyvsp[0].str)); }
1850 : #line 1851 "jsonpath_gram.c"
1851 156 : break;
1852 :
1853 30 : case 76: /* csv_elem: '+' INT_P */
1854 : #line 287 "jsonpath_gram.y"
1855 : { (yyval.value) = makeItemUnary(jpiPlus, makeItemNumeric(&(yyvsp[0].str))); }
1856 : #line 1857 "jsonpath_gram.c"
1857 30 : break;
1858 :
1859 30 : case 77: /* csv_elem: '-' INT_P */
1860 : #line 289 "jsonpath_gram.y"
1861 : { (yyval.value) = makeItemUnary(jpiMinus, makeItemNumeric(&(yyvsp[0].str))); }
1862 : #line 1863 "jsonpath_gram.c"
1863 30 : break;
1864 :
1865 108 : case 78: /* csv_list: csv_elem */
1866 : #line 293 "jsonpath_gram.y"
1867 : { (yyval.elems) = list_make1((yyvsp[0].value)); }
1868 : #line 1869 "jsonpath_gram.c"
1869 108 : break;
1870 :
1871 108 : case 79: /* csv_list: csv_list ',' csv_elem */
1872 : #line 294 "jsonpath_gram.y"
1873 : { (yyval.elems) = lappend((yyvsp[-2].elems), (yyvsp[0].value)); }
1874 : #line 1875 "jsonpath_gram.c"
1875 108 : break;
1876 :
1877 108 : case 80: /* opt_csv_list: csv_list */
1878 : #line 298 "jsonpath_gram.y"
1879 : { (yyval.elems) = (yyvsp[0].elems); }
1880 : #line 1881 "jsonpath_gram.c"
1881 108 : break;
1882 :
1883 168 : case 81: /* opt_csv_list: %empty */
1884 : #line 299 "jsonpath_gram.y"
1885 : { (yyval.elems) = NULL; }
1886 : #line 1887 "jsonpath_gram.c"
1887 168 : break;
1888 :
1889 276 : case 82: /* datetime_precision: INT_P */
1890 : #line 303 "jsonpath_gram.y"
1891 : { (yyval.value) = makeItemNumeric(&(yyvsp[0].str)); }
1892 : #line 1893 "jsonpath_gram.c"
1893 276 : break;
1894 :
1895 276 : case 83: /* opt_datetime_precision: datetime_precision */
1896 : #line 307 "jsonpath_gram.y"
1897 : { (yyval.value) = (yyvsp[0].value); }
1898 : #line 1899 "jsonpath_gram.c"
1899 276 : break;
1900 :
1901 1068 : case 84: /* opt_datetime_precision: %empty */
1902 : #line 308 "jsonpath_gram.y"
1903 : { (yyval.value) = NULL; }
1904 : #line 1905 "jsonpath_gram.c"
1905 1068 : break;
1906 :
1907 516 : case 85: /* datetime_template: STRING_P */
1908 : #line 312 "jsonpath_gram.y"
1909 : { (yyval.value) = makeItemString(&(yyvsp[0].str)); }
1910 : #line 1911 "jsonpath_gram.c"
1911 516 : break;
1912 :
1913 516 : case 86: /* opt_datetime_template: datetime_template */
1914 : #line 316 "jsonpath_gram.y"
1915 : { (yyval.value) = (yyvsp[0].value); }
1916 : #line 1917 "jsonpath_gram.c"
1917 516 : break;
1918 :
1919 516 : case 87: /* opt_datetime_template: %empty */
1920 : #line 317 "jsonpath_gram.y"
1921 : { (yyval.value) = NULL; }
1922 : #line 1923 "jsonpath_gram.c"
1923 516 : break;
1924 :
1925 3836 : case 88: /* key: key_name */
1926 : #line 321 "jsonpath_gram.y"
1927 : { (yyval.value) = makeItemKey(&(yyvsp[0].str)); }
1928 : #line 1929 "jsonpath_gram.c"
1929 3836 : break;
1930 :
1931 42 : case 124: /* method: ABS_P */
1932 : #line 363 "jsonpath_gram.y"
1933 : { (yyval.optype) = jpiAbs; }
1934 : #line 1935 "jsonpath_gram.c"
1935 42 : break;
1936 :
1937 30 : case 125: /* method: SIZE_P */
1938 : #line 364 "jsonpath_gram.y"
1939 : { (yyval.optype) = jpiSize; }
1940 : #line 1941 "jsonpath_gram.c"
1941 30 : break;
1942 :
1943 252 : case 126: /* method: TYPE_P */
1944 : #line 365 "jsonpath_gram.y"
1945 : { (yyval.optype) = jpiType; }
1946 : #line 1947 "jsonpath_gram.c"
1947 252 : break;
1948 :
1949 30 : case 127: /* method: FLOOR_P */
1950 : #line 366 "jsonpath_gram.y"
1951 : { (yyval.optype) = jpiFloor; }
1952 : #line 1953 "jsonpath_gram.c"
1953 30 : break;
1954 :
1955 120 : case 128: /* method: DOUBLE_P */
1956 : #line 367 "jsonpath_gram.y"
1957 : { (yyval.optype) = jpiDouble; }
1958 : #line 1959 "jsonpath_gram.c"
1959 120 : break;
1960 :
1961 36 : case 129: /* method: CEILING_P */
1962 : #line 368 "jsonpath_gram.y"
1963 : { (yyval.optype) = jpiCeiling; }
1964 : #line 1965 "jsonpath_gram.c"
1965 36 : break;
1966 :
1967 66 : case 130: /* method: KEYVALUE_P */
1968 : #line 369 "jsonpath_gram.y"
1969 : { (yyval.optype) = jpiKeyValue; }
1970 : #line 1971 "jsonpath_gram.c"
1971 66 : break;
1972 :
1973 186 : case 131: /* method: BIGINT_P */
1974 : #line 370 "jsonpath_gram.y"
1975 : { (yyval.optype) = jpiBigint; }
1976 : #line 1977 "jsonpath_gram.c"
1977 186 : break;
1978 :
1979 246 : case 132: /* method: BOOLEAN_P */
1980 : #line 371 "jsonpath_gram.y"
1981 : { (yyval.optype) = jpiBoolean; }
1982 : #line 1983 "jsonpath_gram.c"
1983 246 : break;
1984 :
1985 234 : case 133: /* method: DATE_P */
1986 : #line 372 "jsonpath_gram.y"
1987 : { (yyval.optype) = jpiDate; }
1988 : #line 1989 "jsonpath_gram.c"
1989 234 : break;
1990 :
1991 174 : case 134: /* method: INTEGER_P */
1992 : #line 373 "jsonpath_gram.y"
1993 : { (yyval.optype) = jpiInteger; }
1994 : #line 1995 "jsonpath_gram.c"
1995 174 : break;
1996 :
1997 168 : case 135: /* method: NUMBER_P */
1998 : #line 374 "jsonpath_gram.y"
1999 : { (yyval.optype) = jpiNumber; }
2000 : #line 2001 "jsonpath_gram.c"
2001 168 : break;
2002 :
2003 174 : case 136: /* method: STRINGFUNC_P */
2004 : #line 375 "jsonpath_gram.y"
2005 : { (yyval.optype) = jpiStringFunc; }
2006 : #line 2007 "jsonpath_gram.c"
2007 174 : break;
2008 :
2009 :
2010 : #line 2011 "jsonpath_gram.c"
2011 :
2012 3836 : default: break;
2013 : }
2014 : /* User semantic actions sometimes alter yychar, and that requires
2015 : that yytoken be updated with the new translation. We take the
2016 : approach of translating immediately before every use of yytoken.
2017 : One alternative is translating here after every semantic action,
2018 : but that translation would be missed if the semantic action invokes
2019 : YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2020 : if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2021 : incorrect destructor might then be invoked immediately. In the
2022 : case of YYERROR or YYBACKUP, subsequent parser actions might lead
2023 : to an incorrect destructor call or verbose syntax error message
2024 : before the lookahead is translated. */
2025 : YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
2026 :
2027 137282 : YYPOPSTACK (yylen);
2028 137282 : yylen = 0;
2029 :
2030 137282 : *++yyvsp = yyval;
2031 :
2032 : /* Now 'shift' the result of the reduction. Determine what state
2033 : that goes to, based on the state we popped back to and the rule
2034 : number reduced by. */
2035 : {
2036 137282 : const int yylhs = yyr1[yyn] - YYNTOKENS;
2037 137282 : const int yyi = yypgoto[yylhs] + *yyssp;
2038 55544 : yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
2039 33074 : ? yytable[yyi]
2040 192826 : : yydefgoto[yylhs]);
2041 : }
2042 :
2043 137282 : goto yynewstate;
2044 :
2045 :
2046 : /*--------------------------------------.
2047 : | yyerrlab -- here on detecting error. |
2048 : `--------------------------------------*/
2049 132 : yyerrlab:
2050 : /* Make sure we have latest lookahead translation. See comments at
2051 : user semantic actions for why this is necessary. */
2052 132 : yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
2053 : /* If not already recovering from an error, report this error. */
2054 132 : if (!yyerrstatus)
2055 : {
2056 132 : ++yynerrs;
2057 132 : yyerror (result, escontext, yyscanner, YY_("syntax error"));
2058 : }
2059 :
2060 6 : if (yyerrstatus == 3)
2061 : {
2062 : /* If just tried and failed to reuse lookahead token after an
2063 : error, discard it. */
2064 :
2065 0 : if (yychar <= YYEOF)
2066 : {
2067 : /* Return failure if at end of input. */
2068 0 : if (yychar == YYEOF)
2069 0 : YYABORT;
2070 : }
2071 : else
2072 : {
2073 0 : yydestruct ("Error: discarding",
2074 : yytoken, &yylval, result, escontext, yyscanner);
2075 0 : yychar = YYEMPTY;
2076 : }
2077 : }
2078 :
2079 : /* Else will try to reuse lookahead token after shifting the error
2080 : token. */
2081 6 : goto yyerrlab1;
2082 :
2083 :
2084 : /*---------------------------------------------------.
2085 : | yyerrorlab -- error raised explicitly by YYERROR. |
2086 : `---------------------------------------------------*/
2087 : yyerrorlab:
2088 : /* Pacify compilers when the user code never invokes YYERROR and the
2089 : label yyerrorlab therefore never appears in user code. */
2090 : if (0)
2091 : YYERROR;
2092 :
2093 : /* Do not reclaim the symbols of the rule whose action triggered
2094 : this YYERROR. */
2095 : YYPOPSTACK (yylen);
2096 : yylen = 0;
2097 : YY_STACK_PRINT (yyss, yyssp);
2098 : yystate = *yyssp;
2099 : goto yyerrlab1;
2100 :
2101 :
2102 : /*-------------------------------------------------------------.
2103 : | yyerrlab1 -- common code for both syntax error and YYERROR. |
2104 : `-------------------------------------------------------------*/
2105 6 : yyerrlab1:
2106 6 : yyerrstatus = 3; /* Each real token shifted decrements this. */
2107 :
2108 : /* Pop stack until we find a state that shifts the error token. */
2109 : for (;;)
2110 : {
2111 12 : yyn = yypact[yystate];
2112 12 : if (!yypact_value_is_default (yyn))
2113 : {
2114 12 : yyn += YYSYMBOL_YYerror;
2115 12 : if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
2116 : {
2117 0 : yyn = yytable[yyn];
2118 0 : if (0 < yyn)
2119 0 : break;
2120 : }
2121 : }
2122 :
2123 : /* Pop the current state because it cannot handle the error token. */
2124 12 : if (yyssp == yyss)
2125 6 : YYABORT;
2126 :
2127 :
2128 6 : yydestruct ("Error: popping",
2129 6 : YY_ACCESSING_SYMBOL (yystate), yyvsp, result, escontext, yyscanner);
2130 6 : YYPOPSTACK (1);
2131 6 : yystate = *yyssp;
2132 : YY_STACK_PRINT (yyss, yyssp);
2133 : }
2134 :
2135 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2136 0 : *++yyvsp = yylval;
2137 : YY_IGNORE_MAYBE_UNINITIALIZED_END
2138 :
2139 :
2140 : /* Shift the error token. */
2141 : YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
2142 :
2143 0 : yystate = yyn;
2144 0 : goto yynewstate;
2145 :
2146 :
2147 : /*-------------------------------------.
2148 : | yyacceptlab -- YYACCEPT comes here. |
2149 : `-------------------------------------*/
2150 10334 : yyacceptlab:
2151 10334 : yyresult = 0;
2152 10334 : goto yyreturn;
2153 :
2154 :
2155 : /*-----------------------------------.
2156 : | yyabortlab -- YYABORT comes here. |
2157 : `-----------------------------------*/
2158 18 : yyabortlab:
2159 18 : yyresult = 1;
2160 18 : goto yyreturn;
2161 :
2162 :
2163 : #if !defined yyoverflow
2164 : /*-------------------------------------------------.
2165 : | yyexhaustedlab -- memory exhaustion comes here. |
2166 : `-------------------------------------------------*/
2167 0 : yyexhaustedlab:
2168 0 : yyerror (result, escontext, yyscanner, YY_("memory exhausted"));
2169 0 : yyresult = 2;
2170 0 : goto yyreturn;
2171 : #endif
2172 :
2173 :
2174 : /*-------------------------------------------------------.
2175 : | yyreturn -- parsing is finished, clean up and return. |
2176 : `-------------------------------------------------------*/
2177 10352 : yyreturn:
2178 10352 : if (yychar != YYEMPTY)
2179 : {
2180 : /* Make sure we have latest lookahead translation. See comments at
2181 : user semantic actions for why this is necessary. */
2182 6 : yytoken = YYTRANSLATE (yychar);
2183 6 : yydestruct ("Cleanup: discarding lookahead",
2184 : yytoken, &yylval, result, escontext, yyscanner);
2185 : }
2186 : /* Do not reclaim the symbols of the rule whose action triggered
2187 : this YYABORT or YYACCEPT. */
2188 10352 : YYPOPSTACK (yylen);
2189 : YY_STACK_PRINT (yyss, yyssp);
2190 31068 : while (yyssp != yyss)
2191 : {
2192 20716 : yydestruct ("Cleanup: popping",
2193 20716 : YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, result, escontext, yyscanner);
2194 20716 : YYPOPSTACK (1);
2195 : }
2196 : #ifndef yyoverflow
2197 10352 : if (yyss != yyssa)
2198 0 : YYSTACK_FREE (yyss);
2199 : #endif
2200 :
2201 10352 : return yyresult;
2202 : }
2203 :
2204 : #line 377 "jsonpath_gram.y"
2205 :
2206 :
2207 : /*
2208 : * The helper functions below allocate and fill JsonPathParseItem's of various
2209 : * types.
2210 : */
2211 :
2212 : static JsonPathParseItem *
2213 : makeItemType(JsonPathItemType type)
2214 : {
2215 : JsonPathParseItem *v = palloc(sizeof(*v));
2216 :
2217 : CHECK_FOR_INTERRUPTS();
2218 :
2219 : v->type = type;
2220 : v->next = NULL;
2221 :
2222 : return v;
2223 : }
2224 :
2225 : static JsonPathParseItem *
2226 : makeItemString(JsonPathString *s)
2227 : {
2228 : JsonPathParseItem *v;
2229 :
2230 : if (s == NULL)
2231 : {
2232 : v = makeItemType(jpiNull);
2233 : }
2234 : else
2235 : {
2236 : v = makeItemType(jpiString);
2237 : v->value.string.val = s->val;
2238 : v->value.string.len = s->len;
2239 : }
2240 :
2241 : return v;
2242 : }
2243 :
2244 : static JsonPathParseItem *
2245 : makeItemVariable(JsonPathString *s)
2246 : {
2247 : JsonPathParseItem *v;
2248 :
2249 : v = makeItemType(jpiVariable);
2250 : v->value.string.val = s->val;
2251 : v->value.string.len = s->len;
2252 :
2253 : return v;
2254 : }
2255 :
2256 : static JsonPathParseItem *
2257 : makeItemKey(JsonPathString *s)
2258 : {
2259 : JsonPathParseItem *v;
2260 :
2261 : v = makeItemString(s);
2262 : v->type = jpiKey;
2263 :
2264 : return v;
2265 : }
2266 :
2267 : static JsonPathParseItem *
2268 : makeItemNumeric(JsonPathString *s)
2269 : {
2270 : JsonPathParseItem *v;
2271 :
2272 : v = makeItemType(jpiNumeric);
2273 : v->value.numeric =
2274 : DatumGetNumeric(DirectFunctionCall3(numeric_in,
2275 : CStringGetDatum(s->val),
2276 : ObjectIdGetDatum(InvalidOid),
2277 : Int32GetDatum(-1)));
2278 :
2279 : return v;
2280 : }
2281 :
2282 : static JsonPathParseItem *
2283 : makeItemBool(bool val)
2284 : {
2285 : JsonPathParseItem *v = makeItemType(jpiBool);
2286 :
2287 : v->value.boolean = val;
2288 :
2289 : return v;
2290 : }
2291 :
2292 : static JsonPathParseItem *
2293 : makeItemBinary(JsonPathItemType type, JsonPathParseItem *la, JsonPathParseItem *ra)
2294 : {
2295 : JsonPathParseItem *v = makeItemType(type);
2296 :
2297 : v->value.args.left = la;
2298 : v->value.args.right = ra;
2299 :
2300 : return v;
2301 : }
2302 :
2303 : static JsonPathParseItem *
2304 : makeItemUnary(JsonPathItemType type, JsonPathParseItem *a)
2305 : {
2306 : JsonPathParseItem *v;
2307 :
2308 : if (type == jpiPlus && a->type == jpiNumeric && !a->next)
2309 : return a;
2310 :
2311 : if (type == jpiMinus && a->type == jpiNumeric && !a->next)
2312 : {
2313 : v = makeItemType(jpiNumeric);
2314 : v->value.numeric =
2315 : DatumGetNumeric(DirectFunctionCall1(numeric_uminus,
2316 : NumericGetDatum(a->value.numeric)));
2317 : return v;
2318 : }
2319 :
2320 : v = makeItemType(type);
2321 :
2322 : v->value.arg = a;
2323 :
2324 : return v;
2325 : }
2326 :
2327 : static JsonPathParseItem *
2328 : makeItemList(List *list)
2329 : {
2330 : JsonPathParseItem *head,
2331 : *end;
2332 : ListCell *cell;
2333 :
2334 : head = end = (JsonPathParseItem *) linitial(list);
2335 :
2336 : if (list_length(list) == 1)
2337 : return head;
2338 :
2339 : /* append items to the end of already existing list */
2340 : while (end->next)
2341 : end = end->next;
2342 :
2343 : for_each_from(cell, list, 1)
2344 : {
2345 : JsonPathParseItem *c = (JsonPathParseItem *) lfirst(cell);
2346 :
2347 : end->next = c;
2348 : end = c;
2349 : }
2350 :
2351 : return head;
2352 : }
2353 :
2354 : static JsonPathParseItem *
2355 : makeIndexArray(List *list)
2356 : {
2357 : JsonPathParseItem *v = makeItemType(jpiIndexArray);
2358 : ListCell *cell;
2359 : int i = 0;
2360 :
2361 : Assert(list != NIL);
2362 : v->value.array.nelems = list_length(list);
2363 :
2364 : v->value.array.elems = palloc(sizeof(v->value.array.elems[0]) *
2365 : v->value.array.nelems);
2366 :
2367 : foreach(cell, list)
2368 : {
2369 : JsonPathParseItem *jpi = lfirst(cell);
2370 :
2371 : Assert(jpi->type == jpiSubscript);
2372 :
2373 : v->value.array.elems[i].from = jpi->value.args.left;
2374 : v->value.array.elems[i++].to = jpi->value.args.right;
2375 : }
2376 :
2377 : return v;
2378 : }
2379 :
2380 : static JsonPathParseItem *
2381 : makeAny(int first, int last)
2382 : {
2383 : JsonPathParseItem *v = makeItemType(jpiAny);
2384 :
2385 : v->value.anybounds.first = (first >= 0) ? first : PG_UINT32_MAX;
2386 : v->value.anybounds.last = (last >= 0) ? last : PG_UINT32_MAX;
2387 :
2388 : return v;
2389 : }
2390 :
2391 : static bool
2392 : makeItemLikeRegex(JsonPathParseItem *expr, JsonPathString *pattern,
2393 : JsonPathString *flags, JsonPathParseItem **result,
2394 : struct Node *escontext)
2395 : {
2396 : JsonPathParseItem *v = makeItemType(jpiLikeRegex);
2397 : int i;
2398 : int cflags;
2399 :
2400 : v->value.like_regex.expr = expr;
2401 : v->value.like_regex.pattern = pattern->val;
2402 : v->value.like_regex.patternlen = pattern->len;
2403 :
2404 : /* Parse the flags string, convert to bitmask. Duplicate flags are OK. */
2405 : v->value.like_regex.flags = 0;
2406 : for (i = 0; flags && i < flags->len; i++)
2407 : {
2408 : switch (flags->val[i])
2409 : {
2410 : case 'i':
2411 : v->value.like_regex.flags |= JSP_REGEX_ICASE;
2412 : break;
2413 : case 's':
2414 : v->value.like_regex.flags |= JSP_REGEX_DOTALL;
2415 : break;
2416 : case 'm':
2417 : v->value.like_regex.flags |= JSP_REGEX_MLINE;
2418 : break;
2419 : case 'x':
2420 : v->value.like_regex.flags |= JSP_REGEX_WSPACE;
2421 : break;
2422 : case 'q':
2423 : v->value.like_regex.flags |= JSP_REGEX_QUOTE;
2424 : break;
2425 : default:
2426 : ereturn(escontext, false,
2427 : (errcode(ERRCODE_SYNTAX_ERROR),
2428 : errmsg("invalid input syntax for type %s", "jsonpath"),
2429 : errdetail("Unrecognized flag character \"%.*s\" in LIKE_REGEX predicate.",
2430 : pg_mblen(flags->val + i), flags->val + i)));
2431 : break;
2432 : }
2433 : }
2434 :
2435 : /* Convert flags to what pg_regcomp needs */
2436 : if (!jspConvertRegexFlags(v->value.like_regex.flags, &cflags, escontext))
2437 : return false;
2438 :
2439 : /* check regex validity */
2440 : {
2441 : regex_t re_tmp;
2442 : pg_wchar *wpattern;
2443 : int wpattern_len;
2444 : int re_result;
2445 :
2446 : wpattern = (pg_wchar *) palloc((pattern->len + 1) * sizeof(pg_wchar));
2447 : wpattern_len = pg_mb2wchar_with_len(pattern->val,
2448 : wpattern,
2449 : pattern->len);
2450 :
2451 : if ((re_result = pg_regcomp(&re_tmp, wpattern, wpattern_len, cflags,
2452 : DEFAULT_COLLATION_OID)) != REG_OKAY)
2453 : {
2454 : char errMsg[100];
2455 :
2456 : pg_regerror(re_result, &re_tmp, errMsg, sizeof(errMsg));
2457 : ereturn(escontext, false,
2458 : (errcode(ERRCODE_INVALID_REGULAR_EXPRESSION),
2459 : errmsg("invalid regular expression: %s", errMsg)));
2460 : }
2461 :
2462 : pg_regfree(&re_tmp);
2463 : }
2464 :
2465 : *result = v;
2466 :
2467 : return true;
2468 : }
2469 :
2470 : /*
2471 : * Convert from XQuery regex flags to those recognized by our regex library.
2472 : */
2473 : bool
2474 : jspConvertRegexFlags(uint32 xflags, int *result, struct Node *escontext)
2475 : {
2476 : /* By default, XQuery is very nearly the same as Spencer's AREs */
2477 : int cflags = REG_ADVANCED;
2478 :
2479 : /* Ignore-case means the same thing, too, modulo locale issues */
2480 : if (xflags & JSP_REGEX_ICASE)
2481 : cflags |= REG_ICASE;
2482 :
2483 : /* Per XQuery spec, if 'q' is specified then 'm', 's', 'x' are ignored */
2484 : if (xflags & JSP_REGEX_QUOTE)
2485 : {
2486 : cflags &= ~REG_ADVANCED;
2487 : cflags |= REG_QUOTE;
2488 : }
2489 : else
2490 : {
2491 : /* Note that dotall mode is the default in POSIX */
2492 : if (!(xflags & JSP_REGEX_DOTALL))
2493 : cflags |= REG_NLSTOP;
2494 : if (xflags & JSP_REGEX_MLINE)
2495 : cflags |= REG_NLANCH;
2496 :
2497 : /*
2498 : * XQuery's 'x' mode is related to Spencer's expanded mode, but it's
2499 : * not really enough alike to justify treating JSP_REGEX_WSPACE as
2500 : * REG_EXPANDED. For now we treat 'x' as unimplemented; perhaps in
2501 : * future we'll modify the regex library to have an option for
2502 : * XQuery-style ignore-whitespace mode.
2503 : */
2504 : if (xflags & JSP_REGEX_WSPACE)
2505 : ereturn(escontext, false,
2506 : (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2507 : errmsg("XQuery \"x\" flag (expanded regular expressions) is not implemented")));
2508 : }
2509 :
2510 : *result = cflags;
2511 :
2512 : return true;
2513 : }
|