LCOV - code coverage report
Current view: top level - src/bin/pgbench - exprparse.c (source / functions) Hit Total Coverage
Test: PostgreSQL 17devel Lines: 172 233 73.8 %
Date: 2024-04-25 20:11:01 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* A Bison parser, made by GNU Bison 3.7.5.  */
       2             : 
       3             : /* Bison implementation for Yacc-like parsers in C
       4             : 
       5             :    Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
       6             :    Inc.
       7             : 
       8             :    This program is free software: you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation, either version 3 of the License, or
      11             :    (at your option) any later version.
      12             : 
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             : 
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
      20             : 
      21             : /* As a special exception, you may create a larger work that contains
      22             :    part or all of the Bison parser skeleton and distribute that work
      23             :    under terms of your choice, so long as that work isn't itself a
      24             :    parser generator using the skeleton or a modified version thereof
      25             :    as a parser skeleton.  Alternatively, if you modify or redistribute
      26             :    the parser skeleton itself, you may (at your option) remove this
      27             :    special exception, which will cause the skeleton and the resulting
      28             :    Bison output files to be licensed under the GNU General Public
      29             :    License without this special exception.
      30             : 
      31             :    This special exception was added by the Free Software Foundation in
      32             :    version 2.2 of Bison.  */
      33             : 
      34             : /* C LALR(1) parser skeleton written by Richard Stallman, by
      35             :    simplifying the original so-called "semantic" parser.  */
      36             : 
      37             : /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
      38             :    especially those whose name start with YY_ or yy_.  They are
      39             :    private implementation details that can be changed or removed.  */
      40             : 
      41             : /* All symbols defined below should begin with yy or YY, to avoid
      42             :    infringing on user name space.  This should be done even for local
      43             :    variables, as they might otherwise be expanded by user macros.
      44             :    There are some unavoidable exceptions within include files to
      45             :    define necessary library symbols; they are noted "INFRINGES ON
      46             :    USER NAME SPACE" below.  */
      47             : 
      48             : /* Identify Bison output, and Bison version.  */
      49             : #define YYBISON 30705
      50             : 
      51             : /* Bison version string.  */
      52             : #define YYBISON_VERSION "3.7.5"
      53             : 
      54             : /* Skeleton name.  */
      55             : #define YYSKELETON_NAME "yacc.c"
      56             : 
      57             : /* Pure parsers.  */
      58             : #define YYPURE 1
      59             : 
      60             : /* Push parsers.  */
      61             : #define YYPUSH 0
      62             : 
      63             : /* Pull parsers.  */
      64             : #define YYPULL 1
      65             : 
      66             : 
      67             : /* Substitute the variable and function names.  */
      68             : #define yyparse         expr_yyparse
      69             : #define yylex           expr_yylex
      70             : #define yyerror         expr_yyerror
      71             : #define yydebug         expr_yydebug
      72             : #define yynerrs         expr_yynerrs
      73             : 
      74             : /* First part of user prologue.  */
      75             : #line 1 "exprparse.y"
      76             : 
      77             : /*-------------------------------------------------------------------------
      78             :  *
      79             :  * exprparse.y
      80             :  *    bison grammar for a simple expression syntax
      81             :  *
      82             :  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
      83             :  * Portions Copyright (c) 1994, Regents of the University of California
      84             :  *
      85             :  * src/bin/pgbench/exprparse.y
      86             :  *
      87             :  *-------------------------------------------------------------------------
      88             :  */
      89             : 
      90             : #include "postgres_fe.h"
      91             : 
      92             : #include "pgbench.h"
      93             : 
      94             : #define PGBENCH_NARGS_VARIABLE  (-1)
      95             : #define PGBENCH_NARGS_CASE      (-2)
      96             : #define PGBENCH_NARGS_HASH      (-3)
      97             : #define PGBENCH_NARGS_PERMUTE   (-4)
      98             : 
      99             : PgBenchExpr *expr_parse_result;
     100             : 
     101             : static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list);
     102             : static PgBenchExpr *make_null_constant(void);
     103             : static PgBenchExpr *make_boolean_constant(bool bval);
     104             : static PgBenchExpr *make_integer_constant(int64 ival);
     105             : static PgBenchExpr *make_double_constant(double dval);
     106             : static PgBenchExpr *make_variable(char *varname);
     107             : static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator,
     108             :                             PgBenchExpr *lexpr, PgBenchExpr *rexpr);
     109             : static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr);
     110             : static int  find_func(yyscan_t yyscanner, const char *fname);
     111             : static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args);
     112             : static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part);
     113             : 
     114             : 
     115             : #line 116 "exprparse.c"
     116             : 
     117             : # ifndef YY_CAST
     118             : #  ifdef __cplusplus
     119             : #   define YY_CAST(Type, Val) static_cast<Type> (Val)
     120             : #   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
     121             : #  else
     122             : #   define YY_CAST(Type, Val) ((Type) (Val))
     123             : #   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
     124             : #  endif
     125             : # endif
     126             : # ifndef YY_NULLPTR
     127             : #  if defined __cplusplus
     128             : #   if 201103L <= __cplusplus
     129             : #    define YY_NULLPTR nullptr
     130             : #   else
     131             : #    define YY_NULLPTR 0
     132             : #   endif
     133             : #  else
     134             : #   define YY_NULLPTR ((void*)0)
     135             : #  endif
     136             : # endif
     137             : 
     138             : #include "exprparse.h"
     139             : /* Symbol kind.  */
     140             : enum yysymbol_kind_t
     141             : {
     142             :   YYSYMBOL_YYEMPTY = -2,
     143             :   YYSYMBOL_YYEOF = 0,                      /* "end of file"  */
     144             :   YYSYMBOL_YYerror = 1,                    /* error  */
     145             :   YYSYMBOL_YYUNDEF = 2,                    /* "invalid token"  */
     146             :   YYSYMBOL_NULL_CONST = 3,                 /* NULL_CONST  */
     147             :   YYSYMBOL_INTEGER_CONST = 4,              /* INTEGER_CONST  */
     148             :   YYSYMBOL_MAXINT_PLUS_ONE_CONST = 5,      /* MAXINT_PLUS_ONE_CONST  */
     149             :   YYSYMBOL_DOUBLE_CONST = 6,               /* DOUBLE_CONST  */
     150             :   YYSYMBOL_BOOLEAN_CONST = 7,              /* BOOLEAN_CONST  */
     151             :   YYSYMBOL_VARIABLE = 8,                   /* VARIABLE  */
     152             :   YYSYMBOL_FUNCTION = 9,                   /* FUNCTION  */
     153             :   YYSYMBOL_AND_OP = 10,                    /* AND_OP  */
     154             :   YYSYMBOL_OR_OP = 11,                     /* OR_OP  */
     155             :   YYSYMBOL_NOT_OP = 12,                    /* NOT_OP  */
     156             :   YYSYMBOL_NE_OP = 13,                     /* NE_OP  */
     157             :   YYSYMBOL_LE_OP = 14,                     /* LE_OP  */
     158             :   YYSYMBOL_GE_OP = 15,                     /* GE_OP  */
     159             :   YYSYMBOL_LS_OP = 16,                     /* LS_OP  */
     160             :   YYSYMBOL_RS_OP = 17,                     /* RS_OP  */
     161             :   YYSYMBOL_IS_OP = 18,                     /* IS_OP  */
     162             :   YYSYMBOL_CASE_KW = 19,                   /* CASE_KW  */
     163             :   YYSYMBOL_WHEN_KW = 20,                   /* WHEN_KW  */
     164             :   YYSYMBOL_THEN_KW = 21,                   /* THEN_KW  */
     165             :   YYSYMBOL_ELSE_KW = 22,                   /* ELSE_KW  */
     166             :   YYSYMBOL_END_KW = 23,                    /* END_KW  */
     167             :   YYSYMBOL_ISNULL_OP = 24,                 /* ISNULL_OP  */
     168             :   YYSYMBOL_NOTNULL_OP = 25,                /* NOTNULL_OP  */
     169             :   YYSYMBOL_26_ = 26,                       /* '<'  */
     170             :   YYSYMBOL_27_ = 27,                       /* '>'  */
     171             :   YYSYMBOL_28_ = 28,                       /* '='  */
     172             :   YYSYMBOL_29_ = 29,                       /* '|'  */
     173             :   YYSYMBOL_30_ = 30,                       /* '#'  */
     174             :   YYSYMBOL_31_ = 31,                       /* '&'  */
     175             :   YYSYMBOL_32_ = 32,                       /* '~'  */
     176             :   YYSYMBOL_33_ = 33,                       /* '+'  */
     177             :   YYSYMBOL_34_ = 34,                       /* '-'  */
     178             :   YYSYMBOL_35_ = 35,                       /* '*'  */
     179             :   YYSYMBOL_36_ = 36,                       /* '/'  */
     180             :   YYSYMBOL_37_ = 37,                       /* '%'  */
     181             :   YYSYMBOL_UNARY = 38,                     /* UNARY  */
     182             :   YYSYMBOL_39_ = 39,                       /* ','  */
     183             :   YYSYMBOL_40_ = 40,                       /* '('  */
     184             :   YYSYMBOL_41_ = 41,                       /* ')'  */
     185             :   YYSYMBOL_YYACCEPT = 42,                  /* $accept  */
     186             :   YYSYMBOL_result = 43,                    /* result  */
     187             :   YYSYMBOL_elist = 44,                     /* elist  */
     188             :   YYSYMBOL_expr = 45,                      /* expr  */
     189             :   YYSYMBOL_when_then_list = 46,            /* when_then_list  */
     190             :   YYSYMBOL_case_control = 47,              /* case_control  */
     191             :   YYSYMBOL_function = 48                   /* function  */
     192             : };
     193             : typedef enum yysymbol_kind_t yysymbol_kind_t;
     194             : 
     195             : 
     196             : 
     197             : 
     198             : #ifdef short
     199             : # undef short
     200             : #endif
     201             : 
     202             : /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
     203             :    <limits.h> and (if available) <stdint.h> are included
     204             :    so that the code can choose integer types of a good width.  */
     205             : 
     206             : #ifndef __PTRDIFF_MAX__
     207             : # include <limits.h> /* INFRINGES ON USER NAME SPACE */
     208             : # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
     209             : #  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
     210             : #  define YY_STDINT_H
     211             : # endif
     212             : #endif
     213             : 
     214             : /* Narrow types that promote to a signed type and that can represent a
     215             :    signed or unsigned integer of at least N bits.  In tables they can
     216             :    save space and decrease cache pressure.  Promoting to a signed type
     217             :    helps avoid bugs in integer arithmetic.  */
     218             : 
     219             : #ifdef __INT_LEAST8_MAX__
     220             : typedef __INT_LEAST8_TYPE__ yytype_int8;
     221             : #elif defined YY_STDINT_H
     222             : typedef int_least8_t yytype_int8;
     223             : #else
     224             : typedef signed char yytype_int8;
     225             : #endif
     226             : 
     227             : #ifdef __INT_LEAST16_MAX__
     228             : typedef __INT_LEAST16_TYPE__ yytype_int16;
     229             : #elif defined YY_STDINT_H
     230             : typedef int_least16_t yytype_int16;
     231             : #else
     232             : typedef short yytype_int16;
     233             : #endif
     234             : 
     235             : /* Work around bug in HP-UX 11.23, which defines these macros
     236             :    incorrectly for preprocessor constants.  This workaround can likely
     237             :    be removed in 2023, as HPE has promised support for HP-UX 11.23
     238             :    (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
     239             :    <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>.  */
     240             : #ifdef __hpux
     241             : # undef UINT_LEAST8_MAX
     242             : # undef UINT_LEAST16_MAX
     243             : # define UINT_LEAST8_MAX 255
     244             : # define UINT_LEAST16_MAX 65535
     245             : #endif
     246             : 
     247             : #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
     248             : typedef __UINT_LEAST8_TYPE__ yytype_uint8;
     249             : #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
     250             :        && UINT_LEAST8_MAX <= INT_MAX)
     251             : typedef uint_least8_t yytype_uint8;
     252             : #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
     253             : typedef unsigned char yytype_uint8;
     254             : #else
     255             : typedef short yytype_uint8;
     256             : #endif
     257             : 
     258             : #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
     259             : typedef __UINT_LEAST16_TYPE__ yytype_uint16;
     260             : #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
     261             :        && UINT_LEAST16_MAX <= INT_MAX)
     262             : typedef uint_least16_t yytype_uint16;
     263             : #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
     264             : typedef unsigned short yytype_uint16;
     265             : #else
     266             : typedef int yytype_uint16;
     267             : #endif
     268             : 
     269             : #ifndef YYPTRDIFF_T
     270             : # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
     271             : #  define YYPTRDIFF_T __PTRDIFF_TYPE__
     272             : #  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
     273             : # elif defined PTRDIFF_MAX
     274             : #  ifndef ptrdiff_t
     275             : #   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
     276             : #  endif
     277             : #  define YYPTRDIFF_T ptrdiff_t
     278             : #  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
     279             : # else
     280             : #  define YYPTRDIFF_T long
     281             : #  define YYPTRDIFF_MAXIMUM LONG_MAX
     282             : # endif
     283             : #endif
     284             : 
     285             : #ifndef YYSIZE_T
     286             : # ifdef __SIZE_TYPE__
     287             : #  define YYSIZE_T __SIZE_TYPE__
     288             : # elif defined size_t
     289             : #  define YYSIZE_T size_t
     290             : # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
     291             : #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
     292             : #  define YYSIZE_T size_t
     293             : # else
     294             : #  define YYSIZE_T unsigned
     295             : # endif
     296             : #endif
     297             : 
     298             : #define YYSIZE_MAXIMUM                                  \
     299             :   YY_CAST (YYPTRDIFF_T,                                 \
     300             :            (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
     301             :             ? YYPTRDIFF_MAXIMUM                         \
     302             :             : YY_CAST (YYSIZE_T, -1)))
     303             : 
     304             : #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
     305             : 
     306             : 
     307             : /* Stored state numbers (used for stacks). */
     308             : typedef yytype_int8 yy_state_t;
     309             : 
     310             : /* State numbers in computations.  */
     311             : typedef int yy_state_fast_t;
     312             : 
     313             : #ifndef YY_
     314             : # if defined YYENABLE_NLS && YYENABLE_NLS
     315             : #  if ENABLE_NLS
     316             : #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
     317             : #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
     318             : #  endif
     319             : # endif
     320             : # ifndef YY_
     321             : #  define YY_(Msgid) Msgid
     322             : # endif
     323             : #endif
     324             : 
     325             : 
     326             : #ifndef YY_ATTRIBUTE_PURE
     327             : # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
     328             : #  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
     329             : # else
     330             : #  define YY_ATTRIBUTE_PURE
     331             : # endif
     332             : #endif
     333             : 
     334             : #ifndef YY_ATTRIBUTE_UNUSED
     335             : # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
     336             : #  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
     337             : # else
     338             : #  define YY_ATTRIBUTE_UNUSED
     339             : # endif
     340             : #endif
     341             : 
     342             : /* Suppress unused-variable warnings by "using" E.  */
     343             : #if ! defined lint || defined __GNUC__
     344             : # define YY_USE(E) ((void) (E))
     345             : #else
     346             : # define YY_USE(E) /* empty */
     347             : #endif
     348             : 
     349             : #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
     350             : /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
     351             : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                            \
     352             :     _Pragma ("GCC diagnostic push")                                     \
     353             :     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
     354             :     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
     355             : # define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
     356             :     _Pragma ("GCC diagnostic pop")
     357             : #else
     358             : # define YY_INITIAL_VALUE(Value) Value
     359             : #endif
     360             : #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
     361             : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
     362             : # define YY_IGNORE_MAYBE_UNINITIALIZED_END
     363             : #endif
     364             : #ifndef YY_INITIAL_VALUE
     365             : # define YY_INITIAL_VALUE(Value) /* Nothing. */
     366             : #endif
     367             : 
     368             : #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
     369             : # define YY_IGNORE_USELESS_CAST_BEGIN                          \
     370             :     _Pragma ("GCC diagnostic push")                            \
     371             :     _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
     372             : # define YY_IGNORE_USELESS_CAST_END            \
     373             :     _Pragma ("GCC diagnostic pop")
     374             : #endif
     375             : #ifndef YY_IGNORE_USELESS_CAST_BEGIN
     376             : # define YY_IGNORE_USELESS_CAST_BEGIN
     377             : # define YY_IGNORE_USELESS_CAST_END
     378             : #endif
     379             : 
     380             : 
     381             : #define YY_ASSERT(E) ((void) (0 && (E)))
     382             : 
     383             : #if !defined yyoverflow
     384             : 
     385             : /* The parser invokes alloca or malloc; define the necessary symbols.  */
     386             : 
     387             : # ifdef YYSTACK_USE_ALLOCA
     388             : #  if YYSTACK_USE_ALLOCA
     389             : #   ifdef __GNUC__
     390             : #    define YYSTACK_ALLOC __builtin_alloca
     391             : #   elif defined __BUILTIN_VA_ARG_INCR
     392             : #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
     393             : #   elif defined _AIX
     394             : #    define YYSTACK_ALLOC __alloca
     395             : #   elif defined _MSC_VER
     396             : #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
     397             : #    define alloca _alloca
     398             : #   else
     399             : #    define YYSTACK_ALLOC alloca
     400             : #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
     401             : #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
     402             :       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
     403             : #     ifndef EXIT_SUCCESS
     404             : #      define EXIT_SUCCESS 0
     405             : #     endif
     406             : #    endif
     407             : #   endif
     408             : #  endif
     409             : # endif
     410             : 
     411             : # ifdef YYSTACK_ALLOC
     412             :    /* Pacify GCC's 'empty if-body' warning.  */
     413             : #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
     414             : #  ifndef YYSTACK_ALLOC_MAXIMUM
     415             :     /* The OS might guarantee only one guard page at the bottom of the stack,
     416             :        and a page size can be as small as 4096 bytes.  So we cannot safely
     417             :        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
     418             :        to allow for a few compiler-allocated temporary stack slots.  */
     419             : #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
     420             : #  endif
     421             : # else
     422             : #  define YYSTACK_ALLOC YYMALLOC
     423             : #  define YYSTACK_FREE YYFREE
     424             : #  ifndef YYSTACK_ALLOC_MAXIMUM
     425             : #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
     426             : #  endif
     427             : #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
     428             :        && ! ((defined YYMALLOC || defined malloc) \
     429             :              && (defined YYFREE || defined free)))
     430             : #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
     431             : #   ifndef EXIT_SUCCESS
     432             : #    define EXIT_SUCCESS 0
     433             : #   endif
     434             : #  endif
     435             : #  ifndef YYMALLOC
     436             : #   define YYMALLOC malloc
     437             : #   if ! defined malloc && ! defined EXIT_SUCCESS
     438             : void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
     439             : #   endif
     440             : #  endif
     441             : #  ifndef YYFREE
     442             : #   define YYFREE free
     443             : #   if ! defined free && ! defined EXIT_SUCCESS
     444             : void free (void *); /* INFRINGES ON USER NAME SPACE */
     445             : #   endif
     446             : #  endif
     447             : # endif
     448             : #endif /* !defined yyoverflow */
     449             : 
     450             : #if (! defined yyoverflow \
     451             :      && (! defined __cplusplus \
     452             :          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
     453             : 
     454             : /* A type that is properly aligned for any stack member.  */
     455             : union yyalloc
     456             : {
     457             :   yy_state_t yyss_alloc;
     458             :   YYSTYPE yyvs_alloc;
     459             : };
     460             : 
     461             : /* The size of the maximum gap between one aligned stack and the next.  */
     462             : # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
     463             : 
     464             : /* The size of an array large to enough to hold all stacks, each with
     465             :    N elements.  */
     466             : # define YYSTACK_BYTES(N) \
     467             :      ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
     468             :       + YYSTACK_GAP_MAXIMUM)
     469             : 
     470             : # define YYCOPY_NEEDED 1
     471             : 
     472             : /* Relocate STACK from its old location to the new one.  The
     473             :    local variables YYSIZE and YYSTACKSIZE give the old and new number of
     474             :    elements in the stack, and YYPTR gives the new location of the
     475             :    stack.  Advance YYPTR to a properly aligned location for the next
     476             :    stack.  */
     477             : # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
     478             :     do                                                                  \
     479             :       {                                                                 \
     480             :         YYPTRDIFF_T yynewbytes;                                         \
     481             :         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
     482             :         Stack = &yyptr->Stack_alloc;                                    \
     483             :         yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
     484             :         yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
     485             :       }                                                                 \
     486             :     while (0)
     487             : 
     488             : #endif
     489             : 
     490             : #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
     491             : /* Copy COUNT objects from SRC to DST.  The source and destination do
     492             :    not overlap.  */
     493             : # ifndef YYCOPY
     494             : #  if defined __GNUC__ && 1 < __GNUC__
     495             : #   define YYCOPY(Dst, Src, Count) \
     496             :       __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
     497             : #  else
     498             : #   define YYCOPY(Dst, Src, Count)              \
     499             :       do                                        \
     500             :         {                                       \
     501             :           YYPTRDIFF_T yyi;                      \
     502             :           for (yyi = 0; yyi < (Count); yyi++)   \
     503             :             (Dst)[yyi] = (Src)[yyi];            \
     504             :         }                                       \
     505             :       while (0)
     506             : #  endif
     507             : # endif
     508             : #endif /* !YYCOPY_NEEDED */
     509             : 
     510             : /* YYFINAL -- State number of the termination state.  */
     511             : #define YYFINAL  25
     512             : /* YYLAST -- Last index in YYTABLE.  */
     513             : #define YYLAST   320
     514             : 
     515             : /* YYNTOKENS -- Number of terminals.  */
     516             : #define YYNTOKENS  42
     517             : /* YYNNTS -- Number of nonterminals.  */
     518             : #define YYNNTS  7
     519             : /* YYNRULES -- Number of rules.  */
     520             : #define YYNRULES  47
     521             : /* YYNSTATES -- Number of states.  */
     522             : #define YYNSTATES  88
     523             : 
     524             : /* YYMAXUTOK -- Last valid token kind.  */
     525             : #define YYMAXUTOK   281
     526             : 
     527             : 
     528             : /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
     529             :    as returned by yylex, with out-of-bounds checking.  */
     530             : #define YYTRANSLATE(YYX)                                \
     531             :   (0 <= (YYX) && (YYX) <= YYMAXUTOK                     \
     532             :    ? YY_CAST (yysymbol_kind_t, yytranslate[YYX])        \
     533             :    : YYSYMBOL_YYUNDEF)
     534             : 
     535             : /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
     536             :    as returned by yylex.  */
     537             : static const yytype_int8 yytranslate[] =
     538             : {
     539             :        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     540             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     541             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     542             :        2,     2,     2,     2,     2,    30,     2,    37,    31,     2,
     543             :       40,    41,    35,    33,    39,    34,     2,    36,     2,     2,
     544             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     545             :       26,    28,    27,     2,     2,     2,     2,     2,     2,     2,
     546             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     547             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     548             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     549             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     550             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     551             :        2,     2,     2,     2,    29,     2,    32,     2,     2,     2,
     552             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     553             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     554             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     555             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     556             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     557             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     558             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     559             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     560             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     561             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     562             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     563             :        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     564             :        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
     565             :        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
     566             :       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
     567             :       25,    38
     568             : };
     569             : 
     570             : #if YYDEBUG
     571             :   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
     572             : static const yytype_uint8 yyrline[] =
     573             : {
     574             :        0,    83,    83,    88,    89,    90,    93,    94,    96,    99,
     575             :      102,   104,   105,   106,   107,   108,   109,   110,   111,   112,
     576             :      113,   114,   115,   116,   117,   118,   119,   120,   121,   122,
     577             :      124,   125,   129,   130,   135,   139,   145,   146,   147,   148,
     578             :      150,   151,   152,   156,   157,   160,   161,   163
     579             : };
     580             : #endif
     581             : 
     582             : /** Accessing symbol of state STATE.  */
     583             : #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
     584             : 
     585             : #if YYDEBUG || 0
     586             : /* The user-facing name of the symbol whose (internal) number is
     587             :    YYSYMBOL.  No bounds checking.  */
     588             : static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
     589             : 
     590             : /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
     591             :    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
     592             : static const char *const yytname[] =
     593             : {
     594             :   "\"end of file\"", "error", "\"invalid token\"", "NULL_CONST",
     595             :   "INTEGER_CONST", "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST",
     596             :   "BOOLEAN_CONST", "VARIABLE", "FUNCTION", "AND_OP", "OR_OP", "NOT_OP",
     597             :   "NE_OP", "LE_OP", "GE_OP", "LS_OP", "RS_OP", "IS_OP", "CASE_KW",
     598             :   "WHEN_KW", "THEN_KW", "ELSE_KW", "END_KW", "ISNULL_OP", "NOTNULL_OP",
     599             :   "'<'", "'>'", "'='", "'|'", "'#'", "'&'", "'~'", "'+'", "'-'", "'*'",
     600             :   "'/'", "'%'", "UNARY", "','", "'('", "')'", "$accept", "result", "elist",
     601             :   "expr", "when_then_list", "case_control", "function", YY_NULLPTR
     602             : };
     603             : 
     604             : static const char *
     605             : yysymbol_name (yysymbol_kind_t yysymbol)
     606             : {
     607             :   return yytname[yysymbol];
     608             : }
     609             : #endif
     610             : 
     611             : #ifdef YYPRINT
     612             : /* YYTOKNUM[NUM] -- (External) token number corresponding to the
     613             :    (internal) symbol number NUM (which must be that of a token).  */
     614             : static const yytype_int16 yytoknum[] =
     615             : {
     616             :        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
     617             :      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
     618             :      275,   276,   277,   278,   279,   280,    60,    62,    61,   124,
     619             :       35,    38,   126,    43,    45,    42,    47,    37,   281,    44,
     620             :       40,    41
     621             : };
     622             : #endif
     623             : 
     624             : #define YYPACT_NINF (-33)
     625             : 
     626             : #define yypact_value_is_default(Yyn) \
     627             :   ((Yyn) == YYPACT_NINF)
     628             : 
     629             : #define YYTABLE_NINF (-1)
     630             : 
     631             : #define yytable_value_is_error(Yyn) \
     632             :   ((Yyn) == YYTABLE_NINF)
     633             : 
     634             :   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
     635             :      STATE-NUM.  */
     636             : static const yytype_int16 yypact[] =
     637             : {
     638             :       64,   -33,   -33,   -33,   -33,   -33,   -33,    64,   -19,    64,
     639             :       64,    46,    64,    13,   205,   -33,   -22,   258,    64,    -6,
     640             :       11,   -33,   -33,   -33,    92,   -33,    64,    64,    64,    64,
     641             :       64,    64,    64,     3,   -33,   -33,    64,    64,    64,    64,
     642             :       64,    64,    64,    64,    64,    64,    64,    64,   121,    64,
     643             :       64,   -33,   -33,   258,   233,   283,   283,   283,    11,    11,
     644             :      -33,   -33,     5,   283,   283,   283,    11,    11,    11,    -9,
     645             :       -9,   -33,   -33,   -33,   -32,   205,    64,   149,   177,   -33,
     646             :      -33,    64,   -33,   205,    64,   -33,   205,   205
     647             : };
     648             : 
     649             :   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
     650             :      Performed when YYTABLE does not specify something else to do.  Zero
     651             :      means the default is an error.  */
     652             : static const yytype_int8 yydefact[] =
     653             : {
     654             :        0,    36,    38,    39,    37,    40,    47,     0,     0,     0,
     655             :        0,     0,     0,     0,     2,    42,     0,    11,     0,     0,
     656             :       10,     7,     9,     8,     0,     1,     0,     0,     0,     0,
     657             :        0,     0,     0,     0,    30,    31,     0,     0,     0,     0,
     658             :        0,     0,     0,     0,     0,     0,     0,     3,     0,     0,
     659             :        0,    45,     6,    28,    29,    22,    18,    20,    26,    27,
     660             :       32,    34,     0,    17,    19,    21,    24,    25,    23,    12,
     661             :       13,    14,    15,    16,     0,     4,     0,     0,     0,    33,
     662             :       35,     0,    41,    44,     0,    46,     5,    43
     663             : };
     664             : 
     665             :   /* YYPGOTO[NTERM-NUM].  */
     666             : static const yytype_int8 yypgoto[] =
     667             : {
     668             :      -33,   -33,   -33,    -7,   -33,   -33,   -33
     669             : };
     670             : 
     671             :   /* YYDEFGOTO[NTERM-NUM].  */
     672             : static const yytype_int8 yydefgoto[] =
     673             : {
     674             :        0,    13,    74,    14,    19,    15,    16
     675             : };
     676             : 
     677             :   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
     678             :      positive, shift that token.  If negative, reduce the rule whose
     679             :      number is the opposite.  If YYTABLE_NINF, syntax error.  */
     680             : static const yytype_int8 yytable[] =
     681             : {
     682             :       17,    18,    20,    21,    23,    24,    60,    81,    79,    82,
     683             :       61,    48,    80,    25,    49,    62,    50,    51,    47,    53,
     684             :       54,    55,    56,    57,    58,    59,    44,    45,    46,    63,
     685             :       64,    65,    66,    67,    68,    69,    70,    71,    72,    73,
     686             :       75,     0,    77,    78,    42,    43,    44,    45,    46,     1,
     687             :        2,    22,     3,     4,     5,     6,     0,     0,     7,     0,
     688             :        0,     0,     0,     0,     0,     8,     0,     1,     2,    83,
     689             :        3,     4,     5,     6,    86,     0,     7,    87,     9,    10,
     690             :       11,     0,     0,     8,     0,     0,    12,     0,     0,     0,
     691             :        0,     0,     0,     0,     0,     0,     9,    10,    11,     0,
     692             :        0,     0,    26,    27,    12,    28,    29,    30,    31,    32,
     693             :       33,     0,     0,     0,     0,     0,    34,    35,    36,    37,
     694             :       38,    39,    40,    41,     0,    42,    43,    44,    45,    46,
     695             :        0,    26,    27,    52,    28,    29,    30,    31,    32,    33,
     696             :        0,     0,    76,     0,     0,    34,    35,    36,    37,    38,
     697             :       39,    40,    41,     0,    42,    43,    44,    45,    46,    26,
     698             :       27,     0,    28,    29,    30,    31,    32,    33,     0,     0,
     699             :       84,     0,     0,    34,    35,    36,    37,    38,    39,    40,
     700             :       41,     0,    42,    43,    44,    45,    46,    26,    27,     0,
     701             :       28,    29,    30,    31,    32,    33,     0,     0,     0,     0,
     702             :       85,    34,    35,    36,    37,    38,    39,    40,    41,     0,
     703             :       42,    43,    44,    45,    46,    26,    27,     0,    28,    29,
     704             :       30,    31,    32,    33,     0,     0,     0,     0,     0,    34,
     705             :       35,    36,    37,    38,    39,    40,    41,     0,    42,    43,
     706             :       44,    45,    46,    26,     0,     0,    28,    29,    30,    31,
     707             :       32,    33,     0,     0,     0,     0,     0,    34,    35,    36,
     708             :       37,    38,    39,    40,    41,     0,    42,    43,    44,    45,
     709             :       46,    28,    29,    30,    31,    32,    33,     0,     0,     0,
     710             :        0,     0,    34,    35,    36,    37,    38,    39,    40,    41,
     711             :        0,    42,    43,    44,    45,    46,    -1,    -1,    -1,    31,
     712             :       32,     0,     0,     0,     0,     0,     0,     0,     0,    -1,
     713             :       -1,    -1,    39,    40,    41,     0,    42,    43,    44,    45,
     714             :       46
     715             : };
     716             : 
     717             : static const yytype_int8 yycheck[] =
     718             : {
     719             :        7,    20,     9,    10,    11,    12,     3,    39,     3,    41,
     720             :        7,    18,     7,     0,    20,    12,    22,    23,    40,    26,
     721             :       27,    28,    29,    30,    31,    32,    35,    36,    37,    36,
     722             :       37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
     723             :       47,    -1,    49,    50,    33,    34,    35,    36,    37,     3,
     724             :        4,     5,     6,     7,     8,     9,    -1,    -1,    12,    -1,
     725             :       -1,    -1,    -1,    -1,    -1,    19,    -1,     3,     4,    76,
     726             :        6,     7,     8,     9,    81,    -1,    12,    84,    32,    33,
     727             :       34,    -1,    -1,    19,    -1,    -1,    40,    -1,    -1,    -1,
     728             :       -1,    -1,    -1,    -1,    -1,    -1,    32,    33,    34,    -1,
     729             :       -1,    -1,    10,    11,    40,    13,    14,    15,    16,    17,
     730             :       18,    -1,    -1,    -1,    -1,    -1,    24,    25,    26,    27,
     731             :       28,    29,    30,    31,    -1,    33,    34,    35,    36,    37,
     732             :       -1,    10,    11,    41,    13,    14,    15,    16,    17,    18,
     733             :       -1,    -1,    21,    -1,    -1,    24,    25,    26,    27,    28,
     734             :       29,    30,    31,    -1,    33,    34,    35,    36,    37,    10,
     735             :       11,    -1,    13,    14,    15,    16,    17,    18,    -1,    -1,
     736             :       21,    -1,    -1,    24,    25,    26,    27,    28,    29,    30,
     737             :       31,    -1,    33,    34,    35,    36,    37,    10,    11,    -1,
     738             :       13,    14,    15,    16,    17,    18,    -1,    -1,    -1,    -1,
     739             :       23,    24,    25,    26,    27,    28,    29,    30,    31,    -1,
     740             :       33,    34,    35,    36,    37,    10,    11,    -1,    13,    14,
     741             :       15,    16,    17,    18,    -1,    -1,    -1,    -1,    -1,    24,
     742             :       25,    26,    27,    28,    29,    30,    31,    -1,    33,    34,
     743             :       35,    36,    37,    10,    -1,    -1,    13,    14,    15,    16,
     744             :       17,    18,    -1,    -1,    -1,    -1,    -1,    24,    25,    26,
     745             :       27,    28,    29,    30,    31,    -1,    33,    34,    35,    36,
     746             :       37,    13,    14,    15,    16,    17,    18,    -1,    -1,    -1,
     747             :       -1,    -1,    24,    25,    26,    27,    28,    29,    30,    31,
     748             :       -1,    33,    34,    35,    36,    37,    13,    14,    15,    16,
     749             :       17,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    26,
     750             :       27,    28,    29,    30,    31,    -1,    33,    34,    35,    36,
     751             :       37
     752             : };
     753             : 
     754             :   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
     755             :      symbol of state STATE-NUM.  */
     756             : static const yytype_int8 yystos[] =
     757             : {
     758             :        0,     3,     4,     6,     7,     8,     9,    12,    19,    32,
     759             :       33,    34,    40,    43,    45,    47,    48,    45,    20,    46,
     760             :       45,    45,     5,    45,    45,     0,    10,    11,    13,    14,
     761             :       15,    16,    17,    18,    24,    25,    26,    27,    28,    29,
     762             :       30,    31,    33,    34,    35,    36,    37,    40,    45,    20,
     763             :       22,    23,    41,    45,    45,    45,    45,    45,    45,    45,
     764             :        3,     7,    12,    45,    45,    45,    45,    45,    45,    45,
     765             :       45,    45,    45,    45,    44,    45,    21,    45,    45,     3,
     766             :        7,    39,    41,    45,    21,    23,    45,    45
     767             : };
     768             : 
     769             :   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
     770             : static const yytype_int8 yyr1[] =
     771             : {
     772             :        0,    42,    43,    44,    44,    44,    45,    45,    45,    45,
     773             :       45,    45,    45,    45,    45,    45,    45,    45,    45,    45,
     774             :       45,    45,    45,    45,    45,    45,    45,    45,    45,    45,
     775             :       45,    45,    45,    45,    45,    45,    45,    45,    45,    45,
     776             :       45,    45,    45,    46,    46,    47,    47,    48
     777             : };
     778             : 
     779             :   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
     780             : static const yytype_int8 yyr2[] =
     781             : {
     782             :        0,     2,     1,     0,     1,     3,     3,     2,     2,     2,
     783             :        2,     2,     3,     3,     3,     3,     3,     3,     3,     3,
     784             :        3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
     785             :        2,     2,     3,     4,     3,     4,     1,     1,     1,     1,
     786             :        1,     4,     1,     5,     4,     3,     5,     1
     787             : };
     788             : 
     789             : 
     790             : enum { YYENOMEM = -2 };
     791             : 
     792             : #define yyerrok         (yyerrstatus = 0)
     793             : #define yyclearin       (yychar = YYEMPTY)
     794             : 
     795             : #define YYACCEPT        goto yyacceptlab
     796             : #define YYABORT         goto yyabortlab
     797             : #define YYERROR         goto yyerrorlab
     798             : 
     799             : 
     800             : #define YYRECOVERING()  (!!yyerrstatus)
     801             : 
     802             : #define YYBACKUP(Token, Value)                                    \
     803             :   do                                                              \
     804             :     if (yychar == YYEMPTY)                                        \
     805             :       {                                                           \
     806             :         yychar = (Token);                                         \
     807             :         yylval = (Value);                                         \
     808             :         YYPOPSTACK (yylen);                                       \
     809             :         yystate = *yyssp;                                         \
     810             :         goto yybackup;                                            \
     811             :       }                                                           \
     812             :     else                                                          \
     813             :       {                                                           \
     814             :         yyerror (yyscanner, YY_("syntax error: cannot back up")); \
     815             :         YYERROR;                                                  \
     816             :       }                                                           \
     817             :   while (0)
     818             : 
     819             : /* Backward compatibility with an undocumented macro.
     820             :    Use YYerror or YYUNDEF. */
     821             : #define YYERRCODE YYUNDEF
     822             : 
     823             : 
     824             : /* Enable debugging if requested.  */
     825             : #if YYDEBUG
     826             : 
     827             : # ifndef YYFPRINTF
     828             : #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
     829             : #  define YYFPRINTF fprintf
     830             : # endif
     831             : 
     832             : # define YYDPRINTF(Args)                        \
     833             : do {                                            \
     834             :   if (yydebug)                                  \
     835             :     YYFPRINTF Args;                             \
     836             : } while (0)
     837             : 
     838             : /* This macro is provided for backward compatibility. */
     839             : # ifndef YY_LOCATION_PRINT
     840             : #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
     841             : # endif
     842             : 
     843             : 
     844             : # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)                    \
     845             : do {                                                                      \
     846             :   if (yydebug)                                                            \
     847             :     {                                                                     \
     848             :       YYFPRINTF (stderr, "%s ", Title);                                   \
     849             :       yy_symbol_print (stderr,                                            \
     850             :                   Kind, Value, yyscanner); \
     851             :       YYFPRINTF (stderr, "\n");                                           \
     852             :     }                                                                     \
     853             : } while (0)
     854             : 
     855             : 
     856             : /*-----------------------------------.
     857             : | Print this symbol's value on YYO.  |
     858             : `-----------------------------------*/
     859             : 
     860             : static void
     861             : yy_symbol_value_print (FILE *yyo,
     862             :                        yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
     863             : {
     864             :   FILE *yyoutput = yyo;
     865             :   YY_USE (yyoutput);
     866             :   YY_USE (yyscanner);
     867             :   if (!yyvaluep)
     868             :     return;
     869             : # ifdef YYPRINT
     870             :   if (yykind < YYNTOKENS)
     871             :     YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
     872             : # endif
     873             :   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
     874             :   YY_USE (yykind);
     875             :   YY_IGNORE_MAYBE_UNINITIALIZED_END
     876             : }
     877             : 
     878             : 
     879             : /*---------------------------.
     880             : | Print this symbol on YYO.  |
     881             : `---------------------------*/
     882             : 
     883             : static void
     884             : yy_symbol_print (FILE *yyo,
     885             :                  yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
     886             : {
     887             :   YYFPRINTF (yyo, "%s %s (",
     888             :              yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
     889             : 
     890             :   yy_symbol_value_print (yyo, yykind, yyvaluep, yyscanner);
     891             :   YYFPRINTF (yyo, ")");
     892             : }
     893             : 
     894             : /*------------------------------------------------------------------.
     895             : | yy_stack_print -- Print the state stack from its BOTTOM up to its |
     896             : | TOP (included).                                                   |
     897             : `------------------------------------------------------------------*/
     898             : 
     899             : static void
     900             : yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
     901             : {
     902             :   YYFPRINTF (stderr, "Stack now");
     903             :   for (; yybottom <= yytop; yybottom++)
     904             :     {
     905             :       int yybot = *yybottom;
     906             :       YYFPRINTF (stderr, " %d", yybot);
     907             :     }
     908             :   YYFPRINTF (stderr, "\n");
     909             : }
     910             : 
     911             : # define YY_STACK_PRINT(Bottom, Top)                            \
     912             : do {                                                            \
     913             :   if (yydebug)                                                  \
     914             :     yy_stack_print ((Bottom), (Top));                           \
     915             : } while (0)
     916             : 
     917             : 
     918             : /*------------------------------------------------.
     919             : | Report that the YYRULE is going to be reduced.  |
     920             : `------------------------------------------------*/
     921             : 
     922             : static void
     923             : yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
     924             :                  int yyrule, yyscan_t yyscanner)
     925             : {
     926             :   int yylno = yyrline[yyrule];
     927             :   int yynrhs = yyr2[yyrule];
     928             :   int yyi;
     929             :   YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
     930             :              yyrule - 1, yylno);
     931             :   /* The symbols being reduced.  */
     932             :   for (yyi = 0; yyi < yynrhs; yyi++)
     933             :     {
     934             :       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
     935             :       yy_symbol_print (stderr,
     936             :                        YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
     937             :                        &yyvsp[(yyi + 1) - (yynrhs)], yyscanner);
     938             :       YYFPRINTF (stderr, "\n");
     939             :     }
     940             : }
     941             : 
     942             : # define YY_REDUCE_PRINT(Rule)          \
     943             : do {                                    \
     944             :   if (yydebug)                          \
     945             :     yy_reduce_print (yyssp, yyvsp, Rule, yyscanner); \
     946             : } while (0)
     947             : 
     948             : /* Nonzero means print parse trace.  It is left uninitialized so that
     949             :    multiple parsers can coexist.  */
     950             : int yydebug;
     951             : #else /* !YYDEBUG */
     952             : # define YYDPRINTF(Args) ((void) 0)
     953             : # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
     954             : # define YY_STACK_PRINT(Bottom, Top)
     955             : # define YY_REDUCE_PRINT(Rule)
     956             : #endif /* !YYDEBUG */
     957             : 
     958             : 
     959             : /* YYINITDEPTH -- initial size of the parser's stacks.  */
     960             : #ifndef YYINITDEPTH
     961             : # define YYINITDEPTH 200
     962             : #endif
     963             : 
     964             : /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
     965             :    if the built-in stack extension method is used).
     966             : 
     967             :    Do not make this value too large; the results are undefined if
     968             :    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
     969             :    evaluated with infinite-precision integer arithmetic.  */
     970             : 
     971             : #ifndef YYMAXDEPTH
     972             : # define YYMAXDEPTH 10000
     973             : #endif
     974             : 
     975             : 
     976             : 
     977             : 
     978             : 
     979             : 
     980             : /*-----------------------------------------------.
     981             : | Release the memory associated to this symbol.  |
     982             : `-----------------------------------------------*/
     983             : 
     984             : static void
     985        1468 : yydestruct (const char *yymsg,
     986             :             yysymbol_kind_t yykind, YYSTYPE *yyvaluep, yyscan_t yyscanner)
     987             : {
     988             :   YY_USE (yyvaluep);
     989             :   YY_USE (yyscanner);
     990        1468 :   if (!yymsg)
     991           0 :     yymsg = "Deleting";
     992             :   YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
     993             : 
     994             :   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
     995             :   YY_USE (yykind);
     996             :   YY_IGNORE_MAYBE_UNINITIALIZED_END
     997        1468 : }
     998             : 
     999             : 
    1000             : 
    1001             : 
    1002             : 
    1003             : 
    1004             : /*----------.
    1005             : | yyparse.  |
    1006             : `----------*/
    1007             : 
    1008             : int
    1009         772 : yyparse (yyscan_t yyscanner)
    1010             : {
    1011             : /* Lookahead token kind.  */
    1012             : int yychar;
    1013             : 
    1014             : 
    1015             : /* The semantic value of the lookahead symbol.  */
    1016             : /* Default value used for initialization, for pacifying older GCCs
    1017             :    or non-GCC compilers.  */
    1018             : YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
    1019             : YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
    1020             : 
    1021             :     /* Number of syntax errors so far.  */
    1022         772 :     int yynerrs = 0;
    1023             : 
    1024         772 :     yy_state_fast_t yystate = 0;
    1025             :     /* Number of tokens to shift before error messages enabled.  */
    1026         772 :     int yyerrstatus = 0;
    1027             : 
    1028             :     /* Refer to the stacks through separate pointers, to allow yyoverflow
    1029             :        to reallocate them elsewhere.  */
    1030             : 
    1031             :     /* Their size.  */
    1032         772 :     YYPTRDIFF_T yystacksize = YYINITDEPTH;
    1033             : 
    1034             :     /* The state stack: array, bottom, top.  */
    1035             :     yy_state_t yyssa[YYINITDEPTH];
    1036         772 :     yy_state_t *yyss = yyssa;
    1037         772 :     yy_state_t *yyssp = yyss;
    1038             : 
    1039             :     /* The semantic value stack: array, bottom, top.  */
    1040             :     YYSTYPE yyvsa[YYINITDEPTH];
    1041         772 :     YYSTYPE *yyvs = yyvsa;
    1042         772 :     YYSTYPE *yyvsp = yyvs;
    1043             : 
    1044             :   int yyn;
    1045             :   /* The return value of yyparse.  */
    1046             :   int yyresult;
    1047             :   /* Lookahead symbol kind.  */
    1048         772 :   yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
    1049             :   /* The variables used to return semantic value and location from the
    1050             :      action routines.  */
    1051             :   YYSTYPE yyval;
    1052             : 
    1053             : 
    1054             : 
    1055             : #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
    1056             : 
    1057             :   /* The number of symbols on the RHS of the reduced rule.
    1058             :      Keep to zero when no symbol should be popped.  */
    1059         772 :   int yylen = 0;
    1060             : 
    1061             :   YYDPRINTF ((stderr, "Starting parse\n"));
    1062             : 
    1063         772 :   yychar = YYEMPTY; /* Cause a token to be read.  */
    1064         772 :   goto yysetstate;
    1065             : 
    1066             : 
    1067             : /*------------------------------------------------------------.
    1068             : | yynewstate -- push a new state, which is found in yystate.  |
    1069             : `------------------------------------------------------------*/
    1070       14706 : yynewstate:
    1071             :   /* In all cases, when you get here, the value and location stacks
    1072             :      have just been pushed.  So pushing a state here evens the stacks.  */
    1073       14706 :   yyssp++;
    1074             : 
    1075             : 
    1076             : /*--------------------------------------------------------------------.
    1077             : | yysetstate -- set current state (the top of the stack) to yystate.  |
    1078             : `--------------------------------------------------------------------*/
    1079       15478 : yysetstate:
    1080             :   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
    1081             :   YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
    1082             :   YY_IGNORE_USELESS_CAST_BEGIN
    1083       15478 :   *yyssp = YY_CAST (yy_state_t, yystate);
    1084             :   YY_IGNORE_USELESS_CAST_END
    1085             :   YY_STACK_PRINT (yyss, yyssp);
    1086             : 
    1087       15478 :   if (yyss + yystacksize - 1 <= yyssp)
    1088             : #if !defined yyoverflow && !defined YYSTACK_RELOCATE
    1089             :     goto yyexhaustedlab;
    1090             : #else
    1091             :     {
    1092             :       /* Get the current used size of the three stacks, in elements.  */
    1093           0 :       YYPTRDIFF_T yysize = yyssp - yyss + 1;
    1094             : 
    1095             : # if defined yyoverflow
    1096             :       {
    1097             :         /* Give user a chance to reallocate the stack.  Use copies of
    1098             :            these so that the &'s don't force the real ones into
    1099             :            memory.  */
    1100             :         yy_state_t *yyss1 = yyss;
    1101             :         YYSTYPE *yyvs1 = yyvs;
    1102             : 
    1103             :         /* Each stack pointer address is followed by the size of the
    1104             :            data in use in that stack, in bytes.  This used to be a
    1105             :            conditional around just the two extra args, but that might
    1106             :            be undefined if yyoverflow is a macro.  */
    1107             :         yyoverflow (YY_("memory exhausted"),
    1108             :                     &yyss1, yysize * YYSIZEOF (*yyssp),
    1109             :                     &yyvs1, yysize * YYSIZEOF (*yyvsp),
    1110             :                     &yystacksize);
    1111             :         yyss = yyss1;
    1112             :         yyvs = yyvs1;
    1113             :       }
    1114             : # else /* defined YYSTACK_RELOCATE */
    1115             :       /* Extend the stack our own way.  */
    1116           0 :       if (YYMAXDEPTH <= yystacksize)
    1117           0 :         goto yyexhaustedlab;
    1118           0 :       yystacksize *= 2;
    1119           0 :       if (YYMAXDEPTH < yystacksize)
    1120           0 :         yystacksize = YYMAXDEPTH;
    1121             : 
    1122             :       {
    1123           0 :         yy_state_t *yyss1 = yyss;
    1124             :         union yyalloc *yyptr =
    1125           0 :           YY_CAST (union yyalloc *,
    1126             :                    YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
    1127           0 :         if (! yyptr)
    1128           0 :           goto yyexhaustedlab;
    1129           0 :         YYSTACK_RELOCATE (yyss_alloc, yyss);
    1130           0 :         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
    1131             : #  undef YYSTACK_RELOCATE
    1132           0 :         if (yyss1 != yyssa)
    1133           0 :           YYSTACK_FREE (yyss1);
    1134             :       }
    1135             : # endif
    1136             : 
    1137           0 :       yyssp = yyss + yysize - 1;
    1138           0 :       yyvsp = yyvs + yysize - 1;
    1139             : 
    1140             :       YY_IGNORE_USELESS_CAST_BEGIN
    1141             :       YYDPRINTF ((stderr, "Stack size increased to %ld\n",
    1142             :                   YY_CAST (long, yystacksize)));
    1143             :       YY_IGNORE_USELESS_CAST_END
    1144             : 
    1145           0 :       if (yyss + yystacksize - 1 <= yyssp)
    1146           0 :         YYABORT;
    1147             :     }
    1148             : #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
    1149             : 
    1150       15478 :   if (yystate == YYFINAL)
    1151         734 :     YYACCEPT;
    1152             : 
    1153       14744 :   goto yybackup;
    1154             : 
    1155             : 
    1156             : /*-----------.
    1157             : | yybackup.  |
    1158             : `-----------*/
    1159       14744 : yybackup:
    1160             :   /* Do appropriate processing given the current state.  Read a
    1161             :      lookahead token if we need one and don't already have one.  */
    1162             : 
    1163             :   /* First try to decide what to do without reference to lookahead token.  */
    1164       14744 :   yyn = yypact[yystate];
    1165       14744 :   if (yypact_value_is_default (yyn))
    1166        4612 :     goto yydefault;
    1167             : 
    1168             :   /* Not known => get a lookahead token if don't already have one.  */
    1169             : 
    1170             :   /* YYCHAR is either empty, or end-of-input, or a valid lookahead.  */
    1171       10132 :   if (yychar == YYEMPTY)
    1172             :     {
    1173             :       YYDPRINTF ((stderr, "Reading a token\n"));
    1174        7476 :       yychar = yylex (&yylval, yyscanner);
    1175             :     }
    1176             : 
    1177       10124 :   if (yychar <= YYEOF)
    1178             :     {
    1179        1508 :       yychar = YYEOF;
    1180        1508 :       yytoken = YYSYMBOL_YYEOF;
    1181             :       YYDPRINTF ((stderr, "Now at end of input.\n"));
    1182             :     }
    1183        8616 :   else if (yychar == YYerror)
    1184             :     {
    1185             :       /* The scanner already issued an error message, process directly
    1186             :          to error recovery.  But do not keep the error token as
    1187             :          lookahead, it is too special and may lead us to an endless
    1188             :          loop in error recovery. */
    1189           0 :       yychar = YYUNDEF;
    1190           0 :       yytoken = YYSYMBOL_YYerror;
    1191           0 :       goto yyerrlab1;
    1192             :     }
    1193             :   else
    1194             :     {
    1195        8616 :       yytoken = YYTRANSLATE (yychar);
    1196             :       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
    1197             :     }
    1198             : 
    1199             :   /* If the proper action on seeing token YYTOKEN is to reduce or to
    1200             :      detect an error, take that action.  */
    1201       10124 :   yyn += yytoken;
    1202       10124 :   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
    1203        2668 :     goto yydefault;
    1204        7456 :   yyn = yytable[yyn];
    1205        7456 :   if (yyn <= 0)
    1206             :     {
    1207           0 :       if (yytable_value_is_error (yyn))
    1208           0 :         goto yyerrlab;
    1209           0 :       yyn = -yyn;
    1210           0 :       goto yyreduce;
    1211             :     }
    1212             : 
    1213             :   /* Count tokens shifted since error; after three, turn off error
    1214             :      status.  */
    1215        7456 :   if (yyerrstatus)
    1216           0 :     yyerrstatus--;
    1217             : 
    1218             :   /* Shift the lookahead token.  */
    1219             :   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
    1220        7456 :   yystate = yyn;
    1221             :   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
    1222        7456 :   *++yyvsp = yylval;
    1223             :   YY_IGNORE_MAYBE_UNINITIALIZED_END
    1224             : 
    1225             :   /* Discard the shifted token.  */
    1226        7456 :   yychar = YYEMPTY;
    1227        7456 :   goto yynewstate;
    1228             : 
    1229             : 
    1230             : /*-----------------------------------------------------------.
    1231             : | yydefault -- do the default action for the current state.  |
    1232             : `-----------------------------------------------------------*/
    1233        7280 : yydefault:
    1234        7280 :   yyn = yydefact[yystate];
    1235        7280 :   if (yyn == 0)
    1236          12 :     goto yyerrlab;
    1237        7268 :   goto yyreduce;
    1238             : 
    1239             : 
    1240             : /*-----------------------------.
    1241             : | yyreduce -- do a reduction.  |
    1242             : `-----------------------------*/
    1243        7268 : yyreduce:
    1244             :   /* yyn is the number of a rule to reduce with.  */
    1245        7268 :   yylen = yyr2[yyn];
    1246             : 
    1247             :   /* If YYLEN is nonzero, implement the default value of the action:
    1248             :      '$$ = $1'.
    1249             : 
    1250             :      Otherwise, the following line sets YYVAL to garbage.
    1251             :      This behavior is undocumented and Bison
    1252             :      users should not rely upon it.  Assigning to YYVAL
    1253             :      unconditionally makes the parser a bit smaller, and it avoids a
    1254             :      GCC warning that YYVAL may be used uninitialized.  */
    1255        7268 :   yyval = yyvsp[1-yylen];
    1256             : 
    1257             : 
    1258             :   YY_REDUCE_PRINT (yyn);
    1259        7268 :   switch (yyn)
    1260             :     {
    1261         734 :   case 2: /* result: expr  */
    1262             : #line 83 "exprparse.y"
    1263             :                                         {
    1264             :                                 expr_parse_result = (yyvsp[0].expr);
    1265             :                                 (void) yynerrs; /* suppress compiler warning */
    1266             :                             }
    1267             : #line 1268 "exprparse.c"
    1268         734 :     break;
    1269             : 
    1270          10 :   case 3: /* elist: %empty  */
    1271             : #line 88 "exprparse.y"
    1272             :                                                 { (yyval.elist) = NULL; }
    1273             : #line 1274 "exprparse.c"
    1274          10 :     break;
    1275             : 
    1276         786 :   case 4: /* elist: expr  */
    1277             : #line 89 "exprparse.y"
    1278             :                                                 { (yyval.elist) = make_elist((yyvsp[0].expr), NULL); }
    1279             : #line 1280 "exprparse.c"
    1280         786 :     break;
    1281             : 
    1282         686 :   case 5: /* elist: elist ',' expr  */
    1283             : #line 90 "exprparse.y"
    1284             :                                         { (yyval.elist) = make_elist((yyvsp[0].expr), (yyvsp[-2].elist)); }
    1285             : #line 1286 "exprparse.c"
    1286         686 :     break;
    1287             : 
    1288         104 :   case 6: /* expr: '(' expr ')'  */
    1289             : #line 93 "exprparse.y"
    1290             :                                         { (yyval.expr) = (yyvsp[-1].expr); }
    1291             : #line 1292 "exprparse.c"
    1292         104 :     break;
    1293             : 
    1294           4 :   case 7: /* expr: '+' expr  */
    1295             : #line 94 "exprparse.y"
    1296             :                                 { (yyval.expr) = (yyvsp[0].expr); }
    1297             : #line 1298 "exprparse.c"
    1298           4 :     break;
    1299             : 
    1300          92 :   case 8: /* expr: '-' expr  */
    1301             : #line 96 "exprparse.y"
    1302             :                                 { (yyval.expr) = make_op(yyscanner, "-",
    1303             :                                            make_integer_constant(0), (yyvsp[0].expr)); }
    1304             : #line 1305 "exprparse.c"
    1305          92 :     break;
    1306             : 
    1307           2 :   case 9: /* expr: '-' MAXINT_PLUS_ONE_CONST  */
    1308             : #line 100 "exprparse.y"
    1309             :                                                         { (yyval.expr) = make_integer_constant(PG_INT64_MIN); }
    1310             : #line 1311 "exprparse.c"
    1311           2 :     break;
    1312             : 
    1313           4 :   case 10: /* expr: '~' expr  */
    1314             : #line 102 "exprparse.y"
    1315             :                                                 { (yyval.expr) = make_op(yyscanner, "#",
    1316             :                                            make_integer_constant(~INT64CONST(0)), (yyvsp[0].expr)); }
    1317             : #line 1318 "exprparse.c"
    1318           4 :     break;
    1319             : 
    1320          24 :   case 11: /* expr: NOT_OP expr  */
    1321             : #line 104 "exprparse.y"
    1322             :                                         { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[0].expr)); }
    1323             : #line 1324 "exprparse.c"
    1324          24 :     break;
    1325             : 
    1326          96 :   case 12: /* expr: expr '+' expr  */
    1327             : #line 105 "exprparse.y"
    1328             :                                         { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1329             : #line 1330 "exprparse.c"
    1330          96 :     break;
    1331             : 
    1332          36 :   case 13: /* expr: expr '-' expr  */
    1333             : #line 106 "exprparse.y"
    1334             :                                         { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1335             : #line 1336 "exprparse.c"
    1336          36 :     break;
    1337             : 
    1338         408 :   case 14: /* expr: expr '*' expr  */
    1339             : #line 107 "exprparse.y"
    1340             :                                         { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1341             : #line 1342 "exprparse.c"
    1342         408 :     break;
    1343             : 
    1344          26 :   case 15: /* expr: expr '/' expr  */
    1345             : #line 108 "exprparse.y"
    1346             :                                         { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1347             : #line 1348 "exprparse.c"
    1348          26 :     break;
    1349             : 
    1350           4 :   case 16: /* expr: expr '%' expr  */
    1351             : #line 109 "exprparse.y"
    1352             :                                         { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1353             : #line 1354 "exprparse.c"
    1354           4 :     break;
    1355             : 
    1356          20 :   case 17: /* expr: expr '<' expr  */
    1357             : #line 110 "exprparse.y"
    1358             :                                         { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1359             : #line 1360 "exprparse.c"
    1360          20 :     break;
    1361             : 
    1362           8 :   case 18: /* expr: expr LE_OP expr  */
    1363             : #line 111 "exprparse.y"
    1364             :                                         { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1365             : #line 1366 "exprparse.c"
    1366           8 :     break;
    1367             : 
    1368          12 :   case 19: /* expr: expr '>' expr  */
    1369             : #line 112 "exprparse.y"
    1370             :                                         { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[0].expr), (yyvsp[-2].expr)); }
    1371             : #line 1372 "exprparse.c"
    1372          12 :     break;
    1373             : 
    1374           6 :   case 20: /* expr: expr GE_OP expr  */
    1375             : #line 113 "exprparse.y"
    1376             :                                         { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[0].expr), (yyvsp[-2].expr)); }
    1377             : #line 1378 "exprparse.c"
    1378           6 :     break;
    1379             : 
    1380          64 :   case 21: /* expr: expr '=' expr  */
    1381             : #line 114 "exprparse.y"
    1382             :                                         { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1383             : #line 1384 "exprparse.c"
    1384          64 :     break;
    1385             : 
    1386          16 :   case 22: /* expr: expr NE_OP expr  */
    1387             : #line 115 "exprparse.y"
    1388             :                                         { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1389             : #line 1390 "exprparse.c"
    1390          16 :     break;
    1391             : 
    1392           2 :   case 23: /* expr: expr '&' expr  */
    1393             : #line 116 "exprparse.y"
    1394             :                                         { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1395             : #line 1396 "exprparse.c"
    1396           2 :     break;
    1397             : 
    1398           4 :   case 24: /* expr: expr '|' expr  */
    1399             : #line 117 "exprparse.y"
    1400             :                                         { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1401             : #line 1402 "exprparse.c"
    1402           4 :     break;
    1403             : 
    1404           2 :   case 25: /* expr: expr '#' expr  */
    1405             : #line 118 "exprparse.y"
    1406             :                                         { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1407             : #line 1408 "exprparse.c"
    1408           2 :     break;
    1409             : 
    1410          14 :   case 26: /* expr: expr LS_OP expr  */
    1411             : #line 119 "exprparse.y"
    1412             :                                         { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1413             : #line 1414 "exprparse.c"
    1414          14 :     break;
    1415             : 
    1416           2 :   case 27: /* expr: expr RS_OP expr  */
    1417             : #line 120 "exprparse.y"
    1418             :                                         { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1419             : #line 1420 "exprparse.c"
    1420           2 :     break;
    1421             : 
    1422          88 :   case 28: /* expr: expr AND_OP expr  */
    1423             : #line 121 "exprparse.y"
    1424             :                                         { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1425             : #line 1426 "exprparse.c"
    1426          88 :     break;
    1427             : 
    1428          10 :   case 29: /* expr: expr OR_OP expr  */
    1429             : #line 122 "exprparse.y"
    1430             :                                         { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[-2].expr), (yyvsp[0].expr)); }
    1431             : #line 1432 "exprparse.c"
    1432          10 :     break;
    1433             : 
    1434           2 :   case 30: /* expr: expr ISNULL_OP  */
    1435             : #line 124 "exprparse.y"
    1436             :                                         { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[-1].expr), make_null_constant()); }
    1437             : #line 1438 "exprparse.c"
    1438           2 :     break;
    1439             : 
    1440           2 :   case 31: /* expr: expr NOTNULL_OP  */
    1441             : #line 125 "exprparse.y"
    1442             :                                         {
    1443             :                                 (yyval.expr) = make_uop(yyscanner, "!not",
    1444             :                                               make_op(yyscanner, "!is", (yyvsp[-1].expr), make_null_constant()));
    1445             :                             }
    1446             : #line 1447 "exprparse.c"
    1447           2 :     break;
    1448             : 
    1449           8 :   case 32: /* expr: expr IS_OP NULL_CONST  */
    1450             : #line 129 "exprparse.y"
    1451             :                                 { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[-2].expr), make_null_constant()); }
    1452             : #line 1453 "exprparse.c"
    1453           8 :     break;
    1454             : 
    1455           4 :   case 33: /* expr: expr IS_OP NOT_OP NULL_CONST  */
    1456             : #line 131 "exprparse.y"
    1457             :                                                         {
    1458             :                                 (yyval.expr) = make_uop(yyscanner, "!not",
    1459             :                                               make_op(yyscanner, "!is", (yyvsp[-3].expr), make_null_constant()));
    1460             :                             }
    1461             : #line 1462 "exprparse.c"
    1462           4 :     break;
    1463             : 
    1464           2 :   case 34: /* expr: expr IS_OP BOOLEAN_CONST  */
    1465             : #line 136 "exprparse.y"
    1466             :                                                         {
    1467             :                                 (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[-2].expr), make_boolean_constant((yyvsp[0].bval)));
    1468             :                             }
    1469             : #line 1470 "exprparse.c"
    1470           2 :     break;
    1471             : 
    1472           2 :   case 35: /* expr: expr IS_OP NOT_OP BOOLEAN_CONST  */
    1473             : #line 140 "exprparse.y"
    1474             :                                                         {
    1475             :                                 (yyval.expr) = make_uop(yyscanner, "!not",
    1476             :                                               make_op(yyscanner, "!is", (yyvsp[-3].expr), make_boolean_constant((yyvsp[0].bval))));
    1477             :                             }
    1478             : #line 1479 "exprparse.c"
    1479           2 :     break;
    1480             : 
    1481          12 :   case 36: /* expr: NULL_CONST  */
    1482             : #line 145 "exprparse.y"
    1483             :                                         { (yyval.expr) = make_null_constant(); }
    1484             : #line 1485 "exprparse.c"
    1485          12 :     break;
    1486             : 
    1487          40 :   case 37: /* expr: BOOLEAN_CONST  */
    1488             : #line 146 "exprparse.y"
    1489             :                                         { (yyval.expr) = make_boolean_constant((yyvsp[0].bval)); }
    1490             : #line 1491 "exprparse.c"
    1491          40 :     break;
    1492             : 
    1493        1588 :   case 38: /* expr: INTEGER_CONST  */
    1494             : #line 147 "exprparse.y"
    1495             :                                         { (yyval.expr) = make_integer_constant((yyvsp[0].ival)); }
    1496             : #line 1497 "exprparse.c"
    1497        1588 :     break;
    1498             : 
    1499         122 :   case 39: /* expr: DOUBLE_CONST  */
    1500             : #line 148 "exprparse.y"
    1501             :                                         { (yyval.expr) = make_double_constant((yyvsp[0].dval)); }
    1502             : #line 1503 "exprparse.c"
    1503         122 :     break;
    1504             : 
    1505         540 :   case 40: /* expr: VARIABLE  */
    1506             : #line 150 "exprparse.y"
    1507             :                                                 { (yyval.expr) = make_variable((yyvsp[0].str)); }
    1508             : #line 1509 "exprparse.c"
    1509         540 :     break;
    1510             : 
    1511         796 :   case 41: /* expr: function '(' elist ')'  */
    1512             : #line 151 "exprparse.y"
    1513             :                                  { (yyval.expr) = make_func(yyscanner, (yyvsp[-3].ival), (yyvsp[-1].elist)); }
    1514             : #line 1515 "exprparse.c"
    1515         780 :     break;
    1516             : 
    1517          28 :   case 42: /* expr: case_control  */
    1518             : #line 152 "exprparse.y"
    1519             :                                         { (yyval.expr) = (yyvsp[0].expr); }
    1520             : #line 1521 "exprparse.c"
    1521          28 :     break;
    1522             : 
    1523           4 :   case 43: /* when_then_list: when_then_list WHEN_KW expr THEN_KW expr  */
    1524             : #line 156 "exprparse.y"
    1525             :                                                    { (yyval.elist) = make_elist((yyvsp[0].expr), make_elist((yyvsp[-2].expr), (yyvsp[-4].elist))); }
    1526             : #line 1527 "exprparse.c"
    1527           4 :     break;
    1528             : 
    1529          28 :   case 44: /* when_then_list: WHEN_KW expr THEN_KW expr  */
    1530             : #line 157 "exprparse.y"
    1531             :                                     { (yyval.elist) = make_elist((yyvsp[0].expr), make_elist((yyvsp[-2].expr), NULL)); }
    1532             : #line 1533 "exprparse.c"
    1533          28 :     break;
    1534             : 
    1535           8 :   case 45: /* case_control: CASE_KW when_then_list END_KW  */
    1536             : #line 160 "exprparse.y"
    1537             :                                         { (yyval.expr) = make_case(yyscanner, (yyvsp[-1].elist), make_null_constant()); }
    1538             : #line 1539 "exprparse.c"
    1539           8 :     break;
    1540             : 
    1541          20 :   case 46: /* case_control: CASE_KW when_then_list ELSE_KW expr END_KW  */
    1542             : #line 161 "exprparse.y"
    1543             :                                                      { (yyval.expr) = make_case(yyscanner, (yyvsp[-3].elist), (yyvsp[-1].expr)); }
    1544             : #line 1545 "exprparse.c"
    1545          20 :     break;
    1546             : 
    1547         798 :   case 47: /* function: FUNCTION  */
    1548             : #line 163 "exprparse.y"
    1549             :                                         { (yyval.ival) = find_func(yyscanner, (yyvsp[0].str)); pg_free((yyvsp[0].str)); }
    1550             : #line 1551 "exprparse.c"
    1551         796 :     break;
    1552             : 
    1553             : 
    1554             : #line 1555 "exprparse.c"
    1555             : 
    1556           0 :       default: break;
    1557             :     }
    1558             :   /* User semantic actions sometimes alter yychar, and that requires
    1559             :      that yytoken be updated with the new translation.  We take the
    1560             :      approach of translating immediately before every use of yytoken.
    1561             :      One alternative is translating here after every semantic action,
    1562             :      but that translation would be missed if the semantic action invokes
    1563             :      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
    1564             :      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
    1565             :      incorrect destructor might then be invoked immediately.  In the
    1566             :      case of YYERROR or YYBACKUP, subsequent parser actions might lead
    1567             :      to an incorrect destructor call or verbose syntax error message
    1568             :      before the lookahead is translated.  */
    1569             :   YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
    1570             : 
    1571        7250 :   YYPOPSTACK (yylen);
    1572        7250 :   yylen = 0;
    1573             : 
    1574        7250 :   *++yyvsp = yyval;
    1575             : 
    1576             :   /* Now 'shift' the result of the reduction.  Determine what state
    1577             :      that goes to, based on the state we popped back to and the rule
    1578             :      number reduced by.  */
    1579             :   {
    1580        7250 :     const int yylhs = yyr1[yyn] - YYNTOKENS;
    1581        7250 :     const int yyi = yypgoto[yylhs] + *yyssp;
    1582        5042 :     yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
    1583        3400 :                ? yytable[yyi]
    1584       12292 :                : yydefgoto[yylhs]);
    1585             :   }
    1586             : 
    1587        7250 :   goto yynewstate;
    1588             : 
    1589             : 
    1590             : /*--------------------------------------.
    1591             : | yyerrlab -- here on detecting error.  |
    1592             : `--------------------------------------*/
    1593          12 : yyerrlab:
    1594             :   /* Make sure we have latest lookahead translation.  See comments at
    1595             :      user semantic actions for why this is necessary.  */
    1596          12 :   yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
    1597             :   /* If not already recovering from an error, report this error.  */
    1598          12 :   if (!yyerrstatus)
    1599             :     {
    1600          12 :       ++yynerrs;
    1601          12 :       yyerror (yyscanner, YY_("syntax error"));
    1602             :     }
    1603             : 
    1604           0 :   if (yyerrstatus == 3)
    1605             :     {
    1606             :       /* If just tried and failed to reuse lookahead token after an
    1607             :          error, discard it.  */
    1608             : 
    1609           0 :       if (yychar <= YYEOF)
    1610             :         {
    1611             :           /* Return failure if at end of input.  */
    1612           0 :           if (yychar == YYEOF)
    1613           0 :             YYABORT;
    1614             :         }
    1615             :       else
    1616             :         {
    1617           0 :           yydestruct ("Error: discarding",
    1618             :                       yytoken, &yylval, yyscanner);
    1619           0 :           yychar = YYEMPTY;
    1620             :         }
    1621             :     }
    1622             : 
    1623             :   /* Else will try to reuse lookahead token after shifting the error
    1624             :      token.  */
    1625           0 :   goto yyerrlab1;
    1626             : 
    1627             : 
    1628             : /*---------------------------------------------------.
    1629             : | yyerrorlab -- error raised explicitly by YYERROR.  |
    1630             : `---------------------------------------------------*/
    1631             : yyerrorlab:
    1632             :   /* Pacify compilers when the user code never invokes YYERROR and the
    1633             :      label yyerrorlab therefore never appears in user code.  */
    1634             :   if (0)
    1635             :     YYERROR;
    1636             : 
    1637             :   /* Do not reclaim the symbols of the rule whose action triggered
    1638             :      this YYERROR.  */
    1639             :   YYPOPSTACK (yylen);
    1640             :   yylen = 0;
    1641             :   YY_STACK_PRINT (yyss, yyssp);
    1642             :   yystate = *yyssp;
    1643             :   goto yyerrlab1;
    1644             : 
    1645             : 
    1646             : /*-------------------------------------------------------------.
    1647             : | yyerrlab1 -- common code for both syntax error and YYERROR.  |
    1648             : `-------------------------------------------------------------*/
    1649           0 : yyerrlab1:
    1650           0 :   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
    1651             : 
    1652             :   /* Pop stack until we find a state that shifts the error token.  */
    1653             :   for (;;)
    1654             :     {
    1655           0 :       yyn = yypact[yystate];
    1656           0 :       if (!yypact_value_is_default (yyn))
    1657             :         {
    1658           0 :           yyn += YYSYMBOL_YYerror;
    1659           0 :           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
    1660             :             {
    1661           0 :               yyn = yytable[yyn];
    1662           0 :               if (0 < yyn)
    1663           0 :                 break;
    1664             :             }
    1665             :         }
    1666             : 
    1667             :       /* Pop the current state because it cannot handle the error token.  */
    1668           0 :       if (yyssp == yyss)
    1669           0 :         YYABORT;
    1670             : 
    1671             : 
    1672           0 :       yydestruct ("Error: popping",
    1673           0 :                   YY_ACCESSING_SYMBOL (yystate), yyvsp, yyscanner);
    1674           0 :       YYPOPSTACK (1);
    1675           0 :       yystate = *yyssp;
    1676             :       YY_STACK_PRINT (yyss, yyssp);
    1677             :     }
    1678             : 
    1679             :   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
    1680           0 :   *++yyvsp = yylval;
    1681             :   YY_IGNORE_MAYBE_UNINITIALIZED_END
    1682             : 
    1683             : 
    1684             :   /* Shift the error token.  */
    1685             :   YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
    1686             : 
    1687           0 :   yystate = yyn;
    1688           0 :   goto yynewstate;
    1689             : 
    1690             : 
    1691             : /*-------------------------------------.
    1692             : | yyacceptlab -- YYACCEPT comes here.  |
    1693             : `-------------------------------------*/
    1694         734 : yyacceptlab:
    1695         734 :   yyresult = 0;
    1696         734 :   goto yyreturn;
    1697             : 
    1698             : 
    1699             : /*-----------------------------------.
    1700             : | yyabortlab -- YYABORT comes here.  |
    1701             : `-----------------------------------*/
    1702           0 : yyabortlab:
    1703           0 :   yyresult = 1;
    1704           0 :   goto yyreturn;
    1705             : 
    1706             : 
    1707             : #if !defined yyoverflow
    1708             : /*-------------------------------------------------.
    1709             : | yyexhaustedlab -- memory exhaustion comes here.  |
    1710             : `-------------------------------------------------*/
    1711           0 : yyexhaustedlab:
    1712           0 :   yyerror (yyscanner, YY_("memory exhausted"));
    1713             :   yyresult = 2;
    1714             :   goto yyreturn;
    1715             : #endif
    1716             : 
    1717             : 
    1718             : /*-------------------------------------------------------.
    1719             : | yyreturn -- parsing is finished, clean up and return.  |
    1720             : `-------------------------------------------------------*/
    1721         734 : yyreturn:
    1722         734 :   if (yychar != YYEMPTY)
    1723             :     {
    1724             :       /* Make sure we have latest lookahead translation.  See comments at
    1725             :          user semantic actions for why this is necessary.  */
    1726           0 :       yytoken = YYTRANSLATE (yychar);
    1727           0 :       yydestruct ("Cleanup: discarding lookahead",
    1728             :                   yytoken, &yylval, yyscanner);
    1729             :     }
    1730             :   /* Do not reclaim the symbols of the rule whose action triggered
    1731             :      this YYABORT or YYACCEPT.  */
    1732         734 :   YYPOPSTACK (yylen);
    1733             :   YY_STACK_PRINT (yyss, yyssp);
    1734        2202 :   while (yyssp != yyss)
    1735             :     {
    1736        1468 :       yydestruct ("Cleanup: popping",
    1737        1468 :                   YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yyscanner);
    1738        1468 :       YYPOPSTACK (1);
    1739             :     }
    1740             : #ifndef yyoverflow
    1741         734 :   if (yyss != yyssa)
    1742           0 :     YYSTACK_FREE (yyss);
    1743             : #endif
    1744             : 
    1745         734 :   return yyresult;
    1746             : }
    1747             : 
    1748             : #line 166 "exprparse.y"
    1749             : 
    1750             : 
    1751             : static PgBenchExpr *
    1752             : make_null_constant(void)
    1753             : {
    1754             :     PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
    1755             : 
    1756             :     expr->etype = ENODE_CONSTANT;
    1757             :     expr->u.constant.type = PGBT_NULL;
    1758             :     expr->u.constant.u.ival = 0;
    1759             :     return expr;
    1760             : }
    1761             : 
    1762             : static PgBenchExpr *
    1763             : make_integer_constant(int64 ival)
    1764             : {
    1765             :     PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
    1766             : 
    1767             :     expr->etype = ENODE_CONSTANT;
    1768             :     expr->u.constant.type = PGBT_INT;
    1769             :     expr->u.constant.u.ival = ival;
    1770             :     return expr;
    1771             : }
    1772             : 
    1773             : static PgBenchExpr *
    1774             : make_double_constant(double dval)
    1775             : {
    1776             :     PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
    1777             : 
    1778             :     expr->etype = ENODE_CONSTANT;
    1779             :     expr->u.constant.type = PGBT_DOUBLE;
    1780             :     expr->u.constant.u.dval = dval;
    1781             :     return expr;
    1782             : }
    1783             : 
    1784             : static PgBenchExpr *
    1785             : make_boolean_constant(bool bval)
    1786             : {
    1787             :     PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
    1788             : 
    1789             :     expr->etype = ENODE_CONSTANT;
    1790             :     expr->u.constant.type = PGBT_BOOLEAN;
    1791             :     expr->u.constant.u.bval = bval;
    1792             :     return expr;
    1793             : }
    1794             : 
    1795             : static PgBenchExpr *
    1796             : make_variable(char *varname)
    1797             : {
    1798             :     PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
    1799             : 
    1800             :     expr->etype = ENODE_VARIABLE;
    1801             :     expr->u.variable.varname = varname;
    1802             :     return expr;
    1803             : }
    1804             : 
    1805             : /* binary operators */
    1806             : static PgBenchExpr *
    1807             : make_op(yyscan_t yyscanner, const char *operator,
    1808             :         PgBenchExpr *lexpr, PgBenchExpr *rexpr)
    1809             : {
    1810             :     return make_func(yyscanner, find_func(yyscanner, operator),
    1811             :                      make_elist(rexpr, make_elist(lexpr, NULL)));
    1812             : }
    1813             : 
    1814             : /* unary operator */
    1815             : static PgBenchExpr *
    1816             : make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr)
    1817             : {
    1818             :     return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL));
    1819             : }
    1820             : 
    1821             : /*
    1822             :  * List of available functions:
    1823             :  * - fname: function name, "!..." for special internal functions
    1824             :  * - nargs: number of arguments. Special cases:
    1825             :  *          - PGBENCH_NARGS_VARIABLE is a special value for least & greatest
    1826             :  *            meaning #args >= 1;
    1827             :  *          - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which
    1828             :  *            has #args >= 3 and odd;
    1829             :  *          - PGBENCH_NARGS_HASH is for hash functions, which have one required
    1830             :  *            and one optional argument;
    1831             :  * - tag: function identifier from PgBenchFunction enum
    1832             :  */
    1833             : static const struct
    1834             : {
    1835             :     const char *fname;
    1836             :     int         nargs;
    1837             :     PgBenchFunction tag;
    1838             : }   PGBENCH_FUNCTIONS[] =
    1839             : {
    1840             :     /* parsed as operators, executed as functions */
    1841             :     {
    1842             :         "+", 2, PGBENCH_ADD
    1843             :     },
    1844             :     {
    1845             :         "-", 2, PGBENCH_SUB
    1846             :     },
    1847             :     {
    1848             :         "*", 2, PGBENCH_MUL
    1849             :     },
    1850             :     {
    1851             :         "/", 2, PGBENCH_DIV
    1852             :     },
    1853             :     {
    1854             :         "mod", 2, PGBENCH_MOD
    1855             :     },
    1856             :     /* actual functions */
    1857             :     {
    1858             :         "abs", 1, PGBENCH_ABS
    1859             :     },
    1860             :     {
    1861             :         "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST
    1862             :     },
    1863             :     {
    1864             :         "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST
    1865             :     },
    1866             :     {
    1867             :         "debug", 1, PGBENCH_DEBUG
    1868             :     },
    1869             :     {
    1870             :         "pi", 0, PGBENCH_PI
    1871             :     },
    1872             :     {
    1873             :         "sqrt", 1, PGBENCH_SQRT
    1874             :     },
    1875             :     {
    1876             :         "ln", 1, PGBENCH_LN
    1877             :     },
    1878             :     {
    1879             :         "exp", 1, PGBENCH_EXP
    1880             :     },
    1881             :     {
    1882             :         "int", 1, PGBENCH_INT
    1883             :     },
    1884             :     {
    1885             :         "double", 1, PGBENCH_DOUBLE
    1886             :     },
    1887             :     {
    1888             :         "random", 2, PGBENCH_RANDOM
    1889             :     },
    1890             :     {
    1891             :         "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN
    1892             :     },
    1893             :     {
    1894             :         "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL
    1895             :     },
    1896             :     {
    1897             :         "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN
    1898             :     },
    1899             :     {
    1900             :         "pow", 2, PGBENCH_POW
    1901             :     },
    1902             :     {
    1903             :         "power", 2, PGBENCH_POW
    1904             :     },
    1905             :     /* logical operators */
    1906             :     {
    1907             :         "!and", 2, PGBENCH_AND
    1908             :     },
    1909             :     {
    1910             :         "!or", 2, PGBENCH_OR
    1911             :     },
    1912             :     {
    1913             :         "!not", 1, PGBENCH_NOT
    1914             :     },
    1915             :     /* bitwise integer operators */
    1916             :     {
    1917             :         "&", 2, PGBENCH_BITAND
    1918             :     },
    1919             :     {
    1920             :         "|", 2, PGBENCH_BITOR
    1921             :     },
    1922             :     {
    1923             :         "#", 2, PGBENCH_BITXOR
    1924             :     },
    1925             :     {
    1926             :         "<<", 2, PGBENCH_LSHIFT
    1927             :     },
    1928             :     {
    1929             :         ">>", 2, PGBENCH_RSHIFT
    1930             :     },
    1931             :     /* comparison operators */
    1932             :     {
    1933             :         "=", 2, PGBENCH_EQ
    1934             :     },
    1935             :     {
    1936             :         "<>", 2, PGBENCH_NE
    1937             :     },
    1938             :     {
    1939             :         "<=", 2, PGBENCH_LE
    1940             :     },
    1941             :     {
    1942             :         "<", 2, PGBENCH_LT
    1943             :     },
    1944             :     {
    1945             :         "!is", 2, PGBENCH_IS
    1946             :     },
    1947             :     /* "case when ... then ... else ... end" construction */
    1948             :     {
    1949             :         "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE
    1950             :     },
    1951             :     {
    1952             :         "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2
    1953             :     },
    1954             :     {
    1955             :         "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2
    1956             :     },
    1957             :     {
    1958             :         "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A
    1959             :     },
    1960             :     {
    1961             :         "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE
    1962             :     },
    1963             :     /* keep as last array element */
    1964             :     {
    1965             :         NULL, 0, 0
    1966             :     }
    1967             : };
    1968             : 
    1969             : /*
    1970             :  * Find a function from its name
    1971             :  *
    1972             :  * return the index of the function from the PGBENCH_FUNCTIONS array
    1973             :  * or fail if the function is unknown.
    1974             :  */
    1975             : static int
    1976             : find_func(yyscan_t yyscanner, const char *fname)
    1977             : {
    1978             :     int         i = 0;
    1979             : 
    1980             :     while (PGBENCH_FUNCTIONS[i].fname)
    1981             :     {
    1982             :         if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0)
    1983             :             return i;
    1984             :         i++;
    1985             :     }
    1986             : 
    1987             :     expr_yyerror_more(yyscanner, "unexpected function name", fname);
    1988             : 
    1989             :     /* not reached */
    1990             :     return -1;
    1991             : }
    1992             : 
    1993             : /* Expression linked list builder */
    1994             : static PgBenchExprList *
    1995             : make_elist(PgBenchExpr *expr, PgBenchExprList *list)
    1996             : {
    1997             :     PgBenchExprLink *cons;
    1998             : 
    1999             :     if (list == NULL)
    2000             :     {
    2001             :         list = pg_malloc(sizeof(PgBenchExprList));
    2002             :         list->head = NULL;
    2003             :         list->tail = NULL;
    2004             :     }
    2005             : 
    2006             :     cons = pg_malloc(sizeof(PgBenchExprLink));
    2007             :     cons->expr = expr;
    2008             :     cons->next = NULL;
    2009             : 
    2010             :     if (list->head == NULL)
    2011             :         list->head = cons;
    2012             :     else
    2013             :         list->tail->next = cons;
    2014             : 
    2015             :     list->tail = cons;
    2016             : 
    2017             :     return list;
    2018             : }
    2019             : 
    2020             : /* Return the length of an expression list */
    2021             : static int
    2022             : elist_length(PgBenchExprList *list)
    2023             : {
    2024             :     PgBenchExprLink *link = list != NULL ? list->head : NULL;
    2025             :     int         len = 0;
    2026             : 
    2027             :     for (; link != NULL; link = link->next)
    2028             :         len++;
    2029             : 
    2030             :     return len;
    2031             : }
    2032             : 
    2033             : /* Build function call expression */
    2034             : static PgBenchExpr *
    2035             : make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args)
    2036             : {
    2037             :     int len = elist_length(args);
    2038             : 
    2039             :     PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
    2040             : 
    2041             :     Assert(fnumber >= 0);
    2042             : 
    2043             :     /* validate arguments number including few special cases */
    2044             :     switch (PGBENCH_FUNCTIONS[fnumber].nargs)
    2045             :     {
    2046             :         /* check at least one arg for least & greatest */
    2047             :         case PGBENCH_NARGS_VARIABLE:
    2048             :             if (len == 0)
    2049             :                 expr_yyerror_more(yyscanner, "at least one argument expected",
    2050             :                                   PGBENCH_FUNCTIONS[fnumber].fname);
    2051             :             break;
    2052             : 
    2053             :         /* case (when ... then ...)+ (else ...)? end */
    2054             :         case PGBENCH_NARGS_CASE:
    2055             :             /* 'else' branch is always present, but could be a NULL-constant */
    2056             :             if (len < 3 || len % 2 != 1)
    2057             :                 expr_yyerror_more(yyscanner,
    2058             :                                   "odd and >= 3 number of arguments expected",
    2059             :                                   "case control structure");
    2060             :             break;
    2061             : 
    2062             :         /* hash functions with optional seed argument */
    2063             :         case PGBENCH_NARGS_HASH:
    2064             :             if (len < 1 || len > 2)
    2065             :                 expr_yyerror_more(yyscanner, "unexpected number of arguments",
    2066             :                                   PGBENCH_FUNCTIONS[fnumber].fname);
    2067             : 
    2068             :             if (len == 1)
    2069             :             {
    2070             :                 PgBenchExpr *var = make_variable("default_seed");
    2071             :                 args = make_elist(var, args);
    2072             :             }
    2073             :             break;
    2074             : 
    2075             :         /* pseudorandom permutation function with optional seed argument */
    2076             :         case PGBENCH_NARGS_PERMUTE:
    2077             :             if (len < 2 || len > 3)
    2078             :                 expr_yyerror_more(yyscanner, "unexpected number of arguments",
    2079             :                                   PGBENCH_FUNCTIONS[fnumber].fname);
    2080             : 
    2081             :             if (len == 2)
    2082             :             {
    2083             :                 PgBenchExpr *var = make_variable("default_seed");
    2084             :                 args = make_elist(var, args);
    2085             :             }
    2086             :             break;
    2087             : 
    2088             :         /* common case: positive arguments number */
    2089             :         default:
    2090             :             Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0);
    2091             : 
    2092             :             if (PGBENCH_FUNCTIONS[fnumber].nargs != len)
    2093             :                 expr_yyerror_more(yyscanner, "unexpected number of arguments",
    2094             :                                   PGBENCH_FUNCTIONS[fnumber].fname);
    2095             :     }
    2096             : 
    2097             :     expr->etype = ENODE_FUNCTION;
    2098             :     expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag;
    2099             : 
    2100             :     /* only the link is used, the head/tail is not useful anymore */
    2101             :     expr->u.function.args = args != NULL ? args->head : NULL;
    2102             :     if (args)
    2103             :         pg_free(args);
    2104             : 
    2105             :     return expr;
    2106             : }
    2107             : 
    2108             : static PgBenchExpr *
    2109             : make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part)
    2110             : {
    2111             :     return make_func(yyscanner,
    2112             :                      find_func(yyscanner, "!case_end"),
    2113             :                      make_elist(else_part, when_then_list));
    2114             : }

Generated by: LCOV version 1.14