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