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