Branch data Line data Source code
1 : : /* A Bison parser, made by GNU Bison 3.8.2. */
2 : :
3 : : /* Bison implementation for Yacc-like parsers in C
4 : :
5 : : Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6 : : Inc.
7 : :
8 : : This program is free software: you can redistribute it and/or modify
9 : : it under the terms of the GNU General Public License as published by
10 : : the Free Software Foundation, either version 3 of the License, or
11 : : (at your option) any later version.
12 : :
13 : : This program is distributed in the hope that it will be useful,
14 : : but WITHOUT ANY WARRANTY; without even the implied warranty of
15 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 : : GNU General Public License for more details.
17 : :
18 : : You should have received a copy of the GNU General Public License
19 : : along with this program. If not, see <https://www.gnu.org/licenses/>. */
20 : :
21 : : /* As a special exception, you may create a larger work that contains
22 : : part or all of the Bison parser skeleton and distribute that work
23 : : under terms of your choice, so long as that work isn't itself a
24 : : parser generator using the skeleton or a modified version thereof
25 : : as a parser skeleton. Alternatively, if you modify or redistribute
26 : : the parser skeleton itself, you may (at your option) remove this
27 : : special exception, which will cause the skeleton and the resulting
28 : : Bison output files to be licensed under the GNU General Public
29 : : License without this special exception.
30 : :
31 : : This special exception was added by the Free Software Foundation in
32 : : version 2.2 of Bison. */
33 : :
34 : : /* C LALR(1) parser skeleton written by Richard Stallman, by
35 : : simplifying the original so-called "semantic" parser. */
36 : :
37 : : /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 : : especially those whose name start with YY_ or yy_. They are
39 : : private implementation details that can be changed or removed. */
40 : :
41 : : /* All symbols defined below should begin with yy or YY, to avoid
42 : : infringing on user name space. This should be done even for local
43 : : variables, as they might otherwise be expanded by user macros.
44 : : There are some unavoidable exceptions within include files to
45 : : define necessary library symbols; they are noted "INFRINGES ON
46 : : USER NAME SPACE" below. */
47 : :
48 : : /* Identify Bison output, and Bison version. */
49 : : #define YYBISON 30802
50 : :
51 : : /* Bison version string. */
52 : : #define YYBISON_VERSION "3.8.2"
53 : :
54 : : /* Skeleton name. */
55 : : #define YYSKELETON_NAME "yacc.c"
56 : :
57 : : /* Pure parsers. */
58 : : #define YYPURE 1
59 : :
60 : : /* Push parsers. */
61 : : #define YYPUSH 0
62 : :
63 : : /* Pull parsers. */
64 : : #define YYPULL 1
65 : :
66 : :
67 : : /* Substitute the variable and function names. */
68 : : #define yyparse cube_yyparse
69 : : #define yylex cube_yylex
70 : : #define yyerror cube_yyerror
71 : : #define yydebug cube_yydebug
72 : : #define yynerrs cube_yynerrs
73 : :
74 : : /* First part of user prologue. */
75 : : #line 1 "cubeparse.y"
76 : :
77 : : /* contrib/cube/cubeparse.y */
78 : :
79 : : /* NdBox = [(lowerleft),(upperright)] */
80 : : /* [(xLL(1)...xLL(N)),(xUR(1)...xUR(n))] */
81 : :
82 : : #include "postgres.h"
83 : :
84 : : #include "cubedata.h"
85 : : #include "cubeparse.h" /* must be after cubedata.h for YYSTYPE and NDBOX */
86 : : #include "nodes/miscnodes.h"
87 : : #include "utils/float.h"
88 : : #include "varatt.h"
89 : :
90 : : /*
91 : : * Bison doesn't allocate anything that needs to live across parser calls,
92 : : * so we can easily have it use palloc instead of malloc. This prevents
93 : : * memory leaks if we error out during parsing.
94 : : */
95 : : #define YYMALLOC palloc
96 : : #define YYFREE pfree
97 : :
98 : : static int item_count(const char *s, char delim);
99 : : static bool write_box(int dim, char *str1, char *str2,
100 : : NDBOX **result, struct Node *escontext);
101 : : static bool write_point_as_box(int dim, char *str,
102 : : NDBOX **result, struct Node *escontext);
103 : :
104 : :
105 : : #line 106 "cubeparse.c"
106 : :
107 : : # ifndef YY_CAST
108 : : # ifdef __cplusplus
109 : : # define YY_CAST(Type, Val) static_cast<Type> (Val)
110 : : # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
111 : : # else
112 : : # define YY_CAST(Type, Val) ((Type) (Val))
113 : : # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
114 : : # endif
115 : : # endif
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 : : #include "cubeparse.h"
129 : : /* Symbol kind. */
130 : : enum yysymbol_kind_t
131 : : {
132 : : YYSYMBOL_YYEMPTY = -2,
133 : : YYSYMBOL_YYEOF = 0, /* "end of file" */
134 : : YYSYMBOL_YYerror = 1, /* error */
135 : : YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
136 : : YYSYMBOL_CUBEFLOAT = 3, /* CUBEFLOAT */
137 : : YYSYMBOL_O_PAREN = 4, /* O_PAREN */
138 : : YYSYMBOL_C_PAREN = 5, /* C_PAREN */
139 : : YYSYMBOL_O_BRACKET = 6, /* O_BRACKET */
140 : : YYSYMBOL_C_BRACKET = 7, /* C_BRACKET */
141 : : YYSYMBOL_COMMA = 8, /* COMMA */
142 : : YYSYMBOL_YYACCEPT = 9, /* $accept */
143 : : YYSYMBOL_box = 10, /* box */
144 : : YYSYMBOL_paren_list = 11, /* paren_list */
145 : : YYSYMBOL_list = 12 /* list */
146 : : };
147 : : typedef enum yysymbol_kind_t yysymbol_kind_t;
148 : :
149 : :
150 : :
151 : :
152 : : #ifdef short
153 : : # undef short
154 : : #endif
155 : :
156 : : /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
157 : : <limits.h> and (if available) <stdint.h> are included
158 : : so that the code can choose integer types of a good width. */
159 : :
160 : : #ifndef __PTRDIFF_MAX__
161 : : # include <limits.h> /* INFRINGES ON USER NAME SPACE */
162 : : # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
163 : : # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
164 : : # define YY_STDINT_H
165 : : # endif
166 : : #endif
167 : :
168 : : /* Narrow types that promote to a signed type and that can represent a
169 : : signed or unsigned integer of at least N bits. In tables they can
170 : : save space and decrease cache pressure. Promoting to a signed type
171 : : helps avoid bugs in integer arithmetic. */
172 : :
173 : : #ifdef __INT_LEAST8_MAX__
174 : : typedef __INT_LEAST8_TYPE__ yytype_int8;
175 : : #elif defined YY_STDINT_H
176 : : typedef int_least8_t yytype_int8;
177 : : #else
178 : : typedef signed char yytype_int8;
179 : : #endif
180 : :
181 : : #ifdef __INT_LEAST16_MAX__
182 : : typedef __INT_LEAST16_TYPE__ yytype_int16;
183 : : #elif defined YY_STDINT_H
184 : : typedef int_least16_t yytype_int16;
185 : : #else
186 : : typedef short yytype_int16;
187 : : #endif
188 : :
189 : : /* Work around bug in HP-UX 11.23, which defines these macros
190 : : incorrectly for preprocessor constants. This workaround can likely
191 : : be removed in 2023, as HPE has promised support for HP-UX 11.23
192 : : (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
193 : : <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
194 : : #ifdef __hpux
195 : : # undef UINT_LEAST8_MAX
196 : : # undef UINT_LEAST16_MAX
197 : : # define UINT_LEAST8_MAX 255
198 : : # define UINT_LEAST16_MAX 65535
199 : : #endif
200 : :
201 : : #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
202 : : typedef __UINT_LEAST8_TYPE__ yytype_uint8;
203 : : #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
204 : : && UINT_LEAST8_MAX <= INT_MAX)
205 : : typedef uint_least8_t yytype_uint8;
206 : : #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
207 : : typedef unsigned char yytype_uint8;
208 : : #else
209 : : typedef short yytype_uint8;
210 : : #endif
211 : :
212 : : #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
213 : : typedef __UINT_LEAST16_TYPE__ yytype_uint16;
214 : : #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
215 : : && UINT_LEAST16_MAX <= INT_MAX)
216 : : typedef uint_least16_t yytype_uint16;
217 : : #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
218 : : typedef unsigned short yytype_uint16;
219 : : #else
220 : : typedef int yytype_uint16;
221 : : #endif
222 : :
223 : : #ifndef YYPTRDIFF_T
224 : : # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
225 : : # define YYPTRDIFF_T __PTRDIFF_TYPE__
226 : : # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
227 : : # elif defined PTRDIFF_MAX
228 : : # ifndef ptrdiff_t
229 : : # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
230 : : # endif
231 : : # define YYPTRDIFF_T ptrdiff_t
232 : : # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
233 : : # else
234 : : # define YYPTRDIFF_T long
235 : : # define YYPTRDIFF_MAXIMUM LONG_MAX
236 : : # endif
237 : : #endif
238 : :
239 : : #ifndef YYSIZE_T
240 : : # ifdef __SIZE_TYPE__
241 : : # define YYSIZE_T __SIZE_TYPE__
242 : : # elif defined size_t
243 : : # define YYSIZE_T size_t
244 : : # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
245 : : # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
246 : : # define YYSIZE_T size_t
247 : : # else
248 : : # define YYSIZE_T unsigned
249 : : # endif
250 : : #endif
251 : :
252 : : #define YYSIZE_MAXIMUM \
253 : : YY_CAST (YYPTRDIFF_T, \
254 : : (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
255 : : ? YYPTRDIFF_MAXIMUM \
256 : : : YY_CAST (YYSIZE_T, -1)))
257 : :
258 : : #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
259 : :
260 : :
261 : : /* Stored state numbers (used for stacks). */
262 : : typedef yytype_int8 yy_state_t;
263 : :
264 : : /* State numbers in computations. */
265 : : typedef int yy_state_fast_t;
266 : :
267 : : #ifndef YY_
268 : : # if defined YYENABLE_NLS && YYENABLE_NLS
269 : : # if ENABLE_NLS
270 : : # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
271 : : # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
272 : : # endif
273 : : # endif
274 : : # ifndef YY_
275 : : # define YY_(Msgid) Msgid
276 : : # endif
277 : : #endif
278 : :
279 : :
280 : : #ifndef YY_ATTRIBUTE_PURE
281 : : # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
282 : : # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
283 : : # else
284 : : # define YY_ATTRIBUTE_PURE
285 : : # endif
286 : : #endif
287 : :
288 : : #ifndef YY_ATTRIBUTE_UNUSED
289 : : # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
290 : : # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
291 : : # else
292 : : # define YY_ATTRIBUTE_UNUSED
293 : : # endif
294 : : #endif
295 : :
296 : : /* Suppress unused-variable warnings by "using" E. */
297 : : #if ! defined lint || defined __GNUC__
298 : : # define YY_USE(E) ((void) (E))
299 : : #else
300 : : # define YY_USE(E) /* empty */
301 : : #endif
302 : :
303 : : /* Suppress an incorrect diagnostic about yylval being uninitialized. */
304 : : #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
305 : : # if __GNUC__ * 100 + __GNUC_MINOR__ < 407
306 : : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
307 : : _Pragma ("GCC diagnostic push") \
308 : : _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
309 : : # else
310 : : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
311 : : _Pragma ("GCC diagnostic push") \
312 : : _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
313 : : _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
314 : : # endif
315 : : # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
316 : : _Pragma ("GCC diagnostic pop")
317 : : #else
318 : : # define YY_INITIAL_VALUE(Value) Value
319 : : #endif
320 : : #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
321 : : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
322 : : # define YY_IGNORE_MAYBE_UNINITIALIZED_END
323 : : #endif
324 : : #ifndef YY_INITIAL_VALUE
325 : : # define YY_INITIAL_VALUE(Value) /* Nothing. */
326 : : #endif
327 : :
328 : : #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
329 : : # define YY_IGNORE_USELESS_CAST_BEGIN \
330 : : _Pragma ("GCC diagnostic push") \
331 : : _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
332 : : # define YY_IGNORE_USELESS_CAST_END \
333 : : _Pragma ("GCC diagnostic pop")
334 : : #endif
335 : : #ifndef YY_IGNORE_USELESS_CAST_BEGIN
336 : : # define YY_IGNORE_USELESS_CAST_BEGIN
337 : : # define YY_IGNORE_USELESS_CAST_END
338 : : #endif
339 : :
340 : :
341 : : #define YY_ASSERT(E) ((void) (0 && (E)))
342 : :
343 : : #if !defined yyoverflow
344 : :
345 : : /* The parser invokes alloca or malloc; define the necessary symbols. */
346 : :
347 : : # ifdef YYSTACK_USE_ALLOCA
348 : : # if YYSTACK_USE_ALLOCA
349 : : # ifdef __GNUC__
350 : : # define YYSTACK_ALLOC __builtin_alloca
351 : : # elif defined __BUILTIN_VA_ARG_INCR
352 : : # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
353 : : # elif defined _AIX
354 : : # define YYSTACK_ALLOC __alloca
355 : : # elif defined _MSC_VER
356 : : # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
357 : : # define alloca _alloca
358 : : # else
359 : : # define YYSTACK_ALLOC alloca
360 : : # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
361 : : # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
362 : : /* Use EXIT_SUCCESS as a witness for stdlib.h. */
363 : : # ifndef EXIT_SUCCESS
364 : : # define EXIT_SUCCESS 0
365 : : # endif
366 : : # endif
367 : : # endif
368 : : # endif
369 : : # endif
370 : :
371 : : # ifdef YYSTACK_ALLOC
372 : : /* Pacify GCC's 'empty if-body' warning. */
373 : : # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
374 : : # ifndef YYSTACK_ALLOC_MAXIMUM
375 : : /* The OS might guarantee only one guard page at the bottom of the stack,
376 : : and a page size can be as small as 4096 bytes. So we cannot safely
377 : : invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
378 : : to allow for a few compiler-allocated temporary stack slots. */
379 : : # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
380 : : # endif
381 : : # else
382 : : # define YYSTACK_ALLOC YYMALLOC
383 : : # define YYSTACK_FREE YYFREE
384 : : # ifndef YYSTACK_ALLOC_MAXIMUM
385 : : # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
386 : : # endif
387 : : # if (defined __cplusplus && ! defined EXIT_SUCCESS \
388 : : && ! ((defined YYMALLOC || defined malloc) \
389 : : && (defined YYFREE || defined free)))
390 : : # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
391 : : # ifndef EXIT_SUCCESS
392 : : # define EXIT_SUCCESS 0
393 : : # endif
394 : : # endif
395 : : # ifndef YYMALLOC
396 : : # define YYMALLOC malloc
397 : : # if ! defined malloc && ! defined EXIT_SUCCESS
398 : : void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
399 : : # endif
400 : : # endif
401 : : # ifndef YYFREE
402 : : # define YYFREE free
403 : : # if ! defined free && ! defined EXIT_SUCCESS
404 : : void free (void *); /* INFRINGES ON USER NAME SPACE */
405 : : # endif
406 : : # endif
407 : : # endif
408 : : #endif /* !defined yyoverflow */
409 : :
410 : : #if (! defined yyoverflow \
411 : : && (! defined __cplusplus \
412 : : || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
413 : :
414 : : /* A type that is properly aligned for any stack member. */
415 : : union yyalloc
416 : : {
417 : : yy_state_t yyss_alloc;
418 : : YYSTYPE yyvs_alloc;
419 : : };
420 : :
421 : : /* The size of the maximum gap between one aligned stack and the next. */
422 : : # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
423 : :
424 : : /* The size of an array large to enough to hold all stacks, each with
425 : : N elements. */
426 : : # define YYSTACK_BYTES(N) \
427 : : ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
428 : : + YYSTACK_GAP_MAXIMUM)
429 : :
430 : : # define YYCOPY_NEEDED 1
431 : :
432 : : /* Relocate STACK from its old location to the new one. The
433 : : local variables YYSIZE and YYSTACKSIZE give the old and new number of
434 : : elements in the stack, and YYPTR gives the new location of the
435 : : stack. Advance YYPTR to a properly aligned location for the next
436 : : stack. */
437 : : # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
438 : : do \
439 : : { \
440 : : YYPTRDIFF_T yynewbytes; \
441 : : YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
442 : : Stack = &yyptr->Stack_alloc; \
443 : : yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
444 : : yyptr += yynewbytes / YYSIZEOF (*yyptr); \
445 : : } \
446 : : while (0)
447 : :
448 : : #endif
449 : :
450 : : #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
451 : : /* Copy COUNT objects from SRC to DST. The source and destination do
452 : : not overlap. */
453 : : # ifndef YYCOPY
454 : : # if defined __GNUC__ && 1 < __GNUC__
455 : : # define YYCOPY(Dst, Src, Count) \
456 : : __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
457 : : # else
458 : : # define YYCOPY(Dst, Src, Count) \
459 : : do \
460 : : { \
461 : : YYPTRDIFF_T yyi; \
462 : : for (yyi = 0; yyi < (Count); yyi++) \
463 : : (Dst)[yyi] = (Src)[yyi]; \
464 : : } \
465 : : while (0)
466 : : # endif
467 : : # endif
468 : : #endif /* !YYCOPY_NEEDED */
469 : :
470 : : /* YYFINAL -- State number of the termination state. */
471 : : #define YYFINAL 10
472 : : /* YYLAST -- Last index in YYTABLE. */
473 : : #define YYLAST 17
474 : :
475 : : /* YYNTOKENS -- Number of terminals. */
476 : : #define YYNTOKENS 9
477 : : /* YYNNTS -- Number of nonterminals. */
478 : : #define YYNNTS 4
479 : : /* YYNRULES -- Number of rules. */
480 : : #define YYNRULES 9
481 : : /* YYNSTATES -- Number of states. */
482 : : #define YYNSTATES 19
483 : :
484 : : /* YYMAXUTOK -- Last valid token kind. */
485 : : #define YYMAXUTOK 263
486 : :
487 : :
488 : : /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
489 : : as returned by yylex, with out-of-bounds checking. */
490 : : #define YYTRANSLATE(YYX) \
491 : : (0 <= (YYX) && (YYX) <= YYMAXUTOK \
492 : : ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
493 : : : YYSYMBOL_YYUNDEF)
494 : :
495 : : /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
496 : : as returned by yylex. */
497 : : static const yytype_int8 yytranslate[] =
498 : : {
499 : : 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
500 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
501 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
502 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
505 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
506 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
507 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
508 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
512 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
513 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
514 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
515 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
516 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
517 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
518 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
519 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
520 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
521 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
522 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
523 : : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
524 : : 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
525 : : 5, 6, 7, 8
526 : : };
527 : :
528 : : #if YYDEBUG
529 : : /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
530 : : static const yytype_uint8 yyrline[] =
531 : : {
532 : : 0, 47, 47, 77, 105, 124, 144, 148, 154, 160
533 : : };
534 : : #endif
535 : :
536 : : /** Accessing symbol of state STATE. */
537 : : #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
538 : :
539 : : #if YYDEBUG || 0
540 : : /* The user-facing name of the symbol whose (internal) number is
541 : : YYSYMBOL. No bounds checking. */
542 : : static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
543 : :
544 : : /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
545 : : First, the terminals, then, starting at YYNTOKENS, nonterminals. */
546 : : static const char *const yytname[] =
547 : : {
548 : : "\"end of file\"", "error", "\"invalid token\"", "CUBEFLOAT", "O_PAREN",
549 : : "C_PAREN", "O_BRACKET", "C_BRACKET", "COMMA", "$accept", "box",
550 : : "paren_list", "list", YY_NULLPTR
551 : : };
552 : :
553 : : static const char *
554 : : yysymbol_name (yysymbol_kind_t yysymbol)
555 : : {
556 : : return yytname[yysymbol];
557 : : }
558 : : #endif
559 : :
560 : : #define YYPACT_NINF (-4)
561 : :
562 : : #define yypact_value_is_default(Yyn) \
563 : : ((Yyn) == YYPACT_NINF)
564 : :
565 : : #define YYTABLE_NINF (-1)
566 : :
567 : : #define yytable_value_is_error(Yyn) \
568 : : 0
569 : :
570 : : /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
571 : : STATE-NUM. */
572 : : static const yytype_int8 yypact[] =
573 : : {
574 : : -2, -4, 0, 3, 10, 4, 5, -4, 1, 6,
575 : : -4, 3, 12, -4, 3, -4, -4, 9, -4
576 : : };
577 : :
578 : : /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
579 : : Performed when YYTABLE does not specify something else to do. Zero
580 : : means the default is an error. */
581 : : static const yytype_int8 yydefact[] =
582 : : {
583 : : 0, 8, 0, 0, 0, 4, 5, 7, 0, 0,
584 : : 1, 0, 0, 6, 0, 3, 9, 0, 2
585 : : };
586 : :
587 : : /* YYPGOTO[NTERM-NUM]. */
588 : : static const yytype_int8 yypgoto[] =
589 : : {
590 : : -4, -4, -3, 15
591 : : };
592 : :
593 : : /* YYDEFGOTO[NTERM-NUM]. */
594 : : static const yytype_int8 yydefgoto[] =
595 : : {
596 : : 0, 4, 5, 6
597 : : };
598 : :
599 : : /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
600 : : positive, shift that token. If negative, reduce the rule whose
601 : : number is the opposite. If YYTABLE_NINF, syntax error. */
602 : : static const yytype_int8 yytable[] =
603 : : {
604 : : 9, 1, 2, 1, 3, 7, 13, 2, 15, 12,
605 : : 10, 17, 11, 12, 14, 16, 18, 8
606 : : };
607 : :
608 : : static const yytype_int8 yycheck[] =
609 : : {
610 : : 3, 3, 4, 3, 6, 5, 5, 4, 11, 8,
611 : : 0, 14, 8, 8, 8, 3, 7, 2
612 : : };
613 : :
614 : : /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
615 : : state STATE-NUM. */
616 : : static const yytype_int8 yystos[] =
617 : : {
618 : : 0, 3, 4, 6, 10, 11, 12, 5, 12, 11,
619 : : 0, 8, 8, 5, 8, 11, 3, 11, 7
620 : : };
621 : :
622 : : /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
623 : : static const yytype_int8 yyr1[] =
624 : : {
625 : : 0, 9, 10, 10, 10, 10, 11, 11, 12, 12
626 : : };
627 : :
628 : : /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
629 : : static const yytype_int8 yyr2[] =
630 : : {
631 : : 0, 2, 5, 3, 1, 1, 3, 2, 1, 3
632 : : };
633 : :
634 : :
635 : : enum { YYENOMEM = -2 };
636 : :
637 : : #define yyerrok (yyerrstatus = 0)
638 : : #define yyclearin (yychar = YYEMPTY)
639 : :
640 : : #define YYACCEPT goto yyacceptlab
641 : : #define YYABORT goto yyabortlab
642 : : #define YYERROR goto yyerrorlab
643 : : #define YYNOMEM goto yyexhaustedlab
644 : :
645 : :
646 : : #define YYRECOVERING() (!!yyerrstatus)
647 : :
648 : : #define YYBACKUP(Token, Value) \
649 : : do \
650 : : if (yychar == YYEMPTY) \
651 : : { \
652 : : yychar = (Token); \
653 : : yylval = (Value); \
654 : : YYPOPSTACK (yylen); \
655 : : yystate = *yyssp; \
656 : : goto yybackup; \
657 : : } \
658 : : else \
659 : : { \
660 : : yyerror (result, scanbuflen, escontext, yyscanner, YY_("syntax error: cannot back up")); \
661 : : YYERROR; \
662 : : } \
663 : : while (0)
664 : :
665 : : /* Backward compatibility with an undocumented macro.
666 : : Use YYerror or YYUNDEF. */
667 : : #define YYERRCODE YYUNDEF
668 : :
669 : :
670 : : /* Enable debugging if requested. */
671 : : #if YYDEBUG
672 : :
673 : : # ifndef YYFPRINTF
674 : : # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
675 : : # define YYFPRINTF fprintf
676 : : # endif
677 : :
678 : : # define YYDPRINTF(Args) \
679 : : do { \
680 : : if (yydebug) \
681 : : YYFPRINTF Args; \
682 : : } while (0)
683 : :
684 : :
685 : :
686 : :
687 : : # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
688 : : do { \
689 : : if (yydebug) \
690 : : { \
691 : : YYFPRINTF (stderr, "%s ", Title); \
692 : : yy_symbol_print (stderr, \
693 : : Kind, Value, result, scanbuflen, escontext, yyscanner); \
694 : : YYFPRINTF (stderr, "\n"); \
695 : : } \
696 : : } while (0)
697 : :
698 : :
699 : : /*-----------------------------------.
700 : : | Print this symbol's value on YYO. |
701 : : `-----------------------------------*/
702 : :
703 : : static void
704 : : yy_symbol_value_print (FILE *yyo,
705 : : yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner)
706 : : {
707 : : FILE *yyoutput = yyo;
708 : : YY_USE (yyoutput);
709 : : YY_USE (result);
710 : : YY_USE (scanbuflen);
711 : : YY_USE (escontext);
712 : : YY_USE (yyscanner);
713 : : if (!yyvaluep)
714 : : return;
715 : : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
716 : : YY_USE (yykind);
717 : : YY_IGNORE_MAYBE_UNINITIALIZED_END
718 : : }
719 : :
720 : :
721 : : /*---------------------------.
722 : : | Print this symbol on YYO. |
723 : : `---------------------------*/
724 : :
725 : : static void
726 : : yy_symbol_print (FILE *yyo,
727 : : yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner)
728 : : {
729 : : YYFPRINTF (yyo, "%s %s (",
730 : : yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
731 : :
732 : : yy_symbol_value_print (yyo, yykind, yyvaluep, result, scanbuflen, escontext, yyscanner);
733 : : YYFPRINTF (yyo, ")");
734 : : }
735 : :
736 : : /*------------------------------------------------------------------.
737 : : | yy_stack_print -- Print the state stack from its BOTTOM up to its |
738 : : | TOP (included). |
739 : : `------------------------------------------------------------------*/
740 : :
741 : : static void
742 : : yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
743 : : {
744 : : YYFPRINTF (stderr, "Stack now");
745 : : for (; yybottom <= yytop; yybottom++)
746 : : {
747 : : int yybot = *yybottom;
748 : : YYFPRINTF (stderr, " %d", yybot);
749 : : }
750 : : YYFPRINTF (stderr, "\n");
751 : : }
752 : :
753 : : # define YY_STACK_PRINT(Bottom, Top) \
754 : : do { \
755 : : if (yydebug) \
756 : : yy_stack_print ((Bottom), (Top)); \
757 : : } while (0)
758 : :
759 : :
760 : : /*------------------------------------------------.
761 : : | Report that the YYRULE is going to be reduced. |
762 : : `------------------------------------------------*/
763 : :
764 : : static void
765 : : yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
766 : : int yyrule, NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner)
767 : : {
768 : : int yylno = yyrline[yyrule];
769 : : int yynrhs = yyr2[yyrule];
770 : : int yyi;
771 : : YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
772 : : yyrule - 1, yylno);
773 : : /* The symbols being reduced. */
774 : : for (yyi = 0; yyi < yynrhs; yyi++)
775 : : {
776 : : YYFPRINTF (stderr, " $%d = ", yyi + 1);
777 : : yy_symbol_print (stderr,
778 : : YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
779 : : &yyvsp[(yyi + 1) - (yynrhs)], result, scanbuflen, escontext, yyscanner);
780 : : YYFPRINTF (stderr, "\n");
781 : : }
782 : : }
783 : :
784 : : # define YY_REDUCE_PRINT(Rule) \
785 : : do { \
786 : : if (yydebug) \
787 : : yy_reduce_print (yyssp, yyvsp, Rule, result, scanbuflen, escontext, yyscanner); \
788 : : } while (0)
789 : :
790 : : /* Nonzero means print parse trace. It is left uninitialized so that
791 : : multiple parsers can coexist. */
792 : : int yydebug;
793 : : #else /* !YYDEBUG */
794 : : # define YYDPRINTF(Args) ((void) 0)
795 : : # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
796 : : # define YY_STACK_PRINT(Bottom, Top)
797 : : # define YY_REDUCE_PRINT(Rule)
798 : : #endif /* !YYDEBUG */
799 : :
800 : :
801 : : /* YYINITDEPTH -- initial size of the parser's stacks. */
802 : : #ifndef YYINITDEPTH
803 : : # define YYINITDEPTH 200
804 : : #endif
805 : :
806 : : /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
807 : : if the built-in stack extension method is used).
808 : :
809 : : Do not make this value too large; the results are undefined if
810 : : YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
811 : : evaluated with infinite-precision integer arithmetic. */
812 : :
813 : : #ifndef YYMAXDEPTH
814 : : # define YYMAXDEPTH 10000
815 : : #endif
816 : :
817 : :
818 : :
819 : :
820 : :
821 : :
822 : : /*-----------------------------------------------.
823 : : | Release the memory associated to this symbol. |
824 : : `-----------------------------------------------*/
825 : :
826 : : static void
827 : 6810 : yydestruct (const char *yymsg,
828 : : yysymbol_kind_t yykind, YYSTYPE *yyvaluep, NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner)
829 : : {
830 : : YY_USE (yyvaluep);
831 : : YY_USE (result);
832 : : YY_USE (scanbuflen);
833 : : YY_USE (escontext);
834 : : YY_USE (yyscanner);
835 [ - + ]: 6810 : if (!yymsg)
836 : 0 : yymsg = "Deleting";
837 : : YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
838 : :
839 : : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
840 : : YY_USE (yykind);
841 : : YY_IGNORE_MAYBE_UNINITIALIZED_END
842 : 6810 : }
843 : :
844 : :
845 : :
846 : :
847 : :
848 : :
849 : : /*----------.
850 : : | yyparse. |
851 : : `----------*/
852 : :
853 : : int
854 : 3435 : yyparse (NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner)
855 : : {
856 : : /* Lookahead token kind. */
857 : : int yychar;
858 : :
859 : :
860 : : /* The semantic value of the lookahead symbol. */
861 : : /* Default value used for initialization, for pacifying older GCCs
862 : : or non-GCC compilers. */
863 : : YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
864 : : YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
865 : :
866 : : /* Number of syntax errors so far. */
867 : 3435 : int yynerrs = 0;
868 : :
869 : 3435 : yy_state_fast_t yystate = 0;
870 : : /* Number of tokens to shift before error messages enabled. */
871 : 3435 : int yyerrstatus = 0;
872 : :
873 : : /* Refer to the stacks through separate pointers, to allow yyoverflow
874 : : to reallocate them elsewhere. */
875 : :
876 : : /* Their size. */
877 : 3435 : YYPTRDIFF_T yystacksize = YYINITDEPTH;
878 : :
879 : : /* The state stack: array, bottom, top. */
880 : : yy_state_t yyssa[YYINITDEPTH];
881 : 3435 : yy_state_t *yyss = yyssa;
882 : 3435 : yy_state_t *yyssp = yyss;
883 : :
884 : : /* The semantic value stack: array, bottom, top. */
885 : : YYSTYPE yyvsa[YYINITDEPTH];
886 : 3435 : YYSTYPE *yyvs = yyvsa;
887 : 3435 : YYSTYPE *yyvsp = yyvs;
888 : :
889 : : int yyn;
890 : : /* The return value of yyparse. */
891 : : int yyresult;
892 : : /* Lookahead symbol kind. */
893 : 3435 : yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
894 : : /* The variables used to return semantic value and location from the
895 : : action routines. */
896 : : YYSTYPE yyval;
897 : :
898 : :
899 : :
900 : : #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
901 : :
902 : : /* The number of symbols on the RHS of the reduced rule.
903 : : Keep to zero when no symbol should be popped. */
904 : 3435 : int yylen = 0;
905 : :
906 : : YYDPRINTF ((stderr, "Starting parse\n"));
907 : :
908 : 3435 : yychar = YYEMPTY; /* Cause a token to be read. */
909 : :
910 : 3435 : goto yysetstate;
911 : :
912 : :
913 : : /*------------------------------------------------------------.
914 : : | yynewstate -- push a new state, which is found in yystate. |
915 : : `------------------------------------------------------------*/
916 : 65413 : yynewstate:
917 : : /* In all cases, when you get here, the value and location stacks
918 : : have just been pushed. So pushing a state here evens the stacks. */
919 : 65413 : yyssp++;
920 : :
921 : :
922 : : /*--------------------------------------------------------------------.
923 : : | yysetstate -- set current state (the top of the stack) to yystate. |
924 : : `--------------------------------------------------------------------*/
925 : 68848 : yysetstate:
926 : : YYDPRINTF ((stderr, "Entering state %d\n", yystate));
927 : : YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
928 : : YY_IGNORE_USELESS_CAST_BEGIN
929 : 68848 : *yyssp = YY_CAST (yy_state_t, yystate);
930 : : YY_IGNORE_USELESS_CAST_END
931 : : YY_STACK_PRINT (yyss, yyssp);
932 : :
933 [ - + ]: 68848 : if (yyss + yystacksize - 1 <= yyssp)
934 : : #if !defined yyoverflow && !defined YYSTACK_RELOCATE
935 : : YYNOMEM;
936 : : #else
937 : : {
938 : : /* Get the current used size of the three stacks, in elements. */
939 : 0 : YYPTRDIFF_T yysize = yyssp - yyss + 1;
940 : :
941 : : # if defined yyoverflow
942 : : {
943 : : /* Give user a chance to reallocate the stack. Use copies of
944 : : these so that the &'s don't force the real ones into
945 : : memory. */
946 : : yy_state_t *yyss1 = yyss;
947 : : YYSTYPE *yyvs1 = yyvs;
948 : :
949 : : /* Each stack pointer address is followed by the size of the
950 : : data in use in that stack, in bytes. This used to be a
951 : : conditional around just the two extra args, but that might
952 : : be undefined if yyoverflow is a macro. */
953 : : yyoverflow (YY_("memory exhausted"),
954 : : &yyss1, yysize * YYSIZEOF (*yyssp),
955 : : &yyvs1, yysize * YYSIZEOF (*yyvsp),
956 : : &yystacksize);
957 : : yyss = yyss1;
958 : : yyvs = yyvs1;
959 : : }
960 : : # else /* defined YYSTACK_RELOCATE */
961 : : /* Extend the stack our own way. */
962 [ # # ]: 0 : if (YYMAXDEPTH <= yystacksize)
963 : 0 : YYNOMEM;
964 : 0 : yystacksize *= 2;
965 [ # # ]: 0 : if (YYMAXDEPTH < yystacksize)
966 : 0 : yystacksize = YYMAXDEPTH;
967 : :
968 : : {
969 : 0 : yy_state_t *yyss1 = yyss;
970 : : union yyalloc *yyptr =
971 : 0 : YY_CAST (union yyalloc *,
972 : : YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
973 [ # # ]: 0 : if (! yyptr)
974 : 0 : YYNOMEM;
975 : 0 : YYSTACK_RELOCATE (yyss_alloc, yyss);
976 : 0 : YYSTACK_RELOCATE (yyvs_alloc, yyvs);
977 : : # undef YYSTACK_RELOCATE
978 [ # # ]: 0 : if (yyss1 != yyssa)
979 : 0 : YYSTACK_FREE (yyss1);
980 : : }
981 : : # endif
982 : :
983 : 0 : yyssp = yyss + yysize - 1;
984 : 0 : yyvsp = yyvs + yysize - 1;
985 : :
986 : : YY_IGNORE_USELESS_CAST_BEGIN
987 : : YYDPRINTF ((stderr, "Stack size increased to %ld\n",
988 : : YY_CAST (long, yystacksize)));
989 : : YY_IGNORE_USELESS_CAST_END
990 : :
991 [ # # ]: 0 : if (yyss + yystacksize - 1 <= yyssp)
992 : 0 : YYABORT;
993 : : }
994 : : #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
995 : :
996 : :
997 [ + + ]: 68848 : if (yystate == YYFINAL)
998 : 3402 : YYACCEPT;
999 : :
1000 : 65446 : goto yybackup;
1001 : :
1002 : :
1003 : : /*-----------.
1004 : : | yybackup. |
1005 : : `-----------*/
1006 : 65446 : yybackup:
1007 : : /* Do appropriate processing given the current state. Read a
1008 : : lookahead token if we need one and don't already have one. */
1009 : :
1010 : : /* First try to decide what to do without reference to lookahead token. */
1011 : 65446 : yyn = yypact[yystate];
1012 [ + + ]: 65446 : if (yypact_value_is_default (yyn))
1013 : 23921 : goto yydefault;
1014 : :
1015 : : /* Not known => get a lookahead token if don't already have one. */
1016 : :
1017 : : /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1018 [ + + ]: 41525 : if (yychar == YYEMPTY)
1019 : : {
1020 : : YYDPRINTF ((stderr, "Reading a token\n"));
1021 : 41371 : yychar = yylex (&yylval, yyscanner);
1022 : : }
1023 : :
1024 [ + + ]: 41525 : if (yychar <= YYEOF)
1025 : : {
1026 : 3556 : yychar = YYEOF;
1027 : 3556 : yytoken = YYSYMBOL_YYEOF;
1028 : : YYDPRINTF ((stderr, "Now at end of input.\n"));
1029 : : }
1030 [ - + ]: 37969 : else if (yychar == YYerror)
1031 : : {
1032 : : /* The scanner already issued an error message, process directly
1033 : : to error recovery. But do not keep the error token as
1034 : : lookahead, it is too special and may lead us to an endless
1035 : : loop in error recovery. */
1036 : 0 : yychar = YYUNDEF;
1037 : 0 : yytoken = YYSYMBOL_YYerror;
1038 : 0 : goto yyerrlab1;
1039 : : }
1040 : : else
1041 : : {
1042 [ + - + - ]: 37969 : yytoken = YYTRANSLATE (yychar);
1043 : : YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1044 : : }
1045 : :
1046 : : /* If the proper action on seeing token YYTOKEN is to reduce or to
1047 : : detect an error, take that action. */
1048 : 41525 : yyn += yytoken;
1049 [ + + + + : 41525 : if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ + ]
1050 : 182 : goto yydefault;
1051 : 41343 : yyn = yytable[yyn];
1052 [ - + ]: 41343 : if (yyn <= 0)
1053 : : {
1054 : : if (yytable_value_is_error (yyn))
1055 : : goto yyerrlab;
1056 : 0 : yyn = -yyn;
1057 : 0 : goto yyreduce;
1058 : : }
1059 : :
1060 : : /* Count tokens shifted since error; after three, turn off error
1061 : : status. */
1062 [ - + ]: 41343 : if (yyerrstatus)
1063 : 0 : yyerrstatus--;
1064 : :
1065 : : /* Shift the lookahead token. */
1066 : : YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1067 : 41343 : yystate = yyn;
1068 : : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1069 : 41343 : *++yyvsp = yylval;
1070 : : YY_IGNORE_MAYBE_UNINITIALIZED_END
1071 : :
1072 : : /* Discard the shifted token. */
1073 : 41343 : yychar = YYEMPTY;
1074 : 41343 : goto yynewstate;
1075 : :
1076 : :
1077 : : /*-----------------------------------------------------------.
1078 : : | yydefault -- do the default action for the current state. |
1079 : : `-----------------------------------------------------------*/
1080 : 24103 : yydefault:
1081 : 24103 : yyn = yydefact[yystate];
1082 [ + + ]: 24103 : if (yyn == 0)
1083 : 24 : goto yyerrlab;
1084 : 24079 : goto yyreduce;
1085 : :
1086 : :
1087 : : /*-----------------------------.
1088 : : | yyreduce -- do a reduction. |
1089 : : `-----------------------------*/
1090 : 24079 : yyreduce:
1091 : : /* yyn is the number of a rule to reduce with. */
1092 : 24079 : yylen = yyr2[yyn];
1093 : :
1094 : : /* If YYLEN is nonzero, implement the default value of the action:
1095 : : '$$ = $1'.
1096 : :
1097 : : Otherwise, the following line sets YYVAL to garbage.
1098 : : This behavior is undocumented and Bison
1099 : : users should not rely upon it. Assigning to YYVAL
1100 : : unconditionally makes the parser a bit smaller, and it avoids a
1101 : : GCC warning that YYVAL may be used uninitialized. */
1102 : 24079 : yyval = yyvsp[1-yylen];
1103 : :
1104 : :
1105 : : YY_REDUCE_PRINT (yyn);
1106 [ + + + + : 24079 : switch (yyn)
+ + + +
- ]
1107 : : {
1108 : 16 : case 2: /* box: O_BRACKET paren_list COMMA paren_list C_BRACKET */
1109 : : #line 48 "cubeparse.y"
1110 : : {
1111 : : int dim;
1112 : :
1113 : : dim = item_count(yyvsp[-3], ',');
1114 : : if (item_count(yyvsp[-1], ',') != dim)
1115 : : {
1116 : : errsave(escontext,
1117 : : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1118 : : errmsg("invalid input syntax for cube"),
1119 : : errdetail("Different point dimensions in (%s) and (%s).",
1120 : : yyvsp[-3], yyvsp[-1])));
1121 : : YYABORT;
1122 : : }
1123 : : if (dim > CUBE_MAX_DIM)
1124 : : {
1125 : : errsave(escontext,
1126 : : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1127 : : errmsg("invalid input syntax for cube"),
1128 : : errdetail("A cube cannot have more than %d dimensions.",
1129 : : CUBE_MAX_DIM)));
1130 : : YYABORT;
1131 : : }
1132 : :
1133 : : if (!write_box(dim, yyvsp[-3], yyvsp[-1], result, escontext))
1134 : : YYABORT;
1135 : :
1136 : : (void) yynerrs; /* suppress compiler warning */
1137 : : }
1138 : : #line 1139 "cubeparse.c"
1139 : 14 : break;
1140 : :
1141 : 3246 : case 3: /* box: paren_list COMMA paren_list */
1142 : : #line 78 "cubeparse.y"
1143 : : {
1144 : : int dim;
1145 : :
1146 : : dim = item_count(yyvsp[-2], ',');
1147 : : if (item_count(yyvsp[0], ',') != dim)
1148 : : {
1149 : : errsave(escontext,
1150 : : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1151 : : errmsg("invalid input syntax for cube"),
1152 : : errdetail("Different point dimensions in (%s) and (%s).",
1153 : : yyvsp[-2], yyvsp[0])));
1154 : : YYABORT;
1155 : : }
1156 : : if (dim > CUBE_MAX_DIM)
1157 : : {
1158 : : errsave(escontext,
1159 : : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1160 : : errmsg("invalid input syntax for cube"),
1161 : : errdetail("A cube cannot have more than %d dimensions.",
1162 : : CUBE_MAX_DIM)));
1163 : : YYABORT;
1164 : : }
1165 : :
1166 : : if (!write_box(dim, yyvsp[-2], yyvsp[0], result, escontext))
1167 : : YYABORT;
1168 : : }
1169 : : #line 1170 "cubeparse.c"
1170 : 3243 : break;
1171 : :
1172 : 69 : case 4: /* box: paren_list */
1173 : : #line 106 "cubeparse.y"
1174 : : {
1175 : : int dim;
1176 : :
1177 : : dim = item_count(yyvsp[0], ',');
1178 : : if (dim > CUBE_MAX_DIM)
1179 : : {
1180 : : errsave(escontext,
1181 : : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1182 : : errmsg("invalid input syntax for cube"),
1183 : : errdetail("A cube cannot have more than %d dimensions.",
1184 : : CUBE_MAX_DIM)));
1185 : : YYABORT;
1186 : : }
1187 : :
1188 : : if (!write_point_as_box(dim, yyvsp[0], result, escontext))
1189 : : YYABORT;
1190 : : }
1191 : : #line 1192 "cubeparse.c"
1192 : 68 : break;
1193 : :
1194 : 89 : case 5: /* box: list */
1195 : : #line 125 "cubeparse.y"
1196 : : {
1197 : : int dim;
1198 : :
1199 : : dim = item_count(yyvsp[0], ',');
1200 : : if (dim > CUBE_MAX_DIM)
1201 : : {
1202 : : errsave(escontext,
1203 : : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1204 : : errmsg("invalid input syntax for cube"),
1205 : : errdetail("A cube cannot have more than %d dimensions.",
1206 : : CUBE_MAX_DIM)));
1207 : : YYABORT;
1208 : : }
1209 : :
1210 : : if (!write_point_as_box(dim, yyvsp[0], result, escontext))
1211 : : YYABORT;
1212 : : }
1213 : : #line 1214 "cubeparse.c"
1214 : 86 : break;
1215 : :
1216 : 6596 : case 6: /* paren_list: O_PAREN list C_PAREN */
1217 : : #line 145 "cubeparse.y"
1218 : : {
1219 : : yyval = yyvsp[-1];
1220 : : }
1221 : : #line 1222 "cubeparse.c"
1222 : 6596 : break;
1223 : :
1224 : 4 : case 7: /* paren_list: O_PAREN C_PAREN */
1225 : : #line 149 "cubeparse.y"
1226 : : {
1227 : : yyval = pstrdup("");
1228 : : }
1229 : : #line 1230 "cubeparse.c"
1230 : 4 : break;
1231 : :
1232 : 6691 : case 8: /* list: CUBEFLOAT */
1233 : : #line 155 "cubeparse.y"
1234 : : {
1235 : : /* alloc enough space to be sure whole list will fit */
1236 : : yyval = palloc(scanbuflen + 1);
1237 : : strcpy(yyval, yyvsp[0]);
1238 : : }
1239 : : #line 1240 "cubeparse.c"
1240 : 6691 : break;
1241 : :
1242 : 7368 : case 9: /* list: list COMMA CUBEFLOAT */
1243 : : #line 161 "cubeparse.y"
1244 : : {
1245 : : yyval = yyvsp[-2];
1246 : : strcat(yyval, ",");
1247 : : strcat(yyval, yyvsp[0]);
1248 : : }
1249 : : #line 1250 "cubeparse.c"
1250 : 7368 : break;
1251 : :
1252 : :
1253 : : #line 1254 "cubeparse.c"
1254 : :
1255 : 0 : default: break;
1256 : : }
1257 : : /* User semantic actions sometimes alter yychar, and that requires
1258 : : that yytoken be updated with the new translation. We take the
1259 : : approach of translating immediately before every use of yytoken.
1260 : : One alternative is translating here after every semantic action,
1261 : : but that translation would be missed if the semantic action invokes
1262 : : YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1263 : : if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1264 : : incorrect destructor might then be invoked immediately. In the
1265 : : case of YYERROR or YYBACKUP, subsequent parser actions might lead
1266 : : to an incorrect destructor call or verbose syntax error message
1267 : : before the lookahead is translated. */
1268 : : YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1269 : :
1270 : 24070 : YYPOPSTACK (yylen);
1271 : 24070 : yylen = 0;
1272 : :
1273 : 24070 : *++yyvsp = yyval;
1274 : :
1275 : : /* Now 'shift' the result of the reduction. Determine what state
1276 : : that goes to, based on the state we popped back to and the rule
1277 : : number reduced by. */
1278 : : {
1279 : 24070 : const int yylhs = yyr1[yyn] - YYNTOKENS;
1280 : 24070 : const int yyi = yypgoto[yylhs] + *yyssp;
1281 [ + - + + ]: 17344 : yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1282 : 17200 : ? yytable[yyi]
1283 [ + + ]: 41414 : : yydefgoto[yylhs]);
1284 : : }
1285 : :
1286 : 24070 : goto yynewstate;
1287 : :
1288 : :
1289 : : /*--------------------------------------.
1290 : : | yyerrlab -- here on detecting error. |
1291 : : `--------------------------------------*/
1292 : 24 : yyerrlab:
1293 : : /* Make sure we have latest lookahead translation. See comments at
1294 : : user semantic actions for why this is necessary. */
1295 [ + - + - : 24 : yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
+ - ]
1296 : : /* If not already recovering from an error, report this error. */
1297 [ + - ]: 24 : if (!yyerrstatus)
1298 : : {
1299 : 24 : ++yynerrs;
1300 : 24 : yyerror (result, scanbuflen, escontext, yyscanner, YY_("syntax error"));
1301 : : }
1302 : :
1303 [ - + ]: 1 : if (yyerrstatus == 3)
1304 : : {
1305 : : /* If just tried and failed to reuse lookahead token after an
1306 : : error, discard it. */
1307 : :
1308 [ # # ]: 0 : if (yychar <= YYEOF)
1309 : : {
1310 : : /* Return failure if at end of input. */
1311 [ # # ]: 0 : if (yychar == YYEOF)
1312 : 0 : YYABORT;
1313 : : }
1314 : : else
1315 : : {
1316 : 0 : yydestruct ("Error: discarding",
1317 : : yytoken, &yylval, result, scanbuflen, escontext, yyscanner);
1318 : 0 : yychar = YYEMPTY;
1319 : : }
1320 : : }
1321 : :
1322 : : /* Else will try to reuse lookahead token after shifting the error
1323 : : token. */
1324 : 1 : goto yyerrlab1;
1325 : :
1326 : :
1327 : : /*---------------------------------------------------.
1328 : : | yyerrorlab -- error raised explicitly by YYERROR. |
1329 : : `---------------------------------------------------*/
1330 : : yyerrorlab:
1331 : : /* Pacify compilers when the user code never invokes YYERROR and the
1332 : : label yyerrorlab therefore never appears in user code. */
1333 : : if (0)
1334 : : YYERROR;
1335 : : ++yynerrs;
1336 : :
1337 : : /* Do not reclaim the symbols of the rule whose action triggered
1338 : : this YYERROR. */
1339 : : YYPOPSTACK (yylen);
1340 : : yylen = 0;
1341 : : YY_STACK_PRINT (yyss, yyssp);
1342 : : yystate = *yyssp;
1343 : : goto yyerrlab1;
1344 : :
1345 : :
1346 : : /*-------------------------------------------------------------.
1347 : : | yyerrlab1 -- common code for both syntax error and YYERROR. |
1348 : : `-------------------------------------------------------------*/
1349 : 1 : yyerrlab1:
1350 : 1 : yyerrstatus = 3; /* Each real token shifted decrements this. */
1351 : :
1352 : : /* Pop stack until we find a state that shifts the error token. */
1353 : : for (;;)
1354 : : {
1355 : 4 : yyn = yypact[yystate];
1356 [ + - ]: 4 : if (!yypact_value_is_default (yyn))
1357 : : {
1358 : 4 : yyn += YYSYMBOL_YYerror;
1359 [ + + + - : 4 : if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
- + ]
1360 : : {
1361 : 0 : yyn = yytable[yyn];
1362 [ # # ]: 0 : if (0 < yyn)
1363 : 0 : break;
1364 : : }
1365 : : }
1366 : :
1367 : : /* Pop the current state because it cannot handle the error token. */
1368 [ + + ]: 4 : if (yyssp == yyss)
1369 : 1 : YYABORT;
1370 : :
1371 : :
1372 : 3 : yydestruct ("Error: popping",
1373 : 3 : YY_ACCESSING_SYMBOL (yystate), yyvsp, result, scanbuflen, escontext, yyscanner);
1374 : 3 : YYPOPSTACK (1);
1375 : 3 : yystate = *yyssp;
1376 : : YY_STACK_PRINT (yyss, yyssp);
1377 : : }
1378 : :
1379 : : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1380 : 0 : *++yyvsp = yylval;
1381 : : YY_IGNORE_MAYBE_UNINITIALIZED_END
1382 : :
1383 : :
1384 : : /* Shift the error token. */
1385 : : YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1386 : :
1387 : 0 : yystate = yyn;
1388 : 0 : goto yynewstate;
1389 : :
1390 : :
1391 : : /*-------------------------------------.
1392 : : | yyacceptlab -- YYACCEPT comes here. |
1393 : : `-------------------------------------*/
1394 : 3402 : yyacceptlab:
1395 : 3402 : yyresult = 0;
1396 : 3402 : goto yyreturnlab;
1397 : :
1398 : :
1399 : : /*-----------------------------------.
1400 : : | yyabortlab -- YYABORT comes here. |
1401 : : `-----------------------------------*/
1402 : 3 : yyabortlab:
1403 : 3 : yyresult = 1;
1404 : 3 : goto yyreturnlab;
1405 : :
1406 : :
1407 : : /*-----------------------------------------------------------.
1408 : : | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
1409 : : `-----------------------------------------------------------*/
1410 : 0 : yyexhaustedlab:
1411 : 0 : yyerror (result, scanbuflen, escontext, yyscanner, YY_("memory exhausted"));
1412 : 0 : yyresult = 2;
1413 : 0 : goto yyreturnlab;
1414 : :
1415 : :
1416 : : /*----------------------------------------------------------.
1417 : : | yyreturnlab -- parsing is finished, clean up and return. |
1418 : : `----------------------------------------------------------*/
1419 : 3405 : yyreturnlab:
1420 [ + + ]: 3405 : if (yychar != YYEMPTY)
1421 : : {
1422 : : /* Make sure we have latest lookahead translation. See comments at
1423 : : user semantic actions for why this is necessary. */
1424 [ + - + - ]: 3 : yytoken = YYTRANSLATE (yychar);
1425 : 3 : yydestruct ("Cleanup: discarding lookahead",
1426 : : yytoken, &yylval, result, scanbuflen, escontext, yyscanner);
1427 : : }
1428 : : /* Do not reclaim the symbols of the rule whose action triggered
1429 : : this YYABORT or YYACCEPT. */
1430 : 3405 : YYPOPSTACK (yylen);
1431 : : YY_STACK_PRINT (yyss, yyssp);
1432 [ + + ]: 10209 : while (yyssp != yyss)
1433 : : {
1434 : 6804 : yydestruct ("Cleanup: popping",
1435 : 6804 : YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, result, scanbuflen, escontext, yyscanner);
1436 : 6804 : YYPOPSTACK (1);
1437 : : }
1438 : : #ifndef yyoverflow
1439 [ - + ]: 3405 : if (yyss != yyssa)
1440 : 0 : YYSTACK_FREE (yyss);
1441 : : #endif
1442 : :
1443 : 3405 : return yyresult;
1444 : : }
1445 : :
1446 : : #line 168 "cubeparse.y"
1447 : :
1448 : :
1449 : : /* This assumes the string has been normalized by productions above */
1450 : : static int
1451 : : item_count(const char *s, char delim)
1452 : : {
1453 : : int nitems = 0;
1454 : :
1455 : : if (s[0] != '\0')
1456 : : {
1457 : : nitems++;
1458 : : while ((s = strchr(s, delim)) != NULL)
1459 : : {
1460 : : nitems++;
1461 : : s++;
1462 : : }
1463 : : }
1464 : : return nitems;
1465 : : }
1466 : :
1467 : : static bool
1468 : : write_box(int dim, char *str1, char *str2,
1469 : : NDBOX **result, struct Node *escontext)
1470 : : {
1471 : : NDBOX *bp;
1472 : : char *s;
1473 : : char *endptr;
1474 : : int i;
1475 : : int size = CUBE_SIZE(dim);
1476 : : bool point = true;
1477 : :
1478 : : bp = palloc0(size);
1479 : : SET_VARSIZE(bp, size);
1480 : : SET_DIM(bp, dim);
1481 : :
1482 : : s = str1;
1483 : : i = 0;
1484 : : if (dim > 0)
1485 : : {
1486 : : bp->x[i++] = float8in_internal(s, &endptr, "cube", str1, escontext);
1487 : : if (SOFT_ERROR_OCCURRED(escontext))
1488 : : return false;
1489 : : }
1490 : : while ((s = strchr(s, ',')) != NULL)
1491 : : {
1492 : : s++;
1493 : : bp->x[i++] = float8in_internal(s, &endptr, "cube", str1, escontext);
1494 : : if (SOFT_ERROR_OCCURRED(escontext))
1495 : : return false;
1496 : : }
1497 : : Assert(i == dim);
1498 : :
1499 : : s = str2;
1500 : : if (dim > 0)
1501 : : {
1502 : : bp->x[i] = float8in_internal(s, &endptr, "cube", str2, escontext);
1503 : : if (SOFT_ERROR_OCCURRED(escontext))
1504 : : return false;
1505 : : /* code this way to do right thing with NaN */
1506 : : point &= (bp->x[i] == bp->x[0]);
1507 : : i++;
1508 : : }
1509 : : while ((s = strchr(s, ',')) != NULL)
1510 : : {
1511 : : s++;
1512 : : bp->x[i] = float8in_internal(s, &endptr, "cube", str2, escontext);
1513 : : if (SOFT_ERROR_OCCURRED(escontext))
1514 : : return false;
1515 : : point &= (bp->x[i] == bp->x[i - dim]);
1516 : : i++;
1517 : : }
1518 : : Assert(i == dim * 2);
1519 : :
1520 : : if (point)
1521 : : {
1522 : : /*
1523 : : * The value turned out to be a point, ie. all the upper-right
1524 : : * coordinates were equal to the lower-left coordinates. Resize the
1525 : : * cube we constructed. Note: we don't bother to repalloc() it
1526 : : * smaller, as it's unlikely that the tiny amount of memory freed that
1527 : : * way would be useful, and the output is always short-lived.
1528 : : */
1529 : : size = POINT_SIZE(dim);
1530 : : SET_VARSIZE(bp, size);
1531 : : SET_POINT_BIT(bp);
1532 : : }
1533 : :
1534 : : *result = bp;
1535 : : return true;
1536 : : }
1537 : :
1538 : : static bool
1539 : : write_point_as_box(int dim, char *str,
1540 : : NDBOX **result, struct Node *escontext)
1541 : : {
1542 : : NDBOX *bp;
1543 : : int i,
1544 : : size;
1545 : : char *s;
1546 : : char *endptr;
1547 : :
1548 : : size = POINT_SIZE(dim);
1549 : : bp = palloc0(size);
1550 : : SET_VARSIZE(bp, size);
1551 : : SET_DIM(bp, dim);
1552 : : SET_POINT_BIT(bp);
1553 : :
1554 : : s = str;
1555 : : i = 0;
1556 : : if (dim > 0)
1557 : : {
1558 : : bp->x[i++] = float8in_internal(s, &endptr, "cube", str, escontext);
1559 : : if (SOFT_ERROR_OCCURRED(escontext))
1560 : : return false;
1561 : : }
1562 : : while ((s = strchr(s, ',')) != NULL)
1563 : : {
1564 : : s++;
1565 : : bp->x[i++] = float8in_internal(s, &endptr, "cube", str, escontext);
1566 : : if (SOFT_ERROR_OCCURRED(escontext))
1567 : : return false;
1568 : : }
1569 : : Assert(i == dim);
1570 : :
1571 : : *result = bp;
1572 : : return true;
1573 : : }
|