1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
46 /* Identify Bison output. */
50 #define YYBISON_VERSION "2.3"
53 #define YYSKELETON_NAME "yacc.c"
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
66 /* Put the tokens into the symbol table, so that GDB and other debuggers
77 #define TOK_STRING 258
81 #define TOK_ED2K_LINK 262
82 /* Copy the first part of user declarations. */
87 #include "Scanner.h.in"
89 #include "OtherFunctions.h"
90 #include "SearchExpr.h"
92 #include "libs/common/StringFunctions.h"
96 static char THIS_FILE
[] = __FILE__
;
99 extern wxArrayString _astrParserErrors
;
101 void ParsedSearchExpression(const CSearchExpr
* pexpr
);
102 int yyerror(const char* errstr
);
103 int yyerror(wxString errstr
);
107 /* Enabling traces. */
112 /* Enabling verbose error messages. */
113 #ifdef YYERROR_VERBOSE
114 # undef YYERROR_VERBOSE
115 # define YYERROR_VERBOSE 1
117 # define YYERROR_VERBOSE 0
120 /* Enabling the token table. */
121 #ifndef YYTOKEN_TABLE
122 # define YYTOKEN_TABLE 0
125 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
126 typedef union YYSTYPE
127 #line 23 "./Parser.y"
132 /* Line 187 of yacc.c. */
133 #line 137 "Parser.cpp"
135 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
136 # define YYSTYPE_IS_DECLARED 1
137 # define YYSTYPE_IS_TRIVIAL 1
142 /* Copy the second part of user declarations. */
145 /* Line 216 of yacc.c. */
146 #line 150 "Parser.cpp"
153 typedef YYTYPE_UINT8 yytype_uint8
;
155 typedef unsigned char yytype_uint8
;
159 typedef YYTYPE_INT8 yytype_int8
;
160 #elif (defined __STDC__ || defined __C99__FUNC__ \
161 || defined __cplusplus || defined _MSC_VER)
162 typedef signed char yytype_int8
;
164 typedef short int yytype_int8
;
168 typedef YYTYPE_UINT16 yytype_uint16
;
170 typedef unsigned short int yytype_uint16
;
174 typedef YYTYPE_INT16 yytype_int16
;
176 typedef short int yytype_int16
;
180 # ifdef __SIZE_TYPE__
181 # define YYSIZE_T __SIZE_TYPE__
182 # elif defined size_t
183 # define YYSIZE_T size_t
184 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
185 || defined __cplusplus || defined _MSC_VER)
186 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
187 # define YYSIZE_T size_t
189 # define YYSIZE_T unsigned int
193 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
198 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
199 # define YY_(msgid) dgettext ("bison-runtime", msgid)
203 # define YY_(msgid) msgid
207 /* Suppress unused-variable warnings by "using" E. */
208 #if ! defined lint || defined __GNUC__
209 # define YYUSE(e) ((void) (e))
211 # define YYUSE(e) /* empty */
214 /* Identity function, used to suppress warnings about constant conditions. */
218 #if (defined __STDC__ || defined __C99__FUNC__ \
219 || defined __cplusplus || defined _MSC_VER)
232 #if ! defined yyoverflow || YYERROR_VERBOSE
234 /* The parser invokes alloca or malloc; define the necessary symbols. */
236 # ifdef YYSTACK_USE_ALLOCA
237 # if YYSTACK_USE_ALLOCA
239 # define YYSTACK_ALLOC __builtin_alloca
240 # elif defined __BUILTIN_VA_ARG_INCR
241 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
243 # define YYSTACK_ALLOC __alloca
244 # elif defined _MSC_VER
245 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
246 # define alloca _alloca
248 # define YYSTACK_ALLOC alloca
249 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
250 || defined __cplusplus || defined _MSC_VER)
251 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
260 # ifdef YYSTACK_ALLOC
261 /* Pacify GCC's `empty if-body' warning. */
262 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
263 # ifndef YYSTACK_ALLOC_MAXIMUM
264 /* The OS might guarantee only one guard page at the bottom of the stack,
265 and a page size can be as small as 4096 bytes. So we cannot safely
266 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
267 to allow for a few compiler-allocated temporary stack slots. */
268 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
271 # define YYSTACK_ALLOC YYMALLOC
272 # define YYSTACK_FREE YYFREE
273 # ifndef YYSTACK_ALLOC_MAXIMUM
274 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
276 # if (defined __cplusplus && ! defined _STDLIB_H \
277 && ! ((defined YYMALLOC || defined malloc) \
278 && (defined YYFREE || defined free)))
279 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
285 # define YYMALLOC malloc
286 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
287 || defined __cplusplus || defined _MSC_VER)
288 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
293 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
294 || defined __cplusplus || defined _MSC_VER)
295 void free (void *); /* INFRINGES ON USER NAME SPACE */
299 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
302 #if (! defined yyoverflow \
303 && (! defined __cplusplus \
304 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
306 /* A type that is properly aligned for any stack member. */
313 /* The size of the maximum gap between one aligned stack and the next. */
314 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
316 /* The size of an array large to enough to hold all stacks, each with
318 # define YYSTACK_BYTES(N) \
319 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
320 + YYSTACK_GAP_MAXIMUM)
322 /* Copy COUNT objects from FROM to TO. The source and destination do
325 # if defined __GNUC__ && 1 < __GNUC__
326 # define YYCOPY(To, From, Count) \
327 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
329 # define YYCOPY(To, From, Count) \
333 for (yyi = 0; yyi < (Count); yyi++) \
334 (To)[yyi] = (From)[yyi]; \
340 /* Relocate STACK from its old location to the new one. The
341 local variables YYSIZE and YYSTACKSIZE give the old and new number of
342 elements in the stack, and YYPTR gives the new location of the
343 stack. Advance YYPTR to a properly aligned location for the next
345 # define YYSTACK_RELOCATE(Stack) \
348 YYSIZE_T yynewbytes; \
349 YYCOPY (&yyptr->Stack, Stack, yysize); \
350 Stack = &yyptr->Stack; \
351 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
352 yyptr += yynewbytes / sizeof (*yyptr); \
358 /* YYFINAL -- State number of the termination state. */
360 /* YYLAST -- Last index in YYTABLE. */
363 /* YYNTOKENS -- Number of terminals. */
365 /* YYNNTS -- Number of nonterminals. */
367 /* YYNRULES -- Number of rules. */
369 /* YYNRULES -- Number of states. */
372 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
374 #define YYMAXUTOK 262
376 #define YYTRANSLATE(YYX) \
377 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
379 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
380 static const yytype_uint8 yytranslate
[] =
382 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
383 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
384 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
385 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
386 8, 9, 2, 2, 2, 2, 2, 2, 2, 2,
387 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
388 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
389 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
390 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
391 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
392 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
393 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
394 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
395 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
396 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
397 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
398 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
399 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
400 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
401 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
402 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
403 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
404 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
405 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
406 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
407 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
412 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
414 static const yytype_uint8 yyprhs
[] =
416 0, 0, 3, 5, 7, 10, 12, 16, 20, 24,
417 28, 32, 36, 39, 43, 46, 49, 52, 54
420 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
421 static const yytype_int8 yyrhs
[] =
423 11, 0, -1, 12, -1, 7, -1, 12, 1, -1,
424 13, -1, 12, 4, 12, -1, 12, 5, 12, -1,
425 12, 6, 12, -1, 8, 12, 9, -1, 12, 5,
426 1, -1, 12, 6, 1, -1, 8, 1, -1, 8,
427 12, 1, -1, 4, 1, -1, 5, 1, -1, 6,
428 1, -1, 3, -1, 13, 3, -1
431 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
432 static const yytype_uint8 yyrline
[] =
434 0, 42, 42, 48, 57, 66, 67, 77, 87, 97,
435 102, 108, 114, 119, 125, 130, 135, 142, 147
439 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
440 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
441 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
442 static const char *const yytname
[] =
444 "$end", "error", "$undefined", "TOK_STRING", "TOK_AND", "TOK_OR",
445 "TOK_NOT", "TOK_ED2K_LINK", "'('", "')'", "$accept", "action",
446 "searchexpr", "and_strings", 0
451 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
453 static const yytype_uint16 yytoknum
[] =
455 0, 256, 257, 258, 259, 260, 261, 262, 40, 41
459 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
460 static const yytype_uint8 yyr1
[] =
462 0, 10, 11, 11, 11, 12, 12, 12, 12, 12,
463 12, 12, 12, 12, 12, 12, 12, 13, 13
466 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
467 static const yytype_uint8 yyr2
[] =
469 0, 2, 1, 1, 2, 1, 3, 3, 3, 3,
470 3, 3, 2, 3, 2, 2, 2, 1, 2
473 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
474 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
475 means the default is an error. */
476 static const yytype_uint8 yydefact
[] =
478 0, 17, 0, 0, 0, 3, 0, 0, 0, 5,
479 14, 15, 16, 12, 0, 1, 4, 0, 0, 0,
480 18, 13, 9, 6, 10, 7, 11, 8
483 /* YYDEFGOTO[NTERM-NUM]. */
484 static const yytype_int8 yydefgoto
[] =
489 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
491 #define YYPACT_NINF -7
492 static const yytype_int8 yypact
[] =
494 38, -7, 1, 2, 6, -7, 13, 15, 34, 29,
495 -7, -7, -7, -7, 0, -7, -7, 44, 19, 25,
496 -7, -7, -7, 30, -7, 4, -7, -7
499 /* YYPGOTO[NTERM-NUM]. */
500 static const yytype_int8 yypgoto
[] =
505 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
506 positive, shift that token. If negative, reduce the rule which
507 number is the opposite. If zero, do what YYDEFACT says.
508 If YYTABLE_NINF, syntax error. */
509 #define YYTABLE_NINF -3
510 static const yytype_int8 yytable
[] =
512 14, 21, 10, 11, 17, 18, 19, 12, 17, 22,
513 19, 23, 25, 27, 13, 15, 1, 2, 3, 4,
514 24, 6, 1, 2, 3, 4, 26, 6, 1, 2,
515 3, 4, 20, 6, -2, 16, 19, 0, 17, 18,
516 19, 1, 2, 3, 4, 5, 6, 1, 2, 3,
520 static const yytype_int8 yycheck
[] =
522 6, 1, 1, 1, 4, 5, 6, 1, 4, 9,
523 6, 17, 18, 19, 1, 0, 3, 4, 5, 6,
524 1, 8, 3, 4, 5, 6, 1, 8, 3, 4,
525 5, 6, 3, 8, 0, 1, 6, -1, 4, 5,
526 6, 3, 4, 5, 6, 7, 8, 3, 4, 5,
530 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
531 symbol of state STATE-NUM. */
532 static const yytype_uint8 yystos
[] =
534 0, 3, 4, 5, 6, 7, 8, 11, 12, 13,
535 1, 1, 1, 1, 12, 0, 1, 4, 5, 6,
536 3, 1, 9, 12, 1, 12, 1, 12
539 #define yyerrok (yyerrstatus = 0)
540 #define yyclearin (yychar = YYEMPTY)
544 #define YYACCEPT goto yyacceptlab
545 #define YYABORT goto yyabortlab
546 #define YYERROR goto yyerrorlab
549 /* Like YYERROR except do call yyerror. This remains here temporarily
550 to ease the transition to the new meaning of YYERROR, for GCC.
551 Once GCC version 2 has supplanted version 1, this can go. */
553 #define YYFAIL goto yyerrlab
555 #define YYRECOVERING() (!!yyerrstatus)
557 #define YYBACKUP(Token, Value) \
559 if (yychar == YYEMPTY && yylen == 1) \
563 yytoken = YYTRANSLATE (yychar); \
569 yyerror (YY_("syntax error: cannot back up")); \
576 #define YYERRCODE 256
579 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
580 If N is 0, then set CURRENT to the empty location which ends
581 the previous symbol: RHS[0] (always defined). */
583 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
584 #ifndef YYLLOC_DEFAULT
585 # define YYLLOC_DEFAULT(Current, Rhs, N) \
589 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
590 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
591 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
592 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
596 (Current).first_line = (Current).last_line = \
597 YYRHSLOC (Rhs, 0).last_line; \
598 (Current).first_column = (Current).last_column = \
599 YYRHSLOC (Rhs, 0).last_column; \
605 /* YY_LOCATION_PRINT -- Print the location on the stream.
606 This macro was not mandated originally: define only if we know
607 we won't break user code: when these are the locations we know. */
609 #ifndef YY_LOCATION_PRINT
610 # if YYLTYPE_IS_TRIVIAL
611 # define YY_LOCATION_PRINT(File, Loc) \
612 fprintf (File, "%d.%d-%d.%d", \
613 (Loc).first_line, (Loc).first_column, \
614 (Loc).last_line, (Loc).last_column)
616 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
621 /* YYLEX -- calling `yylex' with the right arguments. */
624 # define YYLEX yylex (YYLEX_PARAM)
626 # define YYLEX yylex ()
629 /* Enable debugging if requested. */
633 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
634 # define YYFPRINTF fprintf
637 # define YYDPRINTF(Args) \
643 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
647 YYFPRINTF (stderr, "%s ", Title); \
648 yy_symbol_print (stderr, \
650 YYFPRINTF (stderr, "\n"); \
655 /*--------------------------------.
656 | Print this symbol on YYOUTPUT. |
657 `--------------------------------*/
660 #if (defined __STDC__ || defined __C99__FUNC__ \
661 || defined __cplusplus || defined _MSC_VER)
663 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
666 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
)
669 YYSTYPE
const * const yyvaluep
;
675 if (yytype
< YYNTOKENS
)
676 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
688 /*--------------------------------.
689 | Print this symbol on YYOUTPUT. |
690 `--------------------------------*/
692 #if (defined __STDC__ || defined __C99__FUNC__ \
693 || defined __cplusplus || defined _MSC_VER)
695 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
698 yy_symbol_print (yyoutput
, yytype
, yyvaluep
)
701 YYSTYPE
const * const yyvaluep
;
704 if (yytype
< YYNTOKENS
)
705 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
707 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
709 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
);
710 YYFPRINTF (yyoutput
, ")");
713 /*------------------------------------------------------------------.
714 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
716 `------------------------------------------------------------------*/
718 #if (defined __STDC__ || defined __C99__FUNC__ \
719 || defined __cplusplus || defined _MSC_VER)
721 yy_stack_print (yytype_int16
*bottom
, yytype_int16
*top
)
724 yy_stack_print (bottom
, top
)
725 yytype_int16
*bottom
;
729 YYFPRINTF (stderr
, "Stack now");
730 for (; bottom
<= top
; ++bottom
)
731 YYFPRINTF (stderr
, " %d", *bottom
);
732 YYFPRINTF (stderr
, "\n");
735 # define YY_STACK_PRINT(Bottom, Top) \
738 yy_stack_print ((Bottom), (Top)); \
742 /*------------------------------------------------.
743 | Report that the YYRULE is going to be reduced. |
744 `------------------------------------------------*/
746 #if (defined __STDC__ || defined __C99__FUNC__ \
747 || defined __cplusplus || defined _MSC_VER)
749 yy_reduce_print (YYSTYPE
*yyvsp
, int yyrule
)
752 yy_reduce_print (yyvsp
, yyrule
)
757 int yynrhs
= yyr2
[yyrule
];
759 unsigned long int yylno
= yyrline
[yyrule
];
760 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
762 /* The symbols being reduced. */
763 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
765 fprintf (stderr
, " $%d = ", yyi
+ 1);
766 yy_symbol_print (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
767 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
769 fprintf (stderr
, "\n");
773 # define YY_REDUCE_PRINT(Rule) \
776 yy_reduce_print (yyvsp, Rule); \
779 /* Nonzero means print parse trace. It is left uninitialized so that
780 multiple parsers can coexist. */
783 # define YYDPRINTF(Args)
784 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
785 # define YY_STACK_PRINT(Bottom, Top)
786 # define YY_REDUCE_PRINT(Rule)
787 #endif /* !YYDEBUG */
790 /* YYINITDEPTH -- initial size of the parser's stacks. */
792 # define YYINITDEPTH 200
795 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
796 if the built-in stack extension method is used).
798 Do not make this value too large; the results are undefined if
799 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
800 evaluated with infinite-precision integer arithmetic. */
803 # define YYMAXDEPTH 10000
811 # if defined __GLIBC__ && defined _STRING_H
812 # define yystrlen strlen
814 /* Return the length of YYSTR. */
815 #if (defined __STDC__ || defined __C99__FUNC__ \
816 || defined __cplusplus || defined _MSC_VER)
818 yystrlen (const char *yystr
)
826 for (yylen
= 0; yystr
[yylen
]; yylen
++)
834 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
835 # define yystpcpy stpcpy
837 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
839 #if (defined __STDC__ || defined __C99__FUNC__ \
840 || defined __cplusplus || defined _MSC_VER)
842 yystpcpy (char *yydest
, const char *yysrc
)
845 yystpcpy (yydest
, yysrc
)
851 const char *yys
= yysrc
;
853 while ((*yyd
++ = *yys
++) != '\0')
862 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
863 quotes and backslashes, so that it's suitable for yyerror. The
864 heuristic is that double-quoting is unnecessary unless the string
865 contains an apostrophe, a comma, or backslash (other than
866 backslash-backslash). YYSTR is taken from yytname. If YYRES is
867 null, do not copy; instead, return the length of what the result
870 yytnamerr (char *yyres
, const char *yystr
)
875 char const *yyp
= yystr
;
882 goto do_not_strip_quotes
;
886 goto do_not_strip_quotes
;
899 do_not_strip_quotes
: ;
903 return yystrlen (yystr
);
905 return yystpcpy (yyres
, yystr
) - yyres
;
909 /* Copy into YYRESULT an error message about the unexpected token
910 YYCHAR while in state YYSTATE. Return the number of bytes copied,
911 including the terminating null byte. If YYRESULT is null, do not
912 copy anything; just return the number of bytes that would be
913 copied. As a special case, return 0 if an ordinary "syntax error"
914 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
917 yysyntax_error (char *yyresult
, int yystate
, int yychar
)
919 int yyn
= yypact
[yystate
];
921 if (! (YYPACT_NINF
< yyn
&& yyn
<= YYLAST
))
925 int yytype
= YYTRANSLATE (yychar
);
926 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
927 YYSIZE_T yysize
= yysize0
;
929 int yysize_overflow
= 0;
930 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
931 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
935 /* This is so xgettext sees the translatable formats that are
936 constructed on the fly. */
937 YY_("syntax error, unexpected %s");
938 YY_("syntax error, unexpected %s, expecting %s");
939 YY_("syntax error, unexpected %s, expecting %s or %s");
940 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
941 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
945 static char const yyunexpected
[] = "syntax error, unexpected %s";
946 static char const yyexpecting
[] = ", expecting %s";
947 static char const yyor
[] = " or %s";
948 char yyformat
[sizeof yyunexpected
949 + sizeof yyexpecting
- 1
950 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
951 * (sizeof yyor
- 1))];
952 char const *yyprefix
= yyexpecting
;
954 /* Start YYX at -YYN if negative to avoid negative indexes in
956 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
958 /* Stay within bounds of both yycheck and yytname. */
959 int yychecklim
= YYLAST
- yyn
+ 1;
960 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
963 yyarg
[0] = yytname
[yytype
];
964 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
966 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
967 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
969 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
973 yyformat
[sizeof yyunexpected
- 1] = '\0';
976 yyarg
[yycount
++] = yytname
[yyx
];
977 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
978 yysize_overflow
|= (yysize1
< yysize
);
980 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
985 yysize1
= yysize
+ yystrlen (yyf
);
986 yysize_overflow
|= (yysize1
< yysize
);
990 return YYSIZE_MAXIMUM
;
994 /* Avoid sprintf, as that infringes on the user's name space.
995 Don't have undefined behavior even if the translation
996 produced a string with the wrong number of "%s"s. */
997 char *yyp
= yyresult
;
999 while ((*yyp
= *yyf
) != '\0')
1001 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1003 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1016 #endif /* YYERROR_VERBOSE */
1019 /*-----------------------------------------------.
1020 | Release the memory associated to this symbol. |
1021 `-----------------------------------------------*/
1024 #if (defined __STDC__ || defined __C99__FUNC__ \
1025 || defined __cplusplus || defined _MSC_VER)
1027 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
)
1030 yydestruct (yymsg
, yytype
, yyvaluep
)
1040 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1051 /* Prevent warnings from -Wmissing-prototypes. */
1053 #ifdef YYPARSE_PARAM
1054 #if defined __STDC__ || defined __cplusplus
1055 int yyparse (void *YYPARSE_PARAM
);
1059 #else /* ! YYPARSE_PARAM */
1060 #if defined __STDC__ || defined __cplusplus
1065 #endif /* ! YYPARSE_PARAM */
1069 /* The look-ahead symbol. */
1072 /* The semantic value of the look-ahead symbol. */
1075 /* Number of syntax errors so far. */
1084 #ifdef YYPARSE_PARAM
1085 #if (defined __STDC__ || defined __C99__FUNC__ \
1086 || defined __cplusplus || defined _MSC_VER)
1088 yyparse (void *YYPARSE_PARAM
)
1091 yyparse (YYPARSE_PARAM
)
1092 void *YYPARSE_PARAM
;
1094 #else /* ! YYPARSE_PARAM */
1095 #if (defined __STDC__ || defined __C99__FUNC__ \
1096 || defined __cplusplus || defined _MSC_VER)
1110 /* Number of tokens to shift before error messages enabled. */
1112 /* Look-ahead token as an internal (translated) token number. */
1115 /* Buffer for error messages, and its allocated size. */
1117 char *yymsg
= yymsgbuf
;
1118 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1121 /* Three stacks and their tools:
1122 `yyss': related to states,
1123 `yyvs': related to semantic values,
1124 `yyls': related to locations.
1126 Refer to the stacks thru separate pointers, to allow yyoverflow
1127 to reallocate them elsewhere. */
1129 /* The state stack. */
1130 yytype_int16 yyssa
[YYINITDEPTH
];
1131 yytype_int16
*yyss
= yyssa
;
1132 yytype_int16
*yyssp
;
1134 /* The semantic value stack. */
1135 YYSTYPE yyvsa
[YYINITDEPTH
];
1136 YYSTYPE
*yyvs
= yyvsa
;
1141 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1143 YYSIZE_T yystacksize
= YYINITDEPTH
;
1145 /* The variables used to return semantic value and location from the
1150 /* The number of symbols on the RHS of the reduced rule.
1151 Keep to zero when no symbol should be popped. */
1154 YYDPRINTF ((stderr
, "Starting parse\n"));
1159 yychar
= YYEMPTY
; /* Cause a token to be read. */
1161 /* Initialize stack pointers.
1162 Waste one element of value and location stack
1163 so that they stay on the same level as the state stack.
1164 The wasted elements are never initialized. */
1171 /*------------------------------------------------------------.
1172 | yynewstate -- Push a new state, which is found in yystate. |
1173 `------------------------------------------------------------*/
1175 /* In all cases, when you get here, the value and location stacks
1176 have just been pushed. So pushing a state here evens the stacks. */
1182 if (yyss
+ yystacksize
- 1 <= yyssp
)
1184 /* Get the current used size of the three stacks, in elements. */
1185 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1189 /* Give user a chance to reallocate the stack. Use copies of
1190 these so that the &'s don't force the real ones into
1192 YYSTYPE
*yyvs1
= yyvs
;
1193 yytype_int16
*yyss1
= yyss
;
1196 /* Each stack pointer address is followed by the size of the
1197 data in use in that stack, in bytes. This used to be a
1198 conditional around just the two extra args, but that might
1199 be undefined if yyoverflow is a macro. */
1200 yyoverflow (YY_("memory exhausted"),
1201 &yyss1
, yysize
* sizeof (*yyssp
),
1202 &yyvs1
, yysize
* sizeof (*yyvsp
),
1209 #else /* no yyoverflow */
1210 # ifndef YYSTACK_RELOCATE
1211 goto yyexhaustedlab
;
1213 /* Extend the stack our own way. */
1214 if (YYMAXDEPTH
<= yystacksize
)
1215 goto yyexhaustedlab
;
1217 if (YYMAXDEPTH
< yystacksize
)
1218 yystacksize
= YYMAXDEPTH
;
1221 yytype_int16
*yyss1
= yyss
;
1222 union yyalloc
*yyptr
=
1223 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1225 goto yyexhaustedlab
;
1226 YYSTACK_RELOCATE (yyss
);
1227 YYSTACK_RELOCATE (yyvs
);
1229 # undef YYSTACK_RELOCATE
1231 YYSTACK_FREE (yyss1
);
1234 #endif /* no yyoverflow */
1236 yyssp
= yyss
+ yysize
- 1;
1237 yyvsp
= yyvs
+ yysize
- 1;
1240 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1241 (unsigned long int) yystacksize
));
1243 if (yyss
+ yystacksize
- 1 <= yyssp
)
1247 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1256 /* Do appropriate processing given the current state. Read a
1257 look-ahead token if we need one and don't already have one. */
1259 /* First try to decide what to do without reference to look-ahead token. */
1260 yyn
= yypact
[yystate
];
1261 if (yyn
== YYPACT_NINF
)
1264 /* Not known => get a look-ahead token if don't already have one. */
1266 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1267 if (yychar
== YYEMPTY
)
1269 YYDPRINTF ((stderr
, "Reading a token: "));
1273 if (yychar
<= YYEOF
)
1275 yychar
= yytoken
= YYEOF
;
1276 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1280 yytoken
= YYTRANSLATE (yychar
);
1281 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1284 /* If the proper action on seeing token YYTOKEN is to reduce or to
1285 detect an error, take that action. */
1287 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1292 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1301 /* Count tokens shifted since error; after three, turn off error
1306 /* Shift the look-ahead token. */
1307 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1309 /* Discard the shifted token unless it is eof. */
1310 if (yychar
!= YYEOF
)
1319 /*-----------------------------------------------------------.
1320 | yydefault -- do the default action for the current state. |
1321 `-----------------------------------------------------------*/
1323 yyn
= yydefact
[yystate
];
1329 /*-----------------------------.
1330 | yyreduce -- Do a reduction. |
1331 `-----------------------------*/
1333 /* yyn is the number of a rule to reduce with. */
1336 /* If YYLEN is nonzero, implement the default value of the action:
1339 Otherwise, the following line sets YYVAL to garbage.
1340 This behavior is undocumented and Bison
1341 users should not rely upon it. Assigning to YYVAL
1342 unconditionally makes the parser a bit smaller, and it avoids a
1343 GCC warning that YYVAL may be used uninitialized. */
1344 yyval
= yyvsp
[1-yylen
];
1347 YY_REDUCE_PRINT (yyn
);
1351 #line 43 "./Parser.y"
1353 ParsedSearchExpression((yyvsp
[(1) - (1)].pexpr
));
1354 delete (yyvsp
[(1) - (1)].pexpr
);
1360 #line 49 "./Parser.y"
1362 CSearchExpr
* pexpr
= new CSearchExpr(*(yyvsp
[(1) - (1)].pstr
));
1363 ParsedSearchExpression(pexpr
);
1365 delete (yyvsp
[(1) - (1)].pstr
);
1371 #line 58 "./Parser.y"
1373 yyerror(wxT("Undefined search expression error"));
1374 delete (yyvsp
[(1) - (2)].pexpr
);
1380 #line 68 "./Parser.y"
1382 CSearchExpr
* pexpr
= new CSearchExpr
;
1383 pexpr
->Add(SEARCHOP_AND
);
1384 pexpr
->Add((yyvsp
[(1) - (3)].pexpr
));
1385 pexpr
->Add((yyvsp
[(3) - (3)].pexpr
));
1386 (yyval
.pexpr
) = pexpr
;
1387 delete (yyvsp
[(1) - (3)].pexpr
);
1388 delete (yyvsp
[(3) - (3)].pexpr
);
1393 #line 78 "./Parser.y"
1395 CSearchExpr
* pexpr
= new CSearchExpr
;
1396 pexpr
->Add(SEARCHOP_OR
);
1397 pexpr
->Add((yyvsp
[(1) - (3)].pexpr
));
1398 pexpr
->Add((yyvsp
[(3) - (3)].pexpr
));
1399 (yyval
.pexpr
) = pexpr
;
1400 delete (yyvsp
[(1) - (3)].pexpr
);
1401 delete (yyvsp
[(3) - (3)].pexpr
);
1406 #line 88 "./Parser.y"
1408 CSearchExpr
* pexpr
= new CSearchExpr
;
1409 pexpr
->Add(SEARCHOP_NOT
);
1410 pexpr
->Add((yyvsp
[(1) - (3)].pexpr
));
1411 pexpr
->Add((yyvsp
[(3) - (3)].pexpr
));
1412 (yyval
.pexpr
) = pexpr
;
1413 delete (yyvsp
[(1) - (3)].pexpr
);
1414 delete (yyvsp
[(3) - (3)].pexpr
);
1419 #line 98 "./Parser.y"
1421 (yyval
.pexpr
) = (yyvsp
[(2) - (3)].pexpr
);
1426 #line 103 "./Parser.y"
1428 yyerror(wxT("Missing right operand for OR on search expression"));
1429 delete (yyvsp
[(1) - (3)].pexpr
);
1435 #line 109 "./Parser.y"
1437 yyerror(wxT("Missing operand for NOT on search expression"));
1438 delete (yyvsp
[(1) - (3)].pexpr
);
1444 #line 115 "./Parser.y"
1446 yyerror(wxT("Missing left parenthesis on search expression"));
1452 #line 120 "./Parser.y"
1454 yyerror(wxT("Missing closing parenthesis on search expression"));
1455 delete (yyvsp
[(2) - (3)].pexpr
);
1461 #line 126 "./Parser.y"
1463 yyerror(wxT("Missing left operand for AND on search expression"));
1469 #line 131 "./Parser.y"
1471 yyerror(wxT("Missing left operand for OR on search expression"));
1477 #line 136 "./Parser.y"
1479 yyerror(wxT("Missing left operand for NOT on search expression (?)"));
1485 #line 143 "./Parser.y"
1487 (yyval
.pexpr
) = new CSearchExpr(*(yyvsp
[(1) - (1)].pstr
));
1488 delete (yyvsp
[(1) - (1)].pstr
);
1493 #line 148 "./Parser.y"
1495 /*$1->Concatenate($2);
1497 CSearchExpr
* pexpr
= new CSearchExpr
;
1498 pexpr
->Add(SEARCHOP_AND
);
1499 pexpr
->Add((yyvsp
[(1) - (2)].pexpr
));
1500 pexpr
->Add(*(yyvsp
[(2) - (2)].pstr
));
1501 (yyval
.pexpr
) = pexpr
;
1502 delete (yyvsp
[(1) - (2)].pexpr
);
1503 delete (yyvsp
[(2) - (2)].pstr
);
1508 /* Line 1267 of yacc.c. */
1509 #line 1513 "Parser.cpp"
1512 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1516 YY_STACK_PRINT (yyss
, yyssp
);
1521 /* Now `shift' the result of the reduction. Determine what state
1522 that goes to, based on the state we popped back to and the rule
1523 number reduced by. */
1527 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1528 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1529 yystate
= yytable
[yystate
];
1531 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1536 /*------------------------------------.
1537 | yyerrlab -- here on detecting error |
1538 `------------------------------------*/
1540 /* If not already recovering from an error, report this error. */
1544 #if ! YYERROR_VERBOSE
1545 yyerror (YY_("syntax error"));
1548 YYSIZE_T yysize
= yysyntax_error (0, yystate
, yychar
);
1549 if (yymsg_alloc
< yysize
&& yymsg_alloc
< YYSTACK_ALLOC_MAXIMUM
)
1551 YYSIZE_T yyalloc
= 2 * yysize
;
1552 if (! (yysize
<= yyalloc
&& yyalloc
<= YYSTACK_ALLOC_MAXIMUM
))
1553 yyalloc
= YYSTACK_ALLOC_MAXIMUM
;
1554 if (yymsg
!= yymsgbuf
)
1555 YYSTACK_FREE (yymsg
);
1556 yymsg
= (char *) YYSTACK_ALLOC (yyalloc
);
1558 yymsg_alloc
= yyalloc
;
1562 yymsg_alloc
= sizeof yymsgbuf
;
1566 if (0 < yysize
&& yysize
<= yymsg_alloc
)
1568 (void) yysyntax_error (yymsg
, yystate
, yychar
);
1573 yyerror (YY_("syntax error"));
1575 goto yyexhaustedlab
;
1583 if (yyerrstatus
== 3)
1585 /* If just tried and failed to reuse look-ahead token after an
1586 error, discard it. */
1588 if (yychar
<= YYEOF
)
1590 /* Return failure if at end of input. */
1591 if (yychar
== YYEOF
)
1596 yydestruct ("Error: discarding",
1602 /* Else will try to reuse look-ahead token after shifting the error
1607 /*---------------------------------------------------.
1608 | yyerrorlab -- error raised explicitly by YYERROR. |
1609 `---------------------------------------------------*/
1612 /* Pacify compilers like GCC when the user code never invokes
1613 YYERROR and the label yyerrorlab therefore never appears in user
1615 if (/*CONSTCOND*/ 0)
1618 /* Do not reclaim the symbols of the rule which action triggered
1622 YY_STACK_PRINT (yyss
, yyssp
);
1627 /*-------------------------------------------------------------.
1628 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1629 `-------------------------------------------------------------*/
1631 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1635 yyn
= yypact
[yystate
];
1636 if (yyn
!= YYPACT_NINF
)
1639 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1647 /* Pop the current state because it cannot handle the error token. */
1652 yydestruct ("Error: popping",
1653 yystos
[yystate
], yyvsp
);
1656 YY_STACK_PRINT (yyss
, yyssp
);
1665 /* Shift the error token. */
1666 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1672 /*-------------------------------------.
1673 | yyacceptlab -- YYACCEPT comes here. |
1674 `-------------------------------------*/
1679 /*-----------------------------------.
1680 | yyabortlab -- YYABORT comes here. |
1681 `-----------------------------------*/
1687 /*-------------------------------------------------.
1688 | yyexhaustedlab -- memory exhaustion comes here. |
1689 `-------------------------------------------------*/
1691 yyerror (YY_("memory exhausted"));
1697 if (yychar
!= YYEOF
&& yychar
!= YYEMPTY
)
1698 yydestruct ("Cleanup: discarding lookahead",
1700 /* Do not reclaim the symbols of the rule which action triggered
1701 this YYABORT or YYACCEPT. */
1703 YY_STACK_PRINT (yyss
, yyssp
);
1704 while (yyssp
!= yyss
)
1706 yydestruct ("Cleanup: popping",
1707 yystos
[*yyssp
], yyvsp
);
1712 YYSTACK_FREE (yyss
);
1715 if (yymsg
!= yymsgbuf
)
1716 YYSTACK_FREE (yymsg
);
1718 /* Make sure YYID is used. */
1719 return YYID (yyresult
);
1723 #line 161 "./Parser.y"
1726 int yyerror(const char* errstr
)
1728 // Errors created by yacc generated code
1729 //yyerror ("syntax error: cannot back up");
1730 //yyerror ("syntax error; also virtual memory exhausted");
1731 //yyerror ("syntax error");
1732 //yyerror ("parser stack overflow");
1734 _astrParserErrors
.Add(char2unicode(errstr
));
1735 return EXIT_FAILURE
;
1738 int yyerror(wxString errstr
)
1740 _astrParserErrors
.Add(errstr
);
1741 return EXIT_FAILURE
;