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