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 0
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 : #define yylval cube_yylval
74 : #define yychar cube_yychar
75 :
76 : /* First part of user prologue. */
77 : #line 1 "cubeparse.y"
78 :
79 : /* contrib/cube/cubeparse.y */
80 :
81 : /* NdBox = [(lowerleft),(upperright)] */
82 : /* [(xLL(1)...xLL(N)),(xUR(1)...xUR(n))] */
83 :
84 : #include "postgres.h"
85 :
86 : #include "cubedata.h"
87 : #include "nodes/miscnodes.h"
88 : #include "utils/float.h"
89 : #include "varatt.h"
90 :
91 : /* All grammar constructs return strings */
92 : #define YYSTYPE char *
93 :
94 : #include "cubeparse.h"
95 :
96 : /* silence -Wmissing-variable-declarations */
97 : extern int cube_yychar;
98 : extern int cube_yynerrs;
99 :
100 : /*
101 : * Bison doesn't allocate anything that needs to live across parser calls,
102 : * so we can easily have it use palloc instead of malloc. This prevents
103 : * memory leaks if we error out during parsing.
104 : */
105 : #define YYMALLOC palloc
106 : #define YYFREE pfree
107 :
108 : static int item_count(const char *s, char delim);
109 : static bool write_box(int dim, char *str1, char *str2,
110 : NDBOX **result, struct Node *escontext);
111 : static bool write_point_as_box(int dim, char *str,
112 : NDBOX **result, struct Node *escontext);
113 :
114 :
115 : #line 116 "cubeparse.c"
116 :
117 : # ifndef YY_CAST
118 : # ifdef __cplusplus
119 : # define YY_CAST(Type, Val) static_cast<Type> (Val)
120 : # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
121 : # else
122 : # define YY_CAST(Type, Val) ((Type) (Val))
123 : # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
124 : # endif
125 : # endif
126 : # ifndef YY_NULLPTR
127 : # if defined __cplusplus
128 : # if 201103L <= __cplusplus
129 : # define YY_NULLPTR nullptr
130 : # else
131 : # define YY_NULLPTR 0
132 : # endif
133 : # else
134 : # define YY_NULLPTR ((void*)0)
135 : # endif
136 : # endif
137 :
138 : #include "cubeparse.h"
139 : /* Symbol kind. */
140 : enum yysymbol_kind_t
141 : {
142 : YYSYMBOL_YYEMPTY = -2,
143 : YYSYMBOL_YYEOF = 0, /* "end of file" */
144 : YYSYMBOL_YYerror = 1, /* error */
145 : YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
146 : YYSYMBOL_CUBEFLOAT = 3, /* CUBEFLOAT */
147 : YYSYMBOL_O_PAREN = 4, /* O_PAREN */
148 : YYSYMBOL_C_PAREN = 5, /* C_PAREN */
149 : YYSYMBOL_O_BRACKET = 6, /* O_BRACKET */
150 : YYSYMBOL_C_BRACKET = 7, /* C_BRACKET */
151 : YYSYMBOL_COMMA = 8, /* COMMA */
152 : YYSYMBOL_YYACCEPT = 9, /* $accept */
153 : YYSYMBOL_box = 10, /* box */
154 : YYSYMBOL_paren_list = 11, /* paren_list */
155 : YYSYMBOL_list = 12 /* list */
156 : };
157 : typedef enum yysymbol_kind_t yysymbol_kind_t;
158 :
159 :
160 :
161 :
162 : #ifdef short
163 : # undef short
164 : #endif
165 :
166 : /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
167 : <limits.h> and (if available) <stdint.h> are included
168 : so that the code can choose integer types of a good width. */
169 :
170 : #ifndef __PTRDIFF_MAX__
171 : # include <limits.h> /* INFRINGES ON USER NAME SPACE */
172 : # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
173 : # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
174 : # define YY_STDINT_H
175 : # endif
176 : #endif
177 :
178 : /* Narrow types that promote to a signed type and that can represent a
179 : signed or unsigned integer of at least N bits. In tables they can
180 : save space and decrease cache pressure. Promoting to a signed type
181 : helps avoid bugs in integer arithmetic. */
182 :
183 : #ifdef __INT_LEAST8_MAX__
184 : typedef __INT_LEAST8_TYPE__ yytype_int8;
185 : #elif defined YY_STDINT_H
186 : typedef int_least8_t yytype_int8;
187 : #else
188 : typedef signed char yytype_int8;
189 : #endif
190 :
191 : #ifdef __INT_LEAST16_MAX__
192 : typedef __INT_LEAST16_TYPE__ yytype_int16;
193 : #elif defined YY_STDINT_H
194 : typedef int_least16_t yytype_int16;
195 : #else
196 : typedef short yytype_int16;
197 : #endif
198 :
199 : /* Work around bug in HP-UX 11.23, which defines these macros
200 : incorrectly for preprocessor constants. This workaround can likely
201 : be removed in 2023, as HPE has promised support for HP-UX 11.23
202 : (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
203 : <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
204 : #ifdef __hpux
205 : # undef UINT_LEAST8_MAX
206 : # undef UINT_LEAST16_MAX
207 : # define UINT_LEAST8_MAX 255
208 : # define UINT_LEAST16_MAX 65535
209 : #endif
210 :
211 : #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
212 : typedef __UINT_LEAST8_TYPE__ yytype_uint8;
213 : #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
214 : && UINT_LEAST8_MAX <= INT_MAX)
215 : typedef uint_least8_t yytype_uint8;
216 : #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
217 : typedef unsigned char yytype_uint8;
218 : #else
219 : typedef short yytype_uint8;
220 : #endif
221 :
222 : #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
223 : typedef __UINT_LEAST16_TYPE__ yytype_uint16;
224 : #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
225 : && UINT_LEAST16_MAX <= INT_MAX)
226 : typedef uint_least16_t yytype_uint16;
227 : #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
228 : typedef unsigned short yytype_uint16;
229 : #else
230 : typedef int yytype_uint16;
231 : #endif
232 :
233 : #ifndef YYPTRDIFF_T
234 : # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
235 : # define YYPTRDIFF_T __PTRDIFF_TYPE__
236 : # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
237 : # elif defined PTRDIFF_MAX
238 : # ifndef ptrdiff_t
239 : # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
240 : # endif
241 : # define YYPTRDIFF_T ptrdiff_t
242 : # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
243 : # else
244 : # define YYPTRDIFF_T long
245 : # define YYPTRDIFF_MAXIMUM LONG_MAX
246 : # endif
247 : #endif
248 :
249 : #ifndef YYSIZE_T
250 : # ifdef __SIZE_TYPE__
251 : # define YYSIZE_T __SIZE_TYPE__
252 : # elif defined size_t
253 : # define YYSIZE_T size_t
254 : # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
255 : # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
256 : # define YYSIZE_T size_t
257 : # else
258 : # define YYSIZE_T unsigned
259 : # endif
260 : #endif
261 :
262 : #define YYSIZE_MAXIMUM \
263 : YY_CAST (YYPTRDIFF_T, \
264 : (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
265 : ? YYPTRDIFF_MAXIMUM \
266 : : YY_CAST (YYSIZE_T, -1)))
267 :
268 : #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
269 :
270 :
271 : /* Stored state numbers (used for stacks). */
272 : typedef yytype_int8 yy_state_t;
273 :
274 : /* State numbers in computations. */
275 : typedef int yy_state_fast_t;
276 :
277 : #ifndef YY_
278 : # if defined YYENABLE_NLS && YYENABLE_NLS
279 : # if ENABLE_NLS
280 : # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
281 : # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
282 : # endif
283 : # endif
284 : # ifndef YY_
285 : # define YY_(Msgid) Msgid
286 : # endif
287 : #endif
288 :
289 :
290 : #ifndef YY_ATTRIBUTE_PURE
291 : # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
292 : # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
293 : # else
294 : # define YY_ATTRIBUTE_PURE
295 : # endif
296 : #endif
297 :
298 : #ifndef YY_ATTRIBUTE_UNUSED
299 : # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
300 : # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
301 : # else
302 : # define YY_ATTRIBUTE_UNUSED
303 : # endif
304 : #endif
305 :
306 : /* Suppress unused-variable warnings by "using" E. */
307 : #if ! defined lint || defined __GNUC__
308 : # define YY_USE(E) ((void) (E))
309 : #else
310 : # define YY_USE(E) /* empty */
311 : #endif
312 :
313 : #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
314 : /* Suppress an incorrect diagnostic about yylval being uninitialized. */
315 : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
316 : _Pragma ("GCC diagnostic push") \
317 : _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
318 : _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
319 : # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
320 : _Pragma ("GCC diagnostic pop")
321 : #else
322 : # define YY_INITIAL_VALUE(Value) Value
323 : #endif
324 : #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
325 : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
326 : # define YY_IGNORE_MAYBE_UNINITIALIZED_END
327 : #endif
328 : #ifndef YY_INITIAL_VALUE
329 : # define YY_INITIAL_VALUE(Value) /* Nothing. */
330 : #endif
331 :
332 : #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
333 : # define YY_IGNORE_USELESS_CAST_BEGIN \
334 : _Pragma ("GCC diagnostic push") \
335 : _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
336 : # define YY_IGNORE_USELESS_CAST_END \
337 : _Pragma ("GCC diagnostic pop")
338 : #endif
339 : #ifndef YY_IGNORE_USELESS_CAST_BEGIN
340 : # define YY_IGNORE_USELESS_CAST_BEGIN
341 : # define YY_IGNORE_USELESS_CAST_END
342 : #endif
343 :
344 :
345 : #define YY_ASSERT(E) ((void) (0 && (E)))
346 :
347 : #if !defined yyoverflow
348 :
349 : /* The parser invokes alloca or malloc; define the necessary symbols. */
350 :
351 : # ifdef YYSTACK_USE_ALLOCA
352 : # if YYSTACK_USE_ALLOCA
353 : # ifdef __GNUC__
354 : # define YYSTACK_ALLOC __builtin_alloca
355 : # elif defined __BUILTIN_VA_ARG_INCR
356 : # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
357 : # elif defined _AIX
358 : # define YYSTACK_ALLOC __alloca
359 : # elif defined _MSC_VER
360 : # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
361 : # define alloca _alloca
362 : # else
363 : # define YYSTACK_ALLOC alloca
364 : # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
365 : # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
366 : /* Use EXIT_SUCCESS as a witness for stdlib.h. */
367 : # ifndef EXIT_SUCCESS
368 : # define EXIT_SUCCESS 0
369 : # endif
370 : # endif
371 : # endif
372 : # endif
373 : # endif
374 :
375 : # ifdef YYSTACK_ALLOC
376 : /* Pacify GCC's 'empty if-body' warning. */
377 : # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
378 : # ifndef YYSTACK_ALLOC_MAXIMUM
379 : /* The OS might guarantee only one guard page at the bottom of the stack,
380 : and a page size can be as small as 4096 bytes. So we cannot safely
381 : invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
382 : to allow for a few compiler-allocated temporary stack slots. */
383 : # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
384 : # endif
385 : # else
386 : # define YYSTACK_ALLOC YYMALLOC
387 : # define YYSTACK_FREE YYFREE
388 : # ifndef YYSTACK_ALLOC_MAXIMUM
389 : # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
390 : # endif
391 : # if (defined __cplusplus && ! defined EXIT_SUCCESS \
392 : && ! ((defined YYMALLOC || defined malloc) \
393 : && (defined YYFREE || defined free)))
394 : # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
395 : # ifndef EXIT_SUCCESS
396 : # define EXIT_SUCCESS 0
397 : # endif
398 : # endif
399 : # ifndef YYMALLOC
400 : # define YYMALLOC malloc
401 : # if ! defined malloc && ! defined EXIT_SUCCESS
402 : void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
403 : # endif
404 : # endif
405 : # ifndef YYFREE
406 : # define YYFREE free
407 : # if ! defined free && ! defined EXIT_SUCCESS
408 : void free (void *); /* INFRINGES ON USER NAME SPACE */
409 : # endif
410 : # endif
411 : # endif
412 : #endif /* !defined yyoverflow */
413 :
414 : #if (! defined yyoverflow \
415 : && (! defined __cplusplus \
416 : || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
417 :
418 : /* A type that is properly aligned for any stack member. */
419 : union yyalloc
420 : {
421 : yy_state_t yyss_alloc;
422 : YYSTYPE yyvs_alloc;
423 : };
424 :
425 : /* The size of the maximum gap between one aligned stack and the next. */
426 : # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
427 :
428 : /* The size of an array large to enough to hold all stacks, each with
429 : N elements. */
430 : # define YYSTACK_BYTES(N) \
431 : ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
432 : + YYSTACK_GAP_MAXIMUM)
433 :
434 : # define YYCOPY_NEEDED 1
435 :
436 : /* Relocate STACK from its old location to the new one. The
437 : local variables YYSIZE and YYSTACKSIZE give the old and new number of
438 : elements in the stack, and YYPTR gives the new location of the
439 : stack. Advance YYPTR to a properly aligned location for the next
440 : stack. */
441 : # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
442 : do \
443 : { \
444 : YYPTRDIFF_T yynewbytes; \
445 : YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
446 : Stack = &yyptr->Stack_alloc; \
447 : yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
448 : yyptr += yynewbytes / YYSIZEOF (*yyptr); \
449 : } \
450 : while (0)
451 :
452 : #endif
453 :
454 : #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
455 : /* Copy COUNT objects from SRC to DST. The source and destination do
456 : not overlap. */
457 : # ifndef YYCOPY
458 : # if defined __GNUC__ && 1 < __GNUC__
459 : # define YYCOPY(Dst, Src, Count) \
460 : __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
461 : # else
462 : # define YYCOPY(Dst, Src, Count) \
463 : do \
464 : { \
465 : YYPTRDIFF_T yyi; \
466 : for (yyi = 0; yyi < (Count); yyi++) \
467 : (Dst)[yyi] = (Src)[yyi]; \
468 : } \
469 : while (0)
470 : # endif
471 : # endif
472 : #endif /* !YYCOPY_NEEDED */
473 :
474 : /* YYFINAL -- State number of the termination state. */
475 : #define YYFINAL 10
476 : /* YYLAST -- Last index in YYTABLE. */
477 : #define YYLAST 17
478 :
479 : /* YYNTOKENS -- Number of terminals. */
480 : #define YYNTOKENS 9
481 : /* YYNNTS -- Number of nonterminals. */
482 : #define YYNNTS 4
483 : /* YYNRULES -- Number of rules. */
484 : #define YYNRULES 9
485 : /* YYNSTATES -- Number of states. */
486 : #define YYNSTATES 19
487 :
488 : /* YYMAXUTOK -- Last valid token kind. */
489 : #define YYMAXUTOK 263
490 :
491 :
492 : /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
493 : as returned by yylex, with out-of-bounds checking. */
494 : #define YYTRANSLATE(YYX) \
495 : (0 <= (YYX) && (YYX) <= YYMAXUTOK \
496 : ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
497 : : YYSYMBOL_YYUNDEF)
498 :
499 : /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
500 : as returned by yylex. */
501 : static const yytype_int8 yytranslate[] =
502 : {
503 : 0, 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, 2, 2, 2, 2,
525 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
526 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
527 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
528 : 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
529 : 5, 6, 7, 8
530 : };
531 :
532 : #if YYDEBUG
533 : /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
534 : static const yytype_uint8 yyrline[] =
535 : {
536 : 0, 52, 52, 80, 108, 127, 147, 151, 157, 163
537 : };
538 : #endif
539 :
540 : /** Accessing symbol of state STATE. */
541 : #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
542 :
543 : #if YYDEBUG || 0
544 : /* The user-facing name of the symbol whose (internal) number is
545 : YYSYMBOL. No bounds checking. */
546 : static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
547 :
548 : /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
549 : First, the terminals, then, starting at YYNTOKENS, nonterminals. */
550 : static const char *const yytname[] =
551 : {
552 : "\"end of file\"", "error", "\"invalid token\"", "CUBEFLOAT", "O_PAREN",
553 : "C_PAREN", "O_BRACKET", "C_BRACKET", "COMMA", "$accept", "box",
554 : "paren_list", "list", YY_NULLPTR
555 : };
556 :
557 : static const char *
558 : yysymbol_name (yysymbol_kind_t yysymbol)
559 : {
560 : return yytname[yysymbol];
561 : }
562 : #endif
563 :
564 : #ifdef YYPRINT
565 : /* YYTOKNUM[NUM] -- (External) token number corresponding to the
566 : (internal) symbol number NUM (which must be that of a token). */
567 : static const yytype_int16 yytoknum[] =
568 : {
569 : 0, 256, 257, 258, 259, 260, 261, 262, 263
570 : };
571 : #endif
572 :
573 : #define YYPACT_NINF (-4)
574 :
575 : #define yypact_value_is_default(Yyn) \
576 : ((Yyn) == YYPACT_NINF)
577 :
578 : #define YYTABLE_NINF (-1)
579 :
580 : #define yytable_value_is_error(Yyn) \
581 : 0
582 :
583 : /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
584 : STATE-NUM. */
585 : static const yytype_int8 yypact[] =
586 : {
587 : -2, -4, 0, 3, 10, 4, 5, -4, 1, 6,
588 : -4, 3, 12, -4, 3, -4, -4, 9, -4
589 : };
590 :
591 : /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
592 : Performed when YYTABLE does not specify something else to do. Zero
593 : means the default is an error. */
594 : static const yytype_int8 yydefact[] =
595 : {
596 : 0, 8, 0, 0, 0, 4, 5, 7, 0, 0,
597 : 1, 0, 0, 6, 0, 3, 9, 0, 2
598 : };
599 :
600 : /* YYPGOTO[NTERM-NUM]. */
601 : static const yytype_int8 yypgoto[] =
602 : {
603 : -4, -4, -3, 15
604 : };
605 :
606 : /* YYDEFGOTO[NTERM-NUM]. */
607 : static const yytype_int8 yydefgoto[] =
608 : {
609 : 0, 4, 5, 6
610 : };
611 :
612 : /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
613 : positive, shift that token. If negative, reduce the rule whose
614 : number is the opposite. If YYTABLE_NINF, syntax error. */
615 : static const yytype_int8 yytable[] =
616 : {
617 : 9, 1, 2, 1, 3, 7, 13, 2, 15, 12,
618 : 10, 17, 11, 12, 14, 16, 18, 8
619 : };
620 :
621 : static const yytype_int8 yycheck[] =
622 : {
623 : 3, 3, 4, 3, 6, 5, 5, 4, 11, 8,
624 : 0, 14, 8, 8, 8, 3, 7, 2
625 : };
626 :
627 : /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
628 : symbol of state STATE-NUM. */
629 : static const yytype_int8 yystos[] =
630 : {
631 : 0, 3, 4, 6, 10, 11, 12, 5, 12, 11,
632 : 0, 8, 8, 5, 8, 11, 3, 11, 7
633 : };
634 :
635 : /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
636 : static const yytype_int8 yyr1[] =
637 : {
638 : 0, 9, 10, 10, 10, 10, 11, 11, 12, 12
639 : };
640 :
641 : /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
642 : static const yytype_int8 yyr2[] =
643 : {
644 : 0, 2, 5, 3, 1, 1, 3, 2, 1, 3
645 : };
646 :
647 :
648 : enum { YYENOMEM = -2 };
649 :
650 : #define yyerrok (yyerrstatus = 0)
651 : #define yyclearin (yychar = YYEMPTY)
652 :
653 : #define YYACCEPT goto yyacceptlab
654 : #define YYABORT goto yyabortlab
655 : #define YYERROR goto yyerrorlab
656 :
657 :
658 : #define YYRECOVERING() (!!yyerrstatus)
659 :
660 : #define YYBACKUP(Token, Value) \
661 : do \
662 : if (yychar == YYEMPTY) \
663 : { \
664 : yychar = (Token); \
665 : yylval = (Value); \
666 : YYPOPSTACK (yylen); \
667 : yystate = *yyssp; \
668 : goto yybackup; \
669 : } \
670 : else \
671 : { \
672 : yyerror (result, scanbuflen, escontext, YY_("syntax error: cannot back up")); \
673 : YYERROR; \
674 : } \
675 : while (0)
676 :
677 : /* Backward compatibility with an undocumented macro.
678 : Use YYerror or YYUNDEF. */
679 : #define YYERRCODE YYUNDEF
680 :
681 :
682 : /* Enable debugging if requested. */
683 : #if YYDEBUG
684 :
685 : # ifndef YYFPRINTF
686 : # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
687 : # define YYFPRINTF fprintf
688 : # endif
689 :
690 : # define YYDPRINTF(Args) \
691 : do { \
692 : if (yydebug) \
693 : YYFPRINTF Args; \
694 : } while (0)
695 :
696 : /* This macro is provided for backward compatibility. */
697 : # ifndef YY_LOCATION_PRINT
698 : # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
699 : # endif
700 :
701 :
702 : # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
703 : do { \
704 : if (yydebug) \
705 : { \
706 : YYFPRINTF (stderr, "%s ", Title); \
707 : yy_symbol_print (stderr, \
708 : Kind, Value, result, scanbuflen, escontext); \
709 : YYFPRINTF (stderr, "\n"); \
710 : } \
711 : } while (0)
712 :
713 :
714 : /*-----------------------------------.
715 : | Print this symbol's value on YYO. |
716 : `-----------------------------------*/
717 :
718 : static void
719 : yy_symbol_value_print (FILE *yyo,
720 : yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, NDBOX **result, Size scanbuflen, struct Node *escontext)
721 : {
722 : FILE *yyoutput = yyo;
723 : YY_USE (yyoutput);
724 : YY_USE (result);
725 : YY_USE (scanbuflen);
726 : YY_USE (escontext);
727 : if (!yyvaluep)
728 : return;
729 : # ifdef YYPRINT
730 : if (yykind < YYNTOKENS)
731 : YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
732 : # endif
733 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
734 : YY_USE (yykind);
735 : YY_IGNORE_MAYBE_UNINITIALIZED_END
736 : }
737 :
738 :
739 : /*---------------------------.
740 : | Print this symbol on YYO. |
741 : `---------------------------*/
742 :
743 : static void
744 : yy_symbol_print (FILE *yyo,
745 : yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, NDBOX **result, Size scanbuflen, struct Node *escontext)
746 : {
747 : YYFPRINTF (yyo, "%s %s (",
748 : yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
749 :
750 : yy_symbol_value_print (yyo, yykind, yyvaluep, result, scanbuflen, escontext);
751 : YYFPRINTF (yyo, ")");
752 : }
753 :
754 : /*------------------------------------------------------------------.
755 : | yy_stack_print -- Print the state stack from its BOTTOM up to its |
756 : | TOP (included). |
757 : `------------------------------------------------------------------*/
758 :
759 : static void
760 : yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
761 : {
762 : YYFPRINTF (stderr, "Stack now");
763 : for (; yybottom <= yytop; yybottom++)
764 : {
765 : int yybot = *yybottom;
766 : YYFPRINTF (stderr, " %d", yybot);
767 : }
768 : YYFPRINTF (stderr, "\n");
769 : }
770 :
771 : # define YY_STACK_PRINT(Bottom, Top) \
772 : do { \
773 : if (yydebug) \
774 : yy_stack_print ((Bottom), (Top)); \
775 : } while (0)
776 :
777 :
778 : /*------------------------------------------------.
779 : | Report that the YYRULE is going to be reduced. |
780 : `------------------------------------------------*/
781 :
782 : static void
783 : yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
784 : int yyrule, NDBOX **result, Size scanbuflen, struct Node *escontext)
785 : {
786 : int yylno = yyrline[yyrule];
787 : int yynrhs = yyr2[yyrule];
788 : int yyi;
789 : YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
790 : yyrule - 1, yylno);
791 : /* The symbols being reduced. */
792 : for (yyi = 0; yyi < yynrhs; yyi++)
793 : {
794 : YYFPRINTF (stderr, " $%d = ", yyi + 1);
795 : yy_symbol_print (stderr,
796 : YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
797 : &yyvsp[(yyi + 1) - (yynrhs)], result, scanbuflen, escontext);
798 : YYFPRINTF (stderr, "\n");
799 : }
800 : }
801 :
802 : # define YY_REDUCE_PRINT(Rule) \
803 : do { \
804 : if (yydebug) \
805 : yy_reduce_print (yyssp, yyvsp, Rule, result, scanbuflen, escontext); \
806 : } while (0)
807 :
808 : /* Nonzero means print parse trace. It is left uninitialized so that
809 : multiple parsers can coexist. */
810 : int yydebug;
811 : #else /* !YYDEBUG */
812 : # define YYDPRINTF(Args) ((void) 0)
813 : # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
814 : # define YY_STACK_PRINT(Bottom, Top)
815 : # define YY_REDUCE_PRINT(Rule)
816 : #endif /* !YYDEBUG */
817 :
818 :
819 : /* YYINITDEPTH -- initial size of the parser's stacks. */
820 : #ifndef YYINITDEPTH
821 : # define YYINITDEPTH 200
822 : #endif
823 :
824 : /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
825 : if the built-in stack extension method is used).
826 :
827 : Do not make this value too large; the results are undefined if
828 : YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
829 : evaluated with infinite-precision integer arithmetic. */
830 :
831 : #ifndef YYMAXDEPTH
832 : # define YYMAXDEPTH 10000
833 : #endif
834 :
835 :
836 :
837 :
838 :
839 :
840 : /*-----------------------------------------------.
841 : | Release the memory associated to this symbol. |
842 : `-----------------------------------------------*/
843 :
844 : static void
845 13620 : yydestruct (const char *yymsg,
846 : yysymbol_kind_t yykind, YYSTYPE *yyvaluep, NDBOX **result, Size scanbuflen, struct Node *escontext)
847 : {
848 : YY_USE (yyvaluep);
849 : YY_USE (result);
850 : YY_USE (scanbuflen);
851 : YY_USE (escontext);
852 13620 : if (!yymsg)
853 0 : yymsg = "Deleting";
854 : YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
855 :
856 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
857 : YY_USE (yykind);
858 : YY_IGNORE_MAYBE_UNINITIALIZED_END
859 13620 : }
860 :
861 :
862 : /* Lookahead token kind. */
863 : int yychar;
864 :
865 : /* The semantic value of the lookahead symbol. */
866 : YYSTYPE yylval;
867 : /* Number of syntax errors so far. */
868 : int yynerrs;
869 :
870 :
871 :
872 :
873 : /*----------.
874 : | yyparse. |
875 : `----------*/
876 :
877 : int
878 6870 : yyparse (NDBOX **result, Size scanbuflen, struct Node *escontext)
879 : {
880 6870 : yy_state_fast_t yystate = 0;
881 : /* Number of tokens to shift before error messages enabled. */
882 6870 : int yyerrstatus = 0;
883 :
884 : /* Refer to the stacks through separate pointers, to allow yyoverflow
885 : to reallocate them elsewhere. */
886 :
887 : /* Their size. */
888 6870 : YYPTRDIFF_T yystacksize = YYINITDEPTH;
889 :
890 : /* The state stack: array, bottom, top. */
891 : yy_state_t yyssa[YYINITDEPTH];
892 6870 : yy_state_t *yyss = yyssa;
893 6870 : yy_state_t *yyssp = yyss;
894 :
895 : /* The semantic value stack: array, bottom, top. */
896 : YYSTYPE yyvsa[YYINITDEPTH];
897 6870 : YYSTYPE *yyvs = yyvsa;
898 6870 : YYSTYPE *yyvsp = yyvs;
899 :
900 : int yyn;
901 : /* The return value of yyparse. */
902 : int yyresult;
903 : /* Lookahead symbol kind. */
904 6870 : yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
905 : /* The variables used to return semantic value and location from the
906 : action routines. */
907 : YYSTYPE yyval;
908 :
909 :
910 :
911 : #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
912 :
913 : /* The number of symbols on the RHS of the reduced rule.
914 : Keep to zero when no symbol should be popped. */
915 6870 : int yylen = 0;
916 :
917 : YYDPRINTF ((stderr, "Starting parse\n"));
918 :
919 6870 : yychar = YYEMPTY; /* Cause a token to be read. */
920 6870 : goto yysetstate;
921 :
922 :
923 : /*------------------------------------------------------------.
924 : | yynewstate -- push a new state, which is found in yystate. |
925 : `------------------------------------------------------------*/
926 130826 : yynewstate:
927 : /* In all cases, when you get here, the value and location stacks
928 : have just been pushed. So pushing a state here evens the stacks. */
929 130826 : yyssp++;
930 :
931 :
932 : /*--------------------------------------------------------------------.
933 : | yysetstate -- set current state (the top of the stack) to yystate. |
934 : `--------------------------------------------------------------------*/
935 137696 : yysetstate:
936 : YYDPRINTF ((stderr, "Entering state %d\n", yystate));
937 : YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
938 : YY_IGNORE_USELESS_CAST_BEGIN
939 137696 : *yyssp = YY_CAST (yy_state_t, yystate);
940 : YY_IGNORE_USELESS_CAST_END
941 : YY_STACK_PRINT (yyss, yyssp);
942 :
943 137696 : if (yyss + yystacksize - 1 <= yyssp)
944 : #if !defined yyoverflow && !defined YYSTACK_RELOCATE
945 : goto yyexhaustedlab;
946 : #else
947 : {
948 : /* Get the current used size of the three stacks, in elements. */
949 0 : YYPTRDIFF_T yysize = yyssp - yyss + 1;
950 :
951 : # if defined yyoverflow
952 : {
953 : /* Give user a chance to reallocate the stack. Use copies of
954 : these so that the &'s don't force the real ones into
955 : memory. */
956 : yy_state_t *yyss1 = yyss;
957 : YYSTYPE *yyvs1 = yyvs;
958 :
959 : /* Each stack pointer address is followed by the size of the
960 : data in use in that stack, in bytes. This used to be a
961 : conditional around just the two extra args, but that might
962 : be undefined if yyoverflow is a macro. */
963 : yyoverflow (YY_("memory exhausted"),
964 : &yyss1, yysize * YYSIZEOF (*yyssp),
965 : &yyvs1, yysize * YYSIZEOF (*yyvsp),
966 : &yystacksize);
967 : yyss = yyss1;
968 : yyvs = yyvs1;
969 : }
970 : # else /* defined YYSTACK_RELOCATE */
971 : /* Extend the stack our own way. */
972 0 : if (YYMAXDEPTH <= yystacksize)
973 0 : goto yyexhaustedlab;
974 0 : yystacksize *= 2;
975 0 : if (YYMAXDEPTH < yystacksize)
976 0 : yystacksize = YYMAXDEPTH;
977 :
978 : {
979 0 : yy_state_t *yyss1 = yyss;
980 : union yyalloc *yyptr =
981 0 : YY_CAST (union yyalloc *,
982 : YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
983 0 : if (! yyptr)
984 0 : goto yyexhaustedlab;
985 0 : YYSTACK_RELOCATE (yyss_alloc, yyss);
986 0 : YYSTACK_RELOCATE (yyvs_alloc, yyvs);
987 : # undef YYSTACK_RELOCATE
988 0 : if (yyss1 != yyssa)
989 0 : YYSTACK_FREE (yyss1);
990 : }
991 : # endif
992 :
993 0 : yyssp = yyss + yysize - 1;
994 0 : yyvsp = yyvs + yysize - 1;
995 :
996 : YY_IGNORE_USELESS_CAST_BEGIN
997 : YYDPRINTF ((stderr, "Stack size increased to %ld\n",
998 : YY_CAST (long, yystacksize)));
999 : YY_IGNORE_USELESS_CAST_END
1000 :
1001 0 : if (yyss + yystacksize - 1 <= yyssp)
1002 0 : YYABORT;
1003 : }
1004 : #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1005 :
1006 137696 : if (yystate == YYFINAL)
1007 6804 : YYACCEPT;
1008 :
1009 130892 : goto yybackup;
1010 :
1011 :
1012 : /*-----------.
1013 : | yybackup. |
1014 : `-----------*/
1015 130892 : yybackup:
1016 : /* Do appropriate processing given the current state. Read a
1017 : lookahead token if we need one and don't already have one. */
1018 :
1019 : /* First try to decide what to do without reference to lookahead token. */
1020 130892 : yyn = yypact[yystate];
1021 130892 : if (yypact_value_is_default (yyn))
1022 47842 : goto yydefault;
1023 :
1024 : /* Not known => get a lookahead token if don't already have one. */
1025 :
1026 : /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1027 83050 : if (yychar == YYEMPTY)
1028 : {
1029 : YYDPRINTF ((stderr, "Reading a token\n"));
1030 82742 : yychar = yylex ();
1031 : }
1032 :
1033 83050 : if (yychar <= YYEOF)
1034 : {
1035 7112 : yychar = YYEOF;
1036 7112 : yytoken = YYSYMBOL_YYEOF;
1037 : YYDPRINTF ((stderr, "Now at end of input.\n"));
1038 : }
1039 75938 : else if (yychar == YYerror)
1040 : {
1041 : /* The scanner already issued an error message, process directly
1042 : to error recovery. But do not keep the error token as
1043 : lookahead, it is too special and may lead us to an endless
1044 : loop in error recovery. */
1045 0 : yychar = YYUNDEF;
1046 0 : yytoken = YYSYMBOL_YYerror;
1047 0 : goto yyerrlab1;
1048 : }
1049 : else
1050 : {
1051 75938 : yytoken = YYTRANSLATE (yychar);
1052 : YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1053 : }
1054 :
1055 : /* If the proper action on seeing token YYTOKEN is to reduce or to
1056 : detect an error, take that action. */
1057 83050 : yyn += yytoken;
1058 83050 : if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1059 364 : goto yydefault;
1060 82686 : yyn = yytable[yyn];
1061 82686 : if (yyn <= 0)
1062 : {
1063 : if (yytable_value_is_error (yyn))
1064 : goto yyerrlab;
1065 0 : yyn = -yyn;
1066 0 : goto yyreduce;
1067 : }
1068 :
1069 : /* Count tokens shifted since error; after three, turn off error
1070 : status. */
1071 82686 : if (yyerrstatus)
1072 0 : yyerrstatus--;
1073 :
1074 : /* Shift the lookahead token. */
1075 : YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1076 82686 : yystate = yyn;
1077 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1078 82686 : *++yyvsp = yylval;
1079 : YY_IGNORE_MAYBE_UNINITIALIZED_END
1080 :
1081 : /* Discard the shifted token. */
1082 82686 : yychar = YYEMPTY;
1083 82686 : goto yynewstate;
1084 :
1085 :
1086 : /*-----------------------------------------------------------.
1087 : | yydefault -- do the default action for the current state. |
1088 : `-----------------------------------------------------------*/
1089 48206 : yydefault:
1090 48206 : yyn = yydefact[yystate];
1091 48206 : if (yyn == 0)
1092 48 : goto yyerrlab;
1093 48158 : goto yyreduce;
1094 :
1095 :
1096 : /*-----------------------------.
1097 : | yyreduce -- do a reduction. |
1098 : `-----------------------------*/
1099 48158 : yyreduce:
1100 : /* yyn is the number of a rule to reduce with. */
1101 48158 : yylen = yyr2[yyn];
1102 :
1103 : /* If YYLEN is nonzero, implement the default value of the action:
1104 : '$$ = $1'.
1105 :
1106 : Otherwise, the following line sets YYVAL to garbage.
1107 : This behavior is undocumented and Bison
1108 : users should not rely upon it. Assigning to YYVAL
1109 : unconditionally makes the parser a bit smaller, and it avoids a
1110 : GCC warning that YYVAL may be used uninitialized. */
1111 48158 : yyval = yyvsp[1-yylen];
1112 :
1113 :
1114 : YY_REDUCE_PRINT (yyn);
1115 48158 : switch (yyn)
1116 : {
1117 32 : case 2: /* box: O_BRACKET paren_list COMMA paren_list C_BRACKET */
1118 : #line 53 "cubeparse.y"
1119 : {
1120 : int dim;
1121 :
1122 : dim = item_count(yyvsp[-3], ',');
1123 : if (item_count(yyvsp[-1], ',') != dim)
1124 : {
1125 : errsave(escontext,
1126 : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1127 : errmsg("invalid input syntax for cube"),
1128 : errdetail("Different point dimensions in (%s) and (%s).",
1129 : yyvsp[-3], yyvsp[-1])));
1130 : YYABORT;
1131 : }
1132 : if (dim > CUBE_MAX_DIM)
1133 : {
1134 : errsave(escontext,
1135 : (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
1136 : errmsg("invalid input syntax for cube"),
1137 : errdetail("A cube cannot have more than %d dimensions.",
1138 : CUBE_MAX_DIM)));
1139 : YYABORT;
1140 : }
1141 :
1142 : if (!write_box(dim, yyvsp[-3], yyvsp[-1], result, escontext))
1143 : YYABORT;
1144 : }
1145 : #line 1146 "cubeparse.c"
1146 28 : break;
1147 :
1148 6492 : case 3: /* box: paren_list COMMA paren_list */
1149 : #line 81 "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 109 "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 128 "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 148 "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 152 "cubeparse.y"
1233 : {
1234 : yyval = pstrdup("");
1235 : }
1236 : #line 1237 "cubeparse.c"
1237 8 : break;
1238 :
1239 13382 : case 8: /* list: CUBEFLOAT */
1240 : #line 158 "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 164 "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, 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);
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);
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, 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);
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);
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 171 "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
1535 : * that 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 : }
|