LCOV - code coverage report
Current view: top level - src/backend/utils/adt - jsonpath_gram.c (source / functions) Coverage Total Hit
Test: PostgreSQL 19devel Lines: 88.6 % 341 302
Test Date: 2026-03-12 06:14:44 Functions: 100.0 % 2 2
Legend: Lines:     hit not hit

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

Generated by: LCOV version 2.0-1