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

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

Generated by: LCOV version 1.14