Line data Source code
1 : /* A Bison parser, made by GNU Bison 3.7.5. */
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 <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 : /* 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 30705
50 :
51 : /* Bison version string. */
52 : #define YYBISON_VERSION "3.7.5"
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 : #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
304 : /* Suppress an incorrect diagnostic about yylval being uninitialized. */
305 : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
306 : _Pragma ("GCC diagnostic push") \
307 : _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
308 : _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
309 : # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
310 : _Pragma ("GCC diagnostic pop")
311 : #else
312 : # define YY_INITIAL_VALUE(Value) Value
313 : #endif
314 : #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
315 : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
316 : # define YY_IGNORE_MAYBE_UNINITIALIZED_END
317 : #endif
318 : #ifndef YY_INITIAL_VALUE
319 : # define YY_INITIAL_VALUE(Value) /* Nothing. */
320 : #endif
321 :
322 : #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
323 : # define YY_IGNORE_USELESS_CAST_BEGIN \
324 : _Pragma ("GCC diagnostic push") \
325 : _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
326 : # define YY_IGNORE_USELESS_CAST_END \
327 : _Pragma ("GCC diagnostic pop")
328 : #endif
329 : #ifndef YY_IGNORE_USELESS_CAST_BEGIN
330 : # define YY_IGNORE_USELESS_CAST_BEGIN
331 : # define YY_IGNORE_USELESS_CAST_END
332 : #endif
333 :
334 :
335 : #define YY_ASSERT(E) ((void) (0 && (E)))
336 :
337 : #if !defined yyoverflow
338 :
339 : /* The parser invokes alloca or malloc; define the necessary symbols. */
340 :
341 : # ifdef YYSTACK_USE_ALLOCA
342 : # if YYSTACK_USE_ALLOCA
343 : # ifdef __GNUC__
344 : # define YYSTACK_ALLOC __builtin_alloca
345 : # elif defined __BUILTIN_VA_ARG_INCR
346 : # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
347 : # elif defined _AIX
348 : # define YYSTACK_ALLOC __alloca
349 : # elif defined _MSC_VER
350 : # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
351 : # define alloca _alloca
352 : # else
353 : # define YYSTACK_ALLOC alloca
354 : # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
355 : # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
356 : /* Use EXIT_SUCCESS as a witness for stdlib.h. */
357 : # ifndef EXIT_SUCCESS
358 : # define EXIT_SUCCESS 0
359 : # endif
360 : # endif
361 : # endif
362 : # endif
363 : # endif
364 :
365 : # ifdef YYSTACK_ALLOC
366 : /* Pacify GCC's 'empty if-body' warning. */
367 : # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
368 : # ifndef YYSTACK_ALLOC_MAXIMUM
369 : /* The OS might guarantee only one guard page at the bottom of the stack,
370 : and a page size can be as small as 4096 bytes. So we cannot safely
371 : invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
372 : to allow for a few compiler-allocated temporary stack slots. */
373 : # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
374 : # endif
375 : # else
376 : # define YYSTACK_ALLOC YYMALLOC
377 : # define YYSTACK_FREE YYFREE
378 : # ifndef YYSTACK_ALLOC_MAXIMUM
379 : # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
380 : # endif
381 : # if (defined __cplusplus && ! defined EXIT_SUCCESS \
382 : && ! ((defined YYMALLOC || defined malloc) \
383 : && (defined YYFREE || defined free)))
384 : # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
385 : # ifndef EXIT_SUCCESS
386 : # define EXIT_SUCCESS 0
387 : # endif
388 : # endif
389 : # ifndef YYMALLOC
390 : # define YYMALLOC malloc
391 : # if ! defined malloc && ! defined EXIT_SUCCESS
392 : void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
393 : # endif
394 : # endif
395 : # ifndef YYFREE
396 : # define YYFREE free
397 : # if ! defined free && ! defined EXIT_SUCCESS
398 : void free (void *); /* INFRINGES ON USER NAME SPACE */
399 : # endif
400 : # endif
401 : # endif
402 : #endif /* !defined yyoverflow */
403 :
404 : #if (! defined yyoverflow \
405 : && (! defined __cplusplus \
406 : || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
407 :
408 : /* A type that is properly aligned for any stack member. */
409 : union yyalloc
410 : {
411 : yy_state_t yyss_alloc;
412 : YYSTYPE yyvs_alloc;
413 : };
414 :
415 : /* The size of the maximum gap between one aligned stack and the next. */
416 : # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
417 :
418 : /* The size of an array large to enough to hold all stacks, each with
419 : N elements. */
420 : # define YYSTACK_BYTES(N) \
421 : ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
422 : + YYSTACK_GAP_MAXIMUM)
423 :
424 : # define YYCOPY_NEEDED 1
425 :
426 : /* Relocate STACK from its old location to the new one. The
427 : local variables YYSIZE and YYSTACKSIZE give the old and new number of
428 : elements in the stack, and YYPTR gives the new location of the
429 : stack. Advance YYPTR to a properly aligned location for the next
430 : stack. */
431 : # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
432 : do \
433 : { \
434 : YYPTRDIFF_T yynewbytes; \
435 : YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
436 : Stack = &yyptr->Stack_alloc; \
437 : yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
438 : yyptr += yynewbytes / YYSIZEOF (*yyptr); \
439 : } \
440 : while (0)
441 :
442 : #endif
443 :
444 : #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
445 : /* Copy COUNT objects from SRC to DST. The source and destination do
446 : not overlap. */
447 : # ifndef YYCOPY
448 : # if defined __GNUC__ && 1 < __GNUC__
449 : # define YYCOPY(Dst, Src, Count) \
450 : __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
451 : # else
452 : # define YYCOPY(Dst, Src, Count) \
453 : do \
454 : { \
455 : YYPTRDIFF_T yyi; \
456 : for (yyi = 0; yyi < (Count); yyi++) \
457 : (Dst)[yyi] = (Src)[yyi]; \
458 : } \
459 : while (0)
460 : # endif
461 : # endif
462 : #endif /* !YYCOPY_NEEDED */
463 :
464 : /* YYFINAL -- State number of the termination state. */
465 : #define YYFINAL 10
466 : /* YYLAST -- Last index in YYTABLE. */
467 : #define YYLAST 17
468 :
469 : /* YYNTOKENS -- Number of terminals. */
470 : #define YYNTOKENS 9
471 : /* YYNNTS -- Number of nonterminals. */
472 : #define YYNNTS 4
473 : /* YYNRULES -- Number of rules. */
474 : #define YYNRULES 9
475 : /* YYNSTATES -- Number of states. */
476 : #define YYNSTATES 19
477 :
478 : /* YYMAXUTOK -- Last valid token kind. */
479 : #define YYMAXUTOK 263
480 :
481 :
482 : /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
483 : as returned by yylex, with out-of-bounds checking. */
484 : #define YYTRANSLATE(YYX) \
485 : (0 <= (YYX) && (YYX) <= YYMAXUTOK \
486 : ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
487 : : YYSYMBOL_YYUNDEF)
488 :
489 : /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
490 : as returned by yylex. */
491 : static const yytype_int8 yytranslate[] =
492 : {
493 : 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
494 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
495 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
496 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
497 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
498 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
499 : 2, 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, 1, 2, 3, 4,
519 : 5, 6, 7, 8
520 : };
521 :
522 : #if YYDEBUG
523 : /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
524 : static const yytype_uint8 yyrline[] =
525 : {
526 : 0, 47, 47, 77, 105, 124, 144, 148, 154, 160
527 : };
528 : #endif
529 :
530 : /** Accessing symbol of state STATE. */
531 : #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
532 :
533 : #if YYDEBUG || 0
534 : /* The user-facing name of the symbol whose (internal) number is
535 : YYSYMBOL. No bounds checking. */
536 : static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
537 :
538 : /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
539 : First, the terminals, then, starting at YYNTOKENS, nonterminals. */
540 : static const char *const yytname[] =
541 : {
542 : "\"end of file\"", "error", "\"invalid token\"", "CUBEFLOAT", "O_PAREN",
543 : "C_PAREN", "O_BRACKET", "C_BRACKET", "COMMA", "$accept", "box",
544 : "paren_list", "list", YY_NULLPTR
545 : };
546 :
547 : static const char *
548 : yysymbol_name (yysymbol_kind_t yysymbol)
549 : {
550 : return yytname[yysymbol];
551 : }
552 : #endif
553 :
554 : #ifdef YYPRINT
555 : /* YYTOKNUM[NUM] -- (External) token number corresponding to the
556 : (internal) symbol number NUM (which must be that of a token). */
557 : static const yytype_int16 yytoknum[] =
558 : {
559 : 0, 256, 257, 258, 259, 260, 261, 262, 263
560 : };
561 : #endif
562 :
563 : #define YYPACT_NINF (-4)
564 :
565 : #define yypact_value_is_default(Yyn) \
566 : ((Yyn) == YYPACT_NINF)
567 :
568 : #define YYTABLE_NINF (-1)
569 :
570 : #define yytable_value_is_error(Yyn) \
571 : 0
572 :
573 : /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
574 : STATE-NUM. */
575 : static const yytype_int8 yypact[] =
576 : {
577 : -2, -4, 0, 3, 10, 4, 5, -4, 1, 6,
578 : -4, 3, 12, -4, 3, -4, -4, 9, -4
579 : };
580 :
581 : /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
582 : Performed when YYTABLE does not specify something else to do. Zero
583 : means the default is an error. */
584 : static const yytype_int8 yydefact[] =
585 : {
586 : 0, 8, 0, 0, 0, 4, 5, 7, 0, 0,
587 : 1, 0, 0, 6, 0, 3, 9, 0, 2
588 : };
589 :
590 : /* YYPGOTO[NTERM-NUM]. */
591 : static const yytype_int8 yypgoto[] =
592 : {
593 : -4, -4, -3, 15
594 : };
595 :
596 : /* YYDEFGOTO[NTERM-NUM]. */
597 : static const yytype_int8 yydefgoto[] =
598 : {
599 : 0, 4, 5, 6
600 : };
601 :
602 : /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
603 : positive, shift that token. If negative, reduce the rule whose
604 : number is the opposite. If YYTABLE_NINF, syntax error. */
605 : static const yytype_int8 yytable[] =
606 : {
607 : 9, 1, 2, 1, 3, 7, 13, 2, 15, 12,
608 : 10, 17, 11, 12, 14, 16, 18, 8
609 : };
610 :
611 : static const yytype_int8 yycheck[] =
612 : {
613 : 3, 3, 4, 3, 6, 5, 5, 4, 11, 8,
614 : 0, 14, 8, 8, 8, 3, 7, 2
615 : };
616 :
617 : /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
618 : symbol of state STATE-NUM. */
619 : static const yytype_int8 yystos[] =
620 : {
621 : 0, 3, 4, 6, 10, 11, 12, 5, 12, 11,
622 : 0, 8, 8, 5, 8, 11, 3, 11, 7
623 : };
624 :
625 : /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
626 : static const yytype_int8 yyr1[] =
627 : {
628 : 0, 9, 10, 10, 10, 10, 11, 11, 12, 12
629 : };
630 :
631 : /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
632 : static const yytype_int8 yyr2[] =
633 : {
634 : 0, 2, 5, 3, 1, 1, 3, 2, 1, 3
635 : };
636 :
637 :
638 : enum { YYENOMEM = -2 };
639 :
640 : #define yyerrok (yyerrstatus = 0)
641 : #define yyclearin (yychar = YYEMPTY)
642 :
643 : #define YYACCEPT goto yyacceptlab
644 : #define YYABORT goto yyabortlab
645 : #define YYERROR goto yyerrorlab
646 :
647 :
648 : #define YYRECOVERING() (!!yyerrstatus)
649 :
650 : #define YYBACKUP(Token, Value) \
651 : do \
652 : if (yychar == YYEMPTY) \
653 : { \
654 : yychar = (Token); \
655 : yylval = (Value); \
656 : YYPOPSTACK (yylen); \
657 : yystate = *yyssp; \
658 : goto yybackup; \
659 : } \
660 : else \
661 : { \
662 : yyerror (result, scanbuflen, escontext, yyscanner, YY_("syntax error: cannot back up")); \
663 : YYERROR; \
664 : } \
665 : while (0)
666 :
667 : /* Backward compatibility with an undocumented macro.
668 : Use YYerror or YYUNDEF. */
669 : #define YYERRCODE YYUNDEF
670 :
671 :
672 : /* Enable debugging if requested. */
673 : #if YYDEBUG
674 :
675 : # ifndef YYFPRINTF
676 : # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
677 : # define YYFPRINTF fprintf
678 : # endif
679 :
680 : # define YYDPRINTF(Args) \
681 : do { \
682 : if (yydebug) \
683 : YYFPRINTF Args; \
684 : } while (0)
685 :
686 : /* This macro is provided for backward compatibility. */
687 : # ifndef YY_LOCATION_PRINT
688 : # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
689 : # endif
690 :
691 :
692 : # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
693 : do { \
694 : if (yydebug) \
695 : { \
696 : YYFPRINTF (stderr, "%s ", Title); \
697 : yy_symbol_print (stderr, \
698 : Kind, Value, result, scanbuflen, escontext, yyscanner); \
699 : YYFPRINTF (stderr, "\n"); \
700 : } \
701 : } while (0)
702 :
703 :
704 : /*-----------------------------------.
705 : | Print this symbol's value on YYO. |
706 : `-----------------------------------*/
707 :
708 : static void
709 : yy_symbol_value_print (FILE *yyo,
710 : yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner)
711 : {
712 : FILE *yyoutput = yyo;
713 : YY_USE (yyoutput);
714 : YY_USE (result);
715 : YY_USE (scanbuflen);
716 : YY_USE (escontext);
717 : YY_USE (yyscanner);
718 : if (!yyvaluep)
719 : return;
720 : # ifdef YYPRINT
721 : if (yykind < YYNTOKENS)
722 : YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
723 : # endif
724 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
725 : YY_USE (yykind);
726 : YY_IGNORE_MAYBE_UNINITIALIZED_END
727 : }
728 :
729 :
730 : /*---------------------------.
731 : | Print this symbol on YYO. |
732 : `---------------------------*/
733 :
734 : static void
735 : yy_symbol_print (FILE *yyo,
736 : yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner)
737 : {
738 : YYFPRINTF (yyo, "%s %s (",
739 : yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
740 :
741 : yy_symbol_value_print (yyo, yykind, yyvaluep, result, scanbuflen, escontext, yyscanner);
742 : YYFPRINTF (yyo, ")");
743 : }
744 :
745 : /*------------------------------------------------------------------.
746 : | yy_stack_print -- Print the state stack from its BOTTOM up to its |
747 : | TOP (included). |
748 : `------------------------------------------------------------------*/
749 :
750 : static void
751 : yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
752 : {
753 : YYFPRINTF (stderr, "Stack now");
754 : for (; yybottom <= yytop; yybottom++)
755 : {
756 : int yybot = *yybottom;
757 : YYFPRINTF (stderr, " %d", yybot);
758 : }
759 : YYFPRINTF (stderr, "\n");
760 : }
761 :
762 : # define YY_STACK_PRINT(Bottom, Top) \
763 : do { \
764 : if (yydebug) \
765 : yy_stack_print ((Bottom), (Top)); \
766 : } while (0)
767 :
768 :
769 : /*------------------------------------------------.
770 : | Report that the YYRULE is going to be reduced. |
771 : `------------------------------------------------*/
772 :
773 : static void
774 : yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
775 : int yyrule, NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner)
776 : {
777 : int yylno = yyrline[yyrule];
778 : int yynrhs = yyr2[yyrule];
779 : int yyi;
780 : YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
781 : yyrule - 1, yylno);
782 : /* The symbols being reduced. */
783 : for (yyi = 0; yyi < yynrhs; yyi++)
784 : {
785 : YYFPRINTF (stderr, " $%d = ", yyi + 1);
786 : yy_symbol_print (stderr,
787 : YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
788 : &yyvsp[(yyi + 1) - (yynrhs)], result, scanbuflen, escontext, yyscanner);
789 : YYFPRINTF (stderr, "\n");
790 : }
791 : }
792 :
793 : # define YY_REDUCE_PRINT(Rule) \
794 : do { \
795 : if (yydebug) \
796 : yy_reduce_print (yyssp, yyvsp, Rule, result, scanbuflen, escontext, yyscanner); \
797 : } while (0)
798 :
799 : /* Nonzero means print parse trace. It is left uninitialized so that
800 : multiple parsers can coexist. */
801 : int yydebug;
802 : #else /* !YYDEBUG */
803 : # define YYDPRINTF(Args) ((void) 0)
804 : # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
805 : # define YY_STACK_PRINT(Bottom, Top)
806 : # define YY_REDUCE_PRINT(Rule)
807 : #endif /* !YYDEBUG */
808 :
809 :
810 : /* YYINITDEPTH -- initial size of the parser's stacks. */
811 : #ifndef YYINITDEPTH
812 : # define YYINITDEPTH 200
813 : #endif
814 :
815 : /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
816 : if the built-in stack extension method is used).
817 :
818 : Do not make this value too large; the results are undefined if
819 : YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
820 : evaluated with infinite-precision integer arithmetic. */
821 :
822 : #ifndef YYMAXDEPTH
823 : # define YYMAXDEPTH 10000
824 : #endif
825 :
826 :
827 :
828 :
829 :
830 :
831 : /*-----------------------------------------------.
832 : | Release the memory associated to this symbol. |
833 : `-----------------------------------------------*/
834 :
835 : static void
836 13620 : yydestruct (const char *yymsg,
837 : yysymbol_kind_t yykind, YYSTYPE *yyvaluep, NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner)
838 : {
839 : YY_USE (yyvaluep);
840 : YY_USE (result);
841 : YY_USE (scanbuflen);
842 : YY_USE (escontext);
843 : YY_USE (yyscanner);
844 13620 : if (!yymsg)
845 0 : yymsg = "Deleting";
846 : YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
847 :
848 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
849 : YY_USE (yykind);
850 : YY_IGNORE_MAYBE_UNINITIALIZED_END
851 13620 : }
852 :
853 :
854 :
855 :
856 :
857 :
858 : /*----------.
859 : | yyparse. |
860 : `----------*/
861 :
862 : int
863 6870 : yyparse (NDBOX **result, Size scanbuflen, struct Node *escontext, yyscan_t yyscanner)
864 : {
865 : /* Lookahead token kind. */
866 : int yychar;
867 :
868 :
869 : /* The semantic value of the lookahead symbol. */
870 : /* Default value used for initialization, for pacifying older GCCs
871 : or non-GCC compilers. */
872 : YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
873 : YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
874 :
875 : /* Number of syntax errors so far. */
876 6870 : int yynerrs = 0;
877 :
878 6870 : yy_state_fast_t yystate = 0;
879 : /* Number of tokens to shift before error messages enabled. */
880 6870 : int yyerrstatus = 0;
881 :
882 : /* Refer to the stacks through separate pointers, to allow yyoverflow
883 : to reallocate them elsewhere. */
884 :
885 : /* Their size. */
886 6870 : YYPTRDIFF_T yystacksize = YYINITDEPTH;
887 :
888 : /* The state stack: array, bottom, top. */
889 : yy_state_t yyssa[YYINITDEPTH];
890 6870 : yy_state_t *yyss = yyssa;
891 6870 : yy_state_t *yyssp = yyss;
892 :
893 : /* The semantic value stack: array, bottom, top. */
894 : YYSTYPE yyvsa[YYINITDEPTH];
895 6870 : YYSTYPE *yyvs = yyvsa;
896 6870 : YYSTYPE *yyvsp = yyvs;
897 :
898 : int yyn;
899 : /* The return value of yyparse. */
900 : int yyresult;
901 : /* Lookahead symbol kind. */
902 6870 : yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
903 : /* The variables used to return semantic value and location from the
904 : action routines. */
905 : YYSTYPE yyval;
906 :
907 :
908 :
909 : #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
910 :
911 : /* The number of symbols on the RHS of the reduced rule.
912 : Keep to zero when no symbol should be popped. */
913 6870 : int yylen = 0;
914 :
915 : YYDPRINTF ((stderr, "Starting parse\n"));
916 :
917 6870 : yychar = YYEMPTY; /* Cause a token to be read. */
918 6870 : goto yysetstate;
919 :
920 :
921 : /*------------------------------------------------------------.
922 : | yynewstate -- push a new state, which is found in yystate. |
923 : `------------------------------------------------------------*/
924 130826 : yynewstate:
925 : /* In all cases, when you get here, the value and location stacks
926 : have just been pushed. So pushing a state here evens the stacks. */
927 130826 : yyssp++;
928 :
929 :
930 : /*--------------------------------------------------------------------.
931 : | yysetstate -- set current state (the top of the stack) to yystate. |
932 : `--------------------------------------------------------------------*/
933 137696 : yysetstate:
934 : YYDPRINTF ((stderr, "Entering state %d\n", yystate));
935 : YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
936 : YY_IGNORE_USELESS_CAST_BEGIN
937 137696 : *yyssp = YY_CAST (yy_state_t, yystate);
938 : YY_IGNORE_USELESS_CAST_END
939 : YY_STACK_PRINT (yyss, yyssp);
940 :
941 137696 : if (yyss + yystacksize - 1 <= yyssp)
942 : #if !defined yyoverflow && !defined YYSTACK_RELOCATE
943 : goto yyexhaustedlab;
944 : #else
945 : {
946 : /* Get the current used size of the three stacks, in elements. */
947 0 : YYPTRDIFF_T yysize = yyssp - yyss + 1;
948 :
949 : # if defined yyoverflow
950 : {
951 : /* Give user a chance to reallocate the stack. Use copies of
952 : these so that the &'s don't force the real ones into
953 : memory. */
954 : yy_state_t *yyss1 = yyss;
955 : YYSTYPE *yyvs1 = yyvs;
956 :
957 : /* Each stack pointer address is followed by the size of the
958 : data in use in that stack, in bytes. This used to be a
959 : conditional around just the two extra args, but that might
960 : be undefined if yyoverflow is a macro. */
961 : yyoverflow (YY_("memory exhausted"),
962 : &yyss1, yysize * YYSIZEOF (*yyssp),
963 : &yyvs1, yysize * YYSIZEOF (*yyvsp),
964 : &yystacksize);
965 : yyss = yyss1;
966 : yyvs = yyvs1;
967 : }
968 : # else /* defined YYSTACK_RELOCATE */
969 : /* Extend the stack our own way. */
970 0 : if (YYMAXDEPTH <= yystacksize)
971 0 : goto yyexhaustedlab;
972 0 : yystacksize *= 2;
973 0 : if (YYMAXDEPTH < yystacksize)
974 0 : yystacksize = YYMAXDEPTH;
975 :
976 : {
977 0 : yy_state_t *yyss1 = yyss;
978 : union yyalloc *yyptr =
979 0 : YY_CAST (union yyalloc *,
980 : YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
981 0 : if (! yyptr)
982 0 : goto yyexhaustedlab;
983 0 : YYSTACK_RELOCATE (yyss_alloc, yyss);
984 0 : YYSTACK_RELOCATE (yyvs_alloc, yyvs);
985 : # undef YYSTACK_RELOCATE
986 0 : if (yyss1 != yyssa)
987 0 : YYSTACK_FREE (yyss1);
988 : }
989 : # endif
990 :
991 0 : yyssp = yyss + yysize - 1;
992 0 : yyvsp = yyvs + yysize - 1;
993 :
994 : YY_IGNORE_USELESS_CAST_BEGIN
995 : YYDPRINTF ((stderr, "Stack size increased to %ld\n",
996 : YY_CAST (long, yystacksize)));
997 : YY_IGNORE_USELESS_CAST_END
998 :
999 0 : if (yyss + yystacksize - 1 <= yyssp)
1000 0 : YYABORT;
1001 : }
1002 : #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1003 :
1004 137696 : if (yystate == YYFINAL)
1005 6804 : YYACCEPT;
1006 :
1007 130892 : goto yybackup;
1008 :
1009 :
1010 : /*-----------.
1011 : | yybackup. |
1012 : `-----------*/
1013 130892 : yybackup:
1014 : /* Do appropriate processing given the current state. Read a
1015 : lookahead token if we need one and don't already have one. */
1016 :
1017 : /* First try to decide what to do without reference to lookahead token. */
1018 130892 : yyn = yypact[yystate];
1019 130892 : if (yypact_value_is_default (yyn))
1020 47842 : goto yydefault;
1021 :
1022 : /* Not known => get a lookahead token if don't already have one. */
1023 :
1024 : /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1025 83050 : if (yychar == YYEMPTY)
1026 : {
1027 : YYDPRINTF ((stderr, "Reading a token\n"));
1028 82742 : yychar = yylex (&yylval, yyscanner);
1029 : }
1030 :
1031 83050 : if (yychar <= YYEOF)
1032 : {
1033 7112 : yychar = YYEOF;
1034 7112 : yytoken = YYSYMBOL_YYEOF;
1035 : YYDPRINTF ((stderr, "Now at end of input.\n"));
1036 : }
1037 75938 : else if (yychar == YYerror)
1038 : {
1039 : /* The scanner already issued an error message, process directly
1040 : to error recovery. But do not keep the error token as
1041 : lookahead, it is too special and may lead us to an endless
1042 : loop in error recovery. */
1043 0 : yychar = YYUNDEF;
1044 0 : yytoken = YYSYMBOL_YYerror;
1045 0 : goto yyerrlab1;
1046 : }
1047 : else
1048 : {
1049 75938 : yytoken = YYTRANSLATE (yychar);
1050 : YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1051 : }
1052 :
1053 : /* If the proper action on seeing token YYTOKEN is to reduce or to
1054 : detect an error, take that action. */
1055 83050 : yyn += yytoken;
1056 83050 : if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1057 364 : goto yydefault;
1058 82686 : yyn = yytable[yyn];
1059 82686 : if (yyn <= 0)
1060 : {
1061 : if (yytable_value_is_error (yyn))
1062 : goto yyerrlab;
1063 0 : yyn = -yyn;
1064 0 : goto yyreduce;
1065 : }
1066 :
1067 : /* Count tokens shifted since error; after three, turn off error
1068 : status. */
1069 82686 : if (yyerrstatus)
1070 0 : yyerrstatus--;
1071 :
1072 : /* Shift the lookahead token. */
1073 : YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1074 82686 : yystate = yyn;
1075 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1076 82686 : *++yyvsp = yylval;
1077 : YY_IGNORE_MAYBE_UNINITIALIZED_END
1078 :
1079 : /* Discard the shifted token. */
1080 82686 : yychar = YYEMPTY;
1081 82686 : goto yynewstate;
1082 :
1083 :
1084 : /*-----------------------------------------------------------.
1085 : | yydefault -- do the default action for the current state. |
1086 : `-----------------------------------------------------------*/
1087 48206 : yydefault:
1088 48206 : yyn = yydefact[yystate];
1089 48206 : if (yyn == 0)
1090 48 : goto yyerrlab;
1091 48158 : goto yyreduce;
1092 :
1093 :
1094 : /*-----------------------------.
1095 : | yyreduce -- do a reduction. |
1096 : `-----------------------------*/
1097 48158 : yyreduce:
1098 : /* yyn is the number of a rule to reduce with. */
1099 48158 : yylen = yyr2[yyn];
1100 :
1101 : /* If YYLEN is nonzero, implement the default value of the action:
1102 : '$$ = $1'.
1103 :
1104 : Otherwise, the following line sets YYVAL to garbage.
1105 : This behavior is undocumented and Bison
1106 : users should not rely upon it. Assigning to YYVAL
1107 : unconditionally makes the parser a bit smaller, and it avoids a
1108 : GCC warning that YYVAL may be used uninitialized. */
1109 48158 : yyval = yyvsp[1-yylen];
1110 :
1111 :
1112 : YY_REDUCE_PRINT (yyn);
1113 48158 : switch (yyn)
1114 : {
1115 32 : case 2: /* box: O_BRACKET paren_list COMMA paren_list C_BRACKET */
1116 : #line 48 "cubeparse.y"
1117 : {
1118 : int dim;
1119 :
1120 : dim = item_count(yyvsp[-3], ',');
1121 : if (item_count(yyvsp[-1], ',') != dim)
1122 : {
1123 : errsave(escontext,
1124 : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1125 : errmsg("invalid input syntax for cube"),
1126 : errdetail("Different point dimensions in (%s) and (%s).",
1127 : yyvsp[-3], yyvsp[-1])));
1128 : YYABORT;
1129 : }
1130 : if (dim > CUBE_MAX_DIM)
1131 : {
1132 : errsave(escontext,
1133 : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1134 : errmsg("invalid input syntax for cube"),
1135 : errdetail("A cube cannot have more than %d dimensions.",
1136 : CUBE_MAX_DIM)));
1137 : YYABORT;
1138 : }
1139 :
1140 : if (!write_box(dim, yyvsp[-3], yyvsp[-1], result, escontext))
1141 : YYABORT;
1142 :
1143 : (void) yynerrs; /* suppress compiler warning */
1144 : }
1145 : #line 1146 "cubeparse.c"
1146 28 : break;
1147 :
1148 6492 : case 3: /* box: paren_list COMMA paren_list */
1149 : #line 78 "cubeparse.y"
1150 : {
1151 : int dim;
1152 :
1153 : dim = item_count(yyvsp[-2], ',');
1154 : if (item_count(yyvsp[0], ',') != dim)
1155 : {
1156 : errsave(escontext,
1157 : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1158 : errmsg("invalid input syntax for cube"),
1159 : errdetail("Different point dimensions in (%s) and (%s).",
1160 : yyvsp[-2], yyvsp[0])));
1161 : YYABORT;
1162 : }
1163 : if (dim > CUBE_MAX_DIM)
1164 : {
1165 : errsave(escontext,
1166 : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1167 : errmsg("invalid input syntax for cube"),
1168 : errdetail("A cube cannot have more than %d dimensions.",
1169 : CUBE_MAX_DIM)));
1170 : YYABORT;
1171 : }
1172 :
1173 : if (!write_box(dim, yyvsp[-2], yyvsp[0], result, escontext))
1174 : YYABORT;
1175 : }
1176 : #line 1177 "cubeparse.c"
1177 6486 : break;
1178 :
1179 138 : case 4: /* box: paren_list */
1180 : #line 106 "cubeparse.y"
1181 : {
1182 : int dim;
1183 :
1184 : dim = item_count(yyvsp[0], ',');
1185 : if (dim > CUBE_MAX_DIM)
1186 : {
1187 : errsave(escontext,
1188 : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1189 : errmsg("invalid input syntax for cube"),
1190 : errdetail("A cube cannot have more than %d dimensions.",
1191 : CUBE_MAX_DIM)));
1192 : YYABORT;
1193 : }
1194 :
1195 : if (!write_point_as_box(dim, yyvsp[0], result, escontext))
1196 : YYABORT;
1197 : }
1198 : #line 1199 "cubeparse.c"
1199 136 : break;
1200 :
1201 178 : case 5: /* box: list */
1202 : #line 125 "cubeparse.y"
1203 : {
1204 : int dim;
1205 :
1206 : dim = item_count(yyvsp[0], ',');
1207 : if (dim > CUBE_MAX_DIM)
1208 : {
1209 : errsave(escontext,
1210 : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1211 : errmsg("invalid input syntax for cube"),
1212 : errdetail("A cube cannot have more than %d dimensions.",
1213 : CUBE_MAX_DIM)));
1214 : YYABORT;
1215 : }
1216 :
1217 : if (!write_point_as_box(dim, yyvsp[0], result, escontext))
1218 : YYABORT;
1219 : }
1220 : #line 1221 "cubeparse.c"
1221 172 : break;
1222 :
1223 13192 : case 6: /* paren_list: O_PAREN list C_PAREN */
1224 : #line 145 "cubeparse.y"
1225 : {
1226 : yyval = yyvsp[-1];
1227 : }
1228 : #line 1229 "cubeparse.c"
1229 13192 : break;
1230 :
1231 8 : case 7: /* paren_list: O_PAREN C_PAREN */
1232 : #line 149 "cubeparse.y"
1233 : {
1234 : yyval = pstrdup("");
1235 : }
1236 : #line 1237 "cubeparse.c"
1237 8 : break;
1238 :
1239 13382 : case 8: /* list: CUBEFLOAT */
1240 : #line 155 "cubeparse.y"
1241 : {
1242 : /* alloc enough space to be sure whole list will fit */
1243 : yyval = palloc(scanbuflen + 1);
1244 : strcpy(yyval, yyvsp[0]);
1245 : }
1246 : #line 1247 "cubeparse.c"
1247 13382 : break;
1248 :
1249 14736 : case 9: /* list: list COMMA CUBEFLOAT */
1250 : #line 161 "cubeparse.y"
1251 : {
1252 : yyval = yyvsp[-2];
1253 : strcat(yyval, ",");
1254 : strcat(yyval, yyvsp[0]);
1255 : }
1256 : #line 1257 "cubeparse.c"
1257 14736 : break;
1258 :
1259 :
1260 : #line 1261 "cubeparse.c"
1261 :
1262 0 : default: break;
1263 : }
1264 : /* User semantic actions sometimes alter yychar, and that requires
1265 : that yytoken be updated with the new translation. We take the
1266 : approach of translating immediately before every use of yytoken.
1267 : One alternative is translating here after every semantic action,
1268 : but that translation would be missed if the semantic action invokes
1269 : YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1270 : if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1271 : incorrect destructor might then be invoked immediately. In the
1272 : case of YYERROR or YYBACKUP, subsequent parser actions might lead
1273 : to an incorrect destructor call or verbose syntax error message
1274 : before the lookahead is translated. */
1275 : YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1276 :
1277 48140 : YYPOPSTACK (yylen);
1278 48140 : yylen = 0;
1279 :
1280 48140 : *++yyvsp = yyval;
1281 :
1282 : /* Now 'shift' the result of the reduction. Determine what state
1283 : that goes to, based on the state we popped back to and the rule
1284 : number reduced by. */
1285 : {
1286 48140 : const int yylhs = yyr1[yyn] - YYNTOKENS;
1287 48140 : const int yyi = yypgoto[yylhs] + *yyssp;
1288 34688 : yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1289 34400 : ? yytable[yyi]
1290 82828 : : yydefgoto[yylhs]);
1291 : }
1292 :
1293 48140 : goto yynewstate;
1294 :
1295 :
1296 : /*--------------------------------------.
1297 : | yyerrlab -- here on detecting error. |
1298 : `--------------------------------------*/
1299 48 : yyerrlab:
1300 : /* Make sure we have latest lookahead translation. See comments at
1301 : user semantic actions for why this is necessary. */
1302 48 : yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1303 : /* If not already recovering from an error, report this error. */
1304 48 : if (!yyerrstatus)
1305 : {
1306 48 : ++yynerrs;
1307 48 : yyerror (result, scanbuflen, escontext, yyscanner, YY_("syntax error"));
1308 : }
1309 :
1310 2 : if (yyerrstatus == 3)
1311 : {
1312 : /* If just tried and failed to reuse lookahead token after an
1313 : error, discard it. */
1314 :
1315 0 : if (yychar <= YYEOF)
1316 : {
1317 : /* Return failure if at end of input. */
1318 0 : if (yychar == YYEOF)
1319 0 : YYABORT;
1320 : }
1321 : else
1322 : {
1323 0 : yydestruct ("Error: discarding",
1324 : yytoken, &yylval, result, scanbuflen, escontext, yyscanner);
1325 0 : yychar = YYEMPTY;
1326 : }
1327 : }
1328 :
1329 : /* Else will try to reuse lookahead token after shifting the error
1330 : token. */
1331 2 : goto yyerrlab1;
1332 :
1333 :
1334 : /*---------------------------------------------------.
1335 : | yyerrorlab -- error raised explicitly by YYERROR. |
1336 : `---------------------------------------------------*/
1337 : yyerrorlab:
1338 : /* Pacify compilers when the user code never invokes YYERROR and the
1339 : label yyerrorlab therefore never appears in user code. */
1340 : if (0)
1341 : YYERROR;
1342 :
1343 : /* Do not reclaim the symbols of the rule whose action triggered
1344 : this YYERROR. */
1345 : YYPOPSTACK (yylen);
1346 : yylen = 0;
1347 : YY_STACK_PRINT (yyss, yyssp);
1348 : yystate = *yyssp;
1349 : goto yyerrlab1;
1350 :
1351 :
1352 : /*-------------------------------------------------------------.
1353 : | yyerrlab1 -- common code for both syntax error and YYERROR. |
1354 : `-------------------------------------------------------------*/
1355 2 : yyerrlab1:
1356 2 : yyerrstatus = 3; /* Each real token shifted decrements this. */
1357 :
1358 : /* Pop stack until we find a state that shifts the error token. */
1359 : for (;;)
1360 : {
1361 8 : yyn = yypact[yystate];
1362 8 : if (!yypact_value_is_default (yyn))
1363 : {
1364 8 : yyn += YYSYMBOL_YYerror;
1365 8 : if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1366 : {
1367 0 : yyn = yytable[yyn];
1368 0 : if (0 < yyn)
1369 0 : break;
1370 : }
1371 : }
1372 :
1373 : /* Pop the current state because it cannot handle the error token. */
1374 8 : if (yyssp == yyss)
1375 2 : YYABORT;
1376 :
1377 :
1378 6 : yydestruct ("Error: popping",
1379 6 : YY_ACCESSING_SYMBOL (yystate), yyvsp, result, scanbuflen, escontext, yyscanner);
1380 6 : YYPOPSTACK (1);
1381 6 : yystate = *yyssp;
1382 : YY_STACK_PRINT (yyss, yyssp);
1383 : }
1384 :
1385 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1386 0 : *++yyvsp = yylval;
1387 : YY_IGNORE_MAYBE_UNINITIALIZED_END
1388 :
1389 :
1390 : /* Shift the error token. */
1391 : YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1392 :
1393 0 : yystate = yyn;
1394 0 : goto yynewstate;
1395 :
1396 :
1397 : /*-------------------------------------.
1398 : | yyacceptlab -- YYACCEPT comes here. |
1399 : `-------------------------------------*/
1400 6804 : yyacceptlab:
1401 6804 : yyresult = 0;
1402 6804 : goto yyreturn;
1403 :
1404 :
1405 : /*-----------------------------------.
1406 : | yyabortlab -- YYABORT comes here. |
1407 : `-----------------------------------*/
1408 6 : yyabortlab:
1409 6 : yyresult = 1;
1410 6 : goto yyreturn;
1411 :
1412 :
1413 : #if !defined yyoverflow
1414 : /*-------------------------------------------------.
1415 : | yyexhaustedlab -- memory exhaustion comes here. |
1416 : `-------------------------------------------------*/
1417 0 : yyexhaustedlab:
1418 0 : yyerror (result, scanbuflen, escontext, yyscanner, YY_("memory exhausted"));
1419 0 : yyresult = 2;
1420 0 : goto yyreturn;
1421 : #endif
1422 :
1423 :
1424 : /*-------------------------------------------------------.
1425 : | yyreturn -- parsing is finished, clean up and return. |
1426 : `-------------------------------------------------------*/
1427 6810 : yyreturn:
1428 6810 : if (yychar != YYEMPTY)
1429 : {
1430 : /* Make sure we have latest lookahead translation. See comments at
1431 : user semantic actions for why this is necessary. */
1432 6 : yytoken = YYTRANSLATE (yychar);
1433 6 : yydestruct ("Cleanup: discarding lookahead",
1434 : yytoken, &yylval, result, scanbuflen, escontext, yyscanner);
1435 : }
1436 : /* Do not reclaim the symbols of the rule whose action triggered
1437 : this YYABORT or YYACCEPT. */
1438 6810 : YYPOPSTACK (yylen);
1439 : YY_STACK_PRINT (yyss, yyssp);
1440 20418 : while (yyssp != yyss)
1441 : {
1442 13608 : yydestruct ("Cleanup: popping",
1443 13608 : YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, result, scanbuflen, escontext, yyscanner);
1444 13608 : YYPOPSTACK (1);
1445 : }
1446 : #ifndef yyoverflow
1447 6810 : if (yyss != yyssa)
1448 0 : YYSTACK_FREE (yyss);
1449 : #endif
1450 :
1451 6810 : return yyresult;
1452 : }
1453 :
1454 : #line 168 "cubeparse.y"
1455 :
1456 :
1457 : /* This assumes the string has been normalized by productions above */
1458 : static int
1459 : item_count(const char *s, char delim)
1460 : {
1461 : int nitems = 0;
1462 :
1463 : if (s[0] != '\0')
1464 : {
1465 : nitems++;
1466 : while ((s = strchr(s, delim)) != NULL)
1467 : {
1468 : nitems++;
1469 : s++;
1470 : }
1471 : }
1472 : return nitems;
1473 : }
1474 :
1475 : static bool
1476 : write_box(int dim, char *str1, char *str2,
1477 : NDBOX **result, struct Node *escontext)
1478 : {
1479 : NDBOX *bp;
1480 : char *s;
1481 : char *endptr;
1482 : int i;
1483 : int size = CUBE_SIZE(dim);
1484 : bool point = true;
1485 :
1486 : bp = palloc0(size);
1487 : SET_VARSIZE(bp, size);
1488 : SET_DIM(bp, dim);
1489 :
1490 : s = str1;
1491 : i = 0;
1492 : if (dim > 0)
1493 : {
1494 : bp->x[i++] = float8in_internal(s, &endptr, "cube", str1, escontext);
1495 : if (SOFT_ERROR_OCCURRED(escontext))
1496 : return false;
1497 : }
1498 : while ((s = strchr(s, ',')) != NULL)
1499 : {
1500 : s++;
1501 : bp->x[i++] = float8in_internal(s, &endptr, "cube", str1, escontext);
1502 : if (SOFT_ERROR_OCCURRED(escontext))
1503 : return false;
1504 : }
1505 : Assert(i == dim);
1506 :
1507 : s = str2;
1508 : if (dim > 0)
1509 : {
1510 : bp->x[i] = float8in_internal(s, &endptr, "cube", str2, escontext);
1511 : if (SOFT_ERROR_OCCURRED(escontext))
1512 : return false;
1513 : /* code this way to do right thing with NaN */
1514 : point &= (bp->x[i] == bp->x[0]);
1515 : i++;
1516 : }
1517 : while ((s = strchr(s, ',')) != NULL)
1518 : {
1519 : s++;
1520 : bp->x[i] = float8in_internal(s, &endptr, "cube", str2, escontext);
1521 : if (SOFT_ERROR_OCCURRED(escontext))
1522 : return false;
1523 : point &= (bp->x[i] == bp->x[i - dim]);
1524 : i++;
1525 : }
1526 : Assert(i == dim * 2);
1527 :
1528 : if (point)
1529 : {
1530 : /*
1531 : * The value turned out to be a point, ie. all the upper-right
1532 : * coordinates were equal to the lower-left coordinates. Resize the
1533 : * cube we constructed. Note: we don't bother to repalloc() it
1534 : * smaller, as it's unlikely that the tiny amount of memory freed that
1535 : * way would be useful, and the output is always short-lived.
1536 : */
1537 : size = POINT_SIZE(dim);
1538 : SET_VARSIZE(bp, size);
1539 : SET_POINT_BIT(bp);
1540 : }
1541 :
1542 : *result = bp;
1543 : return true;
1544 : }
1545 :
1546 : static bool
1547 : write_point_as_box(int dim, char *str,
1548 : NDBOX **result, struct Node *escontext)
1549 : {
1550 : NDBOX *bp;
1551 : int i,
1552 : size;
1553 : char *s;
1554 : char *endptr;
1555 :
1556 : size = POINT_SIZE(dim);
1557 : bp = palloc0(size);
1558 : SET_VARSIZE(bp, size);
1559 : SET_DIM(bp, dim);
1560 : SET_POINT_BIT(bp);
1561 :
1562 : s = str;
1563 : i = 0;
1564 : if (dim > 0)
1565 : {
1566 : bp->x[i++] = float8in_internal(s, &endptr, "cube", str, escontext);
1567 : if (SOFT_ERROR_OCCURRED(escontext))
1568 : return false;
1569 : }
1570 : while ((s = strchr(s, ',')) != NULL)
1571 : {
1572 : s++;
1573 : bp->x[i++] = float8in_internal(s, &endptr, "cube", str, escontext);
1574 : if (SOFT_ERROR_OCCURRED(escontext))
1575 : return false;
1576 : }
1577 : Assert(i == dim);
1578 :
1579 : *result = bp;
1580 : return true;
1581 : }
|