Debian Codegraph @

storage/innobase/fts/fts0pars.cc

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