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

Generated by: LCOV version 1.14