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