You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1983 lines
52 KiB

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