Coverage Report

Created: 2025-06-13 06:29

/src/gdal/ogr/swq_parser.cpp
Line
Count
Source (jump to first uncovered line)
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
0
#define yylex           swqlex
70
0
#define yyerror         swqerror
71
#define yydebug         swqdebug
72
0
#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
0
#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
0
#   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
0
#    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
0
#  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
0
  YY_CAST (YYPTRDIFF_T,                                 \
328
           (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
329
            ? YYPTRDIFF_MAXIMUM                         \
330
            : YY_CAST (YYSIZE_T, -1)))
331
332
0
#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
0
#  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
0
# 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
0
# 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
0
#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
0
#  define YYSTACK_FREE YYFREE
458
#  ifndef YYSTACK_ALLOC_MAXIMUM
459
0
#   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
0
#   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
0
# 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
0
    do                                                                  \
513
0
      {                                                                 \
514
0
        YYPTRDIFF_T yynewbytes;                                         \
515
0
        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
516
0
        Stack = &yyptr->Stack_alloc;                                    \
517
0
        yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
518
0
        yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
519
0
      }                                                                 \
520
0
    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
0
      __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
0
#define YYFINAL  22
546
/* YYLAST -- Last index in YYTABLE.  */
547
0
#define YYLAST   469
548
549
/* YYNTOKENS -- Number of terminals.  */
550
0
#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
0
#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
  (0 <= (YYX) && (YYX) <= YYMAXUTOK                     \
566
0
   ? YY_CAST (yysymbol_kind_t, yytranslate[YYX])        \
567
0
   : 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
0
#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
0
#define YYPACT_NINF (-136)
664
665
#define yypact_value_is_default(Yyn) \
666
0
  ((Yyn) == YYPACT_NINF)
667
668
#define YYTABLE_NINF (-1)
669
670
#define yytable_value_is_error(Yyn) \
671
0
  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
0
#define YYACCEPT        goto yyacceptlab
918
0
#define YYABORT         goto yyabortlab
919
0
#define YYERROR         goto yyerrorlab
920
0
#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
0
# 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
0
# 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
0
# 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
yypcontext_expected_tokens (const yypcontext_t *yyctx,
1107
                            yysymbol_kind_t yyarg[], int yyargn)
1108
0
{
1109
  /* Actual size of YYARG. */
1110
0
  int yycount = 0;
1111
0
  int yyn = yypact[+*yyctx->yyssp];
1112
0
  if (!yypact_value_is_default (yyn))
1113
0
    {
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
0
      int yyxbegin = yyn < 0 ? -yyn : 0;
1118
      /* Stay within bounds of both yycheck and yytname.  */
1119
0
      int yychecklim = YYLAST - yyn + 1;
1120
0
      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1121
0
      int yyx;
1122
0
      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1123
0
        if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_YYerror
1124
0
            && !yytable_value_is_error (yytable[yyx + yyn]))
1125
0
          {
1126
0
            if (!yyarg)
1127
0
              ++yycount;
1128
0
            else if (yycount == yyargn)
1129
0
              return 0;
1130
0
            else
1131
0
              yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);
1132
0
          }
1133
0
    }
1134
0
  if (yyarg && yycount == 0 && 0 < yyargn)
1135
0
    yyarg[0] = YYSYMBOL_YYEMPTY;
1136
0
  return yycount;
1137
0
}
1138
1139
1140
1141
1142
#ifndef yystrlen
1143
# if defined __GLIBC__ && defined _STRING_H
1144
0
#  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
0
#  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
yytnamerr (char *yyres, const char *yystr)
1188
0
{
1189
0
  if (*yystr == '"')
1190
0
    {
1191
0
      YYPTRDIFF_T yyn = 0;
1192
0
      char const *yyp = yystr;
1193
0
      for (;;)
1194
0
        switch (*++yyp)
1195
0
          {
1196
0
          case '\'':
1197
0
          case ',':
1198
0
            goto do_not_strip_quotes;
1199
1200
0
          case '\\':
1201
0
            if (*++yyp != '\\')
1202
0
              goto do_not_strip_quotes;
1203
0
            else
1204
0
              goto append;
1205
1206
0
          append:
1207
0
          default:
1208
0
            if (yyres)
1209
0
              yyres[yyn] = *yyp;
1210
0
            yyn++;
1211
0
            break;
1212
1213
0
          case '"':
1214
0
            if (yyres)
1215
0
              yyres[yyn] = '\0';
1216
0
            return yyn;
1217
0
          }
1218
0
    do_not_strip_quotes: ;
1219
0
    }
1220
1221
0
  if (yyres)
1222
0
    return yystpcpy (yyres, yystr) - yyres;
1223
0
  else
1224
0
    return yystrlen (yystr);
1225
0
}
1226
#endif
1227
1228
1229
static int
1230
yy_syntax_error_arguments (const yypcontext_t *yyctx,
1231
                           yysymbol_kind_t yyarg[], int yyargn)
1232
0
{
1233
  /* Actual size of YYARG. */
1234
0
  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
0
  if (yyctx->yytoken != YYSYMBOL_YYEMPTY)
1259
0
    {
1260
0
      int yyn;
1261
0
      if (yyarg)
1262
0
        yyarg[yycount] = yyctx->yytoken;
1263
0
      ++yycount;
1264
0
      yyn = yypcontext_expected_tokens (yyctx,
1265
0
                                        yyarg ? yyarg + 1 : yyarg, yyargn - 1);
1266
0
      if (yyn == YYENOMEM)
1267
0
        return YYENOMEM;
1268
0
      else
1269
0
        yycount += yyn;
1270
0
    }
1271
0
  return yycount;
1272
0
}
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
yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
1284
                const yypcontext_t *yyctx)
1285
0
{
1286
0
  enum { YYARGS_MAX = 5 };
1287
  /* Internationalized format string. */
1288
0
  const char *yyformat = YY_NULLPTR;
1289
  /* Arguments of yyformat: reported tokens (one for the "unexpected",
1290
     one per "expected"). */
1291
0
  yysymbol_kind_t yyarg[YYARGS_MAX];
1292
  /* Cumulated lengths of YYARG.  */
1293
0
  YYPTRDIFF_T yysize = 0;
1294
1295
  /* Actual size of YYARG. */
1296
0
  int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX);
1297
0
  if (yycount == YYENOMEM)
1298
0
    return YYENOMEM;
1299
1300
0
  switch (yycount)
1301
0
    {
1302
0
#define YYCASE_(N, S)                       \
1303
0
      case N:                               \
1304
0
        yyformat = S;                       \
1305
0
        break
1306
0
    default: /* Avoid compiler warnings. */
1307
0
      YYCASE_(0, YY_("syntax error"));
1308
0
      YYCASE_(1, YY_("syntax error, unexpected %s"));
1309
0
      YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1310
0
      YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1311
0
      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
0
#undef YYCASE_
1314
0
    }
1315
1316
  /* Compute error message size.  Don't count the "%s"s, but reserve
1317
     room for the terminator.  */
1318
0
  yysize = yystrlen (yyformat) - 2 * yycount + 1;
1319
0
  {
1320
0
    int yyi;
1321
0
    for (yyi = 0; yyi < yycount; ++yyi)
1322
0
      {
1323
0
        YYPTRDIFF_T yysize1
1324
0
          = yysize + yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]]);
1325
0
        if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1326
0
          yysize = yysize1;
1327
0
        else
1328
0
          return YYENOMEM;
1329
0
      }
1330
0
  }
1331
1332
0
  if (*yymsg_alloc < yysize)
1333
0
    {
1334
0
      *yymsg_alloc = 2 * yysize;
1335
0
      if (! (yysize <= *yymsg_alloc
1336
0
             && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1337
0
        *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1338
0
      return -1;
1339
0
    }
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
0
  {
1345
0
    char *yyp = *yymsg;
1346
0
    int yyi = 0;
1347
0
    while ((*yyp = *yyformat) != '\0')
1348
0
      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1349
0
        {
1350
0
          yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);
1351
0
          yyformat += 2;
1352
0
        }
1353
0
      else
1354
0
        {
1355
0
          ++yyp;
1356
0
          ++yyformat;
1357
0
        }
1358
0
  }
1359
0
  return 0;
1360
0
}
1361
1362
1363
/*-----------------------------------------------.
1364
| Release the memory associated to this symbol.  |
1365
`-----------------------------------------------*/
1366
1367
static void
1368
yydestruct (const char *yymsg,
1369
            yysymbol_kind_t yykind, YYSTYPE *yyvaluep, swq_parse_context *context)
1370
0
{
1371
0
  YY_USE (yyvaluep);
1372
0
  YY_USE (context);
1373
0
  if (!yymsg)
1374
0
    yymsg = "Deleting";
1375
0
  YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1376
1377
0
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1378
0
  switch (yykind)
1379
0
    {
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
0
    case YYSYMBOL_SWQT_STRING: /* "string"  */
1389
0
            { delete (*yyvaluep); }
1390
0
        break;
1391
1392
0
    case YYSYMBOL_SWQT_IDENTIFIER: /* "identifier"  */
1393
0
            { delete (*yyvaluep); }
1394
0
        break;
1395
1396
0
    case YYSYMBOL_SWQT_HIDDEN: /* "HIDDEN"  */
1397
0
            { delete (*yyvaluep); }
1398
0
        break;
1399
1400
0
    case YYSYMBOL_value_expr: /* value_expr  */
1401
0
            { delete (*yyvaluep); }
1402
0
        break;
1403
1404
0
    case YYSYMBOL_value_expr_list: /* value_expr_list  */
1405
0
            { delete (*yyvaluep); }
1406
0
        break;
1407
1408
0
    case YYSYMBOL_identifier: /* identifier  */
1409
0
            { delete (*yyvaluep); }
1410
0
        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
0
      default:
1437
0
        break;
1438
0
    }
1439
0
  YY_IGNORE_MAYBE_UNINITIALIZED_END
1440
0
}
1441
1442
1443
1444
1445
1446
1447
/*----------.
1448
| yyparse.  |
1449
`----------*/
1450
1451
int
1452
yyparse (swq_parse_context *context)
1453
0
{
1454
/* Lookahead token kind.  */
1455
0
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
0
YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1462
0
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1463
1464
    /* Number of syntax errors so far.  */
1465
0
    int yynerrs = 0;
1466
1467
0
    yy_state_fast_t yystate = 0;
1468
    /* Number of tokens to shift before error messages enabled.  */
1469
0
    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
0
    YYPTRDIFF_T yystacksize = YYINITDEPTH;
1476
1477
    /* The state stack: array, bottom, top.  */
1478
0
    yy_state_t yyssa[YYINITDEPTH];
1479
0
    yy_state_t *yyss = yyssa;
1480
0
    yy_state_t *yyssp = yyss;
1481
1482
    /* The semantic value stack: array, bottom, top.  */
1483
0
    YYSTYPE yyvsa[YYINITDEPTH];
1484
0
    YYSTYPE *yyvs = yyvsa;
1485
0
    YYSTYPE *yyvsp = yyvs;
1486
1487
0
  int yyn;
1488
  /* The return value of yyparse.  */
1489
0
  int yyresult;
1490
  /* Lookahead symbol kind.  */
1491
0
  yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1492
  /* The variables used to return semantic value and location from the
1493
     action routines.  */
1494
0
  YYSTYPE yyval;
1495
1496
  /* Buffer for error messages, and its allocated size.  */
1497
0
  char yymsgbuf[128];
1498
0
  char *yymsg = yymsgbuf;
1499
0
  YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
1500
1501
0
#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
0
  int yylen = 0;
1506
1507
0
  YYDPRINTF ((stderr, "Starting parse\n"));
1508
1509
0
  yychar = YYEMPTY; /* Cause a token to be read.  */
1510
1511
0
  goto yysetstate;
1512
1513
1514
/*------------------------------------------------------------.
1515
| yynewstate -- push a new state, which is found in yystate.  |
1516
`------------------------------------------------------------*/
1517
0
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
0
  yyssp++;
1521
1522
1523
/*--------------------------------------------------------------------.
1524
| yysetstate -- set current state (the top of the stack) to yystate.  |
1525
`--------------------------------------------------------------------*/
1526
0
yysetstate:
1527
0
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1528
0
  YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1529
0
  YY_IGNORE_USELESS_CAST_BEGIN
1530
0
  *yyssp = YY_CAST (yy_state_t, yystate);
1531
0
  YY_IGNORE_USELESS_CAST_END
1532
0
  YY_STACK_PRINT (yyss, yyssp);
1533
1534
0
  if (yyss + yystacksize - 1 <= yyssp)
1535
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
1536
    YYNOMEM;
1537
#else
1538
0
    {
1539
      /* Get the current used size of the three stacks, in elements.  */
1540
0
      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
0
      if (YYMAXDEPTH <= yystacksize)
1564
0
        YYNOMEM;
1565
0
      yystacksize *= 2;
1566
0
      if (YYMAXDEPTH < yystacksize)
1567
0
        yystacksize = YYMAXDEPTH;
1568
1569
0
      {
1570
0
        yy_state_t *yyss1 = yyss;
1571
0
        union yyalloc *yyptr =
1572
0
          YY_CAST (union yyalloc *,
1573
0
                   YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1574
0
        if (! yyptr)
1575
0
          YYNOMEM;
1576
0
        YYSTACK_RELOCATE (yyss_alloc, yyss);
1577
0
        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1578
0
#  undef YYSTACK_RELOCATE
1579
0
        if (yyss1 != yyssa)
1580
0
          YYSTACK_FREE (yyss1);
1581
0
      }
1582
0
# endif
1583
1584
0
      yyssp = yyss + yysize - 1;
1585
0
      yyvsp = yyvs + yysize - 1;
1586
1587
0
      YY_IGNORE_USELESS_CAST_BEGIN
1588
0
      YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1589
0
                  YY_CAST (long, yystacksize)));
1590
0
      YY_IGNORE_USELESS_CAST_END
1591
1592
0
      if (yyss + yystacksize - 1 <= yyssp)
1593
0
        YYABORT;
1594
0
    }
1595
0
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1596
1597
1598
0
  if (yystate == YYFINAL)
1599
0
    YYACCEPT;
1600
1601
0
  goto yybackup;
1602
1603
1604
/*-----------.
1605
| yybackup.  |
1606
`-----------*/
1607
0
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
0
  yyn = yypact[yystate];
1613
0
  if (yypact_value_is_default (yyn))
1614
0
    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
0
  if (yychar == YYEMPTY)
1620
0
    {
1621
0
      YYDPRINTF ((stderr, "Reading a token\n"));
1622
0
      yychar = yylex (&yylval, context);
1623
0
    }
1624
1625
0
  if (yychar <= END)
1626
0
    {
1627
0
      yychar = END;
1628
0
      yytoken = YYSYMBOL_YYEOF;
1629
0
      YYDPRINTF ((stderr, "Now at end of input.\n"));
1630
0
    }
1631
0
  else if (yychar == YYerror)
1632
0
    {
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
0
      yychar = YYUNDEF;
1638
0
      yytoken = YYSYMBOL_YYerror;
1639
0
      goto yyerrlab1;
1640
0
    }
1641
0
  else
1642
0
    {
1643
0
      yytoken = YYTRANSLATE (yychar);
1644
0
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1645
0
    }
1646
1647
  /* If the proper action on seeing token YYTOKEN is to reduce or to
1648
     detect an error, take that action.  */
1649
0
  yyn += yytoken;
1650
0
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1651
0
    goto yydefault;
1652
0
  yyn = yytable[yyn];
1653
0
  if (yyn <= 0)
1654
0
    {
1655
0
      if (yytable_value_is_error (yyn))
1656
0
        goto yyerrlab;
1657
0
      yyn = -yyn;
1658
0
      goto yyreduce;
1659
0
    }
1660
1661
  /* Count tokens shifted since error; after three, turn off error
1662
     status.  */
1663
0
  if (yyerrstatus)
1664
0
    yyerrstatus--;
1665
1666
  /* Shift the lookahead token.  */
1667
0
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1668
0
  yystate = yyn;
1669
0
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1670
0
  *++yyvsp = yylval;
1671
0
  YY_IGNORE_MAYBE_UNINITIALIZED_END
1672
1673
  /* Discard the shifted token.  */
1674
0
  yychar = YYEMPTY;
1675
0
  goto yynewstate;
1676
1677
1678
/*-----------------------------------------------------------.
1679
| yydefault -- do the default action for the current state.  |
1680
`-----------------------------------------------------------*/
1681
0
yydefault:
1682
0
  yyn = yydefact[yystate];
1683
0
  if (yyn == 0)
1684
0
    goto yyerrlab;
1685
0
  goto yyreduce;
1686
1687
1688
/*-----------------------------.
1689
| yyreduce -- do a reduction.  |
1690
`-----------------------------*/
1691
0
yyreduce:
1692
  /* yyn is the number of a rule to reduce with.  */
1693
0
  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
0
  yyval = yyvsp[1-yylen];
1704
1705
1706
0
  YY_REDUCE_PRINT (yyn);
1707
0
  switch (yyn)
1708
0
    {
1709
0
  case 3: /* input: SWQT_VALUE_START value_expr  */
1710
0
        {
1711
0
            context->poRoot = yyvsp[0];
1712
0
            swq_fixup(context);
1713
0
        }
1714
0
    break;
1715
1716
0
  case 4: /* input: SWQT_SELECT_START select_statement  */
1717
0
        {
1718
0
            context->poRoot = yyvsp[0];
1719
            // swq_fixup() must be done by caller
1720
0
        }
1721
0
    break;
1722
1723
0
  case 5: /* value_expr: value_expr_non_logical  */
1724
0
        {
1725
0
            yyval = yyvsp[0];
1726
0
        }
1727
0
    break;
1728
1729
0
  case 6: /* value_expr: value_expr "AND" value_expr  */
1730
0
        {
1731
0
            yyval = swq_create_and_or_or( SWQ_AND, yyvsp[-2], yyvsp[0] );
1732
0
            if( yyval->HasReachedMaxDepth() )
1733
0
            {
1734
0
                yyerror (context, "Maximum expression depth reached");
1735
0
                delete yyval;
1736
0
                YYERROR;
1737
0
            }
1738
0
        }
1739
0
    break;
1740
1741
0
  case 7: /* value_expr: value_expr "OR" value_expr  */
1742
0
        {
1743
0
            yyval = swq_create_and_or_or( SWQ_OR, yyvsp[-2], yyvsp[0] );
1744
0
            if( yyval->HasReachedMaxDepth() )
1745
0
            {
1746
0
                yyerror (context, "Maximum expression depth reached");
1747
0
                delete yyval;
1748
0
                YYERROR;
1749
0
            }
1750
0
        }
1751
0
    break;
1752
1753
0
  case 8: /* value_expr: "NOT" value_expr  */
1754
0
        {
1755
0
            yyval = new swq_expr_node( SWQ_NOT );
1756
0
            yyval->field_type = SWQ_BOOLEAN;
1757
0
            yyval->PushSubExpression( yyvsp[0] );
1758
0
            if( yyval->HasReachedMaxDepth() )
1759
0
            {
1760
0
                yyerror (context, "Maximum expression depth reached");
1761
0
                delete yyval;
1762
0
                YYERROR;
1763
0
            }
1764
0
        }
1765
0
    break;
1766
1767
0
  case 9: /* value_expr: value_expr '=' value_expr  */
1768
0
        {
1769
0
            yyval = new swq_expr_node( SWQ_EQ );
1770
0
            yyval->field_type = SWQ_BOOLEAN;
1771
0
            yyval->PushSubExpression( yyvsp[-2] );
1772
0
            yyval->PushSubExpression( yyvsp[0] );
1773
0
            if( yyval->HasReachedMaxDepth() )
1774
0
            {
1775
0
                yyerror (context, "Maximum expression depth reached");
1776
0
                delete yyval;
1777
0
                YYERROR;
1778
0
            }
1779
0
        }
1780
0
    break;
1781
1782
0
  case 10: /* value_expr: value_expr '<' '>' value_expr  */
1783
0
        {
1784
0
            yyval = new swq_expr_node( SWQ_NE );
1785
0
            yyval->field_type = SWQ_BOOLEAN;
1786
0
            yyval->PushSubExpression( yyvsp[-3] );
1787
0
            yyval->PushSubExpression( yyvsp[0] );
1788
0
            if( yyval->HasReachedMaxDepth() )
1789
0
            {
1790
0
                yyerror (context, "Maximum expression depth reached");
1791
0
                delete yyval;
1792
0
                YYERROR;
1793
0
            }
1794
0
        }
1795
0
    break;
1796
1797
0
  case 11: /* value_expr: value_expr '!' '=' value_expr  */
1798
0
        {
1799
0
            yyval = new swq_expr_node( SWQ_NE );
1800
0
            yyval->field_type = SWQ_BOOLEAN;
1801
0
            yyval->PushSubExpression( yyvsp[-3] );
1802
0
            yyval->PushSubExpression( yyvsp[0] );
1803
0
            if( yyval->HasReachedMaxDepth() )
1804
0
            {
1805
0
                yyerror (context, "Maximum expression depth reached");
1806
0
                delete yyval;
1807
0
                YYERROR;
1808
0
            }
1809
0
        }
1810
0
    break;
1811
1812
0
  case 12: /* value_expr: value_expr '<' value_expr  */
1813
0
        {
1814
0
            yyval = new swq_expr_node( SWQ_LT );
1815
0
            yyval->field_type = SWQ_BOOLEAN;
1816
0
            yyval->PushSubExpression( yyvsp[-2] );
1817
0
            yyval->PushSubExpression( yyvsp[0] );
1818
0
            if( yyval->HasReachedMaxDepth() )
1819
0
            {
1820
0
                yyerror (context, "Maximum expression depth reached");
1821
0
                delete yyval;
1822
0
                YYERROR;
1823
0
            }
1824
0
        }
1825
0
    break;
1826
1827
0
  case 13: /* value_expr: value_expr '>' value_expr  */
1828
0
        {
1829
0
            yyval = new swq_expr_node( SWQ_GT );
1830
0
            yyval->field_type = SWQ_BOOLEAN;
1831
0
            yyval->PushSubExpression( yyvsp[-2] );
1832
0
            yyval->PushSubExpression( yyvsp[0] );
1833
0
            if( yyval->HasReachedMaxDepth() )
1834
0
            {
1835
0
                yyerror (context, "Maximum expression depth reached");
1836
0
                delete yyval;
1837
0
                YYERROR;
1838
0
            }
1839
0
        }
1840
0
    break;
1841
1842
0
  case 14: /* value_expr: value_expr '<' '=' value_expr  */
1843
0
        {
1844
0
            yyval = new swq_expr_node( SWQ_LE );
1845
0
            yyval->field_type = SWQ_BOOLEAN;
1846
0
            yyval->PushSubExpression( yyvsp[-3] );
1847
0
            yyval->PushSubExpression( yyvsp[0] );
1848
0
            if( yyval->HasReachedMaxDepth() )
1849
0
            {
1850
0
                yyerror (context, "Maximum expression depth reached");
1851
0
                delete yyval;
1852
0
                YYERROR;
1853
0
            }
1854
0
        }
1855
0
    break;
1856
1857
0
  case 15: /* value_expr: value_expr '=' '<' value_expr  */
1858
0
        {
1859
0
            yyval = new swq_expr_node( SWQ_LE );
1860
0
            yyval->field_type = SWQ_BOOLEAN;
1861
0
            yyval->PushSubExpression( yyvsp[-3] );
1862
0
            yyval->PushSubExpression( yyvsp[0] );
1863
0
            if( yyval->HasReachedMaxDepth() )
1864
0
            {
1865
0
                yyerror (context, "Maximum expression depth reached");
1866
0
                delete yyval;
1867
0
                YYERROR;
1868
0
            }
1869
0
        }
1870
0
    break;
1871
1872
0
  case 16: /* value_expr: value_expr '=' '>' value_expr  */
1873
0
        {
1874
0
            yyval = new swq_expr_node( SWQ_LE );
1875
0
            yyval->field_type = SWQ_BOOLEAN;
1876
0
            yyval->PushSubExpression( yyvsp[-3] );
1877
0
            yyval->PushSubExpression( yyvsp[0] );
1878
0
            if( yyval->HasReachedMaxDepth() )
1879
0
            {
1880
0
                yyerror (context, "Maximum expression depth reached");
1881
0
                delete yyval;
1882
0
                YYERROR;
1883
0
            }
1884
0
        }
1885
0
    break;
1886
1887
0
  case 17: /* value_expr: value_expr '>' '=' value_expr  */
1888
0
        {
1889
0
            yyval = new swq_expr_node( SWQ_GE );
1890
0
            yyval->field_type = SWQ_BOOLEAN;
1891
0
            yyval->PushSubExpression( yyvsp[-3] );
1892
0
            yyval->PushSubExpression( yyvsp[0] );
1893
0
            if( yyval->HasReachedMaxDepth() )
1894
0
            {
1895
0
                yyerror (context, "Maximum expression depth reached");
1896
0
                delete yyval;
1897
0
                YYERROR;
1898
0
            }
1899
0
        }
1900
0
    break;
1901
1902
0
  case 18: /* value_expr: value_expr "LIKE" value_expr  */
1903
0
        {
1904
0
            yyval = new swq_expr_node( SWQ_LIKE );
1905
0
            yyval->field_type = SWQ_BOOLEAN;
1906
0
            yyval->PushSubExpression( yyvsp[-2] );
1907
0
            yyval->PushSubExpression( yyvsp[0] );
1908
0
            if( yyval->HasReachedMaxDepth() )
1909
0
            {
1910
0
                yyerror (context, "Maximum expression depth reached");
1911
0
                delete yyval;
1912
0
                YYERROR;
1913
0
            }
1914
0
        }
1915
0
    break;
1916
1917
0
  case 19: /* value_expr: value_expr "NOT" "LIKE" value_expr  */
1918
0
        {
1919
0
            swq_expr_node *like = new swq_expr_node( SWQ_LIKE );
1920
0
            like->field_type = SWQ_BOOLEAN;
1921
0
            like->PushSubExpression( yyvsp[-3] );
1922
0
            like->PushSubExpression( yyvsp[0] );
1923
1924
0
            yyval = new swq_expr_node( SWQ_NOT );
1925
0
            yyval->field_type = SWQ_BOOLEAN;
1926
0
            yyval->PushSubExpression( like );
1927
0
            if( yyval->HasReachedMaxDepth() )
1928
0
            {
1929
0
                yyerror (context, "Maximum expression depth reached");
1930
0
                delete yyval;
1931
0
                YYERROR;
1932
0
            }
1933
0
        }
1934
0
    break;
1935
1936
0
  case 20: /* value_expr: value_expr "LIKE" value_expr "ESCAPE" value_expr  */
1937
0
        {
1938
0
            yyval = new swq_expr_node( SWQ_LIKE );
1939
0
            yyval->field_type = SWQ_BOOLEAN;
1940
0
            yyval->PushSubExpression( yyvsp[-4] );
1941
0
            yyval->PushSubExpression( yyvsp[-2] );
1942
0
            yyval->PushSubExpression( yyvsp[0] );
1943
0
            if( yyval->HasReachedMaxDepth() )
1944
0
            {
1945
0
                yyerror (context, "Maximum expression depth reached");
1946
0
                delete yyval;
1947
0
                YYERROR;
1948
0
            }
1949
0
        }
1950
0
    break;
1951
1952
0
  case 21: /* value_expr: value_expr "NOT" "LIKE" value_expr "ESCAPE" value_expr  */
1953
0
        {
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
0
            {
1965
0
                yyerror (context, "Maximum expression depth reached");
1966
0
                delete yyval;
1967
0
                YYERROR;
1968
0
            }
1969
0
        }
1970
0
    break;
1971
1972
0
  case 22: /* value_expr: value_expr "ILIKE" value_expr  */
1973
0
        {
1974
0
            yyval = new swq_expr_node( SWQ_ILIKE );
1975
0
            yyval->field_type = SWQ_BOOLEAN;
1976
0
            yyval->PushSubExpression( yyvsp[-2] );
1977
0
            yyval->PushSubExpression( yyvsp[0] );
1978
0
            if( yyval->HasReachedMaxDepth() )
1979
0
            {
1980
0
                yyerror (context, "Maximum expression depth reached");
1981
0
                delete yyval;
1982
0
                YYERROR;
1983
0
            }
1984
0
        }
1985
0
    break;
1986
1987
0
  case 23: /* value_expr: value_expr "NOT" "ILIKE" value_expr  */
1988
0
        {
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
0
            {
1999
0
                yyerror (context, "Maximum expression depth reached");
2000
0
                delete yyval;
2001
0
                YYERROR;
2002
0
            }
2003
0
        }
2004
0
    break;
2005
2006
0
  case 24: /* value_expr: value_expr "ILIKE" value_expr "ESCAPE" value_expr  */
2007
0
        {
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
0
            {
2015
0
                yyerror (context, "Maximum expression depth reached");
2016
0
                delete yyval;
2017
0
                YYERROR;
2018
0
            }
2019
0
        }
2020
0
    break;
2021
2022
0
  case 25: /* value_expr: value_expr "NOT" "ILIKE" value_expr "ESCAPE" value_expr  */
2023
0
        {
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
0
            {
2035
0
                yyerror (context, "Maximum expression depth reached");
2036
0
                delete yyval;
2037
0
                YYERROR;
2038
0
            }
2039
0
        }
2040
0
    break;
2041
2042
0
  case 26: /* value_expr: value_expr "IN" '(' value_expr_list ')'  */
2043
0
        {
2044
0
            yyval = yyvsp[-1];
2045
0
            yyval->field_type = SWQ_BOOLEAN;
2046
0
            yyval->nOperation = SWQ_IN;
2047
0
            yyval->PushSubExpression( yyvsp[-4] );
2048
0
            yyval->ReverseSubExpressions();
2049
0
            if( yyval->HasReachedMaxDepth() )
2050
0
            {
2051
0
                yyerror (context, "Maximum expression depth reached");
2052
0
                delete yyval;
2053
0
                YYERROR;
2054
0
            }
2055
0
        }
2056
0
    break;
2057
2058
0
  case 27: /* value_expr: value_expr "NOT" "IN" '(' value_expr_list ')'  */
2059
0
        {
2060
0
            swq_expr_node *in = yyvsp[-1];
2061
0
            in->field_type = SWQ_BOOLEAN;
2062
0
            in->nOperation = SWQ_IN;
2063
0
            in->PushSubExpression( yyvsp[-5] );
2064
0
            in->ReverseSubExpressions();
2065
2066
0
            yyval = new swq_expr_node( SWQ_NOT );
2067
0
            yyval->field_type = SWQ_BOOLEAN;
2068
0
            yyval->PushSubExpression( in );
2069
0
            if( yyval->HasReachedMaxDepth() )
2070
0
            {
2071
0
                yyerror (context, "Maximum expression depth reached");
2072
0
                delete yyval;
2073
0
                YYERROR;
2074
0
            }
2075
0
        }
2076
0
    break;
2077
2078
0
  case 28: /* value_expr: value_expr "BETWEEN" value_expr_non_logical "AND" value_expr_non_logical  */
2079
0
        {
2080
0
            yyval = new swq_expr_node( SWQ_BETWEEN );
2081
0
            yyval->field_type = SWQ_BOOLEAN;
2082
0
            yyval->PushSubExpression( yyvsp[-4] );
2083
0
            yyval->PushSubExpression( yyvsp[-2] );
2084
0
            yyval->PushSubExpression( yyvsp[0] );
2085
0
            if( yyval->HasReachedMaxDepth() )
2086
0
            {
2087
0
                yyerror (context, "Maximum expression depth reached");
2088
0
                delete yyval;
2089
0
                YYERROR;
2090
0
            }
2091
0
        }
2092
0
    break;
2093
2094
0
  case 29: /* value_expr: value_expr "NOT" "BETWEEN" value_expr_non_logical "AND" value_expr_non_logical  */
2095
0
        {
2096
0
            swq_expr_node *between = new swq_expr_node( SWQ_BETWEEN );
2097
0
            between->field_type = SWQ_BOOLEAN;
2098
0
            between->PushSubExpression( yyvsp[-5] );
2099
0
            between->PushSubExpression( yyvsp[-2] );
2100
0
            between->PushSubExpression( yyvsp[0] );
2101
2102
0
            yyval = new swq_expr_node( SWQ_NOT );
2103
0
            yyval->field_type = SWQ_BOOLEAN;
2104
0
            yyval->PushSubExpression( between );
2105
0
            if( yyval->HasReachedMaxDepth() )
2106
0
            {
2107
0
                yyerror (context, "Maximum expression depth reached");
2108
0
                delete yyval;
2109
0
                YYERROR;
2110
0
            }
2111
0
        }
2112
0
    break;
2113
2114
0
  case 30: /* value_expr: value_expr "IS" "NULL"  */
2115
0
        {
2116
0
            yyval = new swq_expr_node( SWQ_ISNULL );
2117
0
            yyval->field_type = SWQ_BOOLEAN;
2118
0
            yyval->PushSubExpression( yyvsp[-2] );
2119
0
            if( yyval->HasReachedMaxDepth() )
2120
0
            {
2121
0
                yyerror (context, "Maximum expression depth reached");
2122
0
                delete yyval;
2123
0
                YYERROR;
2124
0
            }
2125
0
        }
2126
0
    break;
2127
2128
0
  case 31: /* value_expr: value_expr "IS" "NOT" "NULL"  */
2129
0
        {
2130
0
            swq_expr_node *isnull = new swq_expr_node( SWQ_ISNULL );
2131
0
            isnull->field_type = SWQ_BOOLEAN;
2132
0
            isnull->PushSubExpression( yyvsp[-3] );
2133
2134
0
            yyval = new swq_expr_node( SWQ_NOT );
2135
0
            yyval->field_type = SWQ_BOOLEAN;
2136
0
            yyval->PushSubExpression( isnull );
2137
0
            if( yyval->HasReachedMaxDepth() )
2138
0
            {
2139
0
                yyerror (context, "Maximum expression depth reached");
2140
0
                delete yyval;
2141
0
                YYERROR;
2142
0
            }
2143
0
        }
2144
0
    break;
2145
2146
0
  case 32: /* value_expr_list: value_expr ',' value_expr_list  */
2147
0
        {
2148
0
            yyval = yyvsp[0];
2149
0
            yyval->PushSubExpression( yyvsp[-2] );
2150
0
            if( yyval->HasReachedMaxDepth() )
2151
0
            {
2152
0
                yyerror (context, "Maximum expression depth reached");
2153
0
                delete yyval;
2154
0
                YYERROR;
2155
0
            }
2156
0
        }
2157
0
    break;
2158
2159
0
  case 33: /* value_expr_list: value_expr  */
2160
0
            {
2161
0
            yyval = new swq_expr_node( SWQ_ARGUMENT_LIST ); /* temporary value */
2162
0
            yyval->PushSubExpression( yyvsp[0] );
2163
0
            if( yyval->HasReachedMaxDepth() )
2164
0
            {
2165
0
                yyerror (context, "Maximum expression depth reached");
2166
0
                delete yyval;
2167
0
                YYERROR;
2168
0
            }
2169
0
        }
2170
0
    break;
2171
2172
0
  case 36: /* field_value: identifier  */
2173
0
        {
2174
0
            yyval = yyvsp[0];  // validation deferred.
2175
0
            yyval->eNodeType = SNT_COLUMN;
2176
0
            yyval->field_index = -1;
2177
0
            yyval->table_index = -1;
2178
0
        }
2179
0
    break;
2180
2181
0
  case 37: /* field_value: identifier '.' identifier  */
2182
0
        {
2183
0
            yyval = yyvsp[-2];  // validation deferred.
2184
0
            yyval->eNodeType = SNT_COLUMN;
2185
0
            yyval->field_index = -1;
2186
0
            yyval->table_index = -1;
2187
0
            yyval->table_name = yyval->string_value;
2188
0
            yyval->string_value = CPLStrdup(yyvsp[0]->string_value);
2189
0
            delete yyvsp[0];
2190
0
            yyvsp[0] = nullptr;
2191
0
        }
2192
0
    break;
2193
2194
0
  case 38: /* value_expr_non_logical: "integer number"  */
2195
0
        {
2196
0
            yyval = yyvsp[0];
2197
0
        }
2198
0
    break;
2199
2200
0
  case 39: /* value_expr_non_logical: "floating point number"  */
2201
0
        {
2202
0
            yyval = yyvsp[0];
2203
0
        }
2204
0
    break;
2205
2206
0
  case 40: /* value_expr_non_logical: "string"  */
2207
0
        {
2208
0
            yyval = yyvsp[0];
2209
0
        }
2210
0
    break;
2211
2212
0
  case 41: /* value_expr_non_logical: field_value  */
2213
0
        {
2214
0
            yyval = yyvsp[0];
2215
0
        }
2216
0
    break;
2217
2218
0
  case 42: /* value_expr_non_logical: '(' value_expr ')'  */
2219
0
        {
2220
0
            yyval = yyvsp[-1];
2221
0
        }
2222
0
    break;
2223
2224
0
  case 43: /* value_expr_non_logical: "NULL"  */
2225
0
        {
2226
0
            yyval = new swq_expr_node(static_cast<const char*>(nullptr));
2227
0
        }
2228
0
    break;
2229
2230
0
  case 44: /* value_expr_non_logical: '-' value_expr_non_logical  */
2231
0
        {
2232
0
            if (yyvsp[0]->eNodeType == SNT_CONSTANT)
2233
0
            {
2234
0
                if( yyvsp[0]->field_type == SWQ_FLOAT &&
2235
0
                    yyvsp[0]->string_value &&
2236
0
                    strcmp(yyvsp[0]->string_value, "9223372036854775808") == 0 )
2237
0
                {
2238
0
                    yyval = yyvsp[0];
2239
0
                    yyval->field_type = SWQ_INTEGER64;
2240
0
                    yyval->int_value = std::numeric_limits<GIntBig>::min();
2241
0
                    yyval->float_value = static_cast<double>(std::numeric_limits<GIntBig>::min());
2242
0
                }
2243
                // - (-9223372036854775808) cannot be represented on int64
2244
                // the classic overflow is that its negation is itself.
2245
0
                else if( yyvsp[0]->field_type == SWQ_INTEGER64 &&
2246
0
                         yyvsp[0]->int_value == std::numeric_limits<GIntBig>::min() )
2247
0
                {
2248
0
                    yyval = yyvsp[0];
2249
0
                }
2250
0
                else
2251
0
                {
2252
0
                    yyval = yyvsp[0];
2253
0
                    yyval->int_value *= -1;
2254
0
                    yyval->float_value *= -1;
2255
0
                }
2256
0
            }
2257
0
            else
2258
0
            {
2259
0
                yyval = new swq_expr_node( SWQ_MULTIPLY );
2260
0
                yyval->PushSubExpression( new swq_expr_node(-1) );
2261
0
                yyval->PushSubExpression( yyvsp[0] );
2262
0
                if( yyval->HasReachedMaxDepth() )
2263
0
                {
2264
0
                    yyerror (context, "Maximum expression depth reached");
2265
0
                    delete yyval;
2266
0
                    YYERROR;
2267
0
                }
2268
0
            }
2269
0
        }
2270
0
    break;
2271
2272
0
  case 45: /* value_expr_non_logical: value_expr_non_logical '+' value_expr_non_logical  */
2273
0
        {
2274
0
            yyval = new swq_expr_node( SWQ_ADD );
2275
0
            yyval->PushSubExpression( yyvsp[-2] );
2276
0
            yyval->PushSubExpression( yyvsp[0] );
2277
0
            if( yyval->HasReachedMaxDepth() )
2278
0
            {
2279
0
                yyerror (context, "Maximum expression depth reached");
2280
0
                delete yyval;
2281
0
                YYERROR;
2282
0
            }
2283
0
        }
2284
0
    break;
2285
2286
0
  case 46: /* value_expr_non_logical: value_expr_non_logical '-' value_expr_non_logical  */
2287
0
        {
2288
0
            yyval = new swq_expr_node( SWQ_SUBTRACT );
2289
0
            yyval->PushSubExpression( yyvsp[-2] );
2290
0
            yyval->PushSubExpression( yyvsp[0] );
2291
0
            if( yyval->HasReachedMaxDepth() )
2292
0
            {
2293
0
                yyerror (context, "Maximum expression depth reached");
2294
0
                delete yyval;
2295
0
                YYERROR;
2296
0
            }
2297
0
        }
2298
0
    break;
2299
2300
0
  case 47: /* value_expr_non_logical: value_expr_non_logical '*' value_expr_non_logical  */
2301
0
        {
2302
0
            yyval = new swq_expr_node( SWQ_MULTIPLY );
2303
0
            yyval->PushSubExpression( yyvsp[-2] );
2304
0
            yyval->PushSubExpression( yyvsp[0] );
2305
0
            if( yyval->HasReachedMaxDepth() )
2306
0
            {
2307
0
                yyerror (context, "Maximum expression depth reached");
2308
0
                delete yyval;
2309
0
                YYERROR;
2310
0
            }
2311
0
        }
2312
0
    break;
2313
2314
0
  case 48: /* value_expr_non_logical: value_expr_non_logical '/' value_expr_non_logical  */
2315
0
        {
2316
0
            yyval = new swq_expr_node( SWQ_DIVIDE );
2317
0
            yyval->PushSubExpression( yyvsp[-2] );
2318
0
            yyval->PushSubExpression( yyvsp[0] );
2319
0
            if( yyval->HasReachedMaxDepth() )
2320
0
            {
2321
0
                yyerror (context, "Maximum expression depth reached");
2322
0
                delete yyval;
2323
0
                YYERROR;
2324
0
            }
2325
0
        }
2326
0
    break;
2327
2328
0
  case 49: /* value_expr_non_logical: value_expr_non_logical '%' value_expr_non_logical  */
2329
0
        {
2330
0
            yyval = new swq_expr_node( SWQ_MODULUS );
2331
0
            yyval->PushSubExpression( yyvsp[-2] );
2332
0
            yyval->PushSubExpression( yyvsp[0] );
2333
0
            if( yyval->HasReachedMaxDepth() )
2334
0
            {
2335
0
                yyerror (context, "Maximum expression depth reached");
2336
0
                delete yyval;
2337
0
                YYERROR;
2338
0
            }
2339
0
        }
2340
0
    break;
2341
2342
0
  case 50: /* value_expr_non_logical: identifier '(' value_expr_list ')'  */
2343
0
        {
2344
0
            const swq_operation *poOp =
2345
0
                    swq_op_registrar::GetOperator( yyvsp[-3]->string_value );
2346
2347
0
            if( poOp == nullptr )
2348
0
            {
2349
0
                if( context->bAcceptCustomFuncs )
2350
0
                {
2351
0
                    yyval = yyvsp[-1];
2352
0
                    yyval->eNodeType = SNT_OPERATION;
2353
0
                    yyval->nOperation = SWQ_CUSTOM_FUNC;
2354
0
                    yyval->string_value = CPLStrdup(yyvsp[-3]->string_value);
2355
0
                    yyval->ReverseSubExpressions();
2356
0
                    delete yyvsp[-3];
2357
0
                }
2358
0
                else
2359
0
                {
2360
0
                    CPLError( CE_Failure, CPLE_AppDefined,
2361
0
                                    "Undefined function '%s' used.",
2362
0
                                    yyvsp[-3]->string_value );
2363
0
                    delete yyvsp[-3];
2364
0
                    delete yyvsp[-1];
2365
0
                    YYERROR;
2366
0
                }
2367
0
            }
2368
0
            else
2369
0
            {
2370
0
                yyval = yyvsp[-1];
2371
0
                yyval->eNodeType = SNT_OPERATION;
2372
0
                yyval->nOperation = poOp->eOperation;
2373
0
                yyval->ReverseSubExpressions();
2374
0
                delete yyvsp[-3];
2375
0
            }
2376
0
        }
2377
0
    break;
2378
2379
0
  case 51: /* value_expr_non_logical: "CAST" '(' value_expr "AS" type_def ')'  */
2380
0
        {
2381
0
            yyval = yyvsp[-1];
2382
0
            yyval->PushSubExpression( yyvsp[-3] );
2383
0
            yyval->ReverseSubExpressions();
2384
0
            if( yyval->HasReachedMaxDepth() )
2385
0
            {
2386
0
                yyerror (context, "Maximum expression depth reached");
2387
0
                delete yyval;
2388
0
                YYERROR;
2389
0
            }
2390
0
        }
2391
0
    break;
2392
2393
0
  case 52: /* type_def: identifier  */
2394
0
    {
2395
0
        yyval = new swq_expr_node( SWQ_CAST );
2396
0
        yyval->PushSubExpression( yyvsp[0] );
2397
0
        if( yyval->HasReachedMaxDepth() )
2398
0
        {
2399
0
            yyerror (context, "Maximum expression depth reached");
2400
0
            delete yyval;
2401
0
            YYERROR;
2402
0
        }
2403
0
    }
2404
0
    break;
2405
2406
0
  case 53: /* type_def: identifier '(' "integer number" ')'  */
2407
0
    {
2408
0
        yyval = new swq_expr_node( SWQ_CAST );
2409
0
        yyval->PushSubExpression( yyvsp[-1] );
2410
0
        yyval->PushSubExpression( yyvsp[-3] );
2411
0
    }
2412
0
    break;
2413
2414
0
  case 54: /* type_def: identifier '(' "integer number" ',' "integer number" ')'  */
2415
0
    {
2416
0
        yyval = new swq_expr_node( SWQ_CAST );
2417
0
        yyval->PushSubExpression( yyvsp[-1] );
2418
0
        yyval->PushSubExpression( yyvsp[-3] );
2419
0
        yyval->PushSubExpression( yyvsp[-5] );
2420
0
    }
2421
0
    break;
2422
2423
0
  case 55: /* type_def: identifier '(' identifier ')'  */
2424
0
    {
2425
0
        OGRwkbGeometryType eType = OGRFromOGCGeomType(yyvsp[-1]->string_value);
2426
0
        if( !EQUAL(yyvsp[-3]->string_value, "GEOMETRY") ||
2427
0
            (wkbFlatten(eType) == wkbUnknown &&
2428
0
            !STARTS_WITH_CI(yyvsp[-1]->string_value, "GEOMETRY")) )
2429
0
        {
2430
0
            yyerror (context, "syntax error");
2431
0
            delete yyvsp[-3];
2432
0
            delete yyvsp[-1];
2433
0
            YYERROR;
2434
0
        }
2435
0
        yyval = new swq_expr_node( SWQ_CAST );
2436
0
        yyval->PushSubExpression( yyvsp[-1] );
2437
0
        yyval->PushSubExpression( yyvsp[-3] );
2438
0
    }
2439
0
    break;
2440
2441
0
  case 56: /* type_def: identifier '(' identifier ',' "integer number" ')'  */
2442
0
    {
2443
0
        OGRwkbGeometryType eType = OGRFromOGCGeomType(yyvsp[-3]->string_value);
2444
0
        if( !EQUAL(yyvsp[-5]->string_value, "GEOMETRY") ||
2445
0
            (wkbFlatten(eType) == wkbUnknown &&
2446
0
            !STARTS_WITH_CI(yyvsp[-3]->string_value, "GEOMETRY")) )
2447
0
        {
2448
0
            yyerror (context, "syntax error");
2449
0
            delete yyvsp[-5];
2450
0
            delete yyvsp[-3];
2451
0
            delete yyvsp[-1];
2452
0
            YYERROR;
2453
0
        }
2454
0
        yyval = new swq_expr_node( SWQ_CAST );
2455
0
        yyval->PushSubExpression( yyvsp[-1] );
2456
0
        yyval->PushSubExpression( yyvsp[-3] );
2457
0
        yyval->PushSubExpression( yyvsp[-5] );
2458
0
    }
2459
0
    break;
2460
2461
0
  case 59: /* select_core: "SELECT" select_field_list "FROM" table_def opt_joins opt_where opt_order_by opt_limit opt_offset  */
2462
0
    {
2463
0
        delete yyvsp[-5];
2464
0
    }
2465
0
    break;
2466
2467
0
  case 60: /* select_core: "SELECT" "DISTINCT" select_field_list "FROM" table_def opt_joins opt_where opt_order_by opt_limit opt_offset  */
2468
0
    {
2469
0
        context->poCurSelect->query_mode = SWQM_DISTINCT_LIST;
2470
0
        delete yyvsp[-5];
2471
0
    }
2472
0
    break;
2473
2474
0
  case 63: /* union_all: "UNION" "ALL"  */
2475
0
    {
2476
0
        swq_select* poNewSelect = new swq_select();
2477
0
        context->poCurSelect->PushUnionAll(poNewSelect);
2478
0
        context->poCurSelect = poNewSelect;
2479
0
    }
2480
0
    break;
2481
2482
0
  case 66: /* exclude_field: field_value  */
2483
0
        {
2484
0
            if ( !context->poCurSelect->PushExcludeField( yyvsp[0] ) )
2485
0
            {
2486
0
                delete yyvsp[0];
2487
0
                YYERROR;
2488
0
            }
2489
0
        }
2490
0
    break;
2491
2492
0
  case 71: /* column_spec: value_expr  */
2493
0
        {
2494
0
            if( !context->poCurSelect->PushField( yyvsp[0], nullptr, false, false ) )
2495
0
            {
2496
0
                delete yyvsp[0];
2497
0
                YYERROR;
2498
0
            }
2499
0
        }
2500
0
    break;
2501
2502
0
  case 72: /* column_spec: value_expr as_clause_with_hidden  */
2503
0
        {
2504
0
            if( !context->poCurSelect->PushField( yyvsp[-1], yyvsp[0]->string_value, false, yyvsp[0]->bHidden ) )
2505
0
            {
2506
0
                delete yyvsp[-1];
2507
0
                delete yyvsp[0];
2508
0
                YYERROR;
2509
0
            }
2510
0
            delete yyvsp[0];
2511
0
        }
2512
0
    break;
2513
2514
0
  case 73: /* column_spec: '*' except_or_exclude '(' exclude_field_list ')'  */
2515
0
        {
2516
0
            swq_expr_node *poNode = new swq_expr_node();
2517
0
            poNode->eNodeType = SNT_COLUMN;
2518
0
            poNode->string_value = CPLStrdup( "*" );
2519
0
            poNode->table_index = -1;
2520
0
            poNode->field_index = -1;
2521
2522
0
            if( !context->poCurSelect->PushField( poNode, nullptr, false, false ) )
2523
0
            {
2524
0
                delete poNode;
2525
0
                YYERROR;
2526
0
            }
2527
0
        }
2528
0
    break;
2529
2530
0
  case 74: /* column_spec: '*'  */
2531
0
        {
2532
0
            swq_expr_node *poNode = new swq_expr_node();
2533
0
            poNode->eNodeType = SNT_COLUMN;
2534
0
            poNode->string_value = CPLStrdup( "*" );
2535
0
            poNode->table_index = -1;
2536
0
            poNode->field_index = -1;
2537
2538
0
            if( !context->poCurSelect->PushField( poNode, nullptr, false, false ) )
2539
0
            {
2540
0
                delete poNode;
2541
0
                YYERROR;
2542
0
            }
2543
0
        }
2544
0
    break;
2545
2546
0
  case 75: /* column_spec: identifier '.' '*'  */
2547
0
        {
2548
0
            CPLString osTableName = yyvsp[-2]->string_value;
2549
2550
0
            delete yyvsp[-2];
2551
0
            yyvsp[-2] = nullptr;
2552
2553
0
            swq_expr_node *poNode = new swq_expr_node();
2554
0
            poNode->eNodeType = SNT_COLUMN;
2555
0
            poNode->table_name = CPLStrdup(osTableName );
2556
0
            poNode->string_value = CPLStrdup( "*" );
2557
0
            poNode->table_index = -1;
2558
0
            poNode->field_index = -1;
2559
2560
0
            if( !context->poCurSelect->PushField( poNode, nullptr, false, false ) )
2561
0
            {
2562
0
                delete poNode;
2563
0
                YYERROR;
2564
0
            }
2565
0
        }
2566
0
    break;
2567
2568
0
  case 76: /* column_spec: identifier '(' '*' ')'  */
2569
0
        {
2570
                // special case for COUNT(*), confirm it.
2571
0
            if( !EQUAL(yyvsp[-3]->string_value, "COUNT") )
2572
0
            {
2573
0
                CPLError( CE_Failure, CPLE_AppDefined,
2574
0
                        "Syntax Error with %s(*).",
2575
0
                        yyvsp[-3]->string_value );
2576
0
                delete yyvsp[-3];
2577
0
                YYERROR;
2578
0
            }
2579
2580
0
            delete yyvsp[-3];
2581
0
            yyvsp[-3] = nullptr;
2582
2583
0
            swq_expr_node *poNode = new swq_expr_node();
2584
0
            poNode->eNodeType = SNT_COLUMN;
2585
0
            poNode->string_value = CPLStrdup( "*" );
2586
0
            poNode->table_index = -1;
2587
0
            poNode->field_index = -1;
2588
2589
0
            swq_expr_node *count = new swq_expr_node( SWQ_COUNT );
2590
0
            count->PushSubExpression( poNode );
2591
2592
0
            if( !context->poCurSelect->PushField( count, nullptr, false, false ) )
2593
0
            {
2594
0
                delete count;
2595
0
                YYERROR;
2596
0
            }
2597
0
        }
2598
0
    break;
2599
2600
0
  case 77: /* column_spec: identifier '(' '*' ')' as_clause  */
2601
0
        {
2602
                // special case for COUNT(*), confirm it.
2603
0
            if( !EQUAL(yyvsp[-4]->string_value, "COUNT") )
2604
0
            {
2605
0
                CPLError( CE_Failure, CPLE_AppDefined,
2606
0
                        "Syntax Error with %s(*).",
2607
0
                        yyvsp[-4]->string_value );
2608
0
                delete yyvsp[-4];
2609
0
                delete yyvsp[0];
2610
0
                YYERROR;
2611
0
            }
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
0
            {
2627
0
                delete count;
2628
0
                delete yyvsp[0];
2629
0
                YYERROR;
2630
0
            }
2631
2632
0
            delete yyvsp[0];
2633
0
        }
2634
0
    break;
2635
2636
0
  case 78: /* column_spec: identifier '(' "DISTINCT" field_value ')'  */
2637
0
        {
2638
                // special case for COUNT(DISTINCT x), confirm it.
2639
0
            if( !EQUAL(yyvsp[-4]->string_value, "COUNT") )
2640
0
            {
2641
0
                CPLError(
2642
0
                    CE_Failure, CPLE_AppDefined,
2643
0
                    "DISTINCT keyword can only be used in COUNT() operator." );
2644
0
                delete yyvsp[-4];
2645
0
                delete yyvsp[-1];
2646
0
                    YYERROR;
2647
0
            }
2648
2649
0
            delete yyvsp[-4];
2650
2651
0
            swq_expr_node *count = new swq_expr_node( SWQ_COUNT );
2652
0
            count->PushSubExpression( yyvsp[-1] );
2653
2654
0
            if( !context->poCurSelect->PushField( count, nullptr, true, false ) )
2655
0
            {
2656
0
                delete count;
2657
0
                YYERROR;
2658
0
            }
2659
0
        }
2660
0
    break;
2661
2662
0
  case 79: /* column_spec: identifier '(' "DISTINCT" field_value ')' as_clause  */
2663
0
        {
2664
            // special case for COUNT(DISTINCT x), confirm it.
2665
0
            if( !EQUAL(yyvsp[-5]->string_value, "COUNT") )
2666
0
            {
2667
0
                CPLError( CE_Failure, CPLE_AppDefined,
2668
0
                        "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
0
            }
2674
2675
0
            swq_expr_node *count = new swq_expr_node( SWQ_COUNT );
2676
0
            count->PushSubExpression( yyvsp[-2] );
2677
2678
0
            if( !context->poCurSelect->PushField( count, yyvsp[0]->string_value, true, yyvsp[0]->bHidden ) )
2679
0
            {
2680
0
                delete yyvsp[-5];
2681
0
                delete count;
2682
0
                delete yyvsp[0];
2683
0
                YYERROR;
2684
0
            }
2685
2686
0
            delete yyvsp[-5];
2687
0
            delete yyvsp[0];
2688
0
        }
2689
0
    break;
2690
2691
0
  case 80: /* as_clause: "AS" identifier  */
2692
0
        {
2693
0
            yyval = yyvsp[0];
2694
0
            yyvsp[0] = nullptr;
2695
0
        }
2696
0
    break;
2697
2698
0
  case 83: /* as_clause_with_hidden: as_clause "HIDDEN"  */
2699
0
        {
2700
0
            yyval = yyvsp[-1];
2701
0
            yyvsp[-1] = nullptr;
2702
0
            delete yyvsp[0];
2703
0
            yyvsp[0] = nullptr;
2704
0
            yyval->bHidden = true;
2705
0
        }
2706
0
    break;
2707
2708
0
  case 85: /* opt_where: "WHERE" value_expr  */
2709
0
        {
2710
0
            context->poCurSelect->where_expr = yyvsp[0];
2711
0
        }
2712
0
    break;
2713
2714
0
  case 87: /* opt_joins: "JOIN" table_def "ON" value_expr opt_joins  */
2715
0
        {
2716
0
            context->poCurSelect->PushJoin( static_cast<int>(yyvsp[-3]->int_value),
2717
0
                                            yyvsp[-1] );
2718
0
            delete yyvsp[-3];
2719
0
        }
2720
0
    break;
2721
2722
0
  case 88: /* opt_joins: "LEFT" "JOIN" table_def "ON" value_expr opt_joins  */
2723
0
        {
2724
0
            context->poCurSelect->PushJoin( static_cast<int>(yyvsp[-3]->int_value),
2725
0
                                            yyvsp[-1] );
2726
0
            delete yyvsp[-3];
2727
0
        }
2728
0
    break;
2729
2730
0
  case 93: /* sort_spec: field_value  */
2731
0
        {
2732
0
            context->poCurSelect->PushOrderBy( yyvsp[0]->table_name, yyvsp[0]->string_value, TRUE );
2733
0
            delete yyvsp[0];
2734
0
            yyvsp[0] = nullptr;
2735
0
        }
2736
0
    break;
2737
2738
0
  case 94: /* sort_spec: field_value "ASC"  */
2739
0
        {
2740
0
            context->poCurSelect->PushOrderBy( yyvsp[-1]->table_name, yyvsp[-1]->string_value, TRUE );
2741
0
            delete yyvsp[-1];
2742
0
            yyvsp[-1] = nullptr;
2743
0
        }
2744
0
    break;
2745
2746
0
  case 95: /* sort_spec: field_value "DESC"  */
2747
0
        {
2748
0
            context->poCurSelect->PushOrderBy( yyvsp[-1]->table_name, yyvsp[-1]->string_value, FALSE );
2749
0
            delete yyvsp[-1];
2750
0
            yyvsp[-1] = nullptr;
2751
0
        }
2752
0
    break;
2753
2754
0
  case 97: /* opt_limit: "LIMIT" "integer number"  */
2755
0
    {
2756
0
        context->poCurSelect->SetLimit( yyvsp[0]->int_value );
2757
0
        delete yyvsp[0];
2758
0
        yyvsp[0] = nullptr;
2759
0
    }
2760
0
    break;
2761
2762
0
  case 99: /* opt_offset: "OFFSET" "integer number"  */
2763
0
    {
2764
0
        context->poCurSelect->SetOffset( yyvsp[0]->int_value );
2765
0
        delete yyvsp[0];
2766
0
        yyvsp[0] = nullptr;
2767
0
    }
2768
0
    break;
2769
2770
0
  case 100: /* table_def: identifier  */
2771
0
    {
2772
0
        const int iTable =
2773
0
            context->poCurSelect->PushTableDef( nullptr, yyvsp[0]->string_value,
2774
0
                                                nullptr );
2775
0
        delete yyvsp[0];
2776
2777
0
        yyval = new swq_expr_node( iTable );
2778
0
    }
2779
0
    break;
2780
2781
0
  case 101: /* table_def: identifier as_clause  */
2782
0
    {
2783
0
        const int iTable =
2784
0
            context->poCurSelect->PushTableDef( nullptr, yyvsp[-1]->string_value,
2785
0
                                                yyvsp[0]->string_value );
2786
0
        delete yyvsp[-1];
2787
0
        delete yyvsp[0];
2788
2789
0
        yyval = new swq_expr_node( iTable );
2790
0
    }
2791
0
    break;
2792
2793
0
  case 102: /* table_def: "string" '.' identifier  */
2794
0
    {
2795
0
        const int iTable =
2796
0
            context->poCurSelect->PushTableDef( yyvsp[-2]->string_value,
2797
0
                                                yyvsp[0]->string_value, nullptr );
2798
0
        delete yyvsp[-2];
2799
0
        delete yyvsp[0];
2800
2801
0
        yyval = new swq_expr_node( iTable );
2802
0
    }
2803
0
    break;
2804
2805
0
  case 103: /* table_def: "string" '.' identifier as_clause  */
2806
0
    {
2807
0
        const int iTable =
2808
0
            context->poCurSelect->PushTableDef( yyvsp[-3]->string_value,
2809
0
                                                yyvsp[-1]->string_value,
2810
0
                                                yyvsp[0]->string_value );
2811
0
        delete yyvsp[-3];
2812
0
        delete yyvsp[-1];
2813
0
        delete yyvsp[0];
2814
2815
0
        yyval = new swq_expr_node( iTable );
2816
0
    }
2817
0
    break;
2818
2819
0
  case 104: /* table_def: identifier '.' identifier  */
2820
0
    {
2821
0
        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
0
    }
2829
0
    break;
2830
2831
0
  case 105: /* table_def: identifier '.' identifier as_clause  */
2832
0
    {
2833
0
        const int iTable =
2834
0
            context->poCurSelect->PushTableDef( yyvsp[-3]->string_value,
2835
0
                                                yyvsp[-1]->string_value,
2836
0
                                                yyvsp[0]->string_value );
2837
0
        delete yyvsp[-3];
2838
0
        delete yyvsp[-1];
2839
0
        delete yyvsp[0];
2840
2841
0
        yyval = new swq_expr_node( iTable );
2842
0
    }
2843
0
    break;
2844
2845
2846
2847
0
      default: break;
2848
0
    }
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
0
  YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
2861
2862
0
  YYPOPSTACK (yylen);
2863
0
  yylen = 0;
2864
2865
0
  *++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
0
  {
2871
0
    const int yylhs = yyr1[yyn] - YYNTOKENS;
2872
0
    const int yyi = yypgoto[yylhs] + *yyssp;
2873
0
    yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
2874
0
               ? yytable[yyi]
2875
0
               : yydefgoto[yylhs]);
2876
0
  }
2877
2878
0
  goto yynewstate;
2879
2880
2881
/*--------------------------------------.
2882
| yyerrlab -- here on detecting error.  |
2883
`--------------------------------------*/
2884
0
yyerrlab:
2885
  /* Make sure we have latest lookahead translation.  See comments at
2886
     user semantic actions for why this is necessary.  */
2887
0
  yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
2888
  /* If not already recovering from an error, report this error.  */
2889
0
  if (!yyerrstatus)
2890
0
    {
2891
0
      ++yynerrs; (void)yynerrs;
2892
0
      {
2893
0
        yypcontext_t yyctx
2894
0
          = {yyssp, yytoken};
2895
0
        char const *yymsgp = YY_("syntax error");
2896
0
        int yysyntax_error_status;
2897
0
        yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
2898
0
        if (yysyntax_error_status == 0)
2899
0
          yymsgp = yymsg;
2900
0
        else if (yysyntax_error_status == -1)
2901
0
          {
2902
0
            if (yymsg != yymsgbuf)
2903
0
              YYSTACK_FREE (yymsg);
2904
0
            yymsg = YY_CAST (char *,
2905
0
                             YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
2906
0
            if (yymsg)
2907
0
              {
2908
0
                yysyntax_error_status
2909
0
                  = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
2910
0
                yymsgp = yymsg;
2911
0
              }
2912
0
            else
2913
0
              {
2914
0
                yymsg = yymsgbuf;
2915
0
                yymsg_alloc = sizeof yymsgbuf;
2916
0
                yysyntax_error_status = YYENOMEM;
2917
0
              }
2918
0
          }
2919
0
        yyerror (context, yymsgp);
2920
0
        if (yysyntax_error_status == YYENOMEM)
2921
0
          YYNOMEM;
2922
0
      }
2923
0
    }
2924
2925
0
  if (yyerrstatus == 3)
2926
0
    {
2927
      /* If just tried and failed to reuse lookahead token after an
2928
         error, discard it.  */
2929
2930
0
      if (yychar <= END)
2931
0
        {
2932
          /* Return failure if at end of input.  */
2933
0
          if (yychar == END)
2934
0
            YYABORT;
2935
0
        }
2936
0
      else
2937
0
        {
2938
0
          yydestruct ("Error: discarding",
2939
0
                      yytoken, &yylval, context);
2940
0
          yychar = YYEMPTY;
2941
0
        }
2942
0
    }
2943
2944
  /* Else will try to reuse lookahead token after shifting the error
2945
     token.  */
2946
0
  goto yyerrlab1;
2947
2948
2949
/*---------------------------------------------------.
2950
| yyerrorlab -- error raised explicitly by YYERROR.  |
2951
`---------------------------------------------------*/
2952
0
yyerrorlab:
2953
  /* Pacify compilers when the user code never invokes YYERROR and the
2954
     label yyerrorlab therefore never appears in user code.  */
2955
0
  if (0)
2956
0
    YYERROR;
2957
0
  ++yynerrs; (void)yynerrs;
2958
2959
  /* Do not reclaim the symbols of the rule whose action triggered
2960
     this YYERROR.  */
2961
0
  YYPOPSTACK (yylen);
2962
0
  yylen = 0;
2963
0
  YY_STACK_PRINT (yyss, yyssp);
2964
0
  yystate = *yyssp;
2965
0
  goto yyerrlab1;
2966
2967
2968
/*-------------------------------------------------------------.
2969
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
2970
`-------------------------------------------------------------*/
2971
0
yyerrlab1:
2972
0
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
2973
2974
  /* Pop stack until we find a state that shifts the error token.  */
2975
0
  for (;;)
2976
0
    {
2977
0
      yyn = yypact[yystate];
2978
0
      if (!yypact_value_is_default (yyn))
2979
0
        {
2980
0
          yyn += YYSYMBOL_YYerror;
2981
0
          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
2982
0
            {
2983
0
              yyn = yytable[yyn];
2984
0
              if (0 < yyn)
2985
0
                break;
2986
0
            }
2987
0
        }
2988
2989
      /* Pop the current state because it cannot handle the error token.  */
2990
0
      if (yyssp == yyss)
2991
0
        YYABORT;
2992
2993
2994
0
      yydestruct ("Error: popping",
2995
0
                  YY_ACCESSING_SYMBOL (yystate), yyvsp, context);
2996
0
      YYPOPSTACK (1);
2997
0
      yystate = *yyssp;
2998
0
      YY_STACK_PRINT (yyss, yyssp);
2999
0
    }
3000
3001
0
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
3002
0
  *++yyvsp = yylval;
3003
0
  YY_IGNORE_MAYBE_UNINITIALIZED_END
3004
3005
3006
  /* Shift the error token.  */
3007
0
  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
0
yyacceptlab:
3017
0
  yyresult = 0;
3018
0
  goto yyreturnlab;
3019
3020
3021
/*-----------------------------------.
3022
| yyabortlab -- YYABORT comes here.  |
3023
`-----------------------------------*/
3024
0
yyabortlab:
3025
0
  yyresult = 1;
3026
0
  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
0
yyreturnlab:
3042
0
  if (yychar != YYEMPTY)
3043
0
    {
3044
      /* Make sure we have latest lookahead translation.  See comments at
3045
         user semantic actions for why this is necessary.  */
3046
0
      yytoken = YYTRANSLATE (yychar);
3047
0
      yydestruct ("Cleanup: discarding lookahead",
3048
0
                  yytoken, &yylval, context);
3049
0
    }
3050
  /* Do not reclaim the symbols of the rule whose action triggered
3051
     this YYABORT or YYACCEPT.  */
3052
0
  YYPOPSTACK (yylen);
3053
0
  YY_STACK_PRINT (yyss, yyssp);
3054
0
  while (yyssp != yyss)
3055
0
    {
3056
0
      yydestruct ("Cleanup: popping",
3057
0
                  YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, context);
3058
0
      YYPOPSTACK (1);
3059
0
    }
3060
0
#ifndef yyoverflow
3061
0
  if (yyss != yyssa)
3062
0
    YYSTACK_FREE (yyss);
3063
0
#endif
3064
0
  if (yymsg != yymsgbuf)
3065
0
    YYSTACK_FREE (yymsg);
3066
0
  return yyresult;
3067
0
}
3068