LCOV - code coverage report
Current view: top level - src/bin/pgbench - exprparse.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13beta1 Lines: 168 226 74.3 %
Date: 2020-05-25 04:06:28 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13