1 /* A Bison parser, made by GNU Bison 1.875b.  */
2 
3 /* Skeleton parser for Yacc-like parsing with Bison,
4    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place - Suite 330,
19    Boston, MA 02111-1307, USA.  */
20 
21 /* As a special exception, when this file is copied by Bison into a
22    Bison output file, you may use that output file without restriction.
23    This special exception was added by the Free Software Foundation
24    in version 1.24 of Bison.  */
25 
26 /* Written by Richard Stallman by simplifying the original so called
27    ``semantic'' parser.  */
28 
29 /* All symbols defined below should begin with yy or YY, to avoid
30    infringing on user name space.  This should be done even for local
31    variables, as they might otherwise be expanded by user macros.
32    There are some unavoidable exceptions within include files to
33    define necessary library symbols; they are noted "INFRINGES ON
34    USER NAME SPACE" below.  */
35 
36 /* Identify Bison output.  */
37 #define YYBISON 1
38 
39 /* Skeleton name.  */
40 #define YYSKELETON_NAME "yacc.c"
41 
42 /* Pure parsers.  */
43 #define YYPURE 1
44 
45 /* Using locations.  */
46 #define YYLSP_NEEDED 0
47 
48 
49 
50 /* Tokens.  */
51 #ifndef YYTOKENTYPE
52 # define YYTOKENTYPE
53    /* Put the tokens into the symbol table, so that GDB and other debuggers
54       know about them.  */
55    enum yytokentype {
56      NAME = 258,
57      STRING = 259,
58      NUM = 260,
59      NOT = 261,
60      AND = 262,
61      OR = 263,
62      EQ = 264,
63      NOTEQ = 265,
64      GT = 266,
65      GE = 267,
66      LT = 268,
67      LE = 269
68    };
69 #endif
70 #define NAME 258
71 #define STRING 259
72 #define NUM 260
73 #define NOT 261
74 #define AND 262
75 #define OR 263
76 #define EQ 264
77 #define NOTEQ 265
78 #define GT 266
79 #define GE 267
80 #define LT 268
81 #define LE 269
82 
83 
84 
85 
86 /* Copy the first part of user declarations.  */
87 #line 37 "bdb_query_bison.y"
88 
89 
90 #define YYSTYPE        CBDB_Query::TQueryClause*
91 #define YYPARSE_PARAM  parm
92 #define YYLEX_PARAM    parm
93 #define YYINITDEPTH    50
94 #define YYMAXDEPTH     1000
95 
96 #define YYDEBUG 1
97 
98 
99 /*
100     Utility function to save current yyparse result in the
101     parsing environment object (context).
102 */
103 inline static
BisonSaveStageResult(YYSTYPE res,void * parm)104 void BisonSaveStageResult(YYSTYPE res, void* parm)
105 {
106     CBDB_QueryParserEnvironment* env =
107           (CBDB_QueryParserEnvironment*) parm;
108     env->AttachQueryClause(res);
109     env->AddNodeToPool(res);
110 }
111 
112 
113 
114 
115 /* Enabling traces.  */
116 #ifndef YYDEBUG
117 # define YYDEBUG 0
118 #endif
119 
120 /* Enabling verbose error messages.  */
121 #ifdef YYERROR_VERBOSE
122 # undef YYERROR_VERBOSE
123 # define YYERROR_VERBOSE 1
124 #else
125 # define YYERROR_VERBOSE 0
126 #endif
127 
128 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
129 typedef int YYSTYPE;
130 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
131 # define YYSTYPE_IS_DECLARED 1
132 # define YYSTYPE_IS_TRIVIAL 1
133 #endif
134 
135 
136 
137 /* Copy the second part of user declarations.  */
138 
139 
140 /* Line 214 of yacc.c.  */
141 #line 142 "bdb_query_bison.tab.c"
142 
143 #if ! defined (yyoverflow) || YYERROR_VERBOSE
144 
145 /* The parser invokes alloca or malloc; define the necessary symbols.  */
146 
147 # if YYSTACK_USE_ALLOCA
148 #  define YYSTACK_ALLOC alloca
149 # else
150 #  ifndef YYSTACK_USE_ALLOCA
151 #   if defined (alloca) || defined (_ALLOCA_H)
152 #    define YYSTACK_ALLOC alloca
153 #   else
154 #    ifdef __GNUC__
155 #     define YYSTACK_ALLOC __builtin_alloca
156 #    endif
157 #   endif
158 #  endif
159 # endif
160 
161 # ifdef YYSTACK_ALLOC
162    /* Pacify GCC's `empty if-body' warning. */
163 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
164 # else
165 #  if defined (__STDC__) || defined (__cplusplus)
166 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
167 #   define YYSIZE_T size_t
168 #  endif
169 #  define YYSTACK_ALLOC malloc
170 #  define YYSTACK_FREE free
171 # endif
172 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
173 
174 
175 #if (! defined (yyoverflow) \
176      && (! defined (__cplusplus) \
177 	 || (YYSTYPE_IS_TRIVIAL)))
178 
179 /* A type that is properly aligned for any stack member.  */
180 union yyalloc
181 {
182   short yyss;
183   YYSTYPE yyvs;
184   };
185 
186 /* The size of the maximum gap between one aligned stack and the next.  */
187 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
188 
189 /* The size of an array large to enough to hold all stacks, each with
190    N elements.  */
191 # define YYSTACK_BYTES(N) \
192      ((N) * (sizeof (short) + sizeof (YYSTYPE))				\
193       + YYSTACK_GAP_MAXIMUM)
194 
195 /* Copy COUNT objects from FROM to TO.  The source and destination do
196    not overlap.  */
197 # ifndef YYCOPY
198 #  if 1 < __GNUC__
199 #   define YYCOPY(To, From, Count) \
200       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
201 #  else
202 #   define YYCOPY(To, From, Count)		\
203       do					\
204 	{					\
205 	  register YYSIZE_T yyi;		\
206 	  for (yyi = 0; yyi < (Count); yyi++)	\
207 	    (To)[yyi] = (From)[yyi];		\
208 	}					\
209       while (0)
210 #  endif
211 # endif
212 
213 /* Relocate STACK from its old location to the new one.  The
214    local variables YYSIZE and YYSTACKSIZE give the old and new number of
215    elements in the stack, and YYPTR gives the new location of the
216    stack.  Advance YYPTR to a properly aligned location for the next
217    stack.  */
218 # define YYSTACK_RELOCATE(Stack)					\
219     do									\
220       {									\
221 	YYSIZE_T yynewbytes;						\
222 	YYCOPY (&yyptr->Stack, Stack, yysize);				\
223 	Stack = &yyptr->Stack;						\
224 	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
225 	yyptr += yynewbytes / sizeof (*yyptr);				\
226       }									\
227     while (0)
228 
229 #endif
230 
231 #if defined (__STDC__) || defined (__cplusplus)
232    typedef signed char yysigned_char;
233 #else
234    typedef short yysigned_char;
235 #endif
236 
237 /* YYFINAL -- State number of the termination state. */
238 #define YYFINAL  10
239 /* YYLAST -- Last index in YYTABLE.  */
240 #define YYLAST   60
241 
242 /* YYNTOKENS -- Number of terminals. */
243 #define YYNTOKENS  17
244 /* YYNNTS -- Number of nonterminals. */
245 #define YYNNTS  3
246 /* YYNRULES -- Number of rules. */
247 #define YYNRULES  15
248 /* YYNRULES -- Number of states. */
249 #define YYNSTATES  28
250 
251 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
252 #define YYUNDEFTOK  2
253 #define YYMAXUTOK   269
254 
255 #define YYTRANSLATE(YYX) 						\
256   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
257 
258 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
259 static const unsigned char yytranslate[] =
260 {
261        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
262        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
263        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
264        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
265       15,    16,     2,     2,     2,     2,     2,     2,     2,     2,
266        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
267        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
268        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
269        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
270        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
271        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
272        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
273        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
274        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
275        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
276        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
277        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
278        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
279        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
280        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
281        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
282        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
283        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
284        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
285        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
286        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
287        5,     6,     7,     8,     9,    10,    11,    12,    13,    14
288 };
289 
290 #if YYDEBUG
291 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
292    YYRHS.  */
293 static const unsigned char yyprhs[] =
294 {
295        0,     0,     3,     5,     7,     9,    11,    15,    19,    23,
296       27,    31,    35,    39,    43,    47
297 };
298 
299 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
300 static const yysigned_char yyrhs[] =
301 {
302       18,     0,    -1,    19,    -1,     5,    -1,     4,    -1,     3,
303       -1,    19,     7,    19,    -1,    19,     8,    19,    -1,    19,
304        9,    19,    -1,    19,    10,    19,    -1,    19,    11,    19,
305       -1,    19,    12,    19,    -1,    19,    13,    19,    -1,    19,
306       14,    19,    -1,    15,    19,    16,    -1,     6,    19,    -1
307 };
308 
309 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
310 static const unsigned char yyrline[] =
311 {
312        0,    89,    89,   102,   106,   110,   114,   119,   124,   129,
313      135,   140,   145,   150,   155,   159
314 };
315 #endif
316 
317 #if YYDEBUG || YYERROR_VERBOSE
318 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
319    First, the terminals, then, starting at YYNTOKENS, nonterminals. */
320 static const char *const yytname[] =
321 {
322   "$end", "error", "$undefined", "NAME", "STRING", "NUM", "NOT", "AND",
323   "OR", "EQ", "NOTEQ", "GT", "GE", "LT", "LE", "'('", "')'", "$accept",
324   "input", "exp", 0
325 };
326 #endif
327 
328 # ifdef YYPRINT
329 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
330    token YYLEX-NUM.  */
331 static const unsigned short yytoknum[] =
332 {
333        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
334      265,   266,   267,   268,   269,    40,    41
335 };
336 # endif
337 
338 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
339 static const unsigned char yyr1[] =
340 {
341        0,    17,    18,    19,    19,    19,    19,    19,    19,    19,
342       19,    19,    19,    19,    19,    19
343 };
344 
345 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
346 static const unsigned char yyr2[] =
347 {
348        0,     2,     1,     1,     1,     1,     3,     3,     3,     3,
349        3,     3,     3,     3,     3,     2
350 };
351 
352 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
353    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
354    means the default is an error.  */
355 static const unsigned char yydefact[] =
356 {
357        0,     5,     4,     3,     0,     0,     0,     2,    15,     0,
358        1,     0,     0,     0,     0,     0,     0,     0,     0,    14,
359        6,     7,     8,     9,    10,    11,    12,    13
360 };
361 
362 /* YYDEFGOTO[NTERM-NUM]. */
363 static const yysigned_char yydefgoto[] =
364 {
365       -1,     6,     7
366 };
367 
368 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
369    STATE-NUM.  */
370 #define YYPACT_NINF -5
371 static const yysigned_char yypact[] =
372 {
373        0,    -5,    -5,    -5,     0,     0,     2,    19,    19,     9,
374       -5,     0,     0,     0,     0,     0,     0,     0,     0,    -5,
375       26,    32,    37,    41,    44,    46,    10,    -5
376 };
377 
378 /* YYPGOTO[NTERM-NUM].  */
379 static const yysigned_char yypgoto[] =
380 {
381       -5,    -5,    -4
382 };
383 
384 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
385    positive, shift that token.  If negative, reduce the rule which
386    number is the opposite.  If zero, do what YYDEFACT says.
387    If YYTABLE_NINF, syntax error.  */
388 #define YYTABLE_NINF -1
389 static const unsigned char yytable[] =
390 {
391        8,     9,    10,     1,     2,     3,     4,    20,    21,    22,
392       23,    24,    25,    26,    27,     5,    11,    12,    13,    14,
393       15,    16,    17,    18,    18,    19,    11,    12,    13,    14,
394       15,    16,    17,    18,    12,    13,    14,    15,    16,    17,
395       18,    13,    14,    15,    16,    17,    18,    14,    15,    16,
396       17,    18,    15,    16,    17,    18,    16,    17,    18,    17,
397       18
398 };
399 
400 static const unsigned char yycheck[] =
401 {
402        4,     5,     0,     3,     4,     5,     6,    11,    12,    13,
403       14,    15,    16,    17,    18,    15,     7,     8,     9,    10,
404       11,    12,    13,    14,    14,    16,     7,     8,     9,    10,
405       11,    12,    13,    14,     8,     9,    10,    11,    12,    13,
406       14,     9,    10,    11,    12,    13,    14,    10,    11,    12,
407       13,    14,    11,    12,    13,    14,    12,    13,    14,    13,
408       14
409 };
410 
411 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
412    symbol of state STATE-NUM.  */
413 static const unsigned char yystos[] =
414 {
415        0,     3,     4,     5,     6,    15,    18,    19,    19,    19,
416        0,     7,     8,     9,    10,    11,    12,    13,    14,    16,
417       19,    19,    19,    19,    19,    19,    19,    19
418 };
419 
420 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
421 # define YYSIZE_T __SIZE_TYPE__
422 #endif
423 #if ! defined (YYSIZE_T) && defined (size_t)
424 # define YYSIZE_T size_t
425 #endif
426 #if ! defined (YYSIZE_T)
427 # if defined (__STDC__) || defined (__cplusplus)
428 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
429 #  define YYSIZE_T size_t
430 # endif
431 #endif
432 #if ! defined (YYSIZE_T)
433 # define YYSIZE_T unsigned int
434 #endif
435 
436 #define yyerrok		(yyerrstatus = 0)
437 #define yyclearin	(yychar = YYEMPTY)
438 #define YYEMPTY		(-2)
439 #define YYEOF		0
440 
441 #define YYACCEPT	goto yyacceptlab
442 #define YYABORT		goto yyabortlab
443 #define YYERROR		goto yyerrlab1
444 
445 
446 /* Like YYERROR except do call yyerror.  This remains here temporarily
447    to ease the transition to the new meaning of YYERROR, for GCC.
448    Once GCC version 2 has supplanted version 1, this can go.  */
449 
450 #define YYFAIL		goto yyerrlab
451 
452 #define YYRECOVERING()  (!!yyerrstatus)
453 
454 #define YYBACKUP(Token, Value)					\
455 do								\
456   if (yychar == YYEMPTY && yylen == 1)				\
457     {								\
458       yychar = (Token);						\
459       yylval = (Value);						\
460       yytoken = YYTRANSLATE (yychar);				\
461       YYPOPSTACK;						\
462       goto yybackup;						\
463     }								\
464   else								\
465     { 								\
466       yyerror ("syntax error: cannot back up");\
467       YYERROR;							\
468     }								\
469 while (0)
470 
471 #define YYTERROR	1
472 #define YYERRCODE	256
473 
474 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
475    are run).  */
476 
477 #ifndef YYLLOC_DEFAULT
478 # define YYLLOC_DEFAULT(Current, Rhs, N)         \
479   Current.first_line   = Rhs[1].first_line;      \
480   Current.first_column = Rhs[1].first_column;    \
481   Current.last_line    = Rhs[N].last_line;       \
482   Current.last_column  = Rhs[N].last_column;
483 #endif
484 
485 /* YYLEX -- calling `yylex' with the right arguments.  */
486 
487 #ifdef YYLEX_PARAM
488 # define YYLEX yylex (&yylval, YYLEX_PARAM)
489 #else
490 # define YYLEX yylex (&yylval)
491 #endif
492 
493 /* Enable debugging if requested.  */
494 #if YYDEBUG
495 
496 # ifndef YYFPRINTF
497 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
498 #  define YYFPRINTF fprintf
499 # endif
500 
501 # define YYDPRINTF(Args)			\
502 do {						\
503   if (yydebug)					\
504     YYFPRINTF Args;				\
505 } while (0)
506 
507 # define YYDSYMPRINT(Args)			\
508 do {						\
509   if (yydebug)					\
510     yysymprint Args;				\
511 } while (0)
512 
513 # define YYDSYMPRINTF(Title, Token, Value, Location)		\
514 do {								\
515   if (yydebug)							\
516     {								\
517       YYFPRINTF (stderr, "%s ", Title);				\
518       yysymprint (stderr, 					\
519                   Token, Value);	\
520       YYFPRINTF (stderr, "\n");					\
521     }								\
522 } while (0)
523 
524 /*------------------------------------------------------------------.
525 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
526 | TOP (cinluded).                                                   |
527 `------------------------------------------------------------------*/
528 
529 #if defined (__STDC__) || defined (__cplusplus)
530 static void
yy_stack_print(short * bottom,short * top)531 yy_stack_print (short *bottom, short *top)
532 #else
533 static void
534 yy_stack_print (bottom, top)
535     short *bottom;
536     short *top;
537 #endif
538 {
539   YYFPRINTF (stderr, "Stack now");
540   for (/* Nothing. */; bottom <= top; ++bottom)
541     YYFPRINTF (stderr, " %d", *bottom);
542   YYFPRINTF (stderr, "\n");
543 }
544 
545 # define YY_STACK_PRINT(Bottom, Top)				\
546 do {								\
547   if (yydebug)							\
548     yy_stack_print ((Bottom), (Top));				\
549 } while (0)
550 
551 
552 /*------------------------------------------------.
553 | Report that the YYRULE is going to be reduced.  |
554 `------------------------------------------------*/
555 
556 #if defined (__STDC__) || defined (__cplusplus)
557 static void
yy_reduce_print(int yyrule)558 yy_reduce_print (int yyrule)
559 #else
560 static void
561 yy_reduce_print (yyrule)
562     int yyrule;
563 #endif
564 {
565   int yyi;
566   unsigned int yylno = yyrline[yyrule];
567   YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
568              yyrule - 1, yylno);
569   /* Print the symbols being reduced, and their result.  */
570   for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
571     YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
572   YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
573 }
574 
575 # define YY_REDUCE_PRINT(Rule)		\
576 do {					\
577   if (yydebug)				\
578     yy_reduce_print (Rule);		\
579 } while (0)
580 
581 /* Nonzero means print parse trace.  It is left uninitialized so that
582    multiple parsers can coexist.  */
583 int yydebug;
584 #else /* !YYDEBUG */
585 # define YYDPRINTF(Args)
586 # define YYDSYMPRINT(Args)
587 # define YYDSYMPRINTF(Title, Token, Value, Location)
588 # define YY_STACK_PRINT(Bottom, Top)
589 # define YY_REDUCE_PRINT(Rule)
590 #endif /* !YYDEBUG */
591 
592 
593 /* YYINITDEPTH -- initial size of the parser's stacks.  */
594 #ifndef	YYINITDEPTH
595 # define YYINITDEPTH 200
596 #endif
597 
598 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
599    if the built-in stack extension method is used).
600 
601    Do not make this value too large; the results are undefined if
602    SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
603    evaluated with infinite-precision integer arithmetic.  */
604 
605 #if YYMAXDEPTH == 0
606 # undef YYMAXDEPTH
607 #endif
608 
609 #ifndef YYMAXDEPTH
610 # define YYMAXDEPTH 10000
611 #endif
612 
613 
614 
615 #if YYERROR_VERBOSE
616 
617 # ifndef yystrlen
618 #  if defined (__GLIBC__) && defined (_STRING_H)
619 #   define yystrlen strlen
620 #  else
621 /* Return the length of YYSTR.  */
622 static YYSIZE_T
623 #   if defined (__STDC__) || defined (__cplusplus)
yystrlen(const char * yystr)624 yystrlen (const char *yystr)
625 #   else
626 yystrlen (yystr)
627      const char *yystr;
628 #   endif
629 {
630   register const char *yys = yystr;
631 
632   while (*yys++ != '\0')
633     continue;
634 
635   return yys - yystr - 1;
636 }
637 #  endif
638 # endif
639 
640 # ifndef yystpcpy
641 #  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
642 #   define yystpcpy stpcpy
643 #  else
644 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
645    YYDEST.  */
646 static char *
647 #   if defined (__STDC__) || defined (__cplusplus)
yystpcpy(char * yydest,const char * yysrc)648 yystpcpy (char *yydest, const char *yysrc)
649 #   else
650 yystpcpy (yydest, yysrc)
651      char *yydest;
652      const char *yysrc;
653 #   endif
654 {
655   register char *yyd = yydest;
656   register const char *yys = yysrc;
657 
658   while ((*yyd++ = *yys++) != '\0')
659     continue;
660 
661   return yyd - 1;
662 }
663 #  endif
664 # endif
665 
666 #endif /* !YYERROR_VERBOSE */
667 
668 
669 
670 #if YYDEBUG
671 /*--------------------------------.
672 | Print this symbol on YYOUTPUT.  |
673 `--------------------------------*/
674 
675 #if defined (__STDC__) || defined (__cplusplus)
676 static void
yysymprint(FILE * yyoutput,int yytype,YYSTYPE * yyvaluep)677 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
678 #else
679 static void
680 yysymprint (yyoutput, yytype, yyvaluep)
681     FILE *yyoutput;
682     int yytype;
683     YYSTYPE *yyvaluep;
684 #endif
685 {
686   /* Pacify ``unused variable'' warnings.  */
687   (void) yyvaluep;
688 
689   if (yytype < YYNTOKENS)
690     {
691       YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
692 # ifdef YYPRINT
693       YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
694 # endif
695     }
696   else
697     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
698 
699   switch (yytype)
700     {
701       default:
702         break;
703     }
704   YYFPRINTF (yyoutput, ")");
705 }
706 
707 #endif /* ! YYDEBUG */
708 /*-----------------------------------------------.
709 | Release the memory associated to this symbol.  |
710 `-----------------------------------------------*/
711 
712 #if defined (__STDC__) || defined (__cplusplus)
713 static void
yydestruct(int yytype,YYSTYPE * yyvaluep)714 yydestruct (int yytype, YYSTYPE *yyvaluep)
715 #else
716 static void
717 yydestruct (yytype, yyvaluep)
718     int yytype;
719     YYSTYPE *yyvaluep;
720 #endif
721 {
722   /* Pacify ``unused variable'' warnings.  */
723   (void) yyvaluep;
724 
725   switch (yytype)
726     {
727 
728       default:
729         break;
730     }
731 }
732 
733 
734 /* Prevent warnings from -Wmissing-prototypes.  */
735 
736 #ifdef YYPARSE_PARAM
737 # if defined (__STDC__) || defined (__cplusplus)
738 int yyparse (void *YYPARSE_PARAM);
739 # else
740 int yyparse ();
741 # endif
742 #else /* ! YYPARSE_PARAM */
743 #if defined (__STDC__) || defined (__cplusplus)
744 int yyparse (void);
745 #else
746 int yyparse ();
747 #endif
748 #endif /* ! YYPARSE_PARAM */
749 
750 
751 
752 
753 
754 
755 /*----------.
756 | yyparse.  |
757 `----------*/
758 
759 #ifdef YYPARSE_PARAM
760 # if defined (__STDC__) || defined (__cplusplus)
yyparse(void * YYPARSE_PARAM)761 int yyparse (void *YYPARSE_PARAM)
762 # else
763 int yyparse (YYPARSE_PARAM)
764   void *YYPARSE_PARAM;
765 # endif
766 #else /* ! YYPARSE_PARAM */
767 #if defined (__STDC__) || defined (__cplusplus)
768 int
769 yyparse (void)
770 #else
771 int
772 yyparse ()
773 
774 #endif
775 #endif
776 {
777   /* The lookahead symbol.  */
778 int yychar;
779 
780 /* The semantic value of the lookahead symbol.  */
781 YYSTYPE yylval = 0;
782 
783 /* Number of syntax errors so far.  */
784 int yynerrs;
785 
786   register int yystate;
787   register int yyn;
788   int yyresult;
789   /* Number of tokens to shift before error messages enabled.  */
790   int yyerrstatus;
791   /* Lookahead token as an internal (translated) token number.  */
792   int yytoken = 0;
793 
794   /* Three stacks and their tools:
795      `yyss': related to states,
796      `yyvs': related to semantic values,
797      `yyls': related to locations.
798 
799      Refer to the stacks thru separate pointers, to allow yyoverflow
800      to reallocate them elsewhere.  */
801 
802   /* The state stack.  */
803   short	yyssa[YYINITDEPTH];
804   short *yyss = yyssa;
805   register short *yyssp;
806 
807   /* The semantic value stack.  */
808   YYSTYPE yyvsa[YYINITDEPTH];
809   YYSTYPE *yyvs = yyvsa;
810   register YYSTYPE *yyvsp;
811 
812 
813 
814 #define YYPOPSTACK   (yyvsp--, yyssp--)
815 
816   YYSIZE_T yystacksize = YYINITDEPTH;
817 
818   /* The variables used to return semantic value and location from the
819      action routines.  */
820   YYSTYPE yyval = 0;
821 
822 
823   /* When reducing, the number of symbols on the RHS of the reduced
824      rule.  */
825   int yylen;
826 
827   YYDPRINTF ((stderr, "Starting parse\n"));
828 
829   yystate = 0;
830   yyerrstatus = 0;
831   yynerrs = 0;
832   yychar = YYEMPTY;		/* Cause a token to be read.  */
833 
834   /* Initialize stack pointers.
835      Waste one element of value and location stack
836      so that they stay on the same level as the state stack.
837      The wasted elements are never initialized.  */
838 
839   yyssp = yyss;
840   yyvsp = yyvs;
841 
842   goto yysetstate;
843 
844 /*------------------------------------------------------------.
845 | yynewstate -- Push a new state, which is found in yystate.  |
846 `------------------------------------------------------------*/
847  yynewstate:
848   /* In all cases, when you get here, the value and location stacks
849      have just been pushed. so pushing a state here evens the stacks.
850      */
851   yyssp++;
852 
853  yysetstate:
854   *yyssp = (short)yystate;
855 
856   if (yyss + yystacksize - 1 <= yyssp)
857     {
858       /* Get the current used size of the three stacks, in elements.  */
859       YYSIZE_T yysize = yyssp - yyss + 1;
860 
861 #ifdef yyoverflow
862       {
863 	/* Give user a chance to reallocate the stack. Use copies of
864 	   these so that the &'s don't force the real ones into
865 	   memory.  */
866 	YYSTYPE *yyvs1 = yyvs;
867 	short *yyss1 = yyss;
868 
869 
870 	/* Each stack pointer address is followed by the size of the
871 	   data in use in that stack, in bytes.  This used to be a
872 	   conditional around just the two extra args, but that might
873 	   be undefined if yyoverflow is a macro.  */
874 	yyoverflow ("parser stack overflow",
875 		    &yyss1, yysize * sizeof (*yyssp),
876 		    &yyvs1, yysize * sizeof (*yyvsp),
877 
878 		    &yystacksize);
879 
880 	yyss = yyss1;
881 	yyvs = yyvs1;
882       }
883 #else /* no yyoverflow */
884 # ifndef YYSTACK_RELOCATE
885       goto yyoverflowlab;
886 # else
887       /* Extend the stack our own way.  */
888       if (YYMAXDEPTH <= yystacksize)
889 	goto yyoverflowlab;
890       yystacksize *= 2;
891       if (YYMAXDEPTH < yystacksize)
892 	yystacksize = YYMAXDEPTH;
893 
894       {
895 	short *yyss1 = yyss;
896 	union yyalloc *yyptr =
897 	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
898 	if (! yyptr)
899 	  goto yyoverflowlab;
900 	YYSTACK_RELOCATE (yyss);
901 	YYSTACK_RELOCATE (yyvs);
902 
903 #  undef YYSTACK_RELOCATE
904 	if (yyss1 != yyssa)
905 	  YYSTACK_FREE (yyss1);
906       }
907 # endif
908 #endif /* no yyoverflow */
909 
910       yyssp = yyss + yysize - 1;
911       yyvsp = yyvs + yysize - 1;
912 
913 
914       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
915 		  (unsigned long int) yystacksize));
916 
917       if (yyss + yystacksize - 1 <= yyssp)
918 	YYABORT;
919     }
920 
921   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
922 
923   goto yybackup;
924 
925 /*-----------.
926 | yybackup.  |
927 `-----------*/
928 yybackup:
929 
930 /* Do appropriate processing given the current state.  */
931 /* Read a lookahead token if we need one and don't already have one.  */
932 /* yyresume: */
933 
934   /* First try to decide what to do without reference to lookahead token.  */
935 
936   yyn = yypact[yystate];
937   if (yyn == YYPACT_NINF)
938     goto yydefault;
939 
940   /* Not known => get a lookahead token if don't already have one.  */
941 
942   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
943   if (yychar == YYEMPTY)
944     {
945       YYDPRINTF ((stderr, "Reading a token: "));
946       yychar = YYLEX;
947     }
948 
949   if (yychar <= YYEOF)
950     {
951       yychar = yytoken = YYEOF;
952       YYDPRINTF ((stderr, "Now at end of input.\n"));
953     }
954   else
955     {
956       yytoken = YYTRANSLATE (yychar);
957       YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
958     }
959 
960   /* If the proper action on seeing token YYTOKEN is to reduce or to
961      detect an error, take that action.  */
962   yyn += yytoken;
963   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
964     goto yydefault;
965   yyn = yytable[yyn];
966   if (yyn <= 0)
967     {
968       if (yyn == 0 || yyn == YYTABLE_NINF)
969 	goto yyerrlab;
970       yyn = -yyn;
971       goto yyreduce;
972     }
973 
974   if (yyn == YYFINAL)
975     YYACCEPT;
976 
977   /* Shift the lookahead token.  */
978   YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
979 
980   /* Discard the token being shifted unless it is eof.  */
981   if (yychar != YYEOF)
982     yychar = YYEMPTY;
983 
984   *++yyvsp = yylval;
985 
986 
987   /* Count tokens shifted since error; after three, turn off error
988      status.  */
989   if (yyerrstatus)
990     yyerrstatus--;
991 
992   yystate = yyn;
993   goto yynewstate;
994 
995 
996 /*-----------------------------------------------------------.
997 | yydefault -- do the default action for the current state.  |
998 `-----------------------------------------------------------*/
999 yydefault:
1000   yyn = yydefact[yystate];
1001   if (yyn == 0)
1002     goto yyerrlab;
1003   goto yyreduce;
1004 
1005 
1006 /*-----------------------------.
1007 | yyreduce -- Do a reduction.  |
1008 `-----------------------------*/
1009 yyreduce:
1010   /* yyn is the number of a rule to reduce with.  */
1011   yylen = yyr2[yyn];
1012 
1013   /* If YYLEN is nonzero, implement the default value of the action:
1014      `$$ = $1'.
1015 
1016      Otherwise, the following line sets YYVAL to garbage.
1017      This behavior is undocumented and Bison
1018      users should not rely upon it.  Assigning to YYVAL
1019      unconditionally makes the parser a bit smaller, and it avoids a
1020      GCC warning that YYVAL may be used uninitialized.  */
1021   yyval = yyvsp[1-yylen];
1022 
1023 
1024   YY_REDUCE_PRINT (yyn);
1025   switch (yyn)
1026     {
1027         case 3:
1028 #line 103 "bdb_query_bison.y"
1029     {
1030             yyval = yyvsp[0];
1031         ;}
1032     break;
1033 
1034   case 4:
1035 #line 107 "bdb_query_bison.y"
1036     {
1037             yyval = yyvsp[0];
1038         ;}
1039     break;
1040 
1041   case 5:
1042 #line 111 "bdb_query_bison.y"
1043     {
1044             yyval = yyvsp[0];
1045         ;}
1046     break;
1047 
1048   case 6:
1049 #line 115 "bdb_query_bison.y"
1050     {
1051             yyval = CBDB_Query::NewLogicalNode(CBDB_QueryNode::eAnd, yyvsp[-2], yyvsp[0]);
1052             BisonSaveStageResult(yyval, parm);
1053         ;}
1054     break;
1055 
1056   case 7:
1057 #line 120 "bdb_query_bison.y"
1058     {
1059             yyval = CBDB_Query::NewLogicalNode(CBDB_QueryNode::eOr, yyvsp[-2], yyvsp[0]);
1060             BisonSaveStageResult(yyval, parm);
1061         ;}
1062     break;
1063 
1064   case 8:
1065 #line 125 "bdb_query_bison.y"
1066     {
1067             yyval = CBDB_Query::NewOperatorNode(CBDB_QueryNode::eEQ, yyvsp[-2], yyvsp[0]);
1068             BisonSaveStageResult(yyval, parm);
1069         ;}
1070     break;
1071 
1072   case 9:
1073 #line 130 "bdb_query_bison.y"
1074     {
1075             yyval = CBDB_Query::NewOperatorNode(CBDB_QueryNode::eEQ, yyvsp[-2], yyvsp[0]);
1076             yyval->GetValue().SetNot();
1077             BisonSaveStageResult(yyval, parm);
1078         ;}
1079     break;
1080 
1081   case 10:
1082 #line 136 "bdb_query_bison.y"
1083     {
1084             yyval = CBDB_Query::NewOperatorNode(CBDB_QueryNode::eGT, yyvsp[-2], yyvsp[0]);
1085             BisonSaveStageResult(yyval, parm);
1086         ;}
1087     break;
1088 
1089   case 11:
1090 #line 141 "bdb_query_bison.y"
1091     {
1092             yyval = CBDB_Query::NewOperatorNode(CBDB_QueryNode::eGE, yyvsp[-2], yyvsp[0]);
1093             BisonSaveStageResult(yyval, parm);
1094         ;}
1095     break;
1096 
1097   case 12:
1098 #line 146 "bdb_query_bison.y"
1099     {
1100             yyval = CBDB_Query::NewOperatorNode(CBDB_QueryNode::eLT, yyvsp[-2], yyvsp[0]);
1101             BisonSaveStageResult(yyval, parm);
1102         ;}
1103     break;
1104 
1105   case 13:
1106 #line 151 "bdb_query_bison.y"
1107     {
1108             yyval = CBDB_Query::NewOperatorNode(CBDB_QueryNode::eLE, yyvsp[-2], yyvsp[0]);
1109             BisonSaveStageResult(yyval, parm);
1110         ;}
1111     break;
1112 
1113   case 14:
1114 #line 156 "bdb_query_bison.y"
1115     {
1116             yyval = yyvsp[-1];
1117         ;}
1118     break;
1119 
1120   case 15:
1121 #line 160 "bdb_query_bison.y"
1122     {
1123             yyval = CBDB_Query::NewLogicalNode(CBDB_QueryNode::eNot, yyvsp[0], 0);
1124             BisonSaveStageResult(yyval, parm);
1125         ;}
1126     break;
1127 
1128 
1129     }
1130 
1131 /* Line 999 of yacc.c.  */
1132 #line 1133 "bdb_query_bison.tab.c"
1133 
1134   yyvsp -= yylen;
1135   yyssp -= yylen;
1136 
1137 
1138   YY_STACK_PRINT (yyss, yyssp);
1139 
1140   *++yyvsp = yyval;
1141 
1142 
1143   /* Now `shift' the result of the reduction.  Determine what state
1144      that goes to, based on the state we popped back to and the rule
1145      number reduced by.  */
1146 
1147   yyn = yyr1[yyn];
1148 
1149   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1150   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1151     yystate = yytable[yystate];
1152   else
1153     yystate = yydefgoto[yyn - YYNTOKENS];
1154 
1155   goto yynewstate;
1156 
1157 
1158 /*------------------------------------.
1159 | yyerrlab -- here on detecting error |
1160 `------------------------------------*/
1161 yyerrlab:
1162   /* If not already recovering from an error, report this error.  */
1163   if (!yyerrstatus)
1164     {
1165       ++yynerrs;
1166 #if YYERROR_VERBOSE
1167       yyn = yypact[yystate];
1168 
1169       if (YYPACT_NINF < yyn && yyn < YYLAST)
1170 	{
1171 	  YYSIZE_T yysize = 0;
1172 	  int yytype = YYTRANSLATE (yychar);
1173 	  const char* yyprefix;
1174 	  char *yymsg;
1175 	  int yyx;
1176 
1177 	  /* Start YYX at -YYN if negative to avoid negative indexes in
1178 	     YYCHECK.  */
1179 	  int yyxbegin = yyn < 0 ? -yyn : 0;
1180 
1181 	  /* Stay within bounds of both yycheck and yytname.  */
1182 	  int yychecklim = YYLAST - yyn;
1183 	  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1184 	  int yycount = 0;
1185 
1186 	  yyprefix = ", expecting ";
1187 	  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1188 	    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1189 	      {
1190 		yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
1191 		yycount += 1;
1192 		if (yycount == 5)
1193 		  {
1194 		    yysize = 0;
1195 		    break;
1196 		  }
1197 	      }
1198 	  yysize += (sizeof ("syntax error, unexpected ")
1199 		     + yystrlen (yytname[yytype]));
1200 	  yymsg = (char *) YYSTACK_ALLOC (yysize);
1201 	  if (yymsg != 0)
1202 	    {
1203 	      char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1204 	      yyp = yystpcpy (yyp, yytname[yytype]);
1205 
1206 	      if (yycount < 5)
1207 		{
1208 		  yyprefix = ", expecting ";
1209 		  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1210 		    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1211 		      {
1212 			yyp = yystpcpy (yyp, yyprefix);
1213 			yyp = yystpcpy (yyp, yytname[yyx]);
1214 			yyprefix = " or ";
1215 		      }
1216 		}
1217 	      yyerror (yymsg);
1218 	      YYSTACK_FREE (yymsg);
1219 	    }
1220 	  else
1221 	    yyerror ("syntax error; also virtual memory exhausted");
1222 	}
1223       else
1224 #endif /* YYERROR_VERBOSE */
1225 	yyerror ("syntax error");
1226     }
1227 
1228 
1229 
1230   if (yyerrstatus == 3)
1231     {
1232       /* If just tried and failed to reuse lookahead token after an
1233 	 error, discard it.  */
1234 
1235       /* Return failure if at end of input.  */
1236       if (yychar == YYEOF)
1237         {
1238 	  /* Pop the error token.  */
1239           YYPOPSTACK;
1240 	  /* Pop the rest of the stack.  */
1241 	  while (yyss < yyssp)
1242 	    {
1243 	      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1244 	      yydestruct (yystos[*yyssp], yyvsp);
1245 	      YYPOPSTACK;
1246 	    }
1247 	  YYABORT;
1248         }
1249 
1250       YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1251       yydestruct (yytoken, &yylval);
1252       yychar = YYEMPTY;
1253 
1254     }
1255 
1256   /* Else will try to reuse lookahead token after shifting the error
1257      token.  */
1258   goto yyerrlab1;
1259 
1260 
1261 /*----------------------------------------------------.
1262 | yyerrlab1 -- error raised explicitly by an action.  |
1263 `----------------------------------------------------*/
1264 yyerrlab1:
1265   yyerrstatus = 3;	/* Each real token shifted decrements this.  */
1266 
1267   for (;;)
1268     {
1269       yyn = yypact[yystate];
1270       if (yyn != YYPACT_NINF)
1271 	{
1272 	  yyn += YYTERROR;
1273 	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1274 	    {
1275 	      yyn = yytable[yyn];
1276 	      if (0 < yyn)
1277 		break;
1278 	    }
1279 	}
1280 
1281       /* Pop the current state because it cannot handle the error token.  */
1282       if (yyssp == yyss)
1283 	YYABORT;
1284 
1285       YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1286       yydestruct (yystos[yystate], yyvsp);
1287       yyvsp--;
1288       yystate = *--yyssp;
1289 
1290       YY_STACK_PRINT (yyss, yyssp);
1291     }
1292 
1293   if (yyn == YYFINAL)
1294     YYACCEPT;
1295 
1296   YYDPRINTF ((stderr, "Shifting error token, "));
1297 
1298   *++yyvsp = yylval;
1299 
1300 
1301   yystate = yyn;
1302   goto yynewstate;
1303 
1304 
1305 /*-------------------------------------.
1306 | yyacceptlab -- YYACCEPT comes here.  |
1307 `-------------------------------------*/
1308 yyacceptlab:
1309   yyresult = 0;
1310   goto yyreturn;
1311 
1312 /*-----------------------------------.
1313 | yyabortlab -- YYABORT comes here.  |
1314 `-----------------------------------*/
1315 yyabortlab:
1316   yyresult = 1;
1317   goto yyreturn;
1318 
1319 #ifndef yyoverflow
1320 /*----------------------------------------------.
1321 | yyoverflowlab -- parser overflow comes here.  |
1322 `----------------------------------------------*/
1323 yyoverflowlab:
1324   yyerror ("parser stack overflow");
1325   yyresult = 2;
1326   /* Fall through.  */
1327 #endif
1328 
1329 yyreturn:
1330 #ifndef yyoverflow
1331   if (yyss != yyssa)
1332     YYSTACK_FREE (yyss);
1333 #endif
1334   return yyresult;
1335 }
1336 
1337 
1338 #line 166 "bdb_query_bison.y"
1339 
1340 
1341 
1342