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 
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 
107 typedef	int	(*fts_scanner)(YYSTYPE* val, yyscan_t yyscanner);
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
YYID(int yyi)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 {
482   "$end", "error", "$undefined", "FTS_OPER", "FTS_TEXT", "FTS_TERM",
483   "FTS_NUMB", "'+'", "'-'", "'~'", "'<'", "'>'", "'('", "')'", "'*'",
484   "'@'", "$accept", "query", "expr_lst", "sub_expr", "expr", "prefix",
485   "term", "text", 0
486 };
487 #endif
488 
489 # ifdef YYPRINT
490 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
491    token YYLEX-NUM.  */
492 static const yytype_uint16 yytoknum[] =
493 {
494        0,   256,   257,   258,   259,   260,   261,    43,    45,   126,
495       60,    62,    40,    41,    42,    64
496 };
497 # endif
498 
499 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
500 static const yytype_uint8 yyr1[] =
501 {
502        0,    16,    17,    18,    18,    18,    19,    19,    20,    20,
503       20,    20,    20,    20,    20,    20,    21,    21,    21,    21,
504       21,    22,    22,    22,    23
505 };
506 
507 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
508 static const yytype_uint8 yyr2[] =
509 {
510        0,     2,     1,     0,     2,     2,     3,     4,     1,     1,
511        2,     3,     3,     2,     4,     2,     1,     1,     1,     1,
512        1,     1,     1,     2,     1
513 };
514 
515 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
516    Performed when YYTABLE doesn't specify something else to do.  Zero
517    means the default is an error.  */
518 static const yytype_uint8 yydefact[] =
519 {
520        3,     0,     2,     1,    24,    21,    22,    17,    16,    18,
521       19,    20,     3,     0,     5,     4,     0,     8,     9,     0,
522       23,     3,    13,    15,    10,     0,     6,     0,    12,     0,
523       11,     7,    14
524 };
525 
526 /* YYDEFGOTO[NTERM-NUM].  */
527 static const yytype_int8 yydefgoto[] =
528 {
529       -1,     1,     2,    14,    15,    16,    17,    18
530 };
531 
532 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
533    STATE-NUM.  */
534 #define YYPACT_NINF -5
535 static const yytype_int8 yypact[] =
536 {
537       -5,    38,    18,    -5,    -5,    -5,    -5,    -5,    -5,    -5,
538       -5,    -5,    -5,    31,    -5,    -5,    29,    30,    32,    -4,
539       -5,    -5,    34,    35,    -5,    40,    -5,     7,    -5,    43,
540       -5,    -5,    -5
541 };
542 
543 /* YYPGOTO[NTERM-NUM].  */
544 static const yytype_int8 yypgoto[] =
545 {
546       -5,    -5,    19,    -5,    -5,    -5,    26,    36
547 };
548 
549 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
550    positive, shift that token.  If negative, reduce the rule which
551    number is the opposite.  If YYTABLE_NINF, syntax error.  */
552 #define YYTABLE_NINF -1
553 static const yytype_uint8 yytable[] =
554 {
555        4,     5,     6,     7,     8,     9,    10,    11,    12,    26,
556       13,     4,     5,     6,     7,     8,     9,    10,    11,    12,
557       31,    13,     4,     5,     6,     7,     8,     9,    10,    11,
558       12,    19,    13,     4,     5,     6,     5,     6,     3,    20,
559       27,    21,    22,    13,    24,    13,    30,    25,    28,    32,
560       29,     0,    23
561 };
562 
563 #define yypact_value_is_default(yystate) \
564   ((yystate) == (-5))
565 
566 #define yytable_value_is_error(yytable_value) \
567   YYID (0)
568 
569 static const yytype_int8 yycheck[] =
570 {
571        4,     5,     6,     7,     8,     9,    10,    11,    12,    13,
572       14,     4,     5,     6,     7,     8,     9,    10,    11,    12,
573       13,    14,     4,     5,     6,     7,     8,     9,    10,    11,
574       12,    12,    14,     4,     5,     6,     5,     6,     0,    13,
575       21,    12,    16,    14,    14,    14,     6,    15,    14,     6,
576       15,    -1,    16
577 };
578 
579 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
580    symbol of state STATE-NUM.  */
581 static const yytype_uint8 yystos[] =
582 {
583        0,    17,    18,     0,     4,     5,     6,     7,     8,     9,
584       10,    11,    12,    14,    19,    20,    21,    22,    23,    18,
585       22,    12,    22,    23,    14,    15,    13,    18,    14,    15,
586        6,    13,     6
587 };
588 
589 #define yyerrok		(yyerrstatus = 0)
590 #define yyclearin	(yychar = YYEMPTY)
591 #define YYEMPTY		(-2)
592 #define YYEOF		0
593 
594 #define YYACCEPT	goto yyacceptlab
595 #define YYABORT		goto yyabortlab
596 #define YYERROR		goto yyerrorlab
597 
598 
599 /* Like YYERROR except do call yyerror.  This remains here temporarily
600    to ease the transition to the new meaning of YYERROR, for GCC.
601    Once GCC version 2 has supplanted version 1, this can go.  However,
602    YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
603    in Bison 2.4.2's NEWS entry, where a plan to phase it out is
604    discussed.  */
605 
606 #define YYFAIL		goto yyerrlab
607 #if defined YYFAIL
608   /* This is here to suppress warnings from the GCC cpp's
609      -Wunused-macros.  Normally we don't worry about that warning, but
610      some users do, and we want to make it easy for users to remove
611      YYFAIL uses, which will produce warnings from Bison 2.5.  */
612 #endif
613 
614 #define YYRECOVERING()  (!!yyerrstatus)
615 
616 #define YYBACKUP(Token, Value)					\
617 do								\
618   if (yychar == YYEMPTY && yylen == 1)				\
619     {								\
620       yychar = (Token);						\
621       yylval = (Value);						\
622       YYPOPSTACK (1);						\
623       goto yybackup;						\
624     }								\
625   else								\
626     {								\
627       yyerror (YY_("syntax error: cannot back up")); \
628       YYERROR;							\
629     }								\
630 while (YYID (0))
631 
632 
633 #define YYTERROR	1
634 #define YYERRCODE	256
635 
636 #define YYERRCLEANUP						\
637 do								\
638   switch (yylastchar)						\
639     {								\
640       case FTS_NUMB:						\
641       case FTS_TEXT:						\
642       case FTS_TERM:						\
643         YYTOKENFREE(yylval.token);				\
644         break;							\
645       default:							\
646         break;							\
647     }								\
648 while (YYID (0))
649 
650 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
651    If N is 0, then set CURRENT to the empty location which ends
652    the previous symbol: RHS[0] (always defined).  */
653 
654 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
655 #ifndef YYLLOC_DEFAULT
656 # define YYLLOC_DEFAULT(Current, Rhs, N)				\
657     do									\
658       if (YYID (N))                                                    \
659 	{								\
660 	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;	\
661 	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;	\
662 	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;		\
663 	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;	\
664 	}								\
665       else								\
666 	{								\
667 	  (Current).first_line   = (Current).last_line   =		\
668 	    YYRHSLOC (Rhs, 0).last_line;				\
669 	  (Current).first_column = (Current).last_column =		\
670 	    YYRHSLOC (Rhs, 0).last_column;				\
671 	}								\
672     while (YYID (0))
673 #endif
674 
675 
676 /* This macro is provided for backward compatibility. */
677 
678 #ifndef YY_LOCATION_PRINT
679 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
680 #endif
681 
682 
683 /* YYLEX -- calling `yylex' with the right arguments.  */
684 
685 #ifdef YYLEX_PARAM
686 # define YYLEX yylex (&yylval, YYLEX_PARAM)
687 #else
688 # define YYLEX yylex (&yylval)
689 #endif
690 
691 /* Enable debugging if requested.  */
692 #if YYDEBUG
693 
694 # ifndef YYFPRINTF
695 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
696 #  define YYFPRINTF fprintf
697 # endif
698 
699 # define YYDPRINTF(Args)			\
700 do {						\
701   if (yydebug)					\
702     YYFPRINTF Args;				\
703 } while (YYID (0))
704 
705 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
706 do {									  \
707   if (yydebug)								  \
708     {									  \
709       YYFPRINTF (stderr, "%s ", Title);					  \
710       yy_symbol_print (stderr,						  \
711 		  Type, Value); \
712       YYFPRINTF (stderr, "\n");						  \
713     }									  \
714 } while (YYID (0))
715 
716 
717 /*--------------------------------.
718 | Print this symbol on YYOUTPUT.  |
719 `--------------------------------*/
720 
721 /*ARGSUSED*/
722 #if (defined __STDC__ || defined __C99__FUNC__ \
723      || defined __cplusplus || defined _MSC_VER)
724 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)725 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
726 #else
727 static void
728 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
729     FILE *yyoutput;
730     int yytype;
731     YYSTYPE const * const yyvaluep;
732 #endif
733 {
734   if (!yyvaluep)
735     return;
736 # ifdef YYPRINT
737   if (yytype < YYNTOKENS)
738     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
739 # else
740   YYUSE (yyoutput);
741 # endif
742   switch (yytype)
743     {
744       default:
745 	break;
746     }
747 }
748 
749 
750 /*--------------------------------.
751 | Print this symbol on YYOUTPUT.  |
752 `--------------------------------*/
753 
754 #if (defined __STDC__ || defined __C99__FUNC__ \
755      || defined __cplusplus || defined _MSC_VER)
756 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)757 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
758 #else
759 static void
760 yy_symbol_print (yyoutput, yytype, yyvaluep)
761     FILE *yyoutput;
762     int yytype;
763     YYSTYPE const * const yyvaluep;
764 #endif
765 {
766   if (yytype < YYNTOKENS)
767     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
768   else
769     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
770 
771   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
772   YYFPRINTF (yyoutput, ")");
773 }
774 
775 /*------------------------------------------------------------------.
776 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
777 | TOP (included).                                                   |
778 `------------------------------------------------------------------*/
779 
780 #if (defined __STDC__ || defined __C99__FUNC__ \
781      || defined __cplusplus || defined _MSC_VER)
782 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)783 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
784 #else
785 static void
786 yy_stack_print (yybottom, yytop)
787     yytype_int16 *yybottom;
788     yytype_int16 *yytop;
789 #endif
790 {
791   YYFPRINTF (stderr, "Stack now");
792   for (; yybottom <= yytop; yybottom++)
793     {
794       int yybot = *yybottom;
795       YYFPRINTF (stderr, " %d", yybot);
796     }
797   YYFPRINTF (stderr, "\n");
798 }
799 
800 # define YY_STACK_PRINT(Bottom, Top)				\
801 do {								\
802   if (yydebug)							\
803     yy_stack_print ((Bottom), (Top));				\
804 } while (YYID (0))
805 
806 
807 /*------------------------------------------------.
808 | Report that the YYRULE is going to be reduced.  |
809 `------------------------------------------------*/
810 
811 #if (defined __STDC__ || defined __C99__FUNC__ \
812      || defined __cplusplus || defined _MSC_VER)
813 static void
yy_reduce_print(YYSTYPE * yyvsp,int yyrule)814 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
815 #else
816 static void
817 yy_reduce_print (yyvsp, yyrule)
818     YYSTYPE *yyvsp;
819     int yyrule;
820 #endif
821 {
822   int yynrhs = yyr2[yyrule];
823   int yyi;
824   unsigned long int yylno = yyrline[yyrule];
825   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
826 	     yyrule - 1, yylno);
827   /* The symbols being reduced.  */
828   for (yyi = 0; yyi < yynrhs; yyi++)
829     {
830       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
831       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
832 		       &(yyvsp[(yyi + 1) - (yynrhs)])
833 		       		       );
834       YYFPRINTF (stderr, "\n");
835     }
836 }
837 
838 # define YY_REDUCE_PRINT(Rule)		\
839 do {					\
840   if (yydebug)				\
841     yy_reduce_print (yyvsp, Rule); \
842 } while (YYID (0))
843 
844 /* Nonzero means print parse trace.  It is left uninitialized so that
845    multiple parsers can coexist.  */
846 int yydebug;
847 #else /* !YYDEBUG */
848 # define YYDPRINTF(Args)
849 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
850 # define YY_STACK_PRINT(Bottom, Top)
851 # define YY_REDUCE_PRINT(Rule)
852 #endif /* !YYDEBUG */
853 
854 
855 /* YYINITDEPTH -- initial size of the parser's stacks.  */
856 #ifndef	YYINITDEPTH
857 # define YYINITDEPTH 200
858 #endif
859 
860 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
861    if the built-in stack extension method is used).
862 
863    Do not make this value too large; the results are undefined if
864    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
865    evaluated with infinite-precision integer arithmetic.  */
866 
867 #ifndef YYMAXDEPTH
868 # define YYMAXDEPTH 10000
869 #endif
870 
871 
872 #if YYERROR_VERBOSE
873 
874 # ifndef yystrlen
875 #  if defined __GLIBC__ && defined _STRING_H
876 #   define yystrlen strlen
877 #  else
878 /* Return the length of YYSTR.  */
879 #if (defined __STDC__ || defined __C99__FUNC__ \
880      || defined __cplusplus || defined _MSC_VER)
881 static YYSIZE_T
yystrlen(const char * yystr)882 yystrlen (const char *yystr)
883 #else
884 static YYSIZE_T
885 yystrlen (yystr)
886     const char *yystr;
887 #endif
888 {
889   YYSIZE_T yylen;
890   for (yylen = 0; yystr[yylen]; yylen++)
891     continue;
892   return yylen;
893 }
894 #  endif
895 # endif
896 
897 # ifndef yystpcpy
898 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
899 #   define yystpcpy stpcpy
900 #  else
901 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
902    YYDEST.  */
903 #if (defined __STDC__ || defined __C99__FUNC__ \
904      || defined __cplusplus || defined _MSC_VER)
905 static char *
yystpcpy(char * yydest,const char * yysrc)906 yystpcpy (char *yydest, const char *yysrc)
907 #else
908 static char *
909 yystpcpy (yydest, yysrc)
910     char *yydest;
911     const char *yysrc;
912 #endif
913 {
914   char *yyd = yydest;
915   const char *yys = yysrc;
916 
917   while ((*yyd++ = *yys++) != '\0')
918     continue;
919 
920   return yyd - 1;
921 }
922 #  endif
923 # endif
924 
925 # ifndef yytnamerr
926 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
927    quotes and backslashes, so that it's suitable for yyerror.  The
928    heuristic is that double-quoting is unnecessary unless the string
929    contains an apostrophe, a comma, or backslash (other than
930    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
931    null, do not copy; instead, return the length of what the result
932    would have been.  */
933 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)934 yytnamerr (char *yyres, const char *yystr)
935 {
936   if (*yystr == '"')
937     {
938       YYSIZE_T yyn = 0;
939       char const *yyp = yystr;
940 
941       for (;;)
942 	switch (*++yyp)
943 	  {
944 	  case '\'':
945 	  case ',':
946 	    goto do_not_strip_quotes;
947 
948 	  case '\\':
949 	    if (*++yyp != '\\')
950 	      goto do_not_strip_quotes;
951 	    /* Fall through.  */
952 	  default:
953 	    if (yyres)
954 	      yyres[yyn] = *yyp;
955 	    yyn++;
956 	    break;
957 
958 	  case '"':
959 	    if (yyres)
960 	      yyres[yyn] = '\0';
961 	    return yyn;
962 	  }
963     do_not_strip_quotes: ;
964     }
965 
966   if (! yyres)
967     return yystrlen (yystr);
968 
969   return yystpcpy (yyres, yystr) - yyres;
970 }
971 # endif
972 
973 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
974    about the unexpected token YYTOKEN for the state stack whose top is
975    YYSSP.
976 
977    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
978    not large enough to hold the message.  In that case, also set
979    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
980    required number of bytes is too large to store.  */
981 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)982 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
983                 yytype_int16 *yyssp, int yytoken)
984 {
985   YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
986   YYSIZE_T yysize = yysize0;
987   YYSIZE_T yysize1;
988   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
989   /* Internationalized format string. */
990   const char *yyformat = 0;
991   /* Arguments of yyformat. */
992   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
993   /* Number of reported tokens (one for the "unexpected", one per
994      "expected"). */
995   int yycount = 0;
996 
997   /* There are many possibilities here to consider:
998      - Assume YYFAIL is not used.  It's too flawed to consider.  See
999        <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1000        for details.  YYERROR is fine as it does not invoke this
1001        function.
1002      - If this state is a consistent state with a default action, then
1003        the only way this function was invoked is if the default action
1004        is an error action.  In that case, don't check for expected
1005        tokens because there are none.
1006      - The only way there can be no lookahead present (in yychar) is if
1007        this state is a consistent state with a default action.  Thus,
1008        detecting the absence of a lookahead is sufficient to determine
1009        that there is no unexpected or expected token to report.  In that
1010        case, just report a simple "syntax error".
1011      - Don't assume there isn't a lookahead just because this state is a
1012        consistent state with a default action.  There might have been a
1013        previous inconsistent state, consistent state with a non-default
1014        action, or user semantic action that manipulated yychar.
1015      - Of course, the expected token list depends on states to have
1016        correct lookahead information, and it depends on the parser not
1017        to perform extra reductions after fetching a lookahead from the
1018        scanner and before detecting a syntax error.  Thus, state merging
1019        (from LALR or IELR) and default reductions corrupt the expected
1020        token list.  However, the list is correct for canonical LR with
1021        one exception: it will still contain any token that will not be
1022        accepted due to an error action in a later state.
1023   */
1024   if (yytoken != YYEMPTY)
1025     {
1026       int yyn = yypact[*yyssp];
1027       yyarg[yycount++] = yytname[yytoken];
1028       if (!yypact_value_is_default (yyn))
1029         {
1030           /* Start YYX at -YYN if negative to avoid negative indexes in
1031              YYCHECK.  In other words, skip the first -YYN actions for
1032              this state because they are default actions.  */
1033           int yyxbegin = yyn < 0 ? -yyn : 0;
1034           /* Stay within bounds of both yycheck and yytname.  */
1035           int yychecklim = YYLAST - yyn + 1;
1036           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1037           int yyx;
1038 
1039           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1040             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1041                 && !yytable_value_is_error (yytable[yyx + yyn]))
1042               {
1043                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1044                   {
1045                     yycount = 1;
1046                     yysize = yysize0;
1047                     break;
1048                   }
1049                 yyarg[yycount++] = yytname[yyx];
1050                 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1051                 if (! (yysize <= yysize1
1052                        && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1053                   return 2;
1054                 yysize = yysize1;
1055               }
1056         }
1057     }
1058 
1059   switch (yycount)
1060     {
1061 # define YYCASE_(N, S)                      \
1062       case N:                               \
1063         yyformat = S;                       \
1064       break
1065       YYCASE_(0, YY_("syntax error"));
1066       YYCASE_(1, YY_("syntax error, unexpected %s"));
1067       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1068       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1069       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1070       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1071 # undef YYCASE_
1072     }
1073 
1074   yysize1 = yysize + yystrlen (yyformat);
1075   if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1076     return 2;
1077   yysize = yysize1;
1078 
1079   if (*yymsg_alloc < yysize)
1080     {
1081       *yymsg_alloc = 2 * yysize;
1082       if (! (yysize <= *yymsg_alloc
1083              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1084         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1085       return 1;
1086     }
1087 
1088   /* Avoid sprintf, as that infringes on the user's name space.
1089      Don't have undefined behavior even if the translation
1090      produced a string with the wrong number of "%s"s.  */
1091   {
1092     char *yyp = *yymsg;
1093     int yyi = 0;
1094     while ((*yyp = *yyformat) != '\0')
1095       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1096         {
1097           yyp += yytnamerr (yyp, yyarg[yyi++]);
1098           yyformat += 2;
1099         }
1100       else
1101         {
1102           yyp++;
1103           yyformat++;
1104         }
1105   }
1106   return 0;
1107 }
1108 #endif /* YYERROR_VERBOSE */
1109 
1110 /*-----------------------------------------------.
1111 | Release the memory associated to this symbol.  |
1112 `-----------------------------------------------*/
1113 
1114 /*ARGSUSED*/
1115 #if (defined __STDC__ || defined __C99__FUNC__ \
1116      || defined __cplusplus || defined _MSC_VER)
1117 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep)1118 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1119 #else
1120 static void
1121 yydestruct (yymsg, yytype, yyvaluep)
1122     const char *yymsg;
1123     int yytype;
1124     YYSTYPE *yyvaluep;
1125 #endif
1126 {
1127   YYUSE (yyvaluep);
1128 
1129   if (!yymsg)
1130     yymsg = "Deleting";
1131   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1132 
1133   switch (yytype)
1134     {
1135 
1136       default:
1137 	break;
1138     }
1139 }
1140 
1141 
1142 /* Prevent warnings from -Wmissing-prototypes.  */
1143 #ifdef YYPARSE_PARAM
1144 #if defined __STDC__ || defined __cplusplus
1145 int yyparse (void *YYPARSE_PARAM);
1146 #else
1147 int yyparse ();
1148 #endif
1149 #else /* ! YYPARSE_PARAM */
1150 #if defined __STDC__ || defined __cplusplus
1151 int yyparse (void);
1152 #else
1153 int yyparse ();
1154 #endif
1155 #endif /* ! YYPARSE_PARAM */
1156 
1157 
1158 /*----------.
1159 | yyparse.  |
1160 `----------*/
1161 
1162 #ifdef YYPARSE_PARAM
1163 #if (defined __STDC__ || defined __C99__FUNC__ \
1164      || defined __cplusplus || defined _MSC_VER)
1165 int
yyparse(void * YYPARSE_PARAM)1166 yyparse (void *YYPARSE_PARAM)
1167 #else
1168 int
1169 yyparse (YYPARSE_PARAM)
1170     void *YYPARSE_PARAM;
1171 #endif
1172 #else /* ! YYPARSE_PARAM */
1173 #if (defined __STDC__ || defined __C99__FUNC__ \
1174      || defined __cplusplus || defined _MSC_VER)
1175 int
1176 yyparse (void)
1177 #else
1178 int
1179 yyparse ()
1180 
1181 #endif
1182 #endif
1183 {
1184 /* The lookahead symbol.  */
1185 int yychar;
1186 /* The backup of yychar when there is an error and we're in yyerrlab. */
1187 int yylastchar;
1188 
1189 /* The semantic value of the lookahead symbol.  */
1190 YYSTYPE yylval;
1191 
1192     /* Number of syntax errors so far.  */
1193     int yynerrs;
1194 
1195     int yystate;
1196     /* Number of tokens to shift before error messages enabled.  */
1197     int yyerrstatus;
1198 
1199     /* The stacks and their tools:
1200        `yyss': related to states.
1201        `yyvs': related to semantic values.
1202 
1203        Refer to the stacks thru separate pointers, to allow yyoverflow
1204        to reallocate them elsewhere.  */
1205 
1206     /* The state stack.  */
1207     yytype_int16 yyssa[YYINITDEPTH];
1208     yytype_int16 *yyss;
1209     yytype_int16 *yyssp;
1210 
1211     /* The semantic value stack.  */
1212     YYSTYPE yyvsa[YYINITDEPTH];
1213     YYSTYPE *yyvs;
1214     YYSTYPE *yyvsp;
1215 
1216     YYSIZE_T yystacksize;
1217 
1218   int yyn;
1219   int yyresult;
1220   /* Lookahead token as an internal (translated) token number.  */
1221   int yytoken;
1222   /* The variables used to return semantic value and location from the
1223      action routines.  */
1224   YYSTYPE yyval;
1225 
1226 #if YYERROR_VERBOSE
1227   /* Buffer for error messages, and its allocated size.  */
1228   char yymsgbuf[128];
1229   char *yymsg = yymsgbuf;
1230   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1231 #endif
1232 
1233 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1234 
1235   /* The number of symbols on the RHS of the reduced rule.
1236      Keep to zero when no symbol should be popped.  */
1237   int yylen = 0;
1238 
1239   yytoken = 0;
1240   yyss = yyssa;
1241   yyvs = yyvsa;
1242   yystacksize = YYINITDEPTH;
1243 
1244   YYDPRINTF ((stderr, "Starting parse\n"));
1245 
1246   yystate = 0;
1247   yyerrstatus = 0;
1248   yynerrs = 0;
1249   yychar = YYEMPTY; /* Cause a token to be read.  */
1250 
1251   /* Initialize stack pointers.
1252      Waste one element of value and location stack
1253      so that they stay on the same level as the state stack.
1254      The wasted elements are never initialized.  */
1255   yyssp = yyss;
1256   yyvsp = yyvs;
1257 
1258   goto yysetstate;
1259 
1260 /*------------------------------------------------------------.
1261 | yynewstate -- Push a new state, which is found in yystate.  |
1262 `------------------------------------------------------------*/
1263  yynewstate:
1264   /* In all cases, when you get here, the value and location stacks
1265      have just been pushed.  So pushing a state here evens the stacks.  */
1266   yyssp++;
1267 
1268  yysetstate:
1269   *yyssp = yystate;
1270 
1271   if (yyss + yystacksize - 1 <= yyssp)
1272     {
1273       /* Get the current used size of the three stacks, in elements.  */
1274       YYSIZE_T yysize = yyssp - yyss + 1;
1275 
1276 #ifdef yyoverflow
1277       {
1278 	/* Give user a chance to reallocate the stack.  Use copies of
1279 	   these so that the &'s don't force the real ones into
1280 	   memory.  */
1281 	YYSTYPE *yyvs1 = yyvs;
1282 	yytype_int16 *yyss1 = yyss;
1283 
1284 	/* Each stack pointer address is followed by the size of the
1285 	   data in use in that stack, in bytes.  This used to be a
1286 	   conditional around just the two extra args, but that might
1287 	   be undefined if yyoverflow is a macro.  */
1288 	yyoverflow (YY_("memory exhausted"),
1289 		    &yyss1, yysize * sizeof (*yyssp),
1290 		    &yyvs1, yysize * sizeof (*yyvsp),
1291 		    &yystacksize);
1292 
1293 	yyss = yyss1;
1294 	yyvs = yyvs1;
1295       }
1296 #else /* no yyoverflow */
1297 # ifndef YYSTACK_RELOCATE
1298       goto yyexhaustedlab;
1299 # else
1300       /* Extend the stack our own way.  */
1301       if (YYMAXDEPTH <= yystacksize)
1302 	goto yyexhaustedlab;
1303       yystacksize *= 2;
1304       if (YYMAXDEPTH < yystacksize)
1305 	yystacksize = YYMAXDEPTH;
1306 
1307       {
1308 	yytype_int16 *yyss1 = yyss;
1309 	union yyalloc *yyptr =
1310 	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1311 	if (! yyptr)
1312 	  goto yyexhaustedlab;
1313 	YYSTACK_RELOCATE (yyss_alloc, yyss);
1314 	YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1315 #  undef YYSTACK_RELOCATE
1316 	if (yyss1 != yyssa)
1317 	  YYSTACK_FREE (yyss1);
1318       }
1319 # endif
1320 #endif /* no yyoverflow */
1321 
1322       yyssp = yyss + yysize - 1;
1323       yyvsp = yyvs + yysize - 1;
1324 
1325       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1326 		  (unsigned long int) yystacksize));
1327 
1328       if (yyss + yystacksize - 1 <= yyssp)
1329 	YYABORT;
1330     }
1331 
1332   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1333 
1334   if (yystate == YYFINAL)
1335     YYACCEPT;
1336 
1337   goto yybackup;
1338 
1339 /*-----------.
1340 | yybackup.  |
1341 `-----------*/
1342 yybackup:
1343 
1344   /* Do appropriate processing given the current state.  Read a
1345      lookahead token if we need one and don't already have one.  */
1346 
1347   /* First try to decide what to do without reference to lookahead token.  */
1348   yyn = yypact[yystate];
1349   if (yypact_value_is_default (yyn))
1350     goto yydefault;
1351 
1352   /* Not known => get a lookahead token if don't already have one.  */
1353 
1354   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1355   if (yychar == YYEMPTY)
1356     {
1357       YYDPRINTF ((stderr, "Reading a token: "));
1358       yychar = YYLEX;
1359     }
1360 
1361   if (yychar <= YYEOF)
1362     {
1363       yychar = yytoken = YYEOF;
1364       YYDPRINTF ((stderr, "Now at end of input.\n"));
1365     }
1366   else
1367     {
1368       yytoken = YYTRANSLATE (yychar);
1369       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1370     }
1371 
1372   /* If the proper action on seeing token YYTOKEN is to reduce or to
1373      detect an error, take that action.  */
1374   yyn += yytoken;
1375   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1376     goto yydefault;
1377   yyn = yytable[yyn];
1378   if (yyn <= 0)
1379     {
1380       if (yytable_value_is_error (yyn))
1381         goto yyerrlab;
1382       yyn = -yyn;
1383       goto yyreduce;
1384     }
1385 
1386   /* Count tokens shifted since error; after three, turn off error
1387      status.  */
1388   if (yyerrstatus)
1389     yyerrstatus--;
1390 
1391   /* Shift the lookahead token.  */
1392   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1393 
1394   /* Discard the shifted token.  */
1395   yychar = YYEMPTY;
1396 
1397   yystate = yyn;
1398   *++yyvsp = yylval;
1399 
1400   goto yynewstate;
1401 
1402 
1403 /*-----------------------------------------------------------.
1404 | yydefault -- do the default action for the current state.  |
1405 `-----------------------------------------------------------*/
1406 yydefault:
1407   yyn = yydefact[yystate];
1408   if (yyn == 0)
1409     goto yyerrlab;
1410   goto yyreduce;
1411 
1412 
1413 /*-----------------------------.
1414 | yyreduce -- Do a reduction.  |
1415 `-----------------------------*/
1416 yyreduce:
1417   /* yyn is the number of a rule to reduce with.  */
1418   yylen = yyr2[yyn];
1419 
1420   /* If YYLEN is nonzero, implement the default value of the action:
1421      `$$ = $1'.
1422 
1423      Otherwise, the following line sets YYVAL to garbage.
1424      This behavior is undocumented and Bison
1425      users should not rely upon it.  Assigning to YYVAL
1426      unconditionally makes the parser a bit smaller, and it avoids a
1427      GCC warning that YYVAL may be used uninitialized.  */
1428   yyval = yyvsp[1-yylen];
1429 
1430 
1431   YY_REDUCE_PRINT (yyn);
1432   switch (yyn)
1433     {
1434         case 2:
1435 
1436 /* Line 1806 of yacc.c  */
1437 #line 79 "fts0pars.y"
1438     {
1439 		(yyval.node) = (yyvsp[(1) - (1)].node);
1440 		((fts_ast_state_t*) state)->root = (yyval.node);
1441 	}
1442     break;
1443 
1444   case 3:
1445 
1446 /* Line 1806 of yacc.c  */
1447 #line 85 "fts0pars.y"
1448     {
1449 		(yyval.node) = NULL;
1450 	}
1451     break;
1452 
1453   case 4:
1454 
1455 /* Line 1806 of yacc.c  */
1456 #line 89 "fts0pars.y"
1457     {
1458 		(yyval.node) = (yyvsp[(1) - (2)].node);
1459 
1460 		if (!(yyval.node)) {
1461 			(yyval.node) = fts_ast_create_node_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 5:
1469 
1470 /* Line 1806 of yacc.c  */
1471 #line 99 "fts0pars.y"
1472     {
1473 		(yyval.node) = (yyvsp[(1) - (2)].node);
1474 		(yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (2)].node));
1475 
1476 		if (!(yyval.node)) {
1477 			(yyval.node) = (yyvsp[(2) - (2)].node);
1478 		} else {
1479 			fts_ast_add_node((yyval.node), (yyvsp[(2) - (2)].node));
1480 		}
1481 	}
1482     break;
1483 
1484   case 6:
1485 
1486 /* Line 1806 of yacc.c  */
1487 #line 111 "fts0pars.y"
1488     {
1489 		(yyval.node) = (yyvsp[(2) - (3)].node);
1490 
1491 		if ((yyval.node)) {
1492 			(yyval.node) = fts_ast_create_node_subexp_list(state, (yyval.node));
1493 		}
1494 	}
1495     break;
1496 
1497   case 7:
1498 
1499 /* Line 1806 of yacc.c  */
1500 #line 119 "fts0pars.y"
1501     {
1502 		(yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (4)].node));
1503 
1504 		if ((yyvsp[(3) - (4)].node)) {
1505 			fts_ast_add_node((yyval.node),
1506 				fts_ast_create_node_subexp_list(state, (yyvsp[(3) - (4)].node)));
1507 		}
1508 	}
1509     break;
1510 
1511   case 8:
1512 
1513 /* Line 1806 of yacc.c  */
1514 #line 129 "fts0pars.y"
1515     {
1516 		(yyval.node) = (yyvsp[(1) - (1)].node);
1517 	}
1518     break;
1519 
1520   case 9:
1521 
1522 /* Line 1806 of yacc.c  */
1523 #line 133 "fts0pars.y"
1524     {
1525 		(yyval.node) = (yyvsp[(1) - (1)].node);
1526 	}
1527     break;
1528 
1529   case 10:
1530 
1531 /* Line 1806 of yacc.c  */
1532 #line 137 "fts0pars.y"
1533     {
1534 		fts_ast_term_set_wildcard((yyvsp[(1) - (2)].node));
1535 	}
1536     break;
1537 
1538   case 11:
1539 
1540 /* Line 1806 of yacc.c  */
1541 #line 141 "fts0pars.y"
1542     {
1543 		fts_ast_text_set_distance((yyvsp[(1) - (3)].node), fts_ast_string_to_ul((yyvsp[(3) - (3)].token), 10));
1544 		fts_ast_string_free((yyvsp[(3) - (3)].token));
1545 	}
1546     break;
1547 
1548   case 12:
1549 
1550 /* Line 1806 of yacc.c  */
1551 #line 146 "fts0pars.y"
1552     {
1553 		(yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (3)].node));
1554 		fts_ast_add_node((yyval.node), (yyvsp[(2) - (3)].node));
1555 		fts_ast_term_set_wildcard((yyvsp[(2) - (3)].node));
1556 	}
1557     break;
1558 
1559   case 13:
1560 
1561 /* Line 1806 of yacc.c  */
1562 #line 152 "fts0pars.y"
1563     {
1564 		(yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (2)].node));
1565 		fts_ast_add_node((yyval.node), (yyvsp[(2) - (2)].node));
1566 	}
1567     break;
1568 
1569   case 14:
1570 
1571 /* Line 1806 of yacc.c  */
1572 #line 157 "fts0pars.y"
1573     {
1574 		(yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (4)].node));
1575 		fts_ast_add_node((yyval.node), (yyvsp[(2) - (4)].node));
1576 		fts_ast_text_set_distance((yyvsp[(2) - (4)].node), fts_ast_string_to_ul((yyvsp[(4) - (4)].token), 10));
1577 		fts_ast_string_free((yyvsp[(4) - (4)].token));
1578 	}
1579     break;
1580 
1581   case 15:
1582 
1583 /* Line 1806 of yacc.c  */
1584 #line 164 "fts0pars.y"
1585     {
1586 		(yyval.node) = fts_ast_create_node_list(state, (yyvsp[(1) - (2)].node));
1587 		fts_ast_add_node((yyval.node), (yyvsp[(2) - (2)].node));
1588 	}
1589     break;
1590 
1591   case 16:
1592 
1593 /* Line 1806 of yacc.c  */
1594 #line 170 "fts0pars.y"
1595     {
1596 		(yyval.node) = fts_ast_create_node_oper(state, FTS_IGNORE);
1597 	}
1598     break;
1599 
1600   case 17:
1601 
1602 /* Line 1806 of yacc.c  */
1603 #line 174 "fts0pars.y"
1604     {
1605 		(yyval.node) = fts_ast_create_node_oper(state, FTS_EXIST);
1606 	}
1607     break;
1608 
1609   case 18:
1610 
1611 /* Line 1806 of yacc.c  */
1612 #line 178 "fts0pars.y"
1613     {
1614 		(yyval.node) = fts_ast_create_node_oper(state, FTS_NEGATE);
1615 	}
1616     break;
1617 
1618   case 19:
1619 
1620 /* Line 1806 of yacc.c  */
1621 #line 182 "fts0pars.y"
1622     {
1623 		(yyval.node) = fts_ast_create_node_oper(state, FTS_DECR_RATING);
1624 	}
1625     break;
1626 
1627   case 20:
1628 
1629 /* Line 1806 of yacc.c  */
1630 #line 186 "fts0pars.y"
1631     {
1632 		(yyval.node) = fts_ast_create_node_oper(state, FTS_INCR_RATING);
1633 	}
1634     break;
1635 
1636   case 21:
1637 
1638 /* Line 1806 of yacc.c  */
1639 #line 191 "fts0pars.y"
1640     {
1641 		(yyval.node)  = fts_ast_create_node_term(state, (yyvsp[(1) - (1)].token));
1642 		fts_ast_string_free((yyvsp[(1) - (1)].token));
1643 	}
1644     break;
1645 
1646   case 22:
1647 
1648 /* Line 1806 of yacc.c  */
1649 #line 196 "fts0pars.y"
1650     {
1651 		(yyval.node)  = fts_ast_create_node_term(state, (yyvsp[(1) - (1)].token));
1652 		fts_ast_string_free((yyvsp[(1) - (1)].token));
1653 	}
1654     break;
1655 
1656   case 23:
1657 
1658 /* Line 1806 of yacc.c  */
1659 #line 202 "fts0pars.y"
1660     {
1661 		(yyval.node)  = (yyvsp[(2) - (2)].node);
1662 	}
1663     break;
1664 
1665   case 24:
1666 
1667 /* Line 1806 of yacc.c  */
1668 #line 207 "fts0pars.y"
1669     {
1670 		(yyval.node)  = fts_ast_create_node_text(state, (yyvsp[(1) - (1)].token));
1671 		fts_ast_string_free((yyvsp[(1) - (1)].token));
1672 	}
1673     break;
1674 
1675 
1676 
1677 /* Line 1806 of yacc.c  */
1678 #line 1663 "fts0pars.cc"
1679       default: break;
1680     }
1681   /* User semantic actions sometimes alter yychar, and that requires
1682      that yytoken be updated with the new translation.  We take the
1683      approach of translating immediately before every use of yytoken.
1684      One alternative is translating here after every semantic action,
1685      but that translation would be missed if the semantic action invokes
1686      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1687      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1688      incorrect destructor might then be invoked immediately.  In the
1689      case of YYERROR or YYBACKUP, subsequent parser actions might lead
1690      to an incorrect destructor call or verbose syntax error message
1691      before the lookahead is translated.  */
1692   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1693 
1694   YYPOPSTACK (yylen);
1695   yylen = 0;
1696   YY_STACK_PRINT (yyss, yyssp);
1697 
1698   *++yyvsp = yyval;
1699 
1700   /* Now `shift' the result of the reduction.  Determine what state
1701      that goes to, based on the state we popped back to and the rule
1702      number reduced by.  */
1703 
1704   yyn = yyr1[yyn];
1705 
1706   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1707   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1708     yystate = yytable[yystate];
1709   else
1710     yystate = yydefgoto[yyn - YYNTOKENS];
1711 
1712   goto yynewstate;
1713 
1714 
1715 /*------------------------------------.
1716 | yyerrlab -- here on detecting error |
1717 `------------------------------------*/
1718 yyerrlab:
1719   /* Backup yychar, in case we would change it. */
1720   yylastchar = yychar;
1721   /* Make sure we have latest lookahead translation.  See comments at
1722      user semantic actions for why this is necessary.  */
1723   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1724 
1725   /* If not already recovering from an error, report this error.  */
1726   if (!yyerrstatus)
1727     {
1728       ++yynerrs;
1729 #if ! YYERROR_VERBOSE
1730       yyerror (YY_("syntax error"));
1731 #else
1732 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1733                                         yyssp, yytoken)
1734       {
1735         char const *yymsgp = YY_("syntax error");
1736         int yysyntax_error_status;
1737         yysyntax_error_status = YYSYNTAX_ERROR;
1738         if (yysyntax_error_status == 0)
1739           yymsgp = yymsg;
1740         else if (yysyntax_error_status == 1)
1741           {
1742             if (yymsg != yymsgbuf)
1743               YYSTACK_FREE (yymsg);
1744             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1745             if (!yymsg)
1746               {
1747                 yymsg = yymsgbuf;
1748                 yymsg_alloc = sizeof yymsgbuf;
1749                 yysyntax_error_status = 2;
1750               }
1751             else
1752               {
1753                 yysyntax_error_status = YYSYNTAX_ERROR;
1754                 yymsgp = yymsg;
1755               }
1756           }
1757         yyerror (yymsgp);
1758         if (yysyntax_error_status == 2)
1759           goto yyexhaustedlab;
1760       }
1761 # undef YYSYNTAX_ERROR
1762 #endif
1763     }
1764 
1765 
1766 
1767   if (yyerrstatus == 3)
1768     {
1769       /* If just tried and failed to reuse lookahead token after an
1770 	 error, discard it.  */
1771 
1772       if (yychar <= YYEOF)
1773 	{
1774 	  /* Return failure if at end of input.  */
1775 	  if (yychar == YYEOF)
1776 	    {
1777 	      /* Since we don't need the token, we have to free it first. */
1778 	      YYERRCLEANUP;
1779 	      YYABORT;
1780 	    }
1781 	}
1782       else
1783 	{
1784 	  yydestruct ("Error: discarding",
1785 		      yytoken, &yylval);
1786 	  yychar = YYEMPTY;
1787 	}
1788     }
1789 
1790   /* Else will try to reuse lookahead token after shifting the error
1791      token.  */
1792   goto yyerrlab1;
1793 
1794 
1795 /*---------------------------------------------------.
1796 | yyerrorlab -- error raised explicitly by YYERROR.  |
1797 `---------------------------------------------------*/
1798 yyerrorlab:
1799 
1800   /* Pacify compilers like GCC when the user code never invokes
1801      YYERROR and the label yyerrorlab therefore never appears in user
1802      code.  */
1803   if (/*CONSTCOND*/ 0)
1804      goto yyerrorlab;
1805 
1806   /* Do not reclaim the symbols of the rule which action triggered
1807      this YYERROR.  */
1808   YYPOPSTACK (yylen);
1809   yylen = 0;
1810   YY_STACK_PRINT (yyss, yyssp);
1811   yystate = *yyssp;
1812   goto yyerrlab1;
1813 
1814 
1815 /*-------------------------------------------------------------.
1816 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1817 `-------------------------------------------------------------*/
1818 yyerrlab1:
1819   yyerrstatus = 3;	/* Each real token shifted decrements this.  */
1820 
1821   for (;;)
1822     {
1823       yyn = yypact[yystate];
1824       if (!yypact_value_is_default (yyn))
1825 	{
1826 	  yyn += YYTERROR;
1827 	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1828 	    {
1829 	      yyn = yytable[yyn];
1830 	      if (0 < yyn)
1831 		break;
1832 	    }
1833 	}
1834 
1835       /* Pop the current state because it cannot handle the error token.  */
1836       if (yyssp == yyss)
1837 	{
1838 	  /* Since we don't need the error token, we have to free it first. */
1839 	  YYERRCLEANUP;
1840 	  YYABORT;
1841 	}
1842 
1843 
1844       yydestruct ("Error: popping",
1845 		  yystos[yystate], yyvsp);
1846       YYPOPSTACK (1);
1847       yystate = *yyssp;
1848       YY_STACK_PRINT (yyss, yyssp);
1849     }
1850 
1851   *++yyvsp = yylval;
1852 
1853 
1854   /* Shift the error token.  */
1855   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1856 
1857   yystate = yyn;
1858   goto yynewstate;
1859 
1860 
1861 /*-------------------------------------.
1862 | yyacceptlab -- YYACCEPT comes here.  |
1863 `-------------------------------------*/
1864 yyacceptlab:
1865   yyresult = 0;
1866   goto yyreturn;
1867 
1868 /*-----------------------------------.
1869 | yyabortlab -- YYABORT comes here.  |
1870 `-----------------------------------*/
1871 yyabortlab:
1872   yyresult = 1;
1873   goto yyreturn;
1874 
1875 #if !defined(yyoverflow) || YYERROR_VERBOSE
1876 /*-------------------------------------------------.
1877 | yyexhaustedlab -- memory exhaustion comes here.  |
1878 `-------------------------------------------------*/
1879 yyexhaustedlab:
1880   yyerror (YY_("memory exhausted"));
1881   yyresult = 2;
1882   /* Fall through.  */
1883 #endif
1884 
1885 yyreturn:
1886   if (yychar != YYEMPTY)
1887     {
1888       /* Make sure we have latest lookahead translation.  See comments at
1889          user semantic actions for why this is necessary.  */
1890       yytoken = YYTRANSLATE (yychar);
1891       yydestruct ("Cleanup: discarding lookahead",
1892                   yytoken, &yylval);
1893     }
1894   /* Do not reclaim the symbols of the rule which action triggered
1895      this YYABORT or YYACCEPT.  */
1896   YYPOPSTACK (yylen);
1897   YY_STACK_PRINT (yyss, yyssp);
1898   while (yyssp != yyss)
1899     {
1900       yydestruct ("Cleanup: popping",
1901 		  yystos[*yyssp], yyvsp);
1902       YYPOPSTACK (1);
1903     }
1904 #ifndef yyoverflow
1905   if (yyss != yyssa)
1906     YYSTACK_FREE (yyss);
1907 #endif
1908 #if YYERROR_VERBOSE
1909   if (yymsg != yymsgbuf)
1910     YYSTACK_FREE (yymsg);
1911 #endif
1912   /* Make sure YYID is used.  */
1913   return YYID (yyresult);
1914 }
1915 
1916 
1917 
1918 /* Line 2067 of yacc.c  */
1919 #line 212 "fts0pars.y"
1920 
1921 
1922 /********************************************************************
1923 */
1924 int
ftserror(const char * p)1925 ftserror(
1926 /*=====*/
1927 	const char*	p)
1928 {
1929 	my_printf_error(ER_PARSE_ERROR, "%s", MYF(0), p);
1930 	return(0);
1931 }
1932 
1933 /********************************************************************
1934 Create a fts_lexer_t instance.*/
1935 fts_lexer_t*
fts_lexer_create(ibool boolean_mode,const byte * query,ulint query_len)1936 fts_lexer_create(
1937 /*=============*/
1938 	ibool		boolean_mode,
1939 	const byte*	query,
1940 	ulint		query_len)
1941 {
1942 	fts_lexer_t*	fts_lexer = static_cast<fts_lexer_t*>(
1943 		ut_malloc_nokey(sizeof(fts_lexer_t)));
1944 
1945 	if (boolean_mode) {
1946 		fts0blex_init(&fts_lexer->yyscanner);
1947 		fts0b_scan_bytes(
1948 			reinterpret_cast<const char*>(query),
1949 			static_cast<int>(query_len),
1950 			fts_lexer->yyscanner);
1951 		fts_lexer->scanner = fts_blexer;
1952 		/* FIXME: Debugging */
1953 		/* fts0bset_debug(1 , fts_lexer->yyscanner); */
1954 	} else {
1955 		fts0tlex_init(&fts_lexer->yyscanner);
1956 		fts0t_scan_bytes(
1957 			reinterpret_cast<const char*>(query),
1958 			static_cast<int>(query_len),
1959 			fts_lexer->yyscanner);
1960 		fts_lexer->scanner = fts_tlexer;
1961 	}
1962 
1963 	return(fts_lexer);
1964 }
1965 
1966 /********************************************************************
1967 Free an fts_lexer_t instance.*/
1968 void
1969 
fts_lexer_free(fts_lexer_t * fts_lexer)1970 fts_lexer_free(
1971 /*===========*/
1972 	fts_lexer_t*	fts_lexer)
1973 {
1974 	if (fts_lexer->scanner == fts_blexer) {
1975 		fts0blex_destroy(fts_lexer->yyscanner);
1976 	} else {
1977 		fts0tlex_destroy(fts_lexer->yyscanner);
1978 	}
1979 
1980 	ut_free(fts_lexer);
1981 }
1982 
1983 /********************************************************************
1984 Call the appropaiate scanner.*/
1985 int
fts_lexer(YYSTYPE * val,fts_lexer_t * fts_lexer)1986 fts_lexer(
1987 /*======*/
1988 	YYSTYPE*	val,
1989 	fts_lexer_t*	fts_lexer)
1990 {
1991 	fts_scanner func_ptr;
1992 
1993 	func_ptr = fts_lexer->scanner;
1994 
1995 	return(func_ptr(val, fts_lexer->yyscanner));
1996 }
1997 
1998 /********************************************************************
1999 Parse the query.*/
2000 int
fts_parse(fts_ast_state_t * state)2001 fts_parse(
2002 /*======*/
2003 	fts_ast_state_t*	state)
2004 {
2005 	return(ftsparse(state));
2006 }
2007 
2008