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