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

Generated by: LCOV version 1.14