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