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

Generated by: LCOV version 1.14