Line data Source code
1 : /* A Bison parser, made by GNU Bison 3.8.2. */
2 :
3 : /* Bison implementation for Yacc-like parsers in C
4 :
5 : Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6 : Inc.
7 :
8 : This program is free software: you can redistribute it and/or modify
9 : it under the terms of the GNU General Public License as published by
10 : the Free Software Foundation, either version 3 of the License, or
11 : (at your option) any later version.
12 :
13 : This program is distributed in the hope that it will be useful,
14 : but WITHOUT ANY WARRANTY; without even the implied warranty of
15 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 : GNU General Public License for more details.
17 :
18 : You should have received a copy of the GNU General Public License
19 : along with this program. If not, see <https://www.gnu.org/licenses/>. */
20 :
21 : /* As a special exception, you may create a larger work that contains
22 : part or all of the Bison parser skeleton and distribute that work
23 : under terms of your choice, so long as that work isn't itself a
24 : parser generator using the skeleton or a modified version thereof
25 : as a parser skeleton. Alternatively, if you modify or redistribute
26 : the parser skeleton itself, you may (at your option) remove this
27 : special exception, which will cause the skeleton and the resulting
28 : Bison output files to be licensed under the GNU General Public
29 : License without this special exception.
30 :
31 : This special exception was added by the Free Software Foundation in
32 : version 2.2 of Bison. */
33 :
34 : /* C LALR(1) parser skeleton written by Richard Stallman, by
35 : simplifying the original so-called "semantic" parser. */
36 :
37 : /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 : especially those whose name start with YY_ or yy_. They are
39 : private implementation details that can be changed or removed. */
40 :
41 : /* All symbols defined below should begin with yy or YY, to avoid
42 : infringing on user name space. This should be done even for local
43 : variables, as they might otherwise be expanded by user macros.
44 : There are some unavoidable exceptions within include files to
45 : define necessary library symbols; they are noted "INFRINGES ON
46 : USER NAME SPACE" below. */
47 :
48 : /* Identify Bison output, and Bison version. */
49 : #define YYBISON 30802
50 :
51 : /* Bison version string. */
52 : #define YYBISON_VERSION "3.8.2"
53 :
54 : /* Skeleton name. */
55 : #define YYSKELETON_NAME "yacc.c"
56 :
57 : /* Pure parsers. */
58 : #define YYPURE 1
59 :
60 : /* Push parsers. */
61 : #define YYPUSH 0
62 :
63 : /* Pull parsers. */
64 : #define YYPULL 1
65 :
66 : /* Substitute the variable and function names. */
67 : #define yyparse swqparse
68 : #define yylex swqlex
69 : #define yyerror swqerror
70 : #define yydebug swqdebug
71 : #define yynerrs swqnerrs
72 :
73 : /* First part of user prologue. */
74 :
75 : /******************************************************************************
76 : *
77 : * Component: OGR SQL Engine
78 : * Purpose: expression and select parser grammar.
79 : * Requires Bison 2.4.0 or newer to process. Use "make parser" target.
80 : * Author: Frank Warmerdam <warmerdam@pobox.com>
81 : *
82 : ******************************************************************************
83 : * Copyright (C) 2010 Frank Warmerdam <warmerdam@pobox.com>
84 : *
85 : * Permission is hereby granted, free of charge, to any person obtaining a
86 : * copy of this software and associated documentation files (the "Software"),
87 : * to deal in the Software without restriction, including without limitation
88 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
89 : * and/or sell copies of the Software, and to permit persons to whom the
90 : * Software is furnished to do so, subject to the following conditions:
91 : *
92 : * The above copyright notice and this permission notice shall be included
93 : * in all copies or substantial portions of the Software.
94 : *
95 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
96 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
97 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
98 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
99 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
100 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
101 : * DEALINGS IN THE SOFTWARE.
102 : ****************************************************************************/
103 :
104 : #include "cpl_port.h"
105 : #include "ogr_swq.h"
106 :
107 : #include <cstdlib>
108 : #include <cstring>
109 : #include <limits>
110 :
111 : #include "cpl_conv.h"
112 : #include "cpl_error.h"
113 : #include "cpl_string.h"
114 : #include "ogr_core.h"
115 : #include "ogr_geometry.h"
116 :
117 : #define YYSTYPE swq_expr_node *
118 :
119 : /* Defining YYSTYPE_IS_TRIVIAL is needed because the parser is generated as a C++ file. */
120 : /* See http://www.gnu.org/s/bison/manual/html_node/Memory-Management.html that suggests */
121 : /* increase YYINITDEPTH instead, but this will consume memory. */
122 : /* Setting YYSTYPE_IS_TRIVIAL overcomes this limitation, but might be fragile because */
123 : /* it appears to be a non documented feature of Bison */
124 : #define YYSTYPE_IS_TRIVIAL 1
125 :
126 : #ifndef YY_CAST
127 : #ifdef __cplusplus
128 : #define YY_CAST(Type, Val) static_cast<Type>(Val)
129 : #define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type>(Val)
130 : #else
131 : #define YY_CAST(Type, Val) ((Type)(Val))
132 : #define YY_REINTERPRET_CAST(Type, Val) ((Type)(Val))
133 : #endif
134 : #endif
135 : #ifndef YY_NULLPTR
136 : #if defined __cplusplus
137 : #if 201103L <= __cplusplus
138 : #define YY_NULLPTR nullptr
139 : #else
140 : #define YY_NULLPTR 0
141 : #endif
142 : #else
143 : #define YY_NULLPTR ((void *)0)
144 : #endif
145 : #endif
146 :
147 : #include "swq_parser.hpp"
148 :
149 : /* Symbol kind. */
150 : enum yysymbol_kind_t
151 : {
152 : YYSYMBOL_YYEMPTY = -2,
153 : YYSYMBOL_YYEOF = 0, /* "end of string" */
154 : YYSYMBOL_YYerror = 1, /* error */
155 : YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
156 : YYSYMBOL_SWQT_INTEGER_NUMBER = 3, /* "integer number" */
157 : YYSYMBOL_SWQT_FLOAT_NUMBER = 4, /* "floating point number" */
158 : YYSYMBOL_SWQT_STRING = 5, /* "string" */
159 : YYSYMBOL_SWQT_IDENTIFIER = 6, /* "identifier" */
160 : YYSYMBOL_SWQT_IN = 7, /* "IN" */
161 : YYSYMBOL_SWQT_LIKE = 8, /* "LIKE" */
162 : YYSYMBOL_SWQT_ILIKE = 9, /* "ILIKE" */
163 : YYSYMBOL_SWQT_ESCAPE = 10, /* "ESCAPE" */
164 : YYSYMBOL_SWQT_BETWEEN = 11, /* "BETWEEN" */
165 : YYSYMBOL_SWQT_NULL = 12, /* "NULL" */
166 : YYSYMBOL_SWQT_IS = 13, /* "IS" */
167 : YYSYMBOL_SWQT_SELECT = 14, /* "SELECT" */
168 : YYSYMBOL_SWQT_LEFT = 15, /* "LEFT" */
169 : YYSYMBOL_SWQT_JOIN = 16, /* "JOIN" */
170 : YYSYMBOL_SWQT_WHERE = 17, /* "WHERE" */
171 : YYSYMBOL_SWQT_ON = 18, /* "ON" */
172 : YYSYMBOL_SWQT_ORDER = 19, /* "ORDER" */
173 : YYSYMBOL_SWQT_BY = 20, /* "BY" */
174 : YYSYMBOL_SWQT_FROM = 21, /* "FROM" */
175 : YYSYMBOL_SWQT_AS = 22, /* "AS" */
176 : YYSYMBOL_SWQT_ASC = 23, /* "ASC" */
177 : YYSYMBOL_SWQT_DESC = 24, /* "DESC" */
178 : YYSYMBOL_SWQT_DISTINCT = 25, /* "DISTINCT" */
179 : YYSYMBOL_SWQT_CAST = 26, /* "CAST" */
180 : YYSYMBOL_SWQT_UNION = 27, /* "UNION" */
181 : YYSYMBOL_SWQT_ALL = 28, /* "ALL" */
182 : YYSYMBOL_SWQT_LIMIT = 29, /* "LIMIT" */
183 : YYSYMBOL_SWQT_OFFSET = 30, /* "OFFSET" */
184 : YYSYMBOL_SWQT_EXCEPT = 31, /* "EXCEPT" */
185 : YYSYMBOL_SWQT_EXCLUDE = 32, /* "EXCLUDE" */
186 : YYSYMBOL_SWQT_VALUE_START = 33, /* SWQT_VALUE_START */
187 : YYSYMBOL_SWQT_SELECT_START = 34, /* SWQT_SELECT_START */
188 : YYSYMBOL_SWQT_NOT = 35, /* "NOT" */
189 : YYSYMBOL_SWQT_OR = 36, /* "OR" */
190 : YYSYMBOL_SWQT_AND = 37, /* "AND" */
191 : YYSYMBOL_38_ = 38, /* '=' */
192 : YYSYMBOL_39_ = 39, /* '<' */
193 : YYSYMBOL_40_ = 40, /* '>' */
194 : YYSYMBOL_41_ = 41, /* '!' */
195 : YYSYMBOL_42_ = 42, /* '+' */
196 : YYSYMBOL_43_ = 43, /* '-' */
197 : YYSYMBOL_44_ = 44, /* '*' */
198 : YYSYMBOL_45_ = 45, /* '/' */
199 : YYSYMBOL_46_ = 46, /* '%' */
200 : YYSYMBOL_SWQT_UMINUS = 47, /* SWQT_UMINUS */
201 : YYSYMBOL_SWQT_RESERVED_KEYWORD = 48, /* "reserved keyword" */
202 : YYSYMBOL_49_ = 49, /* '(' */
203 : YYSYMBOL_50_ = 50, /* ')' */
204 : YYSYMBOL_51_ = 51, /* ',' */
205 : YYSYMBOL_52_ = 52, /* '.' */
206 : YYSYMBOL_YYACCEPT = 53, /* $accept */
207 : YYSYMBOL_input = 54, /* input */
208 : YYSYMBOL_value_expr = 55, /* value_expr */
209 : YYSYMBOL_value_expr_list = 56, /* value_expr_list */
210 : YYSYMBOL_field_value = 57, /* field_value */
211 : YYSYMBOL_value_expr_non_logical = 58, /* value_expr_non_logical */
212 : YYSYMBOL_type_def = 59, /* type_def */
213 : YYSYMBOL_select_statement = 60, /* select_statement */
214 : YYSYMBOL_select_core = 61, /* select_core */
215 : YYSYMBOL_opt_union_all = 62, /* opt_union_all */
216 : YYSYMBOL_union_all = 63, /* union_all */
217 : YYSYMBOL_select_field_list = 64, /* select_field_list */
218 : YYSYMBOL_exclude_field = 65, /* exclude_field */
219 : YYSYMBOL_exclude_field_list = 66, /* exclude_field_list */
220 : YYSYMBOL_except_or_exclude = 67, /* except_or_exclude */
221 : YYSYMBOL_column_spec = 68, /* column_spec */
222 : YYSYMBOL_as_clause = 69, /* as_clause */
223 : YYSYMBOL_opt_where = 70, /* opt_where */
224 : YYSYMBOL_opt_joins = 71, /* opt_joins */
225 : YYSYMBOL_opt_order_by = 72, /* opt_order_by */
226 : YYSYMBOL_sort_spec_list = 73, /* sort_spec_list */
227 : YYSYMBOL_sort_spec = 74, /* sort_spec */
228 : YYSYMBOL_opt_limit = 75, /* opt_limit */
229 : YYSYMBOL_opt_offset = 76, /* opt_offset */
230 : YYSYMBOL_table_def = 77 /* table_def */
231 : };
232 : typedef enum yysymbol_kind_t yysymbol_kind_t;
233 :
234 : #ifdef short
235 : #undef short
236 : #endif
237 :
238 : /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
239 : <limits.h> and (if available) <stdint.h> are included
240 : so that the code can choose integer types of a good width. */
241 :
242 : #ifndef __PTRDIFF_MAX__
243 : #include <limits.h> /* INFRINGES ON USER NAME SPACE */
244 : #if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
245 : #include <stdint.h> /* INFRINGES ON USER NAME SPACE */
246 : #define YY_STDINT_H
247 : #endif
248 : #endif
249 :
250 : /* Narrow types that promote to a signed type and that can represent a
251 : signed or unsigned integer of at least N bits. In tables they can
252 : save space and decrease cache pressure. Promoting to a signed type
253 : helps avoid bugs in integer arithmetic. */
254 :
255 : #ifdef __INT_LEAST8_MAX__
256 : typedef __INT_LEAST8_TYPE__ yytype_int8;
257 : #elif defined YY_STDINT_H
258 : typedef int_least8_t yytype_int8;
259 : #else
260 : typedef signed char yytype_int8;
261 : #endif
262 :
263 : #ifdef __INT_LEAST16_MAX__
264 : typedef __INT_LEAST16_TYPE__ yytype_int16;
265 : #elif defined YY_STDINT_H
266 : typedef int_least16_t yytype_int16;
267 : #else
268 : typedef short yytype_int16;
269 : #endif
270 :
271 : /* Work around bug in HP-UX 11.23, which defines these macros
272 : incorrectly for preprocessor constants. This workaround can likely
273 : be removed in 2023, as HPE has promised support for HP-UX 11.23
274 : (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
275 : <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
276 : #ifdef __hpux
277 : #undef UINT_LEAST8_MAX
278 : #undef UINT_LEAST16_MAX
279 : #define UINT_LEAST8_MAX 255
280 : #define UINT_LEAST16_MAX 65535
281 : #endif
282 :
283 : #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
284 : typedef __UINT_LEAST8_TYPE__ yytype_uint8;
285 : #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H && \
286 : UINT_LEAST8_MAX <= INT_MAX)
287 : typedef uint_least8_t yytype_uint8;
288 : #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
289 : typedef unsigned char yytype_uint8;
290 : #else
291 : typedef short yytype_uint8;
292 : #endif
293 :
294 : #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
295 : typedef __UINT_LEAST16_TYPE__ yytype_uint16;
296 : #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H && \
297 : UINT_LEAST16_MAX <= INT_MAX)
298 : typedef uint_least16_t yytype_uint16;
299 : #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
300 : typedef unsigned short yytype_uint16;
301 : #else
302 : typedef int yytype_uint16;
303 : #endif
304 :
305 : #ifndef YYPTRDIFF_T
306 : #if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
307 : #define YYPTRDIFF_T __PTRDIFF_TYPE__
308 : #define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
309 : #elif defined PTRDIFF_MAX
310 : #ifndef ptrdiff_t
311 : #include <stddef.h> /* INFRINGES ON USER NAME SPACE */
312 : #endif
313 : #define YYPTRDIFF_T ptrdiff_t
314 : #define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
315 : #else
316 : #define YYPTRDIFF_T long
317 : #define YYPTRDIFF_MAXIMUM LONG_MAX
318 : #endif
319 : #endif
320 :
321 : #ifndef YYSIZE_T
322 : #ifdef __SIZE_TYPE__
323 : #define YYSIZE_T __SIZE_TYPE__
324 : #elif defined size_t
325 : #define YYSIZE_T size_t
326 : #elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
327 : #include <stddef.h> /* INFRINGES ON USER NAME SPACE */
328 : #define YYSIZE_T size_t
329 : #else
330 : #define YYSIZE_T unsigned
331 : #endif
332 : #endif
333 :
334 : #define YYSIZE_MAXIMUM \
335 : YY_CAST(YYPTRDIFF_T, (YYPTRDIFF_MAXIMUM < YY_CAST(YYSIZE_T, -1) \
336 : ? YYPTRDIFF_MAXIMUM \
337 : : YY_CAST(YYSIZE_T, -1)))
338 :
339 : #define YYSIZEOF(X) YY_CAST(YYPTRDIFF_T, sizeof(X))
340 :
341 : /* Stored state numbers (used for stacks). */
342 : typedef yytype_uint8 yy_state_t;
343 :
344 : /* State numbers in computations. */
345 : typedef int yy_state_fast_t;
346 :
347 : #ifndef YY_
348 : #if defined YYENABLE_NLS && YYENABLE_NLS
349 : #if ENABLE_NLS
350 : #include <libintl.h> /* INFRINGES ON USER NAME SPACE */
351 : #define YY_(Msgid) dgettext("bison-runtime", Msgid)
352 : #endif
353 : #endif
354 : #ifndef YY_
355 : #define YY_(Msgid) Msgid
356 : #endif
357 : #endif
358 :
359 : #ifndef YY_ATTRIBUTE_PURE
360 : #if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
361 : #define YY_ATTRIBUTE_PURE __attribute__((__pure__))
362 : #else
363 : #define YY_ATTRIBUTE_PURE
364 : #endif
365 : #endif
366 :
367 : #ifndef YY_ATTRIBUTE_UNUSED
368 : #if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
369 : #define YY_ATTRIBUTE_UNUSED __attribute__((__unused__))
370 : #else
371 : #define YY_ATTRIBUTE_UNUSED
372 : #endif
373 : #endif
374 :
375 : /* Suppress unused-variable warnings by "using" E. */
376 : #if !defined lint || defined __GNUC__
377 : #define YY_USE(E) ((void)(E))
378 : #else
379 : #define YY_USE(E) /* empty */
380 : #endif
381 :
382 : /* Suppress an incorrect diagnostic about yylval being uninitialized. */
383 : #if defined __GNUC__ && !defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
384 : #if __GNUC__ * 100 + __GNUC_MINOR__ < 407
385 : #define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
386 : _Pragma("GCC diagnostic push") \
387 : _Pragma("GCC diagnostic ignored \"-Wuninitialized\"")
388 : #else
389 : #define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
390 : _Pragma("GCC diagnostic push") \
391 : _Pragma("GCC diagnostic ignored \"-Wuninitialized\"") \
392 : _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
393 : #endif
394 : #define YY_IGNORE_MAYBE_UNINITIALIZED_END _Pragma("GCC diagnostic pop")
395 : #else
396 : #define YY_INITIAL_VALUE(Value) Value
397 : #endif
398 : #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
399 : #define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
400 : #define YY_IGNORE_MAYBE_UNINITIALIZED_END
401 : #endif
402 : #ifndef YY_INITIAL_VALUE
403 : #define YY_INITIAL_VALUE(Value) /* Nothing. */
404 : #endif
405 :
406 : #if defined __cplusplus && defined __GNUC__ && !defined __ICC && 6 <= __GNUC__
407 : #define YY_IGNORE_USELESS_CAST_BEGIN \
408 : _Pragma("GCC diagnostic push") \
409 : _Pragma("GCC diagnostic ignored \"-Wuseless-cast\"")
410 : #define YY_IGNORE_USELESS_CAST_END _Pragma("GCC diagnostic pop")
411 : #endif
412 : #ifndef YY_IGNORE_USELESS_CAST_BEGIN
413 : #define YY_IGNORE_USELESS_CAST_BEGIN
414 : #define YY_IGNORE_USELESS_CAST_END
415 : #endif
416 :
417 : #define YY_ASSERT(E) ((void)(0 && (E)))
418 :
419 : #if 1
420 :
421 : /* The parser invokes alloca or malloc; define the necessary symbols. */
422 :
423 : #ifdef YYSTACK_USE_ALLOCA
424 : #if YYSTACK_USE_ALLOCA
425 : #ifdef __GNUC__
426 : #define YYSTACK_ALLOC __builtin_alloca
427 : #elif defined __BUILTIN_VA_ARG_INCR
428 : #include <alloca.h> /* INFRINGES ON USER NAME SPACE */
429 : #elif defined _AIX
430 : #define YYSTACK_ALLOC __alloca
431 : #elif defined _MSC_VER
432 : #include <malloc.h> /* INFRINGES ON USER NAME SPACE */
433 : #define alloca _alloca
434 : #else
435 : #define YYSTACK_ALLOC alloca
436 : #if !defined _ALLOCA_H && !defined EXIT_SUCCESS
437 : #include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
438 : /* Use EXIT_SUCCESS as a witness for stdlib.h. */
439 : #ifndef EXIT_SUCCESS
440 : #define EXIT_SUCCESS 0
441 : #endif
442 : #endif
443 : #endif
444 : #endif
445 : #endif
446 :
447 : #ifdef YYSTACK_ALLOC
448 : /* Pacify GCC's 'empty if-body' warning. */
449 : #define YYSTACK_FREE(Ptr) \
450 : do \
451 : { /* empty */ \
452 : ; \
453 : } while (0)
454 : #ifndef YYSTACK_ALLOC_MAXIMUM
455 : /* The OS might guarantee only one guard page at the bottom of the stack,
456 : and a page size can be as small as 4096 bytes. So we cannot safely
457 : invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
458 : to allow for a few compiler-allocated temporary stack slots. */
459 : #define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
460 : #endif
461 : #else
462 : #define YYSTACK_ALLOC YYMALLOC
463 : #define YYSTACK_FREE YYFREE
464 : #ifndef YYSTACK_ALLOC_MAXIMUM
465 : #define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
466 : #endif
467 : #if (defined __cplusplus && !defined EXIT_SUCCESS && \
468 : !((defined YYMALLOC || defined malloc) && \
469 : (defined YYFREE || defined free)))
470 : #include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
471 : #ifndef EXIT_SUCCESS
472 : #define EXIT_SUCCESS 0
473 : #endif
474 : #endif
475 : #ifndef YYMALLOC
476 : #define YYMALLOC malloc
477 : #if !defined malloc && !defined EXIT_SUCCESS
478 : void *malloc(YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
479 : #endif
480 : #endif
481 : #ifndef YYFREE
482 : #define YYFREE free
483 : #if !defined free && !defined EXIT_SUCCESS
484 : void free(void *); /* INFRINGES ON USER NAME SPACE */
485 : #endif
486 : #endif
487 : #endif
488 : #endif /* 1 */
489 :
490 : #if (!defined yyoverflow && \
491 : (!defined __cplusplus || \
492 : (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
493 :
494 : /* A type that is properly aligned for any stack member. */
495 : union yyalloc
496 : {
497 : yy_state_t yyss_alloc;
498 : YYSTYPE yyvs_alloc;
499 : };
500 :
501 : /* The size of the maximum gap between one aligned stack and the next. */
502 : #define YYSTACK_GAP_MAXIMUM (YYSIZEOF(union yyalloc) - 1)
503 :
504 : /* The size of an array large to enough to hold all stacks, each with
505 : N elements. */
506 : #define YYSTACK_BYTES(N) \
507 : ((N) * (YYSIZEOF(yy_state_t) + YYSIZEOF(YYSTYPE)) + YYSTACK_GAP_MAXIMUM)
508 :
509 : #define YYCOPY_NEEDED 1
510 :
511 : /* Relocate STACK from its old location to the new one. The
512 : local variables YYSIZE and YYSTACKSIZE give the old and new number of
513 : elements in the stack, and YYPTR gives the new location of the
514 : stack. Advance YYPTR to a properly aligned location for the next
515 : stack. */
516 : #define YYSTACK_RELOCATE(Stack_alloc, Stack) \
517 : do \
518 : { \
519 : YYPTRDIFF_T yynewbytes; \
520 : YYCOPY(&yyptr->Stack_alloc, Stack, yysize); \
521 : Stack = &yyptr->Stack_alloc; \
522 : yynewbytes = yystacksize * YYSIZEOF(*Stack) + YYSTACK_GAP_MAXIMUM; \
523 : yyptr += yynewbytes / YYSIZEOF(*yyptr); \
524 : } while (0)
525 :
526 : #endif
527 :
528 : #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
529 : /* Copy COUNT objects from SRC to DST. The source and destination do
530 : not overlap. */
531 : #ifndef YYCOPY
532 : #if defined __GNUC__ && 1 < __GNUC__
533 : #define YYCOPY(Dst, Src, Count) \
534 : __builtin_memcpy(Dst, Src, YY_CAST(YYSIZE_T, (Count)) * sizeof(*(Src)))
535 : #else
536 : #define YYCOPY(Dst, Src, Count) \
537 : do \
538 : { \
539 : YYPTRDIFF_T yyi; \
540 : for (yyi = 0; yyi < (Count); yyi++) \
541 : (Dst)[yyi] = (Src)[yyi]; \
542 : } while (0)
543 : #endif
544 : #endif
545 : #endif /* !YYCOPY_NEEDED */
546 :
547 : /* YYFINAL -- State number of the termination state. */
548 : #define YYFINAL 20
549 : /* YYLAST -- Last index in YYTABLE. */
550 : #define YYLAST 409
551 :
552 : /* YYNTOKENS -- Number of terminals. */
553 : #define YYNTOKENS 53
554 : /* YYNNTS -- Number of nonterminals. */
555 : #define YYNNTS 25
556 : /* YYNRULES -- Number of rules. */
557 : #define YYNRULES 101
558 : /* YYNSTATES -- Number of states. */
559 : #define YYNSTATES 211
560 :
561 : /* YYMAXUTOK -- Last valid token kind. */
562 : #define YYMAXUTOK 294
563 :
564 : /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
565 : as returned by yylex, with out-of-bounds checking. */
566 : #define YYTRANSLATE(YYX) \
567 : (0 <= (YYX) && (YYX) <= YYMAXUTOK \
568 : ? YY_CAST(yysymbol_kind_t, yytranslate[YYX]) \
569 : : YYSYMBOL_YYUNDEF)
570 :
571 : /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
572 : as returned by yylex. */
573 : static const yytype_int8 yytranslate[] = {
574 : 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
575 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 41, 2, 2, 2, 46,
576 : 2, 2, 49, 50, 44, 42, 51, 43, 52, 45, 2, 2, 2, 2, 2, 2, 2, 2, 2,
577 : 2, 2, 2, 39, 38, 40, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
578 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
579 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
580 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
581 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
582 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
583 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
584 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
585 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
586 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
587 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
588 : 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
589 : 30, 31, 32, 33, 34, 35, 36, 37, 47, 48};
590 :
591 : #if YYDEBUG
592 : /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
593 : static const yytype_int16 yyrline[] = {
594 : 0, 124, 124, 125, 131, 138, 143, 148, 153, 160, 168, 176, 184, 192, 200,
595 : 208, 216, 224, 232, 240, 252, 261, 274, 282, 294, 303, 316, 325, 338, 347,
596 : 360, 367, 379, 385, 392, 400, 413, 418, 423, 427, 432, 437, 442, 477, 484,
597 : 491, 498, 505, 512, 548, 556, 562, 569, 578, 596, 616, 617, 620, 625, 631,
598 : 632, 634, 642, 643, 646, 656, 657, 660, 661, 664, 673, 684, 699, 714, 735,
599 : 766, 801, 826, 855, 861, 863, 864, 869, 870, 876, 883, 884, 887, 888, 891,
600 : 897, 903, 910, 911, 918, 919, 927, 937, 948, 959, 972, 983};
601 : #endif
602 :
603 : /** Accessing symbol of state STATE. */
604 : #define YY_ACCESSING_SYMBOL(State) YY_CAST(yysymbol_kind_t, yystos[State])
605 :
606 : #if 1
607 : /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
608 : First, the terminals, then, starting at YYNTOKENS, nonterminals. */
609 : static const char *const yytname[] = {"\"end of string\"",
610 : "error",
611 : "\"invalid token\"",
612 : "\"integer number\"",
613 : "\"floating point number\"",
614 : "\"string\"",
615 : "\"identifier\"",
616 : "\"IN\"",
617 : "\"LIKE\"",
618 : "\"ILIKE\"",
619 : "\"ESCAPE\"",
620 : "\"BETWEEN\"",
621 : "\"NULL\"",
622 : "\"IS\"",
623 : "\"SELECT\"",
624 : "\"LEFT\"",
625 : "\"JOIN\"",
626 : "\"WHERE\"",
627 : "\"ON\"",
628 : "\"ORDER\"",
629 : "\"BY\"",
630 : "\"FROM\"",
631 : "\"AS\"",
632 : "\"ASC\"",
633 : "\"DESC\"",
634 : "\"DISTINCT\"",
635 : "\"CAST\"",
636 : "\"UNION\"",
637 : "\"ALL\"",
638 : "\"LIMIT\"",
639 : "\"OFFSET\"",
640 : "\"EXCEPT\"",
641 : "\"EXCLUDE\"",
642 : "SWQT_VALUE_START",
643 : "SWQT_SELECT_START",
644 : "\"NOT\"",
645 : "\"OR\"",
646 : "\"AND\"",
647 : "'='",
648 : "'<'",
649 : "'>'",
650 : "'!'",
651 : "'+'",
652 : "'-'",
653 : "'*'",
654 : "'/'",
655 : "'%'",
656 : "SWQT_UMINUS",
657 : "\"reserved keyword\"",
658 : "'('",
659 : "')'",
660 : "','",
661 : "'.'",
662 : "$accept",
663 : "input",
664 : "value_expr",
665 : "value_expr_list",
666 : "field_value",
667 : "value_expr_non_logical",
668 : "type_def",
669 : "select_statement",
670 : "select_core",
671 : "opt_union_all",
672 : "union_all",
673 : "select_field_list",
674 : "exclude_field",
675 : "exclude_field_list",
676 : "except_or_exclude",
677 : "column_spec",
678 : "as_clause",
679 : "opt_where",
680 : "opt_joins",
681 : "opt_order_by",
682 : "sort_spec_list",
683 : "sort_spec",
684 : "opt_limit",
685 : "opt_offset",
686 : "table_def",
687 : YY_NULLPTR};
688 : #endif
689 :
690 : #define YYPACT_NINF (-137)
691 :
692 : #define yypact_value_is_default(Yyn) ((Yyn) == YYPACT_NINF)
693 :
694 : #define YYTABLE_NINF (-1)
695 :
696 : #define yytable_value_is_error(Yyn) 0
697 :
698 : /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
699 : STATE-NUM. */
700 : static const yytype_int16 yypact[] = {
701 : 34, 206, -10, 16, -137, -137, -137, -35, -137, -37, 206, 211,
702 : 206, 326, -137, 298, 79, 11, -137, 4, -137, 206, 23, 206,
703 : 368, -137, 254, -11, 206, 206, 211, -5, 12, 206, 206, 94,
704 : 104, 155, 5, 211, 211, 211, 211, 211, 8, 196, 93, 274,
705 : 48, 26, 30, 65, -137, -10, 235, 45, -137, 310, -137, 206,
706 : 91, 101, 44, -137, 103, 68, 206, 206, 211, 345, 361, 206,
707 : 206, -137, 206, 206, -137, 206, -137, 206, 18, 18, -137, -137,
708 : -137, 145, -3, 100, -137, -137, 89, -137, 140, -137, 121, 196,
709 : 4, -137, -137, 206, -137, 146, 114, 206, 206, 211, -137, 206,
710 : 144, 158, 182, -137, -137, -137, -137, -137, -137, 159, 119, -137,
711 : 121, 159, -137, 120, 2, 116, -137, -137, -137, 124, 125, -137,
712 : -137, -137, 298, 127, 206, 206, 211, 122, 128, 20, 116, -137,
713 : 131, 129, 177, 178, -137, 170, 121, 174, 53, -137, -137, -137,
714 : -137, 298, 20, -137, 174, 159, -137, 20, 20, 121, 169, 206,
715 : 173, 90, 105, -137, 173, -137, -137, -137, 179, 206, 326, 175,
716 : 167, -137, 200, -137, 202, 167, 206, 290, 159, 203, 183, 157,
717 : 171, 183, 290, -137, 139, -137, 184, -137, 217, -137, -137, -137,
718 : -137, -137, -137, -137, 159, -137, -137};
719 :
720 : /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
721 : Performed when YYTABLE does not specify something else to do. Zero
722 : means the default is an error. */
723 : static const yytype_int8 yydefact[] = {
724 : 2, 0, 0, 0, 36, 37, 38, 34, 41, 0, 0, 0, 0, 3, 39, 5, 0, 0,
725 : 4, 59, 1, 0, 0, 0, 8, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
726 : 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, 72, 69, 0, 62, 0, 0, 55, 0,
727 : 33, 0, 35, 0, 40, 0, 18, 22, 0, 30, 0, 0, 0, 0, 0, 7, 6, 0,
728 : 0, 9, 0, 0, 12, 0, 13, 0, 43, 44, 45, 46, 47, 0, 0, 0, 67, 68,
729 : 0, 79, 0, 70, 0, 0, 59, 61, 60, 0, 48, 0, 0, 0, 0, 0, 31, 0,
730 : 19, 23, 0, 15, 16, 14, 10, 17, 11, 0, 0, 73, 0, 0, 78, 0, 96, 82,
731 : 63, 56, 32, 50, 0, 26, 20, 24, 28, 0, 0, 0, 0, 34, 0, 74, 82, 64,
732 : 65, 0, 0, 0, 97, 0, 0, 80, 0, 49, 27, 21, 25, 29, 76, 75, 80, 0,
733 : 71, 98, 100, 0, 0, 0, 85, 0, 0, 77, 85, 66, 99, 101, 0, 0, 81, 0,
734 : 92, 51, 0, 53, 0, 92, 0, 82, 0, 0, 94, 0, 0, 94, 82, 83, 89, 86,
735 : 88, 93, 0, 57, 52, 54, 58, 84, 90, 91, 0, 95, 87};
736 :
737 : /* YYPGOTO[NTERM-NUM]. */
738 : static const yytype_int16 yypgoto[] = {
739 : -137, -137, -1, -46, -116, 7, -137, 176, 213, 137, -137, -43, -137,
740 : 73, -137, -137, -45, 76, -136, 66, 39, -137, 67, 57, -110};
741 :
742 : /* YYDEFGOTO[NTERM-NUM]. */
743 : static const yytype_uint8 yydefgoto[] = {
744 : 0, 3, 54, 55, 14, 15, 130, 18, 19, 52, 53, 48, 144,
745 : 145, 90, 49, 93, 168, 151, 180, 197, 198, 190, 201, 125};
746 :
747 : /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
748 : positive, shift that token. If negative, reduce the rule whose
749 : number is the opposite. If YYTABLE_NINF, syntax error. */
750 : static const yytype_uint8 yytable[] = {
751 : 13, 140, 87, 56, 16, 143, 160, 63, 91, 24, 142, 26, 23, 102, 21,
752 : 47, 20, 22, 25, 65, 66, 67, 57, 68, 92, 16, 91, 60, 61, 56,
753 : 64, 51, 69, 70, 73, 76, 78, 62, 59, 17, 166, 119, 92, 79, 47,
754 : 143, 80, 81, 82, 83, 84, 195, 126, 128, 147, 176, 169, 85, 205, 170,
755 : 86, 135, 41, 42, 43, 108, 109, 1, 2, 94, 111, 112, 196, 113, 114,
756 : 110, 115, 95, 116, 148, 96, 105, 4, 5, 6, 44, 39, 40, 41, 42,
757 : 43, 8, 196, 97, 47, 100, 159, 4, 5, 6, 7, 103, 132, 133, 45,
758 : 9, 8, 4, 5, 6, 7, 104, 134, 171, 10, 106, 8, 107, 174, 175,
759 : 9, 120, 11, 46, 88, 89, 123, 124, 12, 10, 9, 149, 150, 71, 72,
760 : 155, 156, 11, 121, 10, 181, 182, 74, 12, 75, 157, 122, 11, 4, 5,
761 : 6, 7, 129, 12, 136, 183, 184, 8, 4, 5, 6, 7, 206, 207, 131,
762 : 139, 178, 8, 137, 141, 117, 9, 146, 152, 22, 153, 187, 154, 158, 162,
763 : 10, 9, 161, 163, 164, 194, 165, 177, 11, 118, 10, 167, 179, 77, 12,
764 : 188, 189, 186, 11, 4, 5, 6, 44, 191, 12, 192, 199, 202, 8, 4,
765 : 5, 6, 7, 200, 4, 5, 6, 7, 8, 138, 209, 203, 9, 8, 39,
766 : 40, 41, 42, 43, 98, 50, 10, 9, 127, 173, 208, 172, 9, 185, 11,
767 : 46, 10, 27, 28, 29, 12, 30, 210, 31, 11, 204, 0, 193, 0, 11,
768 : 12, 0, 0, 0, 0, 12, 27, 28, 29, 0, 30, 0, 31, 0, 0,
769 : 32, 33, 34, 35, 36, 37, 38, 0, 0, 0, 91, 27, 28, 29, 0,
770 : 30, 99, 31, 0, 32, 33, 34, 35, 36, 37, 38, 92, 27, 28, 29,
771 : 0, 30, 0, 31, 58, 149, 150, 0, 0, 32, 33, 34, 35, 36, 37,
772 : 38, 0, 27, 28, 29, 0, 30, 0, 31, 0, 32, 33, 34, 35, 36,
773 : 37, 38, 101, 27, 28, 29, 0, 30, 0, 31, 39, 40, 41, 42, 43,
774 : 32, 33, 34, 35, 36, 37, 38, 27, 28, 29, 0, 30, 0, 31, 0,
775 : 0, 32, 33, 34, 35, 36, 37, 38, 27, 28, 29, 0, 30, 0, 31,
776 : 27, 28, 29, 0, 30, 32, 31, 34, 35, 36, 37, 38, 0, 0, 0,
777 : 0, 0, 0, 0, 0, 0, 32, 0, 0, 35, 36, 37, 38, 0, 0,
778 : 0, 35, 36, 37, 38};
779 :
780 : static const yytype_int16 yycheck[] = {
781 : 1, 117, 45, 6, 14, 121, 142, 12, 6, 10, 120, 12, 49, 59, 49, 16,
782 : 0, 52, 11, 7, 8, 9, 23, 11, 22, 14, 6, 28, 29, 6, 35, 27,
783 : 33, 34, 35, 36, 37, 30, 49, 49, 150, 44, 22, 38, 45, 161, 39, 40,
784 : 41, 42, 43, 187, 95, 99, 52, 165, 3, 49, 194, 6, 52, 107, 44, 45,
785 : 46, 66, 67, 33, 34, 21, 71, 72, 188, 74, 75, 68, 77, 51, 79, 124,
786 : 50, 37, 3, 4, 5, 6, 42, 43, 44, 45, 46, 12, 208, 28, 95, 50,
787 : 141, 3, 4, 5, 6, 10, 103, 104, 25, 26, 12, 3, 4, 5, 6, 10,
788 : 105, 158, 35, 12, 12, 49, 163, 164, 26, 21, 43, 44, 31, 32, 5, 6,
789 : 49, 35, 26, 15, 16, 39, 40, 136, 137, 43, 49, 35, 50, 51, 38, 49,
790 : 40, 138, 6, 43, 3, 4, 5, 6, 6, 49, 10, 50, 51, 12, 3, 4,
791 : 5, 6, 23, 24, 50, 6, 167, 12, 10, 50, 25, 26, 52, 49, 52, 50,
792 : 177, 50, 50, 50, 35, 26, 51, 6, 6, 186, 16, 18, 43, 44, 35, 17,
793 : 19, 38, 49, 20, 29, 18, 43, 3, 4, 5, 6, 3, 49, 3, 3, 50,
794 : 12, 3, 4, 5, 6, 30, 3, 4, 5, 6, 12, 37, 3, 50, 26, 12,
795 : 42, 43, 44, 45, 46, 53, 17, 35, 26, 96, 161, 51, 160, 26, 172, 43,
796 : 44, 35, 7, 8, 9, 49, 11, 208, 13, 43, 193, -1, 185, -1, 43, 49,
797 : -1, -1, -1, -1, 49, 7, 8, 9, -1, 11, -1, 13, -1, -1, 35, 36,
798 : 37, 38, 39, 40, 41, -1, -1, -1, 6, 7, 8, 9, -1, 11, 51, 13,
799 : -1, 35, 36, 37, 38, 39, 40, 41, 22, 7, 8, 9, -1, 11, -1, 13,
800 : 50, 15, 16, -1, -1, 35, 36, 37, 38, 39, 40, 41, -1, 7, 8, 9,
801 : -1, 11, -1, 13, -1, 35, 36, 37, 38, 39, 40, 41, 22, 7, 8, 9,
802 : -1, 11, -1, 13, 42, 43, 44, 45, 46, 35, 36, 37, 38, 39, 40, 41,
803 : 7, 8, 9, -1, 11, -1, 13, -1, -1, 35, 36, 37, 38, 39, 40, 41,
804 : 7, 8, 9, -1, 11, -1, 13, 7, 8, 9, -1, 11, 35, 13, 37, 38,
805 : 39, 40, 41, -1, -1, -1, -1, -1, -1, -1, -1, -1, 35, -1, -1, 38,
806 : 39, 40, 41, -1, -1, -1, 38, 39, 40, 41};
807 :
808 : /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
809 : state STATE-NUM. */
810 : static const yytype_int8 yystos[] = {
811 : 0, 33, 34, 54, 3, 4, 5, 6, 12, 26, 35, 43, 49, 55, 57, 58, 14, 49,
812 : 60, 61, 0, 49, 52, 49, 55, 58, 55, 7, 8, 9, 11, 13, 35, 36, 37, 38,
813 : 39, 40, 41, 42, 43, 44, 45, 46, 6, 25, 44, 55, 64, 68, 61, 27, 62, 63,
814 : 55, 56, 6, 55, 50, 49, 55, 55, 58, 12, 35, 7, 8, 9, 11, 55, 55, 39,
815 : 40, 55, 38, 40, 55, 38, 55, 38, 58, 58, 58, 58, 58, 49, 52, 64, 31, 32,
816 : 67, 6, 22, 69, 21, 51, 50, 28, 60, 51, 50, 22, 56, 10, 10, 37, 12, 49,
817 : 55, 55, 58, 55, 55, 55, 55, 55, 55, 25, 44, 44, 21, 49, 6, 5, 6, 77,
818 : 64, 62, 56, 6, 59, 50, 55, 55, 58, 56, 10, 10, 37, 6, 57, 50, 77, 57,
819 : 65, 66, 52, 52, 69, 15, 16, 71, 49, 50, 50, 55, 55, 58, 50, 69, 71, 51,
820 : 50, 6, 6, 16, 77, 17, 70, 3, 6, 69, 70, 66, 69, 69, 77, 18, 55, 19,
821 : 72, 50, 51, 50, 51, 72, 18, 55, 20, 29, 75, 3, 3, 75, 55, 71, 57, 73,
822 : 74, 3, 30, 76, 50, 50, 76, 71, 23, 24, 51, 3, 73};
823 :
824 : /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
825 : static const yytype_int8 yyr1[] = {
826 : 0, 53, 54, 54, 54, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
827 : 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 56, 56,
828 : 57, 57, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 59,
829 : 59, 59, 59, 59, 60, 60, 61, 61, 62, 62, 63, 64, 64, 65, 66, 66, 67,
830 : 67, 68, 68, 68, 68, 68, 68, 68, 68, 68, 69, 69, 70, 70, 71, 71, 71,
831 : 72, 72, 73, 73, 74, 74, 74, 75, 75, 76, 76, 77, 77, 77, 77, 77, 77};
832 :
833 : /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
834 : static const yytype_int8 yyr2[] = {
835 : 0, 2, 0, 2, 2, 1, 3, 3, 2, 3, 4, 4, 3, 3, 4, 4, 4, 4, 3, 4, 5,
836 : 6, 3, 4, 5, 6, 5, 6, 5, 6, 3, 4, 3, 1, 1, 3, 1, 1, 1, 1, 3, 1,
837 : 2, 3, 3, 3, 3, 3, 4, 6, 1, 4, 6, 4, 6, 2, 4, 9, 10, 0, 2, 2, 1,
838 : 3, 1, 1, 3, 1, 1, 1, 2, 5, 1, 3, 4, 5, 5, 6, 2, 1, 0, 2, 0, 5,
839 : 6, 0, 3, 3, 1, 1, 2, 2, 0, 2, 0, 2, 1, 2, 3, 4, 3, 4};
840 :
841 : enum
842 : {
843 : YYENOMEM = -2
844 : };
845 :
846 : #define yyerrok (yyerrstatus = 0)
847 : #define yyclearin (yychar = YYEMPTY)
848 :
849 : #define YYACCEPT goto yyacceptlab
850 : #define YYABORT goto yyabortlab
851 : #define YYERROR goto yyerrorlab
852 : #define YYNOMEM goto yyexhaustedlab
853 :
854 : #define YYRECOVERING() (!!yyerrstatus)
855 :
856 : #define YYBACKUP(Token, Value) \
857 : do \
858 : if (yychar == YYEMPTY) \
859 : { \
860 : yychar = (Token); \
861 : yylval = (Value); \
862 : YYPOPSTACK(yylen); \
863 : yystate = *yyssp; \
864 : goto yybackup; \
865 : } \
866 : else \
867 : { \
868 : yyerror(context, YY_("syntax error: cannot back up")); \
869 : YYERROR; \
870 : } \
871 : while (0)
872 :
873 : /* Backward compatibility with an undocumented macro.
874 : Use YYerror or YYUNDEF. */
875 : #define YYERRCODE YYUNDEF
876 :
877 : /* Enable debugging if requested. */
878 : #if YYDEBUG
879 :
880 : #ifndef YYFPRINTF
881 : #include <stdio.h> /* INFRINGES ON USER NAME SPACE */
882 : #define YYFPRINTF fprintf
883 : #endif
884 :
885 : #define YYDPRINTF(Args) \
886 : do \
887 : { \
888 : if (yydebug) \
889 : YYFPRINTF Args; \
890 : } while (0)
891 :
892 : #define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
893 : do \
894 : { \
895 : if (yydebug) \
896 : { \
897 : YYFPRINTF(stderr, "%s ", Title); \
898 : yy_symbol_print(stderr, Kind, Value, context); \
899 : YYFPRINTF(stderr, "\n"); \
900 : } \
901 : } while (0)
902 :
903 : /*-----------------------------------.
904 : | Print this symbol's value on YYO. |
905 : `-----------------------------------*/
906 :
907 : static void yy_symbol_value_print(FILE *yyo, yysymbol_kind_t yykind,
908 : YYSTYPE const *const yyvaluep,
909 : swq_parse_context *context)
910 : {
911 : FILE *yyoutput = yyo;
912 : YY_USE(yyoutput);
913 : YY_USE(context);
914 : if (!yyvaluep)
915 : return;
916 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
917 : YY_USE(yykind);
918 : YY_IGNORE_MAYBE_UNINITIALIZED_END
919 : }
920 :
921 : /*---------------------------.
922 : | Print this symbol on YYO. |
923 : `---------------------------*/
924 :
925 : static void yy_symbol_print(FILE *yyo, yysymbol_kind_t yykind,
926 : YYSTYPE const *const yyvaluep,
927 : swq_parse_context *context)
928 : {
929 : YYFPRINTF(yyo, "%s %s (", yykind < YYNTOKENS ? "token" : "nterm",
930 : yysymbol_name(yykind));
931 :
932 : yy_symbol_value_print(yyo, yykind, yyvaluep, context);
933 : YYFPRINTF(yyo, ")");
934 : }
935 :
936 : /*------------------------------------------------------------------.
937 : | yy_stack_print -- Print the state stack from its BOTTOM up to its |
938 : | TOP (included). |
939 : `------------------------------------------------------------------*/
940 :
941 : static void yy_stack_print(yy_state_t *yybottom, yy_state_t *yytop)
942 : {
943 : YYFPRINTF(stderr, "Stack now");
944 : for (; yybottom <= yytop; yybottom++)
945 : {
946 : int yybot = *yybottom;
947 : YYFPRINTF(stderr, " %d", yybot);
948 : }
949 : YYFPRINTF(stderr, "\n");
950 : }
951 :
952 : #define YY_STACK_PRINT(Bottom, Top) \
953 : do \
954 : { \
955 : if (yydebug) \
956 : yy_stack_print((Bottom), (Top)); \
957 : } while (0)
958 :
959 : /*------------------------------------------------.
960 : | Report that the YYRULE is going to be reduced. |
961 : `------------------------------------------------*/
962 :
963 : static void yy_reduce_print(yy_state_t *yyssp, YYSTYPE *yyvsp, int yyrule,
964 : swq_parse_context *context)
965 : {
966 : int yylno = yyrline[yyrule];
967 : int yynrhs = yyr2[yyrule];
968 : int yyi;
969 : YYFPRINTF(stderr, "Reducing stack by rule %d (line %d):\n", yyrule - 1,
970 : yylno);
971 : /* The symbols being reduced. */
972 : for (yyi = 0; yyi < yynrhs; yyi++)
973 : {
974 : YYFPRINTF(stderr, " $%d = ", yyi + 1);
975 : yy_symbol_print(stderr, YY_ACCESSING_SYMBOL(+yyssp[yyi + 1 - yynrhs]),
976 : &yyvsp[(yyi + 1) - (yynrhs)], context);
977 : YYFPRINTF(stderr, "\n");
978 : }
979 : }
980 :
981 : #define YY_REDUCE_PRINT(Rule) \
982 : do \
983 : { \
984 : if (yydebug) \
985 : yy_reduce_print(yyssp, yyvsp, Rule, context); \
986 : } while (0)
987 :
988 : /* Nonzero means print parse trace. It is left uninitialized so that
989 : multiple parsers can coexist. */
990 : int yydebug;
991 : #else /* !YYDEBUG */
992 : #define YYDPRINTF(Args) ((void)0)
993 : #define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
994 : #define YY_STACK_PRINT(Bottom, Top)
995 : #define YY_REDUCE_PRINT(Rule)
996 : #endif /* !YYDEBUG */
997 :
998 : /* YYINITDEPTH -- initial size of the parser's stacks. */
999 : #ifndef YYINITDEPTH
1000 : #define YYINITDEPTH 200
1001 : #endif
1002 :
1003 : /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1004 : if the built-in stack extension method is used).
1005 :
1006 : Do not make this value too large; the results are undefined if
1007 : YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1008 : evaluated with infinite-precision integer arithmetic. */
1009 :
1010 : #ifndef YYMAXDEPTH
1011 : #define YYMAXDEPTH 10000
1012 : #endif
1013 :
1014 : /* Context of a parse error. */
1015 : typedef struct
1016 : {
1017 : yy_state_t *yyssp;
1018 : yysymbol_kind_t yytoken;
1019 : } yypcontext_t;
1020 :
1021 : /* Put in YYARG at most YYARGN of the expected tokens given the
1022 : current YYCTX, and return the number of tokens stored in YYARG. If
1023 : YYARG is null, return the number of expected tokens (guaranteed to
1024 : be less than YYNTOKENS). Return YYENOMEM on memory exhaustion.
1025 : Return 0 if there are more than YYARGN expected tokens, yet fill
1026 : YYARG up to YYARGN. */
1027 187 : static int yypcontext_expected_tokens(const yypcontext_t *yyctx,
1028 : yysymbol_kind_t yyarg[], int yyargn)
1029 : {
1030 : /* Actual size of YYARG. */
1031 187 : int yycount = 0;
1032 187 : int yyn = yypact[+*yyctx->yyssp];
1033 187 : if (!yypact_value_is_default(yyn))
1034 : {
1035 : /* Start YYX at -YYN if negative to avoid negative indexes in
1036 : YYCHECK. In other words, skip the first -YYN actions for
1037 : this state because they are default actions. */
1038 187 : int yyxbegin = yyn < 0 ? -yyn : 0;
1039 : /* Stay within bounds of both yycheck and yytname. */
1040 187 : int yychecklim = YYLAST - yyn + 1;
1041 187 : int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1042 : int yyx;
1043 7769 : for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1044 7615 : if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_YYerror &&
1045 : !yytable_value_is_error(yytable[yyx + yyn]))
1046 : {
1047 425 : if (!yyarg)
1048 0 : ++yycount;
1049 425 : else if (yycount == yyargn)
1050 33 : return 0;
1051 : else
1052 392 : yyarg[yycount++] = YY_CAST(yysymbol_kind_t, yyx);
1053 : }
1054 : }
1055 154 : if (yyarg && yycount == 0 && 0 < yyargn)
1056 0 : yyarg[0] = YYSYMBOL_YYEMPTY;
1057 154 : return yycount;
1058 : }
1059 :
1060 : #ifndef yystrlen
1061 : #if defined __GLIBC__ && defined _STRING_H
1062 : #define yystrlen(S) (YY_CAST(YYPTRDIFF_T, strlen(S)))
1063 : #else
1064 : /* Return the length of YYSTR. */
1065 : static YYPTRDIFF_T yystrlen(const char *yystr)
1066 : {
1067 : YYPTRDIFF_T yylen;
1068 : for (yylen = 0; yystr[yylen]; yylen++)
1069 : continue;
1070 : return yylen;
1071 : }
1072 : #endif
1073 : #endif
1074 :
1075 : #ifndef yystpcpy
1076 : #if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1077 : #define yystpcpy stpcpy
1078 : #else
1079 : /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1080 : YYDEST. */
1081 : static char *yystpcpy(char *yydest, const char *yysrc)
1082 : {
1083 : char *yyd = yydest;
1084 : const char *yys = yysrc;
1085 :
1086 : while ((*yyd++ = *yys++) != '\0')
1087 : continue;
1088 :
1089 : return yyd - 1;
1090 : }
1091 : #endif
1092 : #endif
1093 :
1094 : #ifndef yytnamerr
1095 : /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1096 : quotes and backslashes, so that it's suitable for yyerror. The
1097 : heuristic is that double-quoting is unnecessary unless the string
1098 : contains an apostrophe, a comma, or backslash (other than
1099 : backslash-backslash). YYSTR is taken from yytname. If YYRES is
1100 : null, do not copy; instead, return the length of what the result
1101 : would have been. */
1102 894 : static YYPTRDIFF_T yytnamerr(char *yyres, const char *yystr)
1103 : {
1104 894 : if (*yystr == '"')
1105 : {
1106 646 : YYPTRDIFF_T yyn = 0;
1107 646 : char const *yyp = yystr;
1108 : for (;;)
1109 6258 : switch (*++yyp)
1110 : {
1111 0 : case '\'':
1112 : case ',':
1113 0 : goto do_not_strip_quotes;
1114 :
1115 0 : case '\\':
1116 0 : if (*++yyp != '\\')
1117 0 : goto do_not_strip_quotes;
1118 : else
1119 0 : goto append;
1120 :
1121 5612 : append:
1122 : default:
1123 5612 : if (yyres)
1124 2806 : yyres[yyn] = *yyp;
1125 5612 : yyn++;
1126 5612 : break;
1127 :
1128 646 : case '"':
1129 646 : if (yyres)
1130 323 : yyres[yyn] = '\0';
1131 646 : return yyn;
1132 : }
1133 0 : do_not_strip_quotes:;
1134 : }
1135 :
1136 248 : if (yyres)
1137 124 : return yystpcpy(yyres, yystr) - yyres;
1138 : else
1139 124 : return yystrlen(yystr);
1140 : }
1141 : #endif
1142 :
1143 187 : static int yy_syntax_error_arguments(const yypcontext_t *yyctx,
1144 : yysymbol_kind_t yyarg[], int yyargn)
1145 : {
1146 : /* Actual size of YYARG. */
1147 187 : int yycount = 0;
1148 : /* There are many possibilities here to consider:
1149 : - If this state is a consistent state with a default action, then
1150 : the only way this function was invoked is if the default action
1151 : is an error action. In that case, don't check for expected
1152 : tokens because there are none.
1153 : - The only way there can be no lookahead present (in yychar) is if
1154 : this state is a consistent state with a default action. Thus,
1155 : detecting the absence of a lookahead is sufficient to determine
1156 : that there is no unexpected or expected token to report. In that
1157 : case, just report a simple "syntax error".
1158 : - Don't assume there isn't a lookahead just because this state is a
1159 : consistent state with a default action. There might have been a
1160 : previous inconsistent state, consistent state with a non-default
1161 : action, or user semantic action that manipulated yychar.
1162 : - Of course, the expected token list depends on states to have
1163 : correct lookahead information, and it depends on the parser not
1164 : to perform extra reductions after fetching a lookahead from the
1165 : scanner and before detecting a syntax error. Thus, state merging
1166 : (from LALR or IELR) and default reductions corrupt the expected
1167 : token list. However, the list is correct for canonical LR with
1168 : one exception: it will still contain any token that will not be
1169 : accepted due to an error action in a later state.
1170 : */
1171 187 : if (yyctx->yytoken != YYSYMBOL_YYEMPTY)
1172 : {
1173 : int yyn;
1174 187 : if (yyarg)
1175 187 : yyarg[yycount] = yyctx->yytoken;
1176 187 : ++yycount;
1177 187 : yyn = yypcontext_expected_tokens(yyctx, yyarg ? yyarg + 1 : yyarg,
1178 : yyargn - 1);
1179 187 : if (yyn == YYENOMEM)
1180 0 : return YYENOMEM;
1181 : else
1182 187 : yycount += yyn;
1183 : }
1184 187 : return yycount;
1185 : }
1186 :
1187 : /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1188 : about the unexpected token YYTOKEN for the state stack whose top is
1189 : YYSSP.
1190 :
1191 : Return 0 if *YYMSG was successfully written. Return -1 if *YYMSG is
1192 : not large enough to hold the message. In that case, also set
1193 : *YYMSG_ALLOC to the required number of bytes. Return YYENOMEM if the
1194 : required number of bytes is too large to store. */
1195 187 : static int yysyntax_error(YYPTRDIFF_T *yymsg_alloc, char **yymsg,
1196 : const yypcontext_t *yyctx)
1197 : {
1198 : enum
1199 : {
1200 : YYARGS_MAX = 5
1201 : };
1202 :
1203 : /* Internationalized format string. */
1204 187 : const char *yyformat = YY_NULLPTR;
1205 : /* Arguments of yyformat: reported tokens (one for the "unexpected",
1206 : one per "expected"). */
1207 : yysymbol_kind_t yyarg[YYARGS_MAX];
1208 : /* Cumulated lengths of YYARG. */
1209 187 : YYPTRDIFF_T yysize = 0;
1210 :
1211 : /* Actual size of YYARG. */
1212 187 : int yycount = yy_syntax_error_arguments(yyctx, yyarg, YYARGS_MAX);
1213 187 : if (yycount == YYENOMEM)
1214 0 : return YYENOMEM;
1215 :
1216 187 : switch (yycount)
1217 : {
1218 : #define YYCASE_(N, S) \
1219 : case N: \
1220 : yyformat = S; \
1221 : break
1222 0 : default: /* Avoid compiler warnings. */
1223 0 : YYCASE_(0, YY_("syntax error"));
1224 33 : YYCASE_(1, YY_("syntax error, unexpected %s"));
1225 48 : YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1226 106 : YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1227 0 : YYCASE_(
1228 : 4,
1229 : YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1230 0 : YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or "
1231 : "%s or %s"));
1232 : #undef YYCASE_
1233 : }
1234 :
1235 : /* Compute error message size. Don't count the "%s"s, but reserve
1236 : room for the terminator. */
1237 187 : yysize = yystrlen(yyformat) - 2 * yycount + 1;
1238 : {
1239 : int yyi;
1240 634 : for (yyi = 0; yyi < yycount; ++yyi)
1241 : {
1242 : YYPTRDIFF_T yysize1 =
1243 447 : yysize + yytnamerr(YY_NULLPTR, yytname[yyarg[yyi]]);
1244 447 : if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1245 447 : yysize = yysize1;
1246 : else
1247 0 : return YYENOMEM;
1248 : }
1249 : }
1250 :
1251 187 : if (*yymsg_alloc < yysize)
1252 : {
1253 0 : *yymsg_alloc = 2 * yysize;
1254 0 : if (!(yysize <= *yymsg_alloc && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1255 0 : *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1256 0 : return -1;
1257 : }
1258 :
1259 : /* Avoid sprintf, as that infringes on the user's name space.
1260 : Don't have undefined behavior even if the translation
1261 : produced a string with the wrong number of "%s"s. */
1262 : {
1263 187 : char *yyp = *yymsg;
1264 187 : int yyi = 0;
1265 7581 : while ((*yyp = *yyformat) != '\0')
1266 7394 : if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1267 : {
1268 447 : yyp += yytnamerr(yyp, yytname[yyarg[yyi++]]);
1269 447 : yyformat += 2;
1270 : }
1271 : else
1272 : {
1273 6947 : ++yyp;
1274 6947 : ++yyformat;
1275 : }
1276 : }
1277 187 : return 0;
1278 : }
1279 :
1280 : /*-----------------------------------------------.
1281 : | Release the memory associated to this symbol. |
1282 : `-----------------------------------------------*/
1283 :
1284 15201 : static void yydestruct(const char *yymsg, yysymbol_kind_t yykind,
1285 : YYSTYPE *yyvaluep, swq_parse_context *context)
1286 : {
1287 : YY_USE(yyvaluep);
1288 : YY_USE(context);
1289 15201 : if (!yymsg)
1290 0 : yymsg = "Deleting";
1291 : YY_SYMBOL_PRINT(yymsg, yykind, yyvaluep, yylocationp);
1292 :
1293 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1294 15201 : switch (yykind)
1295 : {
1296 4 : case YYSYMBOL_SWQT_INTEGER_NUMBER: /* "integer number" */
1297 : {
1298 4 : delete (*yyvaluep);
1299 : }
1300 4 : break;
1301 :
1302 0 : case YYSYMBOL_SWQT_FLOAT_NUMBER: /* "floating point number" */
1303 : {
1304 0 : delete (*yyvaluep);
1305 : }
1306 0 : break;
1307 :
1308 7 : case YYSYMBOL_SWQT_STRING: /* "string" */
1309 : {
1310 7 : delete (*yyvaluep);
1311 : }
1312 7 : break;
1313 :
1314 104 : case YYSYMBOL_SWQT_IDENTIFIER: /* "identifier" */
1315 : {
1316 104 : delete (*yyvaluep);
1317 : }
1318 104 : break;
1319 :
1320 33 : case YYSYMBOL_value_expr: /* value_expr */
1321 : {
1322 33 : delete (*yyvaluep);
1323 : }
1324 33 : break;
1325 :
1326 3 : case YYSYMBOL_value_expr_list: /* value_expr_list */
1327 : {
1328 3 : delete (*yyvaluep);
1329 : }
1330 3 : break;
1331 :
1332 1 : case YYSYMBOL_field_value: /* field_value */
1333 : {
1334 1 : delete (*yyvaluep);
1335 : }
1336 1 : break;
1337 :
1338 5 : case YYSYMBOL_value_expr_non_logical: /* value_expr_non_logical */
1339 : {
1340 5 : delete (*yyvaluep);
1341 : }
1342 5 : break;
1343 :
1344 3 : case YYSYMBOL_type_def: /* type_def */
1345 : {
1346 3 : delete (*yyvaluep);
1347 : }
1348 3 : break;
1349 :
1350 22 : case YYSYMBOL_table_def: /* table_def */
1351 : {
1352 22 : delete (*yyvaluep);
1353 : }
1354 22 : break;
1355 :
1356 15019 : default:
1357 15019 : break;
1358 : }
1359 : YY_IGNORE_MAYBE_UNINITIALIZED_END
1360 15201 : }
1361 :
1362 : /*----------.
1363 : | yyparse. |
1364 : `----------*/
1365 :
1366 7384 : int yyparse(swq_parse_context *context)
1367 : {
1368 : /* Lookahead token kind. */
1369 : int yychar;
1370 :
1371 : /* The semantic value of the lookahead symbol. */
1372 : /* Default value used for initialization, for pacifying older GCCs
1373 : or non-GCC compilers. */
1374 : YY_INITIAL_VALUE(static YYSTYPE yyval_default;)
1375 : YYSTYPE yylval YY_INITIAL_VALUE(= yyval_default);
1376 :
1377 : /* Number of syntax errors so far. */
1378 7384 : int yynerrs = 0;
1379 :
1380 7384 : yy_state_fast_t yystate = 0;
1381 : /* Number of tokens to shift before error messages enabled. */
1382 7384 : int yyerrstatus = 0;
1383 :
1384 : /* Refer to the stacks through separate pointers, to allow yyoverflow
1385 : to reallocate them elsewhere. */
1386 :
1387 : /* Their size. */
1388 7384 : YYPTRDIFF_T yystacksize = YYINITDEPTH;
1389 :
1390 : /* The state stack: array, bottom, top. */
1391 : yy_state_t yyssa[YYINITDEPTH];
1392 7384 : yy_state_t *yyss = yyssa;
1393 7384 : yy_state_t *yyssp = yyss;
1394 :
1395 : /* The semantic value stack: array, bottom, top. */
1396 : YYSTYPE yyvsa[YYINITDEPTH];
1397 7384 : YYSTYPE *yyvs = yyvsa;
1398 7384 : YYSTYPE *yyvsp = yyvs;
1399 :
1400 : int yyn;
1401 : /* The return value of yyparse. */
1402 : int yyresult;
1403 : /* Lookahead symbol kind. */
1404 7384 : yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1405 : /* The variables used to return semantic value and location from the
1406 : action routines. */
1407 : YYSTYPE yyval;
1408 :
1409 : /* Buffer for error messages, and its allocated size. */
1410 : char yymsgbuf[128];
1411 7384 : char *yymsg = yymsgbuf;
1412 7384 : YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
1413 :
1414 : #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1415 :
1416 : /* The number of symbols on the RHS of the reduced rule.
1417 : Keep to zero when no symbol should be popped. */
1418 7384 : int yylen = 0;
1419 :
1420 : YYDPRINTF((stderr, "Starting parse\n"));
1421 :
1422 7384 : yychar = YYEMPTY; /* Cause a token to be read. */
1423 :
1424 7384 : goto yysetstate;
1425 :
1426 : /*------------------------------------------------------------.
1427 : | yynewstate -- push a new state, which is found in yystate. |
1428 : `------------------------------------------------------------*/
1429 187057 : yynewstate:
1430 : /* In all cases, when you get here, the value and location stacks
1431 : have just been pushed. So pushing a state here evens the stacks. */
1432 187057 : yyssp++;
1433 :
1434 : /*--------------------------------------------------------------------.
1435 : | yysetstate -- set current state (the top of the stack) to yystate. |
1436 : `--------------------------------------------------------------------*/
1437 194441 : yysetstate:
1438 : YYDPRINTF((stderr, "Entering state %d\n", yystate));
1439 : YY_IGNORE_USELESS_CAST_BEGIN
1440 194441 : *yyssp = YY_CAST(yy_state_t, yystate);
1441 : YY_IGNORE_USELESS_CAST_END
1442 : YY_STACK_PRINT(yyss, yyssp);
1443 :
1444 194441 : if (yyss + yystacksize - 1 <= yyssp)
1445 : #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1446 : YYNOMEM;
1447 : #else
1448 : {
1449 : /* Get the current used size of the three stacks, in elements. */
1450 4 : YYPTRDIFF_T yysize = yyssp - yyss + 1;
1451 :
1452 : #if defined yyoverflow
1453 : {
1454 : /* Give user a chance to reallocate the stack. Use copies of
1455 : these so that the &'s don't force the real ones into
1456 : memory. */
1457 : yy_state_t *yyss1 = yyss;
1458 : YYSTYPE *yyvs1 = yyvs;
1459 :
1460 : /* Each stack pointer address is followed by the size of the
1461 : data in use in that stack, in bytes. This used to be a
1462 : conditional around just the two extra args, but that might
1463 : be undefined if yyoverflow is a macro. */
1464 : yyoverflow(YY_("memory exhausted"), &yyss1,
1465 : yysize * YYSIZEOF(*yyssp), &yyvs1,
1466 : yysize * YYSIZEOF(*yyvsp), &yystacksize);
1467 : yyss = yyss1;
1468 : yyvs = yyvs1;
1469 : }
1470 : #else /* defined YYSTACK_RELOCATE */
1471 : /* Extend the stack our own way. */
1472 4 : if (YYMAXDEPTH <= yystacksize)
1473 0 : YYNOMEM;
1474 4 : yystacksize *= 2;
1475 4 : if (YYMAXDEPTH < yystacksize)
1476 0 : yystacksize = YYMAXDEPTH;
1477 :
1478 : {
1479 4 : yy_state_t *yyss1 = yyss;
1480 4 : union yyalloc *yyptr = YY_CAST(
1481 : union yyalloc *,
1482 : YYSTACK_ALLOC(YY_CAST(YYSIZE_T, YYSTACK_BYTES(yystacksize))));
1483 4 : if (!yyptr)
1484 0 : YYNOMEM;
1485 4 : YYSTACK_RELOCATE(yyss_alloc, yyss);
1486 4 : YYSTACK_RELOCATE(yyvs_alloc, yyvs);
1487 : #undef YYSTACK_RELOCATE
1488 4 : if (yyss1 != yyssa)
1489 3 : YYSTACK_FREE(yyss1);
1490 : }
1491 : #endif
1492 :
1493 4 : yyssp = yyss + yysize - 1;
1494 4 : yyvsp = yyvs + yysize - 1;
1495 :
1496 : YY_IGNORE_USELESS_CAST_BEGIN
1497 : YYDPRINTF((stderr, "Stack size increased to %ld\n",
1498 : YY_CAST(long, yystacksize)));
1499 : YY_IGNORE_USELESS_CAST_END
1500 :
1501 4 : if (yyss + yystacksize - 1 <= yyssp)
1502 0 : YYABORT;
1503 : }
1504 : #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1505 :
1506 194441 : if (yystate == YYFINAL)
1507 7182 : YYACCEPT;
1508 :
1509 187259 : goto yybackup;
1510 :
1511 : /*-----------.
1512 : | yybackup. |
1513 : `-----------*/
1514 187259 : yybackup:
1515 : /* Do appropriate processing given the current state. Read a
1516 : lookahead token if we need one and don't already have one. */
1517 :
1518 : /* First try to decide what to do without reference to lookahead token. */
1519 187259 : yyn = yypact[yystate];
1520 187259 : if (yypact_value_is_default(yyn))
1521 46224 : goto yydefault;
1522 :
1523 : /* Not known => get a lookahead token if don't already have one. */
1524 :
1525 : /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1526 141035 : if (yychar == YYEMPTY)
1527 : {
1528 : YYDPRINTF((stderr, "Reading a token\n"));
1529 73934 : yychar = yylex(&yylval, context);
1530 : }
1531 :
1532 141035 : if (yychar <= END)
1533 : {
1534 33390 : yychar = END;
1535 33390 : yytoken = YYSYMBOL_YYEOF;
1536 : YYDPRINTF((stderr, "Now at end of input.\n"));
1537 : }
1538 107645 : else if (yychar == YYerror)
1539 : {
1540 : /* The scanner already issued an error message, process directly
1541 : to error recovery. But do not keep the error token as
1542 : lookahead, it is too special and may lead us to an endless
1543 : loop in error recovery. */
1544 0 : yychar = YYUNDEF;
1545 0 : yytoken = YYSYMBOL_YYerror;
1546 0 : goto yyerrlab1;
1547 : }
1548 : else
1549 : {
1550 107645 : yytoken = YYTRANSLATE(yychar);
1551 : YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc);
1552 : }
1553 :
1554 : /* If the proper action on seeing token YYTOKEN is to reduce or to
1555 : detect an error, take that action. */
1556 141035 : yyn += yytoken;
1557 141035 : if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1558 67298 : goto yydefault;
1559 73737 : yyn = yytable[yyn];
1560 73737 : if (yyn <= 0)
1561 : {
1562 : if (yytable_value_is_error(yyn))
1563 : goto yyerrlab;
1564 0 : yyn = -yyn;
1565 0 : goto yyreduce;
1566 : }
1567 :
1568 : /* Count tokens shifted since error; after three, turn off error
1569 : status. */
1570 73737 : if (yyerrstatus)
1571 0 : yyerrstatus--;
1572 :
1573 : /* Shift the lookahead token. */
1574 : YY_SYMBOL_PRINT("Shifting", yytoken, &yylval, &yylloc);
1575 73737 : yystate = yyn;
1576 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1577 73737 : *++yyvsp = yylval;
1578 : YY_IGNORE_MAYBE_UNINITIALIZED_END
1579 :
1580 : /* Discard the shifted token. */
1581 73737 : yychar = YYEMPTY;
1582 73737 : goto yynewstate;
1583 :
1584 : /*-----------------------------------------------------------.
1585 : | yydefault -- do the default action for the current state. |
1586 : `-----------------------------------------------------------*/
1587 113522 : yydefault:
1588 113522 : yyn = yydefact[yystate];
1589 113522 : if (yyn == 0)
1590 187 : goto yyerrlab;
1591 113335 : goto yyreduce;
1592 :
1593 : /*-----------------------------.
1594 : | yyreduce -- do a reduction. |
1595 : `-----------------------------*/
1596 113335 : yyreduce:
1597 : /* yyn is the number of a rule to reduce with. */
1598 113335 : yylen = yyr2[yyn];
1599 :
1600 : /* If YYLEN is nonzero, implement the default value of the action:
1601 : '$$ = $1'.
1602 :
1603 : Otherwise, the following line sets YYVAL to garbage.
1604 : This behavior is undocumented and Bison
1605 : users should not rely upon it. Assigning to YYVAL
1606 : unconditionally makes the parser a bit smaller, and it avoids a
1607 : GCC warning that YYVAL may be used uninitialized. */
1608 113335 : yyval = yyvsp[1 - yylen];
1609 :
1610 : YY_REDUCE_PRINT(yyn);
1611 113335 : switch (yyn)
1612 : {
1613 4622 : case 3: /* input: SWQT_VALUE_START value_expr */
1614 : {
1615 4622 : context->poRoot = yyvsp[0];
1616 4622 : swq_fixup(context);
1617 : }
1618 4622 : break;
1619 :
1620 2563 : case 4: /* input: SWQT_SELECT_START select_statement */
1621 : {
1622 2563 : context->poRoot = yyvsp[0];
1623 : // swq_fixup() must be done by caller
1624 : }
1625 2563 : break;
1626 :
1627 23350 : case 5: /* value_expr: value_expr_non_logical */
1628 : {
1629 23350 : yyval = yyvsp[0];
1630 : }
1631 23350 : break;
1632 :
1633 2416 : case 6: /* value_expr: value_expr "AND" value_expr */
1634 : {
1635 2416 : yyval = swq_create_and_or_or(SWQ_AND, yyvsp[-2], yyvsp[0]);
1636 : }
1637 2416 : break;
1638 :
1639 2243 : case 7: /* value_expr: value_expr "OR" value_expr */
1640 : {
1641 2243 : yyval = swq_create_and_or_or(SWQ_OR, yyvsp[-2], yyvsp[0]);
1642 : }
1643 2243 : break;
1644 :
1645 40 : case 8: /* value_expr: "NOT" value_expr */
1646 : {
1647 40 : yyval = new swq_expr_node(SWQ_NOT);
1648 40 : yyval->field_type = SWQ_BOOLEAN;
1649 40 : yyval->PushSubExpression(yyvsp[0]);
1650 : }
1651 40 : break;
1652 :
1653 8876 : case 9: /* value_expr: value_expr '=' value_expr */
1654 : {
1655 8876 : yyval = new swq_expr_node(SWQ_EQ);
1656 8876 : yyval->field_type = SWQ_BOOLEAN;
1657 8876 : yyval->PushSubExpression(yyvsp[-2]);
1658 8876 : yyval->PushSubExpression(yyvsp[0]);
1659 : }
1660 8876 : break;
1661 :
1662 627 : case 10: /* value_expr: value_expr '<' '>' value_expr */
1663 : {
1664 627 : yyval = new swq_expr_node(SWQ_NE);
1665 627 : yyval->field_type = SWQ_BOOLEAN;
1666 627 : yyval->PushSubExpression(yyvsp[-3]);
1667 627 : yyval->PushSubExpression(yyvsp[0]);
1668 : }
1669 627 : break;
1670 :
1671 38 : case 11: /* value_expr: value_expr '!' '=' value_expr */
1672 : {
1673 38 : yyval = new swq_expr_node(SWQ_NE);
1674 38 : yyval->field_type = SWQ_BOOLEAN;
1675 38 : yyval->PushSubExpression(yyvsp[-3]);
1676 38 : yyval->PushSubExpression(yyvsp[0]);
1677 : }
1678 38 : break;
1679 :
1680 184 : case 12: /* value_expr: value_expr '<' value_expr */
1681 : {
1682 184 : yyval = new swq_expr_node(SWQ_LT);
1683 184 : yyval->field_type = SWQ_BOOLEAN;
1684 184 : yyval->PushSubExpression(yyvsp[-2]);
1685 184 : yyval->PushSubExpression(yyvsp[0]);
1686 : }
1687 184 : break;
1688 :
1689 193 : case 13: /* value_expr: value_expr '>' value_expr */
1690 : {
1691 193 : yyval = new swq_expr_node(SWQ_GT);
1692 193 : yyval->field_type = SWQ_BOOLEAN;
1693 193 : yyval->PushSubExpression(yyvsp[-2]);
1694 193 : yyval->PushSubExpression(yyvsp[0]);
1695 : }
1696 193 : break;
1697 :
1698 100 : case 14: /* value_expr: value_expr '<' '=' value_expr */
1699 : {
1700 100 : yyval = new swq_expr_node(SWQ_LE);
1701 100 : yyval->field_type = SWQ_BOOLEAN;
1702 100 : yyval->PushSubExpression(yyvsp[-3]);
1703 100 : yyval->PushSubExpression(yyvsp[0]);
1704 : }
1705 100 : break;
1706 :
1707 0 : case 15: /* value_expr: value_expr '=' '<' value_expr */
1708 : {
1709 0 : yyval = new swq_expr_node(SWQ_LE);
1710 0 : yyval->field_type = SWQ_BOOLEAN;
1711 0 : yyval->PushSubExpression(yyvsp[-3]);
1712 0 : yyval->PushSubExpression(yyvsp[0]);
1713 : }
1714 0 : break;
1715 :
1716 0 : case 16: /* value_expr: value_expr '=' '>' value_expr */
1717 : {
1718 0 : yyval = new swq_expr_node(SWQ_LE);
1719 0 : yyval->field_type = SWQ_BOOLEAN;
1720 0 : yyval->PushSubExpression(yyvsp[-3]);
1721 0 : yyval->PushSubExpression(yyvsp[0]);
1722 : }
1723 0 : break;
1724 :
1725 114 : case 17: /* value_expr: value_expr '>' '=' value_expr */
1726 : {
1727 114 : yyval = new swq_expr_node(SWQ_GE);
1728 114 : yyval->field_type = SWQ_BOOLEAN;
1729 114 : yyval->PushSubExpression(yyvsp[-3]);
1730 114 : yyval->PushSubExpression(yyvsp[0]);
1731 : }
1732 114 : break;
1733 :
1734 38 : case 18: /* value_expr: value_expr "LIKE" value_expr */
1735 : {
1736 38 : yyval = new swq_expr_node(SWQ_LIKE);
1737 38 : yyval->field_type = SWQ_BOOLEAN;
1738 38 : yyval->PushSubExpression(yyvsp[-2]);
1739 38 : yyval->PushSubExpression(yyvsp[0]);
1740 : }
1741 38 : break;
1742 :
1743 1 : case 19: /* value_expr: value_expr "NOT" "LIKE" value_expr */
1744 : {
1745 1 : swq_expr_node *like = new swq_expr_node(SWQ_LIKE);
1746 1 : like->field_type = SWQ_BOOLEAN;
1747 1 : like->PushSubExpression(yyvsp[-3]);
1748 1 : like->PushSubExpression(yyvsp[0]);
1749 :
1750 1 : yyval = new swq_expr_node(SWQ_NOT);
1751 1 : yyval->field_type = SWQ_BOOLEAN;
1752 1 : yyval->PushSubExpression(like);
1753 : }
1754 1 : break;
1755 :
1756 3 : case 20: /* value_expr: value_expr "LIKE" value_expr "ESCAPE" value_expr */
1757 : {
1758 3 : yyval = new swq_expr_node(SWQ_LIKE);
1759 3 : yyval->field_type = SWQ_BOOLEAN;
1760 3 : yyval->PushSubExpression(yyvsp[-4]);
1761 3 : yyval->PushSubExpression(yyvsp[-2]);
1762 3 : yyval->PushSubExpression(yyvsp[0]);
1763 : }
1764 3 : break;
1765 :
1766 0 : case 21: /* value_expr: value_expr "NOT" "LIKE" value_expr "ESCAPE" value_expr */
1767 : {
1768 0 : swq_expr_node *like = new swq_expr_node(SWQ_LIKE);
1769 0 : like->field_type = SWQ_BOOLEAN;
1770 0 : like->PushSubExpression(yyvsp[-5]);
1771 0 : like->PushSubExpression(yyvsp[-2]);
1772 0 : like->PushSubExpression(yyvsp[0]);
1773 :
1774 0 : yyval = new swq_expr_node(SWQ_NOT);
1775 0 : yyval->field_type = SWQ_BOOLEAN;
1776 0 : yyval->PushSubExpression(like);
1777 : }
1778 0 : break;
1779 :
1780 22 : case 22: /* value_expr: value_expr "ILIKE" value_expr */
1781 : {
1782 22 : yyval = new swq_expr_node(SWQ_ILIKE);
1783 22 : yyval->field_type = SWQ_BOOLEAN;
1784 22 : yyval->PushSubExpression(yyvsp[-2]);
1785 22 : yyval->PushSubExpression(yyvsp[0]);
1786 : }
1787 22 : break;
1788 :
1789 0 : case 23: /* value_expr: value_expr "NOT" "ILIKE" value_expr */
1790 : {
1791 0 : swq_expr_node *like = new swq_expr_node(SWQ_ILIKE);
1792 0 : like->field_type = SWQ_BOOLEAN;
1793 0 : like->PushSubExpression(yyvsp[-3]);
1794 0 : like->PushSubExpression(yyvsp[0]);
1795 :
1796 0 : yyval = new swq_expr_node(SWQ_NOT);
1797 0 : yyval->field_type = SWQ_BOOLEAN;
1798 0 : yyval->PushSubExpression(like);
1799 : }
1800 0 : break;
1801 :
1802 0 : case 24: /* value_expr: value_expr "ILIKE" value_expr "ESCAPE" value_expr */
1803 : {
1804 0 : yyval = new swq_expr_node(SWQ_ILIKE);
1805 0 : yyval->field_type = SWQ_BOOLEAN;
1806 0 : yyval->PushSubExpression(yyvsp[-4]);
1807 0 : yyval->PushSubExpression(yyvsp[-2]);
1808 0 : yyval->PushSubExpression(yyvsp[0]);
1809 : }
1810 0 : break;
1811 :
1812 0 : case 25: /* value_expr: value_expr "NOT" "ILIKE" value_expr "ESCAPE" value_expr */
1813 : {
1814 0 : swq_expr_node *like = new swq_expr_node(SWQ_ILIKE);
1815 0 : like->field_type = SWQ_BOOLEAN;
1816 0 : like->PushSubExpression(yyvsp[-5]);
1817 0 : like->PushSubExpression(yyvsp[-2]);
1818 0 : like->PushSubExpression(yyvsp[0]);
1819 :
1820 0 : yyval = new swq_expr_node(SWQ_NOT);
1821 0 : yyval->field_type = SWQ_BOOLEAN;
1822 0 : yyval->PushSubExpression(like);
1823 : }
1824 0 : break;
1825 :
1826 80 : case 26: /* value_expr: value_expr "IN" '(' value_expr_list ')' */
1827 : {
1828 80 : yyval = yyvsp[-1];
1829 80 : yyval->field_type = SWQ_BOOLEAN;
1830 80 : yyval->nOperation = SWQ_IN;
1831 80 : yyval->PushSubExpression(yyvsp[-4]);
1832 80 : yyval->ReverseSubExpressions();
1833 : }
1834 80 : break;
1835 :
1836 1 : case 27: /* value_expr: value_expr "NOT" "IN" '(' value_expr_list ')' */
1837 : {
1838 1 : swq_expr_node *in = yyvsp[-1];
1839 1 : in->field_type = SWQ_BOOLEAN;
1840 1 : in->nOperation = SWQ_IN;
1841 1 : in->PushSubExpression(yyvsp[-5]);
1842 1 : in->ReverseSubExpressions();
1843 :
1844 1 : yyval = new swq_expr_node(SWQ_NOT);
1845 1 : yyval->field_type = SWQ_BOOLEAN;
1846 1 : yyval->PushSubExpression(in);
1847 : }
1848 1 : break;
1849 :
1850 28 : case 28: /* value_expr: value_expr "BETWEEN" value_expr_non_logical "AND" value_expr_non_logical */
1851 : {
1852 28 : yyval = new swq_expr_node(SWQ_BETWEEN);
1853 28 : yyval->field_type = SWQ_BOOLEAN;
1854 28 : yyval->PushSubExpression(yyvsp[-4]);
1855 28 : yyval->PushSubExpression(yyvsp[-2]);
1856 28 : yyval->PushSubExpression(yyvsp[0]);
1857 : }
1858 28 : break;
1859 :
1860 1 : case 29: /* value_expr: value_expr "NOT" "BETWEEN" value_expr_non_logical "AND" value_expr_non_logical */
1861 : {
1862 1 : swq_expr_node *between = new swq_expr_node(SWQ_BETWEEN);
1863 1 : between->field_type = SWQ_BOOLEAN;
1864 1 : between->PushSubExpression(yyvsp[-5]);
1865 1 : between->PushSubExpression(yyvsp[-2]);
1866 1 : between->PushSubExpression(yyvsp[0]);
1867 :
1868 1 : yyval = new swq_expr_node(SWQ_NOT);
1869 1 : yyval->field_type = SWQ_BOOLEAN;
1870 1 : yyval->PushSubExpression(between);
1871 : }
1872 1 : break;
1873 :
1874 73 : case 30: /* value_expr: value_expr "IS" "NULL" */
1875 : {
1876 73 : yyval = new swq_expr_node(SWQ_ISNULL);
1877 73 : yyval->field_type = SWQ_BOOLEAN;
1878 73 : yyval->PushSubExpression(yyvsp[-2]);
1879 : }
1880 73 : break;
1881 :
1882 62 : case 31: /* value_expr: value_expr "IS" "NOT" "NULL" */
1883 : {
1884 62 : swq_expr_node *isnull = new swq_expr_node(SWQ_ISNULL);
1885 62 : isnull->field_type = SWQ_BOOLEAN;
1886 62 : isnull->PushSubExpression(yyvsp[-3]);
1887 :
1888 62 : yyval = new swq_expr_node(SWQ_NOT);
1889 62 : yyval->field_type = SWQ_BOOLEAN;
1890 62 : yyval->PushSubExpression(isnull);
1891 : }
1892 62 : break;
1893 :
1894 270 : case 32: /* value_expr_list: value_expr ',' value_expr_list */
1895 : {
1896 270 : yyval = yyvsp[0];
1897 270 : yyvsp[0]->PushSubExpression(yyvsp[-2]);
1898 : }
1899 270 : break;
1900 :
1901 426 : case 33: /* value_expr_list: value_expr */
1902 : {
1903 426 : yyval = new swq_expr_node(SWQ_ARGUMENT_LIST); /* temporary value */
1904 426 : yyval->PushSubExpression(yyvsp[0]);
1905 : }
1906 426 : break;
1907 :
1908 9295 : case 34: /* field_value: "identifier" */
1909 : {
1910 9295 : yyval = yyvsp[0]; // validation deferred.
1911 9295 : yyval->eNodeType = SNT_COLUMN;
1912 9295 : yyval->field_index = -1;
1913 9295 : yyval->table_index = -1;
1914 : }
1915 9295 : break;
1916 :
1917 198 : case 35: /* field_value: "identifier" '.' "identifier" */
1918 : {
1919 198 : yyval = yyvsp[-2]; // validation deferred.
1920 198 : yyval->eNodeType = SNT_COLUMN;
1921 198 : yyval->field_index = -1;
1922 198 : yyval->table_index = -1;
1923 198 : yyval->table_name = yyval->string_value;
1924 198 : yyval->string_value = CPLStrdup(yyvsp[0]->string_value);
1925 198 : delete yyvsp[0];
1926 198 : yyvsp[0] = nullptr;
1927 : }
1928 198 : break;
1929 :
1930 11446 : case 36: /* value_expr_non_logical: "integer number" */
1931 : {
1932 11446 : yyval = yyvsp[0];
1933 : }
1934 11446 : break;
1935 :
1936 429 : case 37: /* value_expr_non_logical: "floating point number" */
1937 : {
1938 429 : yyval = yyvsp[0];
1939 : }
1940 429 : break;
1941 :
1942 1580 : case 38: /* value_expr_non_logical: "string" */
1943 : {
1944 1580 : yyval = yyvsp[0];
1945 : }
1946 1580 : break;
1947 :
1948 9355 : case 39: /* value_expr_non_logical: field_value */
1949 : {
1950 9355 : yyval = yyvsp[0];
1951 : }
1952 9355 : break;
1953 :
1954 255 : case 40: /* value_expr_non_logical: '(' value_expr ')' */
1955 : {
1956 255 : yyval = yyvsp[-1];
1957 : }
1958 255 : break;
1959 :
1960 20 : case 41: /* value_expr_non_logical: "NULL" */
1961 : {
1962 20 : yyval = new swq_expr_node(static_cast<const char *>(nullptr));
1963 : }
1964 20 : break;
1965 :
1966 2354 : case 42: /* value_expr_non_logical: '-' value_expr_non_logical */
1967 : {
1968 2354 : if (yyvsp[0]->eNodeType == SNT_CONSTANT)
1969 : {
1970 2353 : if (yyvsp[0]->field_type == SWQ_FLOAT &&
1971 28 : yyvsp[0]->string_value &&
1972 10 : strcmp(yyvsp[0]->string_value, "9223372036854775808") == 0)
1973 : {
1974 10 : yyval = yyvsp[0];
1975 10 : yyval->field_type = SWQ_INTEGER64;
1976 10 : yyval->int_value = std::numeric_limits<GIntBig>::min();
1977 10 : yyval->float_value = static_cast<double>(
1978 10 : std::numeric_limits<GIntBig>::min());
1979 : }
1980 : // - (-9223372036854775808) cannot be represented on int64
1981 : // the classic overflow is that its negation is itself.
1982 2353 : else if (yyvsp[0]->field_type == SWQ_INTEGER64 &&
1983 10 : yyvsp[0]->int_value ==
1984 10 : std::numeric_limits<GIntBig>::min())
1985 : {
1986 1 : yyval = yyvsp[0];
1987 : }
1988 : else
1989 : {
1990 2342 : yyval = yyvsp[0];
1991 2342 : yyval->int_value *= -1;
1992 2342 : yyval->float_value *= -1;
1993 : }
1994 : }
1995 : else
1996 : {
1997 1 : yyval = new swq_expr_node(SWQ_MULTIPLY);
1998 1 : yyval->PushSubExpression(new swq_expr_node(-1));
1999 1 : yyval->PushSubExpression(yyvsp[0]);
2000 : }
2001 : }
2002 2354 : break;
2003 :
2004 36 : case 43: /* value_expr_non_logical: value_expr_non_logical '+' value_expr_non_logical */
2005 : {
2006 36 : yyval = new swq_expr_node(SWQ_ADD);
2007 36 : yyval->PushSubExpression(yyvsp[-2]);
2008 36 : yyval->PushSubExpression(yyvsp[0]);
2009 : }
2010 36 : break;
2011 :
2012 15 : case 44: /* value_expr_non_logical: value_expr_non_logical '-' value_expr_non_logical */
2013 : {
2014 15 : yyval = new swq_expr_node(SWQ_SUBTRACT);
2015 15 : yyval->PushSubExpression(yyvsp[-2]);
2016 15 : yyval->PushSubExpression(yyvsp[0]);
2017 : }
2018 15 : break;
2019 :
2020 27 : case 45: /* value_expr_non_logical: value_expr_non_logical '*' value_expr_non_logical */
2021 : {
2022 27 : yyval = new swq_expr_node(SWQ_MULTIPLY);
2023 27 : yyval->PushSubExpression(yyvsp[-2]);
2024 27 : yyval->PushSubExpression(yyvsp[0]);
2025 : }
2026 27 : break;
2027 :
2028 19 : case 46: /* value_expr_non_logical: value_expr_non_logical '/' value_expr_non_logical */
2029 : {
2030 19 : yyval = new swq_expr_node(SWQ_DIVIDE);
2031 19 : yyval->PushSubExpression(yyvsp[-2]);
2032 19 : yyval->PushSubExpression(yyvsp[0]);
2033 : }
2034 19 : break;
2035 :
2036 11 : case 47: /* value_expr_non_logical: value_expr_non_logical '%' value_expr_non_logical */
2037 : {
2038 11 : yyval = new swq_expr_node(SWQ_MODULUS);
2039 11 : yyval->PushSubExpression(yyvsp[-2]);
2040 11 : yyval->PushSubExpression(yyvsp[0]);
2041 : }
2042 11 : break;
2043 :
2044 342 : case 48: /* value_expr_non_logical: "identifier" '(' value_expr_list ')' */
2045 : {
2046 : const swq_operation *poOp =
2047 342 : swq_op_registrar::GetOperator(yyvsp[-3]->string_value);
2048 :
2049 342 : if (poOp == nullptr)
2050 : {
2051 129 : if (context->bAcceptCustomFuncs)
2052 : {
2053 128 : yyval = yyvsp[-1];
2054 128 : yyval->eNodeType = SNT_OPERATION;
2055 128 : yyval->nOperation = SWQ_CUSTOM_FUNC;
2056 128 : yyval->string_value = CPLStrdup(yyvsp[-3]->string_value);
2057 128 : yyval->ReverseSubExpressions();
2058 128 : delete yyvsp[-3];
2059 : }
2060 : else
2061 : {
2062 1 : CPLError(CE_Failure, CPLE_AppDefined,
2063 : "Undefined function '%s' used.",
2064 1 : yyvsp[-3]->string_value);
2065 1 : delete yyvsp[-3];
2066 1 : delete yyvsp[-1];
2067 1 : YYERROR;
2068 : }
2069 : }
2070 : else
2071 : {
2072 213 : yyval = yyvsp[-1];
2073 213 : yyval->eNodeType = SNT_OPERATION;
2074 213 : yyval->nOperation = poOp->eOperation;
2075 213 : yyval->ReverseSubExpressions();
2076 213 : delete yyvsp[-3];
2077 : }
2078 : }
2079 341 : break;
2080 :
2081 95 : case 49: /* value_expr_non_logical: "CAST" '(' value_expr "AS" type_def ')' */
2082 : {
2083 95 : yyval = yyvsp[-1];
2084 95 : yyval->PushSubExpression(yyvsp[-3]);
2085 95 : yyval->ReverseSubExpressions();
2086 : }
2087 95 : break;
2088 :
2089 77 : case 50: /* type_def: "identifier" */
2090 : {
2091 77 : yyval = new swq_expr_node(SWQ_CAST);
2092 77 : yyval->PushSubExpression(yyvsp[0]);
2093 : }
2094 77 : break;
2095 :
2096 9 : case 51: /* type_def: "identifier" '(' "integer number" ')' */
2097 : {
2098 9 : yyval = new swq_expr_node(SWQ_CAST);
2099 9 : yyval->PushSubExpression(yyvsp[-1]);
2100 9 : yyval->PushSubExpression(yyvsp[-3]);
2101 : }
2102 9 : break;
2103 :
2104 2 : case 52: /* type_def: "identifier" '(' "integer number" ',' "integer number" ')' */
2105 : {
2106 2 : yyval = new swq_expr_node(SWQ_CAST);
2107 2 : yyval->PushSubExpression(yyvsp[-1]);
2108 2 : yyval->PushSubExpression(yyvsp[-3]);
2109 2 : yyval->PushSubExpression(yyvsp[-5]);
2110 : }
2111 2 : break;
2112 :
2113 8 : case 53: /* type_def: "identifier" '(' "identifier" ')' */
2114 : {
2115 : OGRwkbGeometryType eType =
2116 8 : OGRFromOGCGeomType(yyvsp[-1]->string_value);
2117 16 : if (!EQUAL(yyvsp[-3]->string_value, "GEOMETRY") ||
2118 8 : (wkbFlatten(eType) == wkbUnknown &&
2119 1 : !STARTS_WITH_CI(yyvsp[-1]->string_value, "GEOMETRY")))
2120 : {
2121 1 : yyerror(context, "syntax error");
2122 1 : delete yyvsp[-3];
2123 1 : delete yyvsp[-1];
2124 1 : YYERROR;
2125 : }
2126 7 : yyval = new swq_expr_node(SWQ_CAST);
2127 7 : yyval->PushSubExpression(yyvsp[-1]);
2128 7 : yyval->PushSubExpression(yyvsp[-3]);
2129 : }
2130 7 : break;
2131 :
2132 4 : case 54: /* type_def: "identifier" '(' "identifier" ',' "integer number" ')' */
2133 : {
2134 : OGRwkbGeometryType eType =
2135 4 : OGRFromOGCGeomType(yyvsp[-3]->string_value);
2136 8 : if (!EQUAL(yyvsp[-5]->string_value, "GEOMETRY") ||
2137 4 : (wkbFlatten(eType) == wkbUnknown &&
2138 1 : !STARTS_WITH_CI(yyvsp[-3]->string_value, "GEOMETRY")))
2139 : {
2140 1 : yyerror(context, "syntax error");
2141 1 : delete yyvsp[-5];
2142 1 : delete yyvsp[-3];
2143 1 : delete yyvsp[-1];
2144 1 : YYERROR;
2145 : }
2146 3 : yyval = new swq_expr_node(SWQ_CAST);
2147 3 : yyval->PushSubExpression(yyvsp[-1]);
2148 3 : yyval->PushSubExpression(yyvsp[-3]);
2149 3 : yyval->PushSubExpression(yyvsp[-5]);
2150 : }
2151 3 : break;
2152 :
2153 2539 : case 57: /* select_core: "SELECT" select_field_list "FROM" table_def opt_joins opt_where opt_order_by opt_limit opt_offset */
2154 : {
2155 2539 : delete yyvsp[-5];
2156 : }
2157 2539 : break;
2158 :
2159 34 : case 58: /* select_core: "SELECT" "DISTINCT" select_field_list "FROM" table_def opt_joins opt_where opt_order_by opt_limit opt_offset */
2160 : {
2161 34 : context->poCurSelect->query_mode = SWQM_DISTINCT_LIST;
2162 34 : delete yyvsp[-5];
2163 : }
2164 34 : break;
2165 :
2166 9 : case 61: /* union_all: "UNION" "ALL" */
2167 : {
2168 9 : swq_select *poNewSelect = new swq_select();
2169 9 : context->poCurSelect->PushUnionAll(poNewSelect);
2170 9 : context->poCurSelect = poNewSelect;
2171 : }
2172 9 : break;
2173 :
2174 16 : case 64: /* exclude_field: field_value */
2175 : {
2176 16 : if (!context->poCurSelect->PushExcludeField(yyvsp[0]))
2177 : {
2178 1 : delete yyvsp[0];
2179 1 : YYERROR;
2180 : }
2181 : }
2182 15 : break;
2183 :
2184 1612 : case 69: /* column_spec: value_expr */
2185 : {
2186 1612 : if (!context->poCurSelect->PushField(yyvsp[0]))
2187 : {
2188 7 : delete yyvsp[0];
2189 7 : YYERROR;
2190 : }
2191 : }
2192 1605 : break;
2193 :
2194 55 : case 70: /* column_spec: value_expr as_clause */
2195 : {
2196 55 : if (!context->poCurSelect->PushField(yyvsp[-1],
2197 55 : yyvsp[0]->string_value))
2198 : {
2199 0 : delete yyvsp[-1];
2200 0 : delete yyvsp[0];
2201 0 : YYERROR;
2202 : }
2203 55 : delete yyvsp[0];
2204 : }
2205 55 : break;
2206 :
2207 8 : case 71: /* column_spec: '*' except_or_exclude '(' exclude_field_list ')' */
2208 : {
2209 8 : swq_expr_node *poNode = new swq_expr_node();
2210 8 : poNode->eNodeType = SNT_COLUMN;
2211 8 : poNode->string_value = CPLStrdup("*");
2212 8 : poNode->table_index = -1;
2213 8 : poNode->field_index = -1;
2214 :
2215 8 : if (!context->poCurSelect->PushField(poNode))
2216 : {
2217 0 : delete poNode;
2218 0 : YYERROR;
2219 : }
2220 : }
2221 8 : break;
2222 :
2223 1770 : case 72: /* column_spec: '*' */
2224 : {
2225 1770 : swq_expr_node *poNode = new swq_expr_node();
2226 1770 : poNode->eNodeType = SNT_COLUMN;
2227 1770 : poNode->string_value = CPLStrdup("*");
2228 1770 : poNode->table_index = -1;
2229 1770 : poNode->field_index = -1;
2230 :
2231 1770 : if (!context->poCurSelect->PushField(poNode))
2232 : {
2233 0 : delete poNode;
2234 0 : YYERROR;
2235 : }
2236 : }
2237 1770 : break;
2238 :
2239 17 : case 73: /* column_spec: "identifier" '.' '*' */
2240 : {
2241 17 : CPLString osTableName = yyvsp[-2]->string_value;
2242 :
2243 17 : delete yyvsp[-2];
2244 17 : yyvsp[-2] = nullptr;
2245 :
2246 17 : swq_expr_node *poNode = new swq_expr_node();
2247 17 : poNode->eNodeType = SNT_COLUMN;
2248 17 : poNode->table_name = CPLStrdup(osTableName);
2249 17 : poNode->string_value = CPLStrdup("*");
2250 17 : poNode->table_index = -1;
2251 17 : poNode->field_index = -1;
2252 :
2253 17 : if (!context->poCurSelect->PushField(poNode))
2254 : {
2255 0 : delete poNode;
2256 0 : YYERROR;
2257 : }
2258 : }
2259 17 : break;
2260 :
2261 380 : case 74: /* column_spec: "identifier" '(' '*' ')' */
2262 : {
2263 : // special case for COUNT(*), confirm it.
2264 380 : if (!EQUAL(yyvsp[-3]->string_value, "COUNT"))
2265 : {
2266 1 : CPLError(CE_Failure, CPLE_AppDefined,
2267 1 : "Syntax Error with %s(*).", yyvsp[-3]->string_value);
2268 1 : delete yyvsp[-3];
2269 1 : YYERROR;
2270 : }
2271 :
2272 379 : delete yyvsp[-3];
2273 379 : yyvsp[-3] = nullptr;
2274 :
2275 379 : swq_expr_node *poNode = new swq_expr_node();
2276 379 : poNode->eNodeType = SNT_COLUMN;
2277 379 : poNode->string_value = CPLStrdup("*");
2278 379 : poNode->table_index = -1;
2279 379 : poNode->field_index = -1;
2280 :
2281 379 : swq_expr_node *count = new swq_expr_node(SWQ_COUNT);
2282 379 : count->PushSubExpression(poNode);
2283 :
2284 379 : if (!context->poCurSelect->PushField(count))
2285 : {
2286 0 : delete count;
2287 0 : YYERROR;
2288 : }
2289 : }
2290 379 : break;
2291 :
2292 2 : case 75: /* column_spec: "identifier" '(' '*' ')' as_clause */
2293 : {
2294 : // special case for COUNT(*), confirm it.
2295 2 : if (!EQUAL(yyvsp[-4]->string_value, "COUNT"))
2296 : {
2297 1 : CPLError(CE_Failure, CPLE_AppDefined,
2298 1 : "Syntax Error with %s(*).", yyvsp[-4]->string_value);
2299 1 : delete yyvsp[-4];
2300 1 : delete yyvsp[0];
2301 1 : YYERROR;
2302 : }
2303 :
2304 1 : delete yyvsp[-4];
2305 1 : yyvsp[-4] = nullptr;
2306 :
2307 1 : swq_expr_node *poNode = new swq_expr_node();
2308 1 : poNode->eNodeType = SNT_COLUMN;
2309 1 : poNode->string_value = CPLStrdup("*");
2310 1 : poNode->table_index = -1;
2311 1 : poNode->field_index = -1;
2312 :
2313 1 : swq_expr_node *count = new swq_expr_node(SWQ_COUNT);
2314 1 : count->PushSubExpression(poNode);
2315 :
2316 1 : if (!context->poCurSelect->PushField(count, yyvsp[0]->string_value))
2317 : {
2318 0 : delete count;
2319 0 : delete yyvsp[0];
2320 0 : YYERROR;
2321 : }
2322 :
2323 1 : delete yyvsp[0];
2324 : }
2325 1 : break;
2326 :
2327 11 : case 76: /* column_spec: "identifier" '(' "DISTINCT" field_value ')' */
2328 : {
2329 : // special case for COUNT(DISTINCT x), confirm it.
2330 11 : if (!EQUAL(yyvsp[-4]->string_value, "COUNT"))
2331 : {
2332 1 : CPLError(
2333 : CE_Failure, CPLE_AppDefined,
2334 : "DISTINCT keyword can only be used in COUNT() operator.");
2335 1 : delete yyvsp[-4];
2336 1 : delete yyvsp[-1];
2337 1 : YYERROR;
2338 : }
2339 :
2340 10 : delete yyvsp[-4];
2341 :
2342 10 : swq_expr_node *count = new swq_expr_node(SWQ_COUNT);
2343 10 : count->PushSubExpression(yyvsp[-1]);
2344 :
2345 10 : if (!context->poCurSelect->PushField(count, nullptr, TRUE))
2346 : {
2347 0 : delete count;
2348 0 : YYERROR;
2349 : }
2350 : }
2351 10 : break;
2352 :
2353 2 : case 77: /* column_spec: "identifier" '(' "DISTINCT" field_value ')' as_clause */
2354 : {
2355 : // special case for COUNT(DISTINCT x), confirm it.
2356 2 : if (!EQUAL(yyvsp[-5]->string_value, "COUNT"))
2357 : {
2358 1 : CPLError(
2359 : CE_Failure, CPLE_AppDefined,
2360 : "DISTINCT keyword can only be used in COUNT() operator.");
2361 1 : delete yyvsp[-5];
2362 1 : delete yyvsp[-2];
2363 1 : delete yyvsp[0];
2364 1 : YYERROR;
2365 : }
2366 :
2367 1 : swq_expr_node *count = new swq_expr_node(SWQ_COUNT);
2368 1 : count->PushSubExpression(yyvsp[-2]);
2369 :
2370 1 : if (!context->poCurSelect->PushField(count, yyvsp[0]->string_value,
2371 : TRUE))
2372 : {
2373 0 : delete yyvsp[-5];
2374 0 : delete count;
2375 0 : delete yyvsp[0];
2376 0 : YYERROR;
2377 : }
2378 :
2379 1 : delete yyvsp[-5];
2380 1 : delete yyvsp[0];
2381 : }
2382 1 : break;
2383 :
2384 61 : case 78: /* as_clause: "AS" "identifier" */
2385 : {
2386 61 : delete yyvsp[-1];
2387 61 : yyval = yyvsp[0];
2388 : }
2389 61 : break;
2390 :
2391 1052 : case 81: /* opt_where: "WHERE" value_expr */
2392 : {
2393 1052 : context->poCurSelect->where_expr = yyvsp[0];
2394 : }
2395 1052 : break;
2396 :
2397 44 : case 83: /* opt_joins: "JOIN" table_def "ON" value_expr opt_joins */
2398 : {
2399 44 : context->poCurSelect->PushJoin(
2400 44 : static_cast<int>(yyvsp[-3]->int_value), yyvsp[-1]);
2401 44 : delete yyvsp[-3];
2402 : }
2403 44 : break;
2404 :
2405 28 : case 84: /* opt_joins: "LEFT" "JOIN" table_def "ON" value_expr opt_joins */
2406 : {
2407 28 : context->poCurSelect->PushJoin(
2408 28 : static_cast<int>(yyvsp[-3]->int_value), yyvsp[-1]);
2409 28 : delete yyvsp[-3];
2410 : }
2411 28 : break;
2412 :
2413 68 : case 89: /* sort_spec: field_value */
2414 : {
2415 68 : context->poCurSelect->PushOrderBy(yyvsp[0]->table_name,
2416 68 : yyvsp[0]->string_value, TRUE);
2417 68 : delete yyvsp[0];
2418 68 : yyvsp[0] = nullptr;
2419 : }
2420 68 : break;
2421 :
2422 20 : case 90: /* sort_spec: field_value "ASC" */
2423 : {
2424 20 : context->poCurSelect->PushOrderBy(yyvsp[-1]->table_name,
2425 20 : yyvsp[-1]->string_value, TRUE);
2426 20 : delete yyvsp[-1];
2427 20 : yyvsp[-1] = nullptr;
2428 : }
2429 20 : break;
2430 :
2431 20 : case 91: /* sort_spec: field_value "DESC" */
2432 : {
2433 20 : context->poCurSelect->PushOrderBy(yyvsp[-1]->table_name,
2434 20 : yyvsp[-1]->string_value, FALSE);
2435 20 : delete yyvsp[-1];
2436 20 : yyvsp[-1] = nullptr;
2437 : }
2438 20 : break;
2439 :
2440 34 : case 93: /* opt_limit: "LIMIT" "integer number" */
2441 : {
2442 34 : context->poCurSelect->SetLimit(yyvsp[0]->int_value);
2443 34 : delete yyvsp[0];
2444 34 : yyvsp[0] = nullptr;
2445 : }
2446 34 : break;
2447 :
2448 18 : case 95: /* opt_offset: "OFFSET" "integer number" */
2449 : {
2450 18 : context->poCurSelect->SetOffset(yyvsp[0]->int_value);
2451 18 : delete yyvsp[0];
2452 18 : yyvsp[0] = nullptr;
2453 : }
2454 18 : break;
2455 :
2456 2638 : case 96: /* table_def: "identifier" */
2457 : {
2458 5276 : const int iTable = context->poCurSelect->PushTableDef(
2459 2638 : nullptr, yyvsp[0]->string_value, nullptr);
2460 2638 : delete yyvsp[0];
2461 :
2462 2638 : yyval = new swq_expr_node(iTable);
2463 : }
2464 2638 : break;
2465 :
2466 20 : case 97: /* table_def: "identifier" as_clause */
2467 : {
2468 40 : const int iTable = context->poCurSelect->PushTableDef(
2469 20 : nullptr, yyvsp[-1]->string_value, yyvsp[0]->string_value);
2470 20 : delete yyvsp[-1];
2471 20 : delete yyvsp[0];
2472 :
2473 20 : yyval = new swq_expr_node(iTable);
2474 : }
2475 20 : break;
2476 :
2477 1 : case 98: /* table_def: "string" '.' "identifier" */
2478 : {
2479 2 : const int iTable = context->poCurSelect->PushTableDef(
2480 1 : yyvsp[-2]->string_value, yyvsp[0]->string_value, nullptr);
2481 1 : delete yyvsp[-2];
2482 1 : delete yyvsp[0];
2483 :
2484 1 : yyval = new swq_expr_node(iTable);
2485 : }
2486 1 : break;
2487 :
2488 2 : case 99: /* table_def: "string" '.' "identifier" as_clause */
2489 : {
2490 4 : const int iTable = context->poCurSelect->PushTableDef(
2491 2 : yyvsp[-3]->string_value, yyvsp[-1]->string_value,
2492 2 : yyvsp[0]->string_value);
2493 2 : delete yyvsp[-3];
2494 2 : delete yyvsp[-1];
2495 2 : delete yyvsp[0];
2496 :
2497 2 : yyval = new swq_expr_node(iTable);
2498 : }
2499 2 : break;
2500 :
2501 0 : case 100: /* table_def: "identifier" '.' "identifier" */
2502 : {
2503 0 : const int iTable = context->poCurSelect->PushTableDef(
2504 0 : yyvsp[-2]->string_value, yyvsp[0]->string_value, nullptr);
2505 0 : delete yyvsp[-2];
2506 0 : delete yyvsp[0];
2507 :
2508 0 : yyval = new swq_expr_node(iTable);
2509 : }
2510 0 : break;
2511 :
2512 6 : case 101: /* table_def: "identifier" '.' "identifier" as_clause */
2513 : {
2514 12 : const int iTable = context->poCurSelect->PushTableDef(
2515 6 : yyvsp[-3]->string_value, yyvsp[-1]->string_value,
2516 6 : yyvsp[0]->string_value);
2517 6 : delete yyvsp[-3];
2518 6 : delete yyvsp[-1];
2519 6 : delete yyvsp[0];
2520 :
2521 6 : yyval = new swq_expr_node(iTable);
2522 : }
2523 6 : break;
2524 :
2525 20920 : default:
2526 20920 : break;
2527 : }
2528 : /* User semantic actions sometimes alter yychar, and that requires
2529 : that yytoken be updated with the new translation. We take the
2530 : approach of translating immediately before every use of yytoken.
2531 : One alternative is translating here after every semantic action,
2532 : but that translation would be missed if the semantic action invokes
2533 : YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2534 : if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2535 : incorrect destructor might then be invoked immediately. In the
2536 : case of YYERROR or YYBACKUP, subsequent parser actions might lead
2537 : to an incorrect destructor call or verbose syntax error message
2538 : before the lookahead is translated. */
2539 : YY_SYMBOL_PRINT("-> $$ =", YY_CAST(yysymbol_kind_t, yyr1[yyn]), &yyval,
2540 : &yyloc);
2541 :
2542 113320 : YYPOPSTACK(yylen);
2543 113320 : yylen = 0;
2544 :
2545 113320 : *++yyvsp = yyval;
2546 :
2547 : /* Now 'shift' the result of the reduction. Determine what state
2548 : that goes to, based on the state we popped back to and the rule
2549 : number reduced by. */
2550 : {
2551 113320 : const int yylhs = yyr1[yyn] - YYNTOKENS;
2552 113320 : const int yyi = yypgoto[yylhs] + *yyssp;
2553 85358 : yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
2554 155788 : ? yytable[yyi]
2555 70852 : : yydefgoto[yylhs]);
2556 : }
2557 :
2558 113320 : goto yynewstate;
2559 :
2560 : /*--------------------------------------.
2561 : | yyerrlab -- here on detecting error. |
2562 : `--------------------------------------*/
2563 187 : yyerrlab:
2564 : /* Make sure we have latest lookahead translation. See comments at
2565 : user semantic actions for why this is necessary. */
2566 187 : yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE(yychar);
2567 : /* If not already recovering from an error, report this error. */
2568 187 : if (!yyerrstatus)
2569 : {
2570 187 : ++yynerrs;
2571 : (void)yynerrs;
2572 : {
2573 187 : yypcontext_t yyctx = {yyssp, yytoken};
2574 187 : char const *yymsgp = YY_("syntax error");
2575 : int yysyntax_error_status;
2576 : yysyntax_error_status =
2577 187 : yysyntax_error(&yymsg_alloc, &yymsg, &yyctx);
2578 187 : if (yysyntax_error_status == 0)
2579 187 : yymsgp = yymsg;
2580 0 : else if (yysyntax_error_status == -1)
2581 : {
2582 0 : if (yymsg != yymsgbuf)
2583 0 : YYSTACK_FREE(yymsg);
2584 0 : yymsg = YY_CAST(char *,
2585 : YYSTACK_ALLOC(YY_CAST(YYSIZE_T, yymsg_alloc)));
2586 0 : if (yymsg)
2587 : {
2588 : yysyntax_error_status =
2589 0 : yysyntax_error(&yymsg_alloc, &yymsg, &yyctx);
2590 0 : yymsgp = yymsg;
2591 : }
2592 : else
2593 : {
2594 0 : yymsg = yymsgbuf;
2595 0 : yymsg_alloc = sizeof yymsgbuf;
2596 0 : yysyntax_error_status = YYENOMEM;
2597 : }
2598 : }
2599 187 : yyerror(context, yymsgp);
2600 187 : if (yysyntax_error_status == YYENOMEM)
2601 0 : YYNOMEM;
2602 : }
2603 : }
2604 :
2605 187 : if (yyerrstatus == 3)
2606 : {
2607 : /* If just tried and failed to reuse lookahead token after an
2608 : error, discard it. */
2609 :
2610 0 : if (yychar <= END)
2611 : {
2612 : /* Return failure if at end of input. */
2613 0 : if (yychar == END)
2614 0 : YYABORT;
2615 : }
2616 : else
2617 : {
2618 0 : yydestruct("Error: discarding", yytoken, &yylval, context);
2619 0 : yychar = YYEMPTY;
2620 : }
2621 : }
2622 :
2623 : /* Else will try to reuse lookahead token after shifting the error
2624 : token. */
2625 187 : goto yyerrlab1;
2626 :
2627 : /*---------------------------------------------------.
2628 : | yyerrorlab -- error raised explicitly by YYERROR. |
2629 : `---------------------------------------------------*/
2630 15 : yyerrorlab:
2631 : /* Pacify compilers when the user code never invokes YYERROR and the
2632 : label yyerrorlab therefore never appears in user code. */
2633 : if (0)
2634 : YYERROR;
2635 15 : ++yynerrs;
2636 : (void)yynerrs;
2637 :
2638 : /* Do not reclaim the symbols of the rule whose action triggered
2639 : this YYERROR. */
2640 15 : YYPOPSTACK(yylen);
2641 15 : yylen = 0;
2642 : YY_STACK_PRINT(yyss, yyssp);
2643 15 : yystate = *yyssp;
2644 15 : goto yyerrlab1;
2645 :
2646 : /*-------------------------------------------------------------.
2647 : | yyerrlab1 -- common code for both syntax error and YYERROR. |
2648 : `-------------------------------------------------------------*/
2649 202 : yyerrlab1:
2650 202 : yyerrstatus = 3; /* Each real token shifted decrements this. */
2651 :
2652 : /* Pop stack until we find a state that shifts the error token. */
2653 : for (;;)
2654 : {
2655 842 : yyn = yypact[yystate];
2656 842 : if (!yypact_value_is_default(yyn))
2657 : {
2658 842 : yyn += YYSYMBOL_YYerror;
2659 842 : if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
2660 : {
2661 0 : yyn = yytable[yyn];
2662 0 : if (0 < yyn)
2663 0 : break;
2664 : }
2665 : }
2666 :
2667 : /* Pop the current state because it cannot handle the error token. */
2668 842 : if (yyssp == yyss)
2669 202 : YYABORT;
2670 :
2671 640 : yydestruct("Error: popping", YY_ACCESSING_SYMBOL(yystate), yyvsp,
2672 : context);
2673 640 : YYPOPSTACK(1);
2674 640 : yystate = *yyssp;
2675 : YY_STACK_PRINT(yyss, yyssp);
2676 : }
2677 :
2678 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2679 0 : *++yyvsp = yylval;
2680 : YY_IGNORE_MAYBE_UNINITIALIZED_END
2681 :
2682 : /* Shift the error token. */
2683 : YY_SYMBOL_PRINT("Shifting", YY_ACCESSING_SYMBOL(yyn), yyvsp, yylsp);
2684 :
2685 0 : yystate = yyn;
2686 0 : goto yynewstate;
2687 :
2688 : /*-------------------------------------.
2689 : | yyacceptlab -- YYACCEPT comes here. |
2690 : `-------------------------------------*/
2691 7182 : yyacceptlab:
2692 7182 : yyresult = 0;
2693 7182 : goto yyreturnlab;
2694 :
2695 : /*-----------------------------------.
2696 : | yyabortlab -- YYABORT comes here. |
2697 : `-----------------------------------*/
2698 202 : yyabortlab:
2699 202 : yyresult = 1;
2700 202 : goto yyreturnlab;
2701 :
2702 : /*-----------------------------------------------------------.
2703 : | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
2704 : `-----------------------------------------------------------*/
2705 0 : yyexhaustedlab:
2706 0 : yyerror(context, YY_("memory exhausted"));
2707 0 : yyresult = 2;
2708 0 : goto yyreturnlab;
2709 :
2710 : /*----------------------------------------------------------.
2711 : | yyreturnlab -- parsing is finished, clean up and return. |
2712 : `----------------------------------------------------------*/
2713 7384 : yyreturnlab:
2714 7384 : if (yychar != YYEMPTY)
2715 : {
2716 : /* Make sure we have latest lookahead translation. See comments at
2717 : user semantic actions for why this is necessary. */
2718 197 : yytoken = YYTRANSLATE(yychar);
2719 197 : yydestruct("Cleanup: discarding lookahead", yytoken, &yylval, context);
2720 : }
2721 : /* Do not reclaim the symbols of the rule whose action triggered
2722 : this YYABORT or YYACCEPT. */
2723 7384 : YYPOPSTACK(yylen);
2724 : YY_STACK_PRINT(yyss, yyssp);
2725 21748 : while (yyssp != yyss)
2726 : {
2727 14364 : yydestruct("Cleanup: popping", YY_ACCESSING_SYMBOL(+*yyssp), yyvsp,
2728 : context);
2729 14364 : YYPOPSTACK(1);
2730 : }
2731 : #ifndef yyoverflow
2732 7384 : if (yyss != yyssa)
2733 1 : YYSTACK_FREE(yyss);
2734 : #endif
2735 7384 : if (yymsg != yymsgbuf)
2736 0 : YYSTACK_FREE(yymsg);
2737 7384 : return yyresult;
2738 : }
|