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