MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fts0pars.cc
1 /* A Bison parser, made by GNU Bison 2.5. */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 /* As a special exception, you may create a larger work that contains
21  part or all of the Bison parser skeleton and distribute that work
22  under terms of your choice, so long as that work isn't itself a
23  parser generator using the skeleton or a modified version thereof
24  as a parser skeleton. Alternatively, if you modify or redistribute
25  the parser skeleton itself, you may (at your option) remove this
26  special exception, which will cause the skeleton and the resulting
27  Bison output files to be licensed under the GNU General Public
28  License without this special exception.
29 
30  This special exception was added by the Free Software Foundation in
31  version 2.2 of Bison. */
32 
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34  simplifying the original so-called "semantic" parser. */
35 
36 /* All symbols defined below should begin with yy or YY, to avoid
37  infringing on user name space. This should be done even for local
38  variables, as they might otherwise be expanded by user macros.
39  There are some unavoidable exceptions within include files to
40  define necessary library symbols; they are noted "INFRINGES ON
41  USER NAME SPACE" below. */
42 
43 /* Identify Bison output. */
44 #define YYBISON 1
45 
46 /* Bison version. */
47 #define YYBISON_VERSION "2.5"
48 
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51 
52 /* Pure parsers. */
53 #define YYPURE 1
54 
55 /* Push parsers. */
56 #define YYPUSH 0
57 
58 /* Pull parsers. */
59 #define YYPULL 1
60 
61 /* Using locations. */
62 #define YYLSP_NEEDED 0
63 
64 /* Substitute the variable and function names. */
65 #define yyparse ftsparse
66 #define yylex ftslex
67 #define yyerror ftserror
68 #define yylval ftslval
69 #define yychar ftschar
70 #define yydebug ftsdebug
71 #define yynerrs ftsnerrs
72 
73 
74 /* Copy the first part of user declarations. */
75 
76 /* Line 268 of yacc.c */
77 #line 26 "fts0pars.y"
78 
79 
80 #include "mem0mem.h"
81 #include "fts0ast.h"
82 #include "fts0blex.h"
83 #include "fts0tlex.h"
84 #include "fts0pars.h"
85 
86 extern int fts_lexer(YYSTYPE*, fts_lexer_t*);
87 extern int fts_blexer(YYSTYPE*, yyscan_t);
88 extern int fts_tlexer(YYSTYPE*, yyscan_t);
89 
90 typedef int (*fts_scan)();
91 
92 extern int ftserror(const char* p);
93 
94 /* Required for reentrant parser */
95 #define ftslex fts_lexer
96 
97 #define YYERROR_VERBOSE
98 
99 /* For passing an argument to yyparse() */
100 #define YYPARSE_PARAM state
101 #define YYLEX_PARAM ((fts_ast_state_t*) state)->lexer
102 
103 typedef int (*fts_scanner_alt)(YYSTYPE* val, yyscan_t yyscanner);
104 typedef int (*fts_scanner)();
105 
106 struct fts_lexer_t {
107  fts_scanner scanner;
108  void* yyscanner;
109 };
110 
111 
112 
113 /* Line 268 of yacc.c */
114 #line 115 "fts0pars.cc"
115 
116 /* Enabling traces. */
117 #ifndef YYDEBUG
118 # define YYDEBUG 0
119 #endif
120 
121 /* Enabling verbose error messages. */
122 #ifdef YYERROR_VERBOSE
123 # undef YYERROR_VERBOSE
124 # define YYERROR_VERBOSE 1
125 #else
126 # define YYERROR_VERBOSE 0
127 #endif
128 
129 /* Enabling the token table. */
130 #ifndef YYTOKEN_TABLE
131 # define YYTOKEN_TABLE 0
132 #endif
133 
134 
135 /* Tokens. */
136 #ifndef YYTOKENTYPE
137 # define YYTOKENTYPE
138  /* Put the tokens into the symbol table, so that GDB and other debuggers
139  know about them. */
140  enum yytokentype {
141  FTS_OPER = 258,
142  FTS_TEXT = 259,
143  FTS_TERM = 260,
144  FTS_NUMB = 261
145  };
146 #endif
147 
148 
149 
150 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
151 typedef union YYSTYPE
152 {
153 
154 /* Line 293 of yacc.c */
155 #line 61 "fts0pars.y"
156 
157  int oper;
158  char* token;
159  fts_ast_node_t* node;
160 
161 
162 
163 /* Line 293 of yacc.c */
164 #line 165 "fts0pars.cc"
165 } YYSTYPE;
166 # define YYSTYPE_IS_TRIVIAL 1
167 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
168 # define YYSTYPE_IS_DECLARED 1
169 #endif
170 
171 
172 /* Copy the second part of user declarations. */
173 
174 
175 /* Line 343 of yacc.c */
176 #line 177 "fts0pars.cc"
177 
178 #ifdef short
179 # undef short
180 #endif
181 
182 #ifdef YYTYPE_UINT8
183 typedef YYTYPE_UINT8 yytype_uint8;
184 #else
185 typedef unsigned char yytype_uint8;
186 #endif
187 
188 #ifdef YYTYPE_INT8
189 typedef YYTYPE_INT8 yytype_int8;
190 #elif (defined __STDC__ || defined __C99__FUNC__ \
191  || defined __cplusplus || defined _MSC_VER)
192 typedef signed char yytype_int8;
193 #else
194 typedef short int yytype_int8;
195 #endif
196 
197 #ifdef YYTYPE_UINT16
198 typedef YYTYPE_UINT16 yytype_uint16;
199 #else
200 typedef unsigned short int yytype_uint16;
201 #endif
202 
203 #ifdef YYTYPE_INT16
204 typedef YYTYPE_INT16 yytype_int16;
205 #else
206 typedef short int yytype_int16;
207 #endif
208 
209 #ifndef YYSIZE_T
210 # ifdef __SIZE_TYPE__
211 # define YYSIZE_T __SIZE_TYPE__
212 # elif defined size_t
213 # define YYSIZE_T size_t
214 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
215  || defined __cplusplus || defined _MSC_VER)
216 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
217 # define YYSIZE_T size_t
218 # else
219 # define YYSIZE_T unsigned int
220 # endif
221 #endif
222 
223 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
224 
225 #ifndef YY_
226 # if defined YYENABLE_NLS && YYENABLE_NLS
227 # if ENABLE_NLS
228 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
229 # define YY_(msgid) dgettext ("bison-runtime", msgid)
230 # endif
231 # endif
232 # ifndef YY_
233 # define YY_(msgid) msgid
234 # endif
235 #endif
236 
237 /* Suppress unused-variable warnings by "using" E. */
238 #if ! defined lint || defined __GNUC__
239 # define YYUSE(e) ((void) (e))
240 #else
241 # define YYUSE(e) /* empty */
242 #endif
243 
244 /* Identity function, used to suppress warnings about constant conditions. */
245 #ifndef lint
246 # define YYID(n) (n)
247 #else
248 #if (defined __STDC__ || defined __C99__FUNC__ \
249  || defined __cplusplus || defined _MSC_VER)
250 static int
251 YYID (int yyi)
252 #else
253 static int
254 YYID (yyi)
255  int yyi;
256 #endif
257 {
258  return yyi;
259 }
260 #endif
261 
262 #if ! defined yyoverflow || YYERROR_VERBOSE
263 
264 /* The parser invokes alloca or malloc; define the necessary symbols. */
265 
266 # ifdef YYSTACK_USE_ALLOCA
267 # if YYSTACK_USE_ALLOCA
268 # ifdef __GNUC__
269 # define YYSTACK_ALLOC __builtin_alloca
270 # elif defined __BUILTIN_VA_ARG_INCR
271 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
272 # elif defined _AIX
273 # define YYSTACK_ALLOC __alloca
274 # elif defined _MSC_VER
275 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
276 # define alloca _alloca
277 # else
278 # define YYSTACK_ALLOC alloca
279 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
280  || defined __cplusplus || defined _MSC_VER)
281 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
282 # ifndef EXIT_SUCCESS
283 # define EXIT_SUCCESS 0
284 # endif
285 # endif
286 # endif
287 # endif
288 # endif
289 
290 # ifdef YYSTACK_ALLOC
291  /* Pacify GCC's `empty if-body' warning. */
292 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
293 # ifndef YYSTACK_ALLOC_MAXIMUM
294  /* The OS might guarantee only one guard page at the bottom of the stack,
295  and a page size can be as small as 4096 bytes. So we cannot safely
296  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
297  to allow for a few compiler-allocated temporary stack slots. */
298 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
299 # endif
300 # else
301 # define YYSTACK_ALLOC YYMALLOC
302 # define YYSTACK_FREE YYFREE
303 # ifndef YYSTACK_ALLOC_MAXIMUM
304 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
305 # endif
306 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
307  && ! ((defined YYMALLOC || defined malloc) \
308  && (defined YYFREE || defined free)))
309 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
310 # ifndef EXIT_SUCCESS
311 # define EXIT_SUCCESS 0
312 # endif
313 # endif
314 # ifndef YYMALLOC
315 # define YYMALLOC malloc
316 # if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
317  || defined __cplusplus || defined _MSC_VER)
318 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
319 # endif
320 # endif
321 # ifndef YYFREE
322 # define YYFREE free
323 # if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
324  || defined __cplusplus || defined _MSC_VER)
325 void free (void *); /* INFRINGES ON USER NAME SPACE */
326 # endif
327 # endif
328 # endif
329 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
330 
331 
332 #if (! defined yyoverflow \
333  && (! defined __cplusplus \
334  || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
335 
336 /* A type that is properly aligned for any stack member. */
337 union yyalloc
338 {
339  yytype_int16 yyss_alloc;
340  YYSTYPE yyvs_alloc;
341 };
342 
343 /* The size of the maximum gap between one aligned stack and the next. */
344 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
345 
346 /* The size of an array large to enough to hold all stacks, each with
347  N elements. */
348 # define YYSTACK_BYTES(N) \
349  ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
350  + YYSTACK_GAP_MAXIMUM)
351 
352 # define YYCOPY_NEEDED 1
353 
354 /* Relocate STACK from its old location to the new one. The
355  local variables YYSIZE and YYSTACKSIZE give the old and new number of
356  elements in the stack, and YYPTR gives the new location of the
357  stack. Advance YYPTR to a properly aligned location for the next
358  stack. */
359 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
360  do \
361  { \
362  YYSIZE_T yynewbytes; \
363  YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
364  Stack = &yyptr->Stack_alloc; \
365  yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
366  yyptr += yynewbytes / sizeof (*yyptr); \
367  } \
368  while (YYID (0))
369 
370 #endif
371 
372 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
373 /* Copy COUNT objects from FROM to TO. The source and destination do
374  not overlap. */
375 # ifndef YYCOPY
376 # if defined __GNUC__ && 1 < __GNUC__
377 # define YYCOPY(To, From, Count) \
378  __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
379 # else
380 # define YYCOPY(To, From, Count) \
381  do \
382  { \
383  YYSIZE_T yyi; \
384  for (yyi = 0; yyi < (Count); yyi++) \
385  (To)[yyi] = (From)[yyi]; \
386  } \
387  while (YYID (0))
388 # endif
389 # endif
390 #endif /* !YYCOPY_NEEDED */
391 
392 /* YYFINAL -- State number of the termination state. */
393 #define YYFINAL 3
394 /* YYLAST -- Last index in YYTABLE. */
395 #define YYLAST 52
396 
397 /* YYNTOKENS -- Number of terminals. */
398 #define YYNTOKENS 16
399 /* YYNNTS -- Number of nonterminals. */
400 #define YYNNTS 8
401 /* YYNRULES -- Number of rules. */
402 #define YYNRULES 24
403 /* YYNRULES -- Number of states. */
404 #define YYNSTATES 33
405 
406 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
407 #define YYUNDEFTOK 2
408 #define YYMAXUTOK 261
409 
410 #define YYTRANSLATE(YYX) \
411  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
412 
413 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
414 static const yytype_uint8 yytranslate[] =
415 {
416  0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
417  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
420  12, 13, 14, 7, 2, 8, 2, 2, 2, 2,
421  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
422  10, 2, 11, 2, 15, 2, 2, 2, 2, 2,
423  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
425  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
426  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
428  2, 2, 2, 2, 2, 2, 9, 2, 2, 2,
429  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
430  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
432  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
433  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
434  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
435  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
436  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
437  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
438  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
440  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
441  2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
442  5, 6
443 };
444 
445 #if YYDEBUG
446 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
447  YYRHS. */
448 static const yytype_uint8 yyprhs[] =
449 {
450  0, 0, 3, 5, 6, 9, 12, 16, 21, 23,
451  25, 28, 32, 36, 39, 44, 47, 49, 51, 53,
452  55, 57, 59, 61, 64
453 };
454 
455 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
456 static const yytype_int8 yyrhs[] =
457 {
458  17, 0, -1, 18, -1, -1, 18, 20, -1, 18,
459  19, -1, 12, 18, 13, -1, 21, 12, 18, 13,
460  -1, 22, -1, 23, -1, 22, 14, -1, 23, 15,
461  6, -1, 21, 22, 14, -1, 21, 22, -1, 21,
462  23, 15, 6, -1, 21, 23, -1, 8, -1, 7,
463  -1, 9, -1, 10, -1, 11, -1, 5, -1, 6,
464  -1, 14, 22, -1, 4, -1
465 };
466 
467 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
468 static const yytype_uint8 yyrline[] =
469 {
470  0, 79, 79, 85, 89, 99, 111, 115, 124, 128,
471  132, 136, 141, 147, 152, 159, 165, 169, 173, 177,
472  181, 186, 191, 197, 202
473 };
474 #endif
475 
476 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
477 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
478  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
479 static const char *const yytname[] =
480 {
481  "$end", "error", "$undefined", "FTS_OPER", "FTS_TEXT", "FTS_TERM",
482  "FTS_NUMB", "'+'", "'-'", "'~'", "'<'", "'>'", "'('", "')'", "'*'",
483  "'@'", "$accept", "query", "expr_lst", "sub_expr", "expr", "prefix",
484  "term", "text", 0
485 };
486 #endif
487 
488 # ifdef YYPRINT
489 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
490  token YYLEX-NUM. */
491 static const yytype_uint16 yytoknum[] =
492 {
493  0, 256, 257, 258, 259, 260, 261, 43, 45, 126,
494  60, 62, 40, 41, 42, 64
495 };
496 # endif
497 
498 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
499 static const yytype_uint8 yyr1[] =
500 {
501  0, 16, 17, 18, 18, 18, 19, 19, 20, 20,
502  20, 20, 20, 20, 20, 20, 21, 21, 21, 21,
503  21, 22, 22, 22, 23
504 };
505 
506 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
507 static const yytype_uint8 yyr2[] =
508 {
509  0, 2, 1, 0, 2, 2, 3, 4, 1, 1,
510  2, 3, 3, 2, 4, 2, 1, 1, 1, 1,
511  1, 1, 1, 2, 1
512 };
513 
514 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
515  Performed when YYTABLE doesn't specify something else to do. Zero
516  means the default is an error. */
517 static const yytype_uint8 yydefact[] =
518 {
519  3, 0, 2, 1, 24, 21, 22, 17, 16, 18,
520  19, 20, 3, 0, 5, 4, 0, 8, 9, 0,
521  23, 3, 13, 15, 10, 0, 6, 0, 12, 0,
522  11, 7, 14
523 };
524 
525 /* YYDEFGOTO[NTERM-NUM]. */
526 static const yytype_int8 yydefgoto[] =
527 {
528  -1, 1, 2, 14, 15, 16, 17, 18
529 };
530 
531 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
532  STATE-NUM. */
533 #define YYPACT_NINF -5
534 static const yytype_int8 yypact[] =
535 {
536  -5, 38, 18, -5, -5, -5, -5, -5, -5, -5,
537  -5, -5, -5, 31, -5, -5, 29, 30, 32, -4,
538  -5, -5, 34, 35, -5, 40, -5, 7, -5, 43,
539  -5, -5, -5
540 };
541 
542 /* YYPGOTO[NTERM-NUM]. */
543 static const yytype_int8 yypgoto[] =
544 {
545  -5, -5, 19, -5, -5, -5, 26, 36
546 };
547 
548 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
549  positive, shift that token. If negative, reduce the rule which
550  number is the opposite. If YYTABLE_NINF, syntax error. */
551 #define YYTABLE_NINF -1
552 static const yytype_uint8 yytable[] =
553 {
554  4, 5, 6, 7, 8, 9, 10, 11, 12, 26,
555  13, 4, 5, 6, 7, 8, 9, 10, 11, 12,
556  31, 13, 4, 5, 6, 7, 8, 9, 10, 11,
557  12, 19, 13, 4, 5, 6, 5, 6, 3, 20,
558  27, 21, 22, 13, 24, 13, 30, 25, 28, 32,
559  29, 0, 23
560 };
561 
562 #define yypact_value_is_default(yystate) \
563  ((yystate) == (-5))
564 
565 #define yytable_value_is_error(yytable_value) \
566  YYID (0)
567 
568 static const yytype_int8 yycheck[] =
569 {
570  4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
571  14, 4, 5, 6, 7, 8, 9, 10, 11, 12,
572  13, 14, 4, 5, 6, 7, 8, 9, 10, 11,
573  12, 12, 14, 4, 5, 6, 5, 6, 0, 13,
574  21, 12, 16, 14, 14, 14, 6, 15, 14, 6,
575  15, -1, 16
576 };
577 
578 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
579  symbol of state STATE-NUM. */
580 static const yytype_uint8 yystos[] =
581 {
582  0, 17, 18, 0, 4, 5, 6, 7, 8, 9,
583  10, 11, 12, 14, 19, 20, 21, 22, 23, 18,
584  22, 12, 22, 23, 14, 15, 13, 18, 14, 15,
585  6, 13, 6
586 };
587 
588 #define yyerrok (yyerrstatus = 0)
589 #define yyclearin (yychar = YYEMPTY)
590 #define YYEMPTY (-2)
591 #define YYEOF 0
592 
593 #define YYACCEPT goto yyacceptlab
594 #define YYABORT goto yyabortlab
595 #define YYERROR goto yyerrorlab
596 
597 
598 /* Like YYERROR except do call yyerror. This remains here temporarily
599  to ease the transition to the new meaning of YYERROR, for GCC.
600  Once GCC version 2 has supplanted version 1, this can go. However,
601  YYFAIL appears to be in use. Nevertheless, it is formally deprecated
602  in Bison 2.4.2's NEWS entry, where a plan to phase it out is
603  discussed. */
604 
605 #define YYFAIL goto yyerrlab
606 #if defined YYFAIL
607  /* This is here to suppress warnings from the GCC cpp's
608  -Wunused-macros. Normally we don't worry about that warning, but
609  some users do, and we want to make it easy for users to remove
610  YYFAIL uses, which will produce warnings from Bison 2.5. */
611 #endif
612 
613 #define YYRECOVERING() (!!yyerrstatus)
614 
615 #define YYBACKUP(Token, Value) \
616 do \
617  if (yychar == YYEMPTY && yylen == 1) \
618  { \
619  yychar = (Token); \
620  yylval = (Value); \
621  YYPOPSTACK (1); \
622  goto yybackup; \
623  } \
624  else \
625  { \
626  yyerror (YY_("syntax error: cannot back up")); \
627  YYERROR; \
628  } \
629 while (YYID (0))
630 
631 
632 #define YYTERROR 1
633 #define YYERRCODE 256
634 
635 
636 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
637  If N is 0, then set CURRENT to the empty location which ends
638  the previous symbol: RHS[0] (always defined). */
639 
640 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
641 #ifndef YYLLOC_DEFAULT
642 # define YYLLOC_DEFAULT(Current, Rhs, N) \
643  do \
644  if (YYID (N)) \
645  { \
646  (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
647  (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
648  (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
649  (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
650  } \
651  else \
652  { \
653  (Current).first_line = (Current).last_line = \
654  YYRHSLOC (Rhs, 0).last_line; \
655  (Current).first_column = (Current).last_column = \
656  YYRHSLOC (Rhs, 0).last_column; \
657  } \
658  while (YYID (0))
659 #endif
660 
661 
662 /* This macro is provided for backward compatibility. */
663 
664 #ifndef YY_LOCATION_PRINT
665 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
666 #endif
667 
668 
669 /* YYLEX -- calling `yylex' with the right arguments. */
670 
671 #ifdef YYLEX_PARAM
672 # define YYLEX yylex (&yylval, YYLEX_PARAM)
673 #else
674 # define YYLEX yylex (&yylval)
675 #endif
676 
677 /* Enable debugging if requested. */
678 #if YYDEBUG
679 
680 # ifndef YYFPRINTF
681 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
682 # define YYFPRINTF fprintf
683 # endif
684 
685 # define YYDPRINTF(Args) \
686 do { \
687  if (yydebug) \
688  YYFPRINTF Args; \
689 } while (YYID (0))
690 
691 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
692 do { \
693  if (yydebug) \
694  { \
695  YYFPRINTF (stderr, "%s ", Title); \
696  yy_symbol_print (stderr, \
697  Type, Value); \
698  YYFPRINTF (stderr, "\n"); \
699  } \
700 } while (YYID (0))
701 
702 
703 /*--------------------------------.
704 | Print this symbol on YYOUTPUT. |
705 `--------------------------------*/
706 
707 /*ARGSUSED*/
708 #if (defined __STDC__ || defined __C99__FUNC__ \
709  || defined __cplusplus || defined _MSC_VER)
710 static void
711 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
712 #else
713 static void
714 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
715  FILE *yyoutput;
716  int yytype;
717  YYSTYPE const * const yyvaluep;
718 #endif
719 {
720  if (!yyvaluep)
721  return;
722 # ifdef YYPRINT
723  if (yytype < YYNTOKENS)
724  YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
725 # else
726  YYUSE (yyoutput);
727 # endif
728  switch (yytype)
729  {
730  default:
731  break;
732  }
733 }
734 
735 
736 /*--------------------------------.
737 | Print this symbol on YYOUTPUT. |
738 `--------------------------------*/
739 
740 #if (defined __STDC__ || defined __C99__FUNC__ \
741  || defined __cplusplus || defined _MSC_VER)
742 static void
743 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
744 #else
745 static void
746 yy_symbol_print (yyoutput, yytype, yyvaluep)
747  FILE *yyoutput;
748  int yytype;
749  YYSTYPE const * const yyvaluep;
750 #endif
751 {
752  if (yytype < YYNTOKENS)
753  YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
754  else
755  YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
756 
757  yy_symbol_value_print (yyoutput, yytype, yyvaluep);
758  YYFPRINTF (yyoutput, ")");
759 }
760 
761 /*------------------------------------------------------------------.
762 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
763 | TOP (included). |
764 `------------------------------------------------------------------*/
765 
766 #if (defined __STDC__ || defined __C99__FUNC__ \
767  || defined __cplusplus || defined _MSC_VER)
768 static void
769 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
770 #else
771 static void
772 yy_stack_print (yybottom, yytop)
773  yytype_int16 *yybottom;
774  yytype_int16 *yytop;
775 #endif
776 {
777  YYFPRINTF (stderr, "Stack now");
778  for (; yybottom <= yytop; yybottom++)
779  {
780  int yybot = *yybottom;
781  YYFPRINTF (stderr, " %d", yybot);
782  }
783  YYFPRINTF (stderr, "\n");
784 }
785 
786 # define YY_STACK_PRINT(Bottom, Top) \
787 do { \
788  if (yydebug) \
789  yy_stack_print ((Bottom), (Top)); \
790 } while (YYID (0))
791 
792 
793 /*------------------------------------------------.
794 | Report that the YYRULE is going to be reduced. |
795 `------------------------------------------------*/
796 
797 #if (defined __STDC__ || defined __C99__FUNC__ \
798  || defined __cplusplus || defined _MSC_VER)
799 static void
800 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
801 #else
802 static void
803 yy_reduce_print (yyvsp, yyrule)
804  YYSTYPE *yyvsp;
805  int yyrule;
806 #endif
807 {
808  int yynrhs = yyr2[yyrule];
809  int yyi;
810  unsigned long int yylno = yyrline[yyrule];
811  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
812  yyrule - 1, yylno);
813  /* The symbols being reduced. */
814  for (yyi = 0; yyi < yynrhs; yyi++)
815  {
816  YYFPRINTF (stderr, " $%d = ", yyi + 1);
817  yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
818  &(yyvsp[(yyi + 1) - (yynrhs)])
819  );
820  YYFPRINTF (stderr, "\n");
821  }
822 }
823 
824 # define YY_REDUCE_PRINT(Rule) \
825 do { \
826  if (yydebug) \
827  yy_reduce_print (yyvsp, Rule); \
828 } while (YYID (0))
829 
830 /* Nonzero means print parse trace. It is left uninitialized so that
831  multiple parsers can coexist. */
832 int yydebug;
833 #else /* !YYDEBUG */
834 # define YYDPRINTF(Args)
835 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
836 # define YY_STACK_PRINT(Bottom, Top)
837 # define YY_REDUCE_PRINT(Rule)
838 #endif /* !YYDEBUG */
839 
840 
841 /* YYINITDEPTH -- initial size of the parser's stacks. */
842 #ifndef YYINITDEPTH
843 # define YYINITDEPTH 200
844 #endif
845 
846 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
847  if the built-in stack extension method is used).
848 
849  Do not make this value too large; the results are undefined if
850  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
851  evaluated with infinite-precision integer arithmetic. */
852 
853 #ifndef YYMAXDEPTH
854 # define YYMAXDEPTH 10000
855 #endif
856 
857 
858 #if YYERROR_VERBOSE
859 
860 # ifndef yystrlen
861 # if defined __GLIBC__ && defined _STRING_H
862 # define yystrlen strlen
863 # else
864 /* Return the length of YYSTR. */
865 #if (defined __STDC__ || defined __C99__FUNC__ \
866  || defined __cplusplus || defined _MSC_VER)
867 static YYSIZE_T
868 yystrlen (const char *yystr)
869 #else
870 static YYSIZE_T
871 yystrlen (yystr)
872  const char *yystr;
873 #endif
874 {
875  YYSIZE_T yylen;
876  for (yylen = 0; yystr[yylen]; yylen++)
877  continue;
878  return yylen;
879 }
880 # endif
881 # endif
882 
883 # ifndef yystpcpy
884 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
885 # define yystpcpy stpcpy
886 # else
887 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
888  YYDEST. */
889 #if (defined __STDC__ || defined __C99__FUNC__ \
890  || defined __cplusplus || defined _MSC_VER)
891 static char *
892 yystpcpy (char *yydest, const char *yysrc)
893 #else
894 static char *
895 yystpcpy (yydest, yysrc)
896  char *yydest;
897  const char *yysrc;
898 #endif
899 {
900  char *yyd = yydest;
901  const char *yys = yysrc;
902 
903  while ((*yyd++ = *yys++) != '\0')
904  continue;
905 
906  return yyd - 1;
907 }
908 # endif
909 # endif
910 
911 # ifndef yytnamerr
912 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
913  quotes and backslashes, so that it's suitable for yyerror. The
914  heuristic is that double-quoting is unnecessary unless the string
915  contains an apostrophe, a comma, or backslash (other than
916  backslash-backslash). YYSTR is taken from yytname. If YYRES is
917  null, do not copy; instead, return the length of what the result
918  would have been. */
919 static YYSIZE_T
920 yytnamerr (char *yyres, const char *yystr)
921 {
922  if (*yystr == '"')
923  {
924  YYSIZE_T yyn = 0;
925  char const *yyp = yystr;
926 
927  for (;;)
928  switch (*++yyp)
929  {
930  case '\'':
931  case ',':
932  goto do_not_strip_quotes;
933 
934  case '\\':
935  if (*++yyp != '\\')
936  goto do_not_strip_quotes;
937  /* Fall through. */
938  default:
939  if (yyres)
940  yyres[yyn] = *yyp;
941  yyn++;
942  break;
943 
944  case '"':
945  if (yyres)
946  yyres[yyn] = '\0';
947  return yyn;
948  }
949  do_not_strip_quotes: ;
950  }
951 
952  if (! yyres)
953  return yystrlen (yystr);
954 
955  return yystpcpy (yyres, yystr) - yyres;
956 }
957 # endif
958 
959 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
960  about the unexpected token YYTOKEN for the state stack whose top is
961  YYSSP.
962 
963  Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
964  not large enough to hold the message. In that case, also set
965  *YYMSG_ALLOC to the required number of bytes. Return 2 if the
966  required number of bytes is too large to store. */
967 static int
968 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
969  yytype_int16 *yyssp, int yytoken)
970 {
971  YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
972  YYSIZE_T yysize = yysize0;
973  YYSIZE_T yysize1;
974  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
975  /* Internationalized format string. */
976  const char *yyformat = 0;
977  /* Arguments of yyformat. */
978  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
979  /* Number of reported tokens (one for the "unexpected", one per
980  "expected"). */
981  int yycount = 0;
982 
983  /* There are many possibilities here to consider:
984  - Assume YYFAIL is not used. It's too flawed to consider. See
985  <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
986  for details. YYERROR is fine as it does not invoke this
987  function.
988  - If this state is a consistent state with a default action, then
989  the only way this function was invoked is if the default action
990  is an error action. In that case, don't check for expected
991  tokens because there are none.
992  - The only way there can be no lookahead present (in yychar) is if
993  this state is a consistent state with a default action. Thus,
994  detecting the absence of a lookahead is sufficient to determine
995  that there is no unexpected or expected token to report. In that
996  case, just report a simple "syntax error".
997  - Don't assume there isn't a lookahead just because this state is a
998  consistent state with a default action. There might have been a
999  previous inconsistent state, consistent state with a non-default
1000  action, or user semantic action that manipulated yychar.
1001  - Of course, the expected token list depends on states to have
1002  correct lookahead information, and it depends on the parser not
1003  to perform extra reductions after fetching a lookahead from the
1004  scanner and before detecting a syntax error. Thus, state merging
1005  (from LALR or IELR) and default reductions corrupt the expected
1006  token list. However, the list is correct for canonical LR with
1007  one exception: it will still contain any token that will not be
1008  accepted due to an error action in a later state.
1009  */
1010  if (yytoken != YYEMPTY)
1011  {
1012  int yyn = yypact[*yyssp];
1013  yyarg[yycount++] = yytname[yytoken];
1014  if (!yypact_value_is_default (yyn))
1015  {
1016  /* Start YYX at -YYN if negative to avoid negative indexes in
1017  YYCHECK. In other words, skip the first -YYN actions for
1018  this state because they are default actions. */
1019  int yyxbegin = yyn < 0 ? -yyn : 0;
1020  /* Stay within bounds of both yycheck and yytname. */
1021  int yychecklim = YYLAST - yyn + 1;
1022  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1023  int yyx;
1024 
1025  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1026  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1027  && !yytable_value_is_error (yytable[yyx + yyn]))
1028  {
1029  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1030  {
1031  yycount = 1;
1032  yysize = yysize0;
1033  break;
1034  }
1035  yyarg[yycount++] = yytname[yyx];
1036  yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1037  if (! (yysize <= yysize1
1038  && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1039  return 2;
1040  yysize = yysize1;
1041  }
1042  }
1043  }
1044 
1045  switch (yycount)
1046  {
1047 # define YYCASE_(N, S) \
1048  case N: \
1049  yyformat = S; \
1050  break
1051  YYCASE_(0, YY_("syntax error"));
1052  YYCASE_(1, YY_("syntax error, unexpected %s"));
1053  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1054  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1055  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1056  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1057 # undef YYCASE_
1058  }
1059 
1060  yysize1 = yysize + yystrlen (yyformat);
1061  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1062  return 2;
1063  yysize = yysize1;
1064 
1065  if (*yymsg_alloc < yysize)
1066  {
1067  *yymsg_alloc = 2 * yysize;
1068  if (! (yysize <= *yymsg_alloc
1069  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1070  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1071  return 1;
1072  }
1073 
1074  /* Avoid sprintf, as that infringes on the user's name space.
1075  Don't have undefined behavior even if the translation
1076  produced a string with the wrong number of "%s"s. */
1077  {
1078  char *yyp = *yymsg;
1079  int yyi = 0;
1080  while ((*yyp = *yyformat) != '\0')
1081  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1082  {
1083  yyp += yytnamerr (yyp, yyarg[yyi++]);
1084  yyformat += 2;
1085  }
1086  else
1087  {
1088  yyp++;
1089  yyformat++;
1090  }
1091  }
1092  return 0;
1093 }
1094 #endif /* YYERROR_VERBOSE */
1095 
1096 /*-----------------------------------------------.
1097 | Release the memory associated to this symbol. |
1098 `-----------------------------------------------*/
1099 
1100 /*ARGSUSED*/
1101 #if (defined __STDC__ || defined __C99__FUNC__ \
1102  || defined __cplusplus || defined _MSC_VER)
1103 static void
1104 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1105 #else
1106 static void
1107 yydestruct (yymsg, yytype, yyvaluep)
1108  const char *yymsg;
1109  int yytype;
1110  YYSTYPE *yyvaluep;
1111 #endif
1112 {
1113  YYUSE (yyvaluep);
1114 
1115  if (!yymsg)
1116  yymsg = "Deleting";
1117  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1118 
1119  switch (yytype)
1120  {
1121 
1122  default:
1123  break;
1124  }
1125 }
1126 
1127 
1128 /* Prevent warnings from -Wmissing-prototypes. */
1129 #ifdef YYPARSE_PARAM
1130 #if defined __STDC__ || defined __cplusplus
1131 int yyparse (void *YYPARSE_PARAM);
1132 #else
1133 int yyparse ();
1134 #endif
1135 #else /* ! YYPARSE_PARAM */
1136 #if defined __STDC__ || defined __cplusplus
1137 int yyparse (void);
1138 #else
1139 int yyparse ();
1140 #endif
1141 #endif /* ! YYPARSE_PARAM */
1142 
1143 
1144 /*----------.
1145 | yyparse. |
1146 `----------*/
1147 
1148 #ifdef YYPARSE_PARAM
1149 #if (defined __STDC__ || defined __C99__FUNC__ \
1150  || defined __cplusplus || defined _MSC_VER)
1151 int
1152 yyparse (void *YYPARSE_PARAM)
1153 #else
1154 int
1155 yyparse (YYPARSE_PARAM)
1156  void *YYPARSE_PARAM;
1157 #endif
1158 #else /* ! YYPARSE_PARAM */
1159 #if (defined __STDC__ || defined __C99__FUNC__ \
1160  || defined __cplusplus || defined _MSC_VER)
1161 int
1162 yyparse (void)
1163 #else
1164 int
1165 yyparse ()
1166 
1167 #endif
1168 #endif
1169 {
1170 /* The lookahead symbol. */
1171 int yychar;
1172 
1173 /* The semantic value of the lookahead symbol. */
1174 YYSTYPE yylval;
1175 
1176  /* Number of syntax errors so far. */
1177  int yynerrs;
1178 
1179  int yystate;
1180  /* Number of tokens to shift before error messages enabled. */
1181  int yyerrstatus;
1182 
1183  /* The stacks and their tools:
1184  `yyss': related to states.
1185  `yyvs': related to semantic values.
1186 
1187  Refer to the stacks thru separate pointers, to allow yyoverflow
1188  to reallocate them elsewhere. */
1189 
1190  /* The state stack. */
1191  yytype_int16 yyssa[YYINITDEPTH];
1192  yytype_int16 *yyss;
1193  yytype_int16 *yyssp;
1194 
1195  /* The semantic value stack. */
1196  YYSTYPE yyvsa[YYINITDEPTH];
1197  YYSTYPE *yyvs;
1198  YYSTYPE *yyvsp;
1199 
1200  YYSIZE_T yystacksize;
1201 
1202  int yyn;
1203  int yyresult;
1204  /* Lookahead token as an internal (translated) token number. */
1205  int yytoken;
1206  /* The variables used to return semantic value and location from the
1207  action routines. */
1208  YYSTYPE yyval;
1209 
1210 #if YYERROR_VERBOSE
1211  /* Buffer for error messages, and its allocated size. */
1212  char yymsgbuf[128];
1213  char *yymsg = yymsgbuf;
1214  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1215 #endif
1216 
1217 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1218 
1219  /* The number of symbols on the RHS of the reduced rule.
1220  Keep to zero when no symbol should be popped. */
1221  int yylen = 0;
1222 
1223  yytoken = 0;
1224  yyss = yyssa;
1225  yyvs = yyvsa;
1226  yystacksize = YYINITDEPTH;
1227 
1228  YYDPRINTF ((stderr, "Starting parse\n"));
1229 
1230  yystate = 0;
1231  yyerrstatus = 0;
1232  yynerrs = 0;
1233  yychar = YYEMPTY; /* Cause a token to be read. */
1234 
1235  /* Initialize stack pointers.
1236  Waste one element of value and location stack
1237  so that they stay on the same level as the state stack.
1238  The wasted elements are never initialized. */
1239  yyssp = yyss;
1240  yyvsp = yyvs;
1241 
1242  goto yysetstate;
1243 
1244 /*------------------------------------------------------------.
1245 | yynewstate -- Push a new state, which is found in yystate. |
1246 `------------------------------------------------------------*/
1247  yynewstate:
1248  /* In all cases, when you get here, the value and location stacks
1249  have just been pushed. So pushing a state here evens the stacks. */
1250  yyssp++;
1251 
1252  yysetstate:
1253  *yyssp = yystate;
1254 
1255  if (yyss + yystacksize - 1 <= yyssp)
1256  {
1257  /* Get the current used size of the three stacks, in elements. */
1258  YYSIZE_T yysize = yyssp - yyss + 1;
1259 
1260 #ifdef yyoverflow
1261  {
1262  /* Give user a chance to reallocate the stack. Use copies of
1263  these so that the &'s don't force the real ones into
1264  memory. */
1265  YYSTYPE *yyvs1 = yyvs;
1266  yytype_int16 *yyss1 = yyss;
1267 
1268  /* Each stack pointer address is followed by the size of the
1269  data in use in that stack, in bytes. This used to be a
1270  conditional around just the two extra args, but that might
1271  be undefined if yyoverflow is a macro. */
1272  yyoverflow (YY_("memory exhausted"),
1273  &yyss1, yysize * sizeof (*yyssp),
1274  &yyvs1, yysize * sizeof (*yyvsp),
1275  &yystacksize);
1276 
1277  yyss = yyss1;
1278  yyvs = yyvs1;
1279  }
1280 #else /* no yyoverflow */
1281 # ifndef YYSTACK_RELOCATE
1282  goto yyexhaustedlab;
1283 # else
1284  /* Extend the stack our own way. */
1285  if (YYMAXDEPTH <= yystacksize)
1286  goto yyexhaustedlab;
1287  yystacksize *= 2;
1288  if (YYMAXDEPTH < yystacksize)
1289  yystacksize = YYMAXDEPTH;
1290 
1291  {
1292  yytype_int16 *yyss1 = yyss;
1293  union yyalloc *yyptr =
1294  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1295  if (! yyptr)
1296  goto yyexhaustedlab;
1297  YYSTACK_RELOCATE (yyss_alloc, yyss);
1298  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1299 # undef YYSTACK_RELOCATE
1300  if (yyss1 != yyssa)
1301  YYSTACK_FREE (yyss1);
1302  }
1303 # endif
1304 #endif /* no yyoverflow */
1305 
1306  yyssp = yyss + yysize - 1;
1307  yyvsp = yyvs + yysize - 1;
1308 
1309  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1310  (unsigned long int) yystacksize));
1311 
1312  if (yyss + yystacksize - 1 <= yyssp)
1313  YYABORT;
1314  }
1315 
1316  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1317 
1318  if (yystate == YYFINAL)
1319  YYACCEPT;
1320 
1321  goto yybackup;
1322 
1323 /*-----------.
1324 | yybackup. |
1325 `-----------*/
1326 yybackup:
1327 
1328  /* Do appropriate processing given the current state. Read a
1329  lookahead token if we need one and don't already have one. */
1330 
1331  /* First try to decide what to do without reference to lookahead token. */
1332  yyn = yypact[yystate];
1333  if (yypact_value_is_default (yyn))
1334  goto yydefault;
1335 
1336  /* Not known => get a lookahead token if don't already have one. */
1337 
1338  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1339  if (yychar == YYEMPTY)
1340  {
1341  YYDPRINTF ((stderr, "Reading a token: "));
1342  yychar = YYLEX;
1343  }
1344 
1345  if (yychar <= YYEOF)
1346  {
1347  yychar = yytoken = YYEOF;
1348  YYDPRINTF ((stderr, "Now at end of input.\n"));
1349  }
1350  else
1351  {
1352  yytoken = YYTRANSLATE (yychar);
1353  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1354  }
1355 
1356  /* If the proper action on seeing token YYTOKEN is to reduce or to
1357  detect an error, take that action. */
1358  yyn += yytoken;
1359  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1360  goto yydefault;
1361  yyn = yytable[yyn];
1362  if (yyn <= 0)
1363  {
1364  if (yytable_value_is_error (yyn))
1365  goto yyerrlab;
1366  yyn = -yyn;
1367  goto yyreduce;
1368  }
1369 
1370  /* Count tokens shifted since error; after three, turn off error
1371  status. */
1372  if (yyerrstatus)
1373  yyerrstatus--;
1374 
1375  /* Shift the lookahead token. */
1376  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1377 
1378  /* Discard the shifted token. */
1379  yychar = YYEMPTY;
1380 
1381  yystate = yyn;
1382  *++yyvsp = yylval;
1383 
1384  goto yynewstate;
1385 
1386 
1387 /*-----------------------------------------------------------.
1388 | yydefault -- do the default action for the current state. |
1389 `-----------------------------------------------------------*/
1390 yydefault:
1391  yyn = yydefact[yystate];
1392  if (yyn == 0)
1393  goto yyerrlab;
1394  goto yyreduce;
1395 
1396 
1397 /*-----------------------------.
1398 | yyreduce -- Do a reduction. |
1399 `-----------------------------*/
1400 yyreduce:
1401  /* yyn is the number of a rule to reduce with. */
1402  yylen = yyr2[yyn];
1403 
1404  /* If YYLEN is nonzero, implement the default value of the action:
1405  `$$ = $1'.
1406 
1407  Otherwise, the following line sets YYVAL to garbage.
1408  This behavior is undocumented and Bison
1409  users should not rely upon it. Assigning to YYVAL
1410  unconditionally makes the parser a bit smaller, and it avoids a
1411  GCC warning that YYVAL may be used uninitialized. */
1412  yyval = yyvsp[1-yylen];
1413 
1414 
1415  YY_REDUCE_PRINT (yyn);
1416  switch (yyn)
1417  {
1418  case 2:
1419 
1420 /* Line 1806 of yacc.c */
1421 #line 79 "fts0pars.y"
1422  {
1423  (yyval.node) = (yyvsp[(1) - (1)].node);
1424  ((fts_ast_state_t*) state)->root = (yyval.node);
1425  }
1426  break;
1427 
1428  case 3:
1429 
1430 /* Line 1806 of yacc.c */
1431 #line 85 "fts0pars.y"
1432  {
1433  (yyval.node) = NULL;
1434  }
1435  break;
1436 
1437  case 4:
1438 
1439 /* Line 1806 of yacc.c */
1440 #line 89 "fts0pars.y"
1441  {
1442  (yyval.node) = (yyvsp[(1) - (2)].node);
1443 
1444  if (!(yyval.node)) {
1445  (yyval.node) = fts_ast_create_node_list(state, (yyvsp[(2) - (2)].node));
1446  } else {
1447  fts_ast_add_node((yyval.node), (yyvsp[(2) - (2)].node));
1448  }
1449  }
1450  break;
1451 
1452  case 5:
1453 
1454 /* Line 1806 of yacc.c */
1455 #line 99 "fts0pars.y"
1456  {
1457  (yyval.node) = (yyvsp[(1) - (2)].node);
1458  (yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (2)].node));
1459 
1460  if (!(yyval.node)) {
1461  (yyval.node) = fts_ast_create_node_subexp_list(state, (yyvsp[(2) - (2)].node));
1462  } else {
1463  fts_ast_add_node((yyval.node), (yyvsp[(2) - (2)].node));
1464  }
1465  }
1466  break;
1467 
1468  case 6:
1469 
1470 /* Line 1806 of yacc.c */
1471 #line 111 "fts0pars.y"
1472  {
1473  (yyval.node) = (yyvsp[(2) - (3)].node);
1474  }
1475  break;
1476 
1477  case 7:
1478 
1479 /* Line 1806 of yacc.c */
1480 #line 115 "fts0pars.y"
1481  {
1482  (yyval.node) = fts_ast_create_node_subexp_list(state, (yyvsp[(1) - (4)].node));
1483 
1484  if ((yyvsp[(3) - (4)].node)) {
1485  fts_ast_add_node((yyval.node), (yyvsp[(3) - (4)].node));
1486  }
1487  }
1488  break;
1489 
1490  case 8:
1491 
1492 /* Line 1806 of yacc.c */
1493 #line 124 "fts0pars.y"
1494  {
1495  (yyval.node) = (yyvsp[(1) - (1)].node);
1496  }
1497  break;
1498 
1499  case 9:
1500 
1501 /* Line 1806 of yacc.c */
1502 #line 128 "fts0pars.y"
1503  {
1504  (yyval.node) = (yyvsp[(1) - (1)].node);
1505  }
1506  break;
1507 
1508  case 10:
1509 
1510 /* Line 1806 of yacc.c */
1511 #line 132 "fts0pars.y"
1512  {
1513  fts_ast_term_set_wildcard((yyvsp[(1) - (2)].node));
1514  }
1515  break;
1516 
1517  case 11:
1518 
1519 /* Line 1806 of yacc.c */
1520 #line 136 "fts0pars.y"
1521  {
1522  fts_ast_term_set_distance((yyvsp[(1) - (3)].node), strtoul((yyvsp[(3) - (3)].token), NULL, 10));
1523  free((yyvsp[(3) - (3)].token));
1524  }
1525  break;
1526 
1527  case 12:
1528 
1529 /* Line 1806 of yacc.c */
1530 #line 141 "fts0pars.y"
1531  {
1532  (yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (3)].node));
1533  fts_ast_add_node((yyval.node), (yyvsp[(2) - (3)].node));
1534  fts_ast_term_set_wildcard((yyvsp[(2) - (3)].node));
1535  }
1536  break;
1537 
1538  case 13:
1539 
1540 /* Line 1806 of yacc.c */
1541 #line 147 "fts0pars.y"
1542  {
1543  (yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (2)].node));
1544  fts_ast_add_node((yyval.node), (yyvsp[(2) - (2)].node));
1545  }
1546  break;
1547 
1548  case 14:
1549 
1550 /* Line 1806 of yacc.c */
1551 #line 152 "fts0pars.y"
1552  {
1553  (yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (4)].node));
1554  fts_ast_add_node((yyval.node), (yyvsp[(2) - (4)].node));
1555  fts_ast_term_set_distance((yyvsp[(2) - (4)].node), strtoul((yyvsp[(4) - (4)].token), NULL, 10));
1556  free((yyvsp[(4) - (4)].token));
1557  }
1558  break;
1559 
1560  case 15:
1561 
1562 /* Line 1806 of yacc.c */
1563 #line 159 "fts0pars.y"
1564  {
1565  (yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (2)].node));
1566  fts_ast_add_node((yyval.node), (yyvsp[(2) - (2)].node));
1567  }
1568  break;
1569 
1570  case 16:
1571 
1572 /* Line 1806 of yacc.c */
1573 #line 165 "fts0pars.y"
1574  {
1575  (yyval.node) = fts_ast_create_node_oper(state, FTS_IGNORE);
1576  }
1577  break;
1578 
1579  case 17:
1580 
1581 /* Line 1806 of yacc.c */
1582 #line 169 "fts0pars.y"
1583  {
1584  (yyval.node) = fts_ast_create_node_oper(state, FTS_EXIST);
1585  }
1586  break;
1587 
1588  case 18:
1589 
1590 /* Line 1806 of yacc.c */
1591 #line 173 "fts0pars.y"
1592  {
1593  (yyval.node) = fts_ast_create_node_oper(state, FTS_NEGATE);
1594  }
1595  break;
1596 
1597  case 19:
1598 
1599 /* Line 1806 of yacc.c */
1600 #line 177 "fts0pars.y"
1601  {
1602  (yyval.node) = fts_ast_create_node_oper(state, FTS_DECR_RATING);
1603  }
1604  break;
1605 
1606  case 20:
1607 
1608 /* Line 1806 of yacc.c */
1609 #line 181 "fts0pars.y"
1610  {
1611  (yyval.node) = fts_ast_create_node_oper(state, FTS_INCR_RATING);
1612  }
1613  break;
1614 
1615  case 21:
1616 
1617 /* Line 1806 of yacc.c */
1618 #line 186 "fts0pars.y"
1619  {
1620  (yyval.node) = fts_ast_create_node_term(state, (yyvsp[(1) - (1)].token));
1621  free((yyvsp[(1) - (1)].token));
1622  }
1623  break;
1624 
1625  case 22:
1626 
1627 /* Line 1806 of yacc.c */
1628 #line 191 "fts0pars.y"
1629  {
1630  (yyval.node) = fts_ast_create_node_term(state, (yyvsp[(1) - (1)].token));
1631  free((yyvsp[(1) - (1)].token));
1632  }
1633  break;
1634 
1635  case 23:
1636 
1637 /* Line 1806 of yacc.c */
1638 #line 197 "fts0pars.y"
1639  {
1640  (yyval.node) = (yyvsp[(2) - (2)].node);
1641  }
1642  break;
1643 
1644  case 24:
1645 
1646 /* Line 1806 of yacc.c */
1647 #line 202 "fts0pars.y"
1648  {
1649  (yyval.node) = fts_ast_create_node_text(state, (yyvsp[(1) - (1)].token));
1650  free((yyvsp[(1) - (1)].token));
1651  }
1652  break;
1653 
1654 
1655 
1656 /* Line 1806 of yacc.c */
1657 #line 1658 "fts0pars.cc"
1658  default: break;
1659  }
1660  /* User semantic actions sometimes alter yychar, and that requires
1661  that yytoken be updated with the new translation. We take the
1662  approach of translating immediately before every use of yytoken.
1663  One alternative is translating here after every semantic action,
1664  but that translation would be missed if the semantic action invokes
1665  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1666  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1667  incorrect destructor might then be invoked immediately. In the
1668  case of YYERROR or YYBACKUP, subsequent parser actions might lead
1669  to an incorrect destructor call or verbose syntax error message
1670  before the lookahead is translated. */
1671  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1672 
1673  YYPOPSTACK (yylen);
1674  yylen = 0;
1675  YY_STACK_PRINT (yyss, yyssp);
1676 
1677  *++yyvsp = yyval;
1678 
1679  /* Now `shift' the result of the reduction. Determine what state
1680  that goes to, based on the state we popped back to and the rule
1681  number reduced by. */
1682 
1683  yyn = yyr1[yyn];
1684 
1685  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1686  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1687  yystate = yytable[yystate];
1688  else
1689  yystate = yydefgoto[yyn - YYNTOKENS];
1690 
1691  goto yynewstate;
1692 
1693 
1694 /*------------------------------------.
1695 | yyerrlab -- here on detecting error |
1696 `------------------------------------*/
1697 yyerrlab:
1698  /* Make sure we have latest lookahead translation. See comments at
1699  user semantic actions for why this is necessary. */
1700  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1701 
1702  /* If not already recovering from an error, report this error. */
1703  if (!yyerrstatus)
1704  {
1705  ++yynerrs;
1706 #if ! YYERROR_VERBOSE
1707  yyerror (YY_("syntax error"));
1708 #else
1709 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1710  yyssp, yytoken)
1711  {
1712  char const *yymsgp = YY_("syntax error");
1713  int yysyntax_error_status;
1714  yysyntax_error_status = YYSYNTAX_ERROR;
1715  if (yysyntax_error_status == 0)
1716  yymsgp = yymsg;
1717  else if (yysyntax_error_status == 1)
1718  {
1719  if (yymsg != yymsgbuf)
1720  YYSTACK_FREE (yymsg);
1721  yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1722  if (!yymsg)
1723  {
1724  yymsg = yymsgbuf;
1725  yymsg_alloc = sizeof yymsgbuf;
1726  yysyntax_error_status = 2;
1727  }
1728  else
1729  {
1730  yysyntax_error_status = YYSYNTAX_ERROR;
1731  yymsgp = yymsg;
1732  }
1733  }
1734  yyerror (yymsgp);
1735  if (yysyntax_error_status == 2)
1736  goto yyexhaustedlab;
1737  }
1738 # undef YYSYNTAX_ERROR
1739 #endif
1740  }
1741 
1742 
1743 
1744  if (yyerrstatus == 3)
1745  {
1746  /* If just tried and failed to reuse lookahead token after an
1747  error, discard it. */
1748 
1749  if (yychar <= YYEOF)
1750  {
1751  /* Return failure if at end of input. */
1752  if (yychar == YYEOF)
1753  YYABORT;
1754  }
1755  else
1756  {
1757  yydestruct ("Error: discarding",
1758  yytoken, &yylval);
1759  yychar = YYEMPTY;
1760  }
1761  }
1762 
1763  /* Else will try to reuse lookahead token after shifting the error
1764  token. */
1765  goto yyerrlab1;
1766 
1767 
1768 /*---------------------------------------------------.
1769 | yyerrorlab -- error raised explicitly by YYERROR. |
1770 `---------------------------------------------------*/
1771 yyerrorlab:
1772 
1773  /* Pacify compilers like GCC when the user code never invokes
1774  YYERROR and the label yyerrorlab therefore never appears in user
1775  code. */
1776  if (/*CONSTCOND*/ 0)
1777  goto yyerrorlab;
1778 
1779  /* Do not reclaim the symbols of the rule which action triggered
1780  this YYERROR. */
1781  YYPOPSTACK (yylen);
1782  yylen = 0;
1783  YY_STACK_PRINT (yyss, yyssp);
1784  yystate = *yyssp;
1785  goto yyerrlab1;
1786 
1787 
1788 /*-------------------------------------------------------------.
1789 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1790 `-------------------------------------------------------------*/
1791 yyerrlab1:
1792  yyerrstatus = 3; /* Each real token shifted decrements this. */
1793 
1794  for (;;)
1795  {
1796  yyn = yypact[yystate];
1797  if (!yypact_value_is_default (yyn))
1798  {
1799  yyn += YYTERROR;
1800  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1801  {
1802  yyn = yytable[yyn];
1803  if (0 < yyn)
1804  break;
1805  }
1806  }
1807 
1808  /* Pop the current state because it cannot handle the error token. */
1809  if (yyssp == yyss)
1810  YYABORT;
1811 
1812 
1813  yydestruct ("Error: popping",
1814  yystos[yystate], yyvsp);
1815  YYPOPSTACK (1);
1816  yystate = *yyssp;
1817  YY_STACK_PRINT (yyss, yyssp);
1818  }
1819 
1820  *++yyvsp = yylval;
1821 
1822 
1823  /* Shift the error token. */
1824  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1825 
1826  yystate = yyn;
1827  goto yynewstate;
1828 
1829 
1830 /*-------------------------------------.
1831 | yyacceptlab -- YYACCEPT comes here. |
1832 `-------------------------------------*/
1833 yyacceptlab:
1834  yyresult = 0;
1835  goto yyreturn;
1836 
1837 /*-----------------------------------.
1838 | yyabortlab -- YYABORT comes here. |
1839 `-----------------------------------*/
1840 yyabortlab:
1841  yyresult = 1;
1842  goto yyreturn;
1843 
1844 #if !defined(yyoverflow) || YYERROR_VERBOSE
1845 /*-------------------------------------------------.
1846 | yyexhaustedlab -- memory exhaustion comes here. |
1847 `-------------------------------------------------*/
1848 yyexhaustedlab:
1849  yyerror (YY_("memory exhausted"));
1850  yyresult = 2;
1851  /* Fall through. */
1852 #endif
1853 
1854 yyreturn:
1855  if (yychar != YYEMPTY)
1856  {
1857  /* Make sure we have latest lookahead translation. See comments at
1858  user semantic actions for why this is necessary. */
1859  yytoken = YYTRANSLATE (yychar);
1860  yydestruct ("Cleanup: discarding lookahead",
1861  yytoken, &yylval);
1862  }
1863  /* Do not reclaim the symbols of the rule which action triggered
1864  this YYABORT or YYACCEPT. */
1865  YYPOPSTACK (yylen);
1866  YY_STACK_PRINT (yyss, yyssp);
1867  while (yyssp != yyss)
1868  {
1869  yydestruct ("Cleanup: popping",
1870  yystos[*yyssp], yyvsp);
1871  YYPOPSTACK (1);
1872  }
1873 #ifndef yyoverflow
1874  if (yyss != yyssa)
1875  YYSTACK_FREE (yyss);
1876 #endif
1877 #if YYERROR_VERBOSE
1878  if (yymsg != yymsgbuf)
1879  YYSTACK_FREE (yymsg);
1880 #endif
1881  /* Make sure YYID is used. */
1882  return YYID (yyresult);
1883 }
1884 
1885 
1886 
1887 /* Line 2067 of yacc.c */
1888 #line 207 "fts0pars.y"
1889 
1890 
1891 /********************************************************************
1892 */
1893 int
1894 ftserror(
1895 /*=====*/
1896  const char* p)
1897 {
1898  my_printf_error(ER_PARSE_ERROR, "%s", MYF(0), p);
1899  return(0);
1900 }
1901 
1902 /********************************************************************
1903 Create a fts_lexer_t instance.*/
1904 
1905 fts_lexer_t*
1907 /*=============*/
1908  ibool boolean_mode,
1909  const byte* query,
1910  ulint query_len)
1911 {
1912  fts_lexer_t* fts_lexer = static_cast<fts_lexer_t*>(
1913  ut_malloc(sizeof(fts_lexer_t)));
1914 
1915  if (boolean_mode) {
1916  fts0blex_init(&fts_lexer->yyscanner);
1917  fts0b_scan_bytes((char*) query, query_len, fts_lexer->yyscanner);
1918  fts_lexer->scanner = (fts_scan) fts_blexer;
1919  /* FIXME: Debugging */
1920  /* fts0bset_debug(1 , fts_lexer->yyscanner); */
1921  } else {
1922  fts0tlex_init(&fts_lexer->yyscanner);
1923  fts0t_scan_bytes((char*) query, query_len, fts_lexer->yyscanner);
1924  fts_lexer->scanner = (fts_scan) fts_tlexer;
1925  }
1926 
1927  return(fts_lexer);
1928 }
1929 
1930 /********************************************************************
1931 Free an fts_lexer_t instance.*/
1932 void
1933 
1935 /*===========*/
1936  fts_lexer_t* fts_lexer)
1937 {
1938  if (fts_lexer->scanner == (fts_scan) fts_blexer) {
1939  fts0blex_destroy(fts_lexer->yyscanner);
1940  } else {
1941  fts0tlex_destroy(fts_lexer->yyscanner);
1942  }
1943 
1944  ut_free(fts_lexer);
1945 }
1946 
1947 /********************************************************************
1948 Call the appropaiate scanner.*/
1949 
1950 int
1951 fts_lexer(
1952 /*======*/
1953  YYSTYPE* val,
1954  fts_lexer_t* fts_lexer)
1955 {
1956  fts_scanner_alt func_ptr;
1957 
1958  func_ptr = (fts_scanner_alt) fts_lexer->scanner;
1959 
1960  return(func_ptr(val, fts_lexer->yyscanner));
1961 }
1962 
1963 /********************************************************************
1964 Parse the query.*/
1965 int
1966 fts_parse(
1967 /*======*/
1968  fts_ast_state_t* state)
1969 {
1970  return(ftsparse(state));
1971 }
1972