1 /* A Bison parser, made by GNU Bison 3.7.6. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6 Inc.
7
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 3 of the License, or
11 (at your option) any later version.
12
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.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
20
21 /* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
30
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
33
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
36
37 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 especially those whose name start with YY_ or yy_. They are
39 private implementation details that can be changed or removed. */
40
41 /* All symbols defined below should begin with yy or YY, to avoid
42 infringing on user name space. This should be done even for local
43 variables, as they might otherwise be expanded by user macros.
44 There are some unavoidable exceptions within include files to
45 define necessary library symbols; they are noted "INFRINGES ON
46 USER NAME SPACE" below. */
47
48 /* Identify Bison output, and Bison version. */
49 #define YYBISON 30706
50
51 /* Bison version string. */
52 #define YYBISON_VERSION "3.7.6"
53
54 /* Skeleton name. */
55 #define YYSKELETON_NAME "yacc.c"
56
57 /* Pure parsers. */
58 #define YYPURE 0
59
60 /* Push parsers. */
61 #define YYPUSH 0
62
63 /* Pull parsers. */
64 #define YYPULL 1
65
66
67
68
69 /* First part of user prologue. */
70 #line 1 "../lib/parse.ypp"
71
72
73 #include <stdio.h>
74 #include <stdlib.h>
75
76 #include "src/parse/ast.h"
77 #include "src/util/attribute.h"
78 #include "src/util/c99_stdint.h"
79 #include "lib/lex.h"
80
81 // disable certain GCC and/or Clang warnings, as we have no control over
82 // autogenerated code (Clang also understands '#pragma GCC')
83 #pragma GCC diagnostic push
84 #pragma GCC diagnostic ignored "-Wpragmas"
85 #pragma GCC diagnostic ignored "-Wconversion"
86 #pragma GCC diagnostic ignored "-Wsign-conversion"
87 #pragma GCC diagnostic ignored "-Wunused-macros"
88 #pragma GCC diagnostic ignored "-Wmissing-variable-declarations"
89 #pragma GCC diagnostic ignored "-Wunreachable-code"
90 #pragma GCC diagnostic ignored "-Wunreachable-code-break"
91
92 using namespace re2c;
93
94 extern "C" {
95
96 int yylex(const char *&pattern);
97 void yyerror(const char *pattern, const char*) RE2C_ATTR((noreturn));
98
99 } // extern "C"
100
101
102 #line 103 "lib/parse.cc"
103
104 # ifndef YY_CAST
105 # ifdef __cplusplus
106 # define YY_CAST(Type, Val) static_cast<Type> (Val)
107 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
108 # else
109 # define YY_CAST(Type, Val) ((Type) (Val))
110 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
111 # endif
112 # endif
113 # ifndef YY_NULLPTR
114 # if defined __cplusplus
115 # if 201103L <= __cplusplus
116 # define YY_NULLPTR nullptr
117 # else
118 # define YY_NULLPTR 0
119 # endif
120 # else
121 # define YY_NULLPTR ((void*)0)
122 # endif
123 # endif
124
125 #include "parse.h"
126 /* Symbol kind. */
127 enum yysymbol_kind_t
128 {
129 YYSYMBOL_YYEMPTY = -2,
130 YYSYMBOL_YYEOF = 0, /* "end of file" */
131 YYSYMBOL_YYerror = 1, /* error */
132 YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
133 YYSYMBOL_TOKEN_COUNT = 3, /* TOKEN_COUNT */
134 YYSYMBOL_TOKEN_ERROR = 4, /* TOKEN_ERROR */
135 YYSYMBOL_TOKEN_REGEXP = 5, /* TOKEN_REGEXP */
136 YYSYMBOL_6_ = 6, /* '|' */
137 YYSYMBOL_7_ = 7, /* '*' */
138 YYSYMBOL_8_ = 8, /* '+' */
139 YYSYMBOL_9_ = 9, /* '?' */
140 YYSYMBOL_10_ = 10, /* '(' */
141 YYSYMBOL_11_ = 11, /* ')' */
142 YYSYMBOL_YYACCEPT = 12, /* $accept */
143 YYSYMBOL_regexp = 13, /* regexp */
144 YYSYMBOL_expr = 14, /* expr */
145 YYSYMBOL_term = 15, /* term */
146 YYSYMBOL_factor = 16, /* factor */
147 YYSYMBOL_primary = 17 /* primary */
148 };
149 typedef enum yysymbol_kind_t yysymbol_kind_t;
150
151
152
153
154 #ifdef short
155 # undef short
156 #endif
157
158 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
159 <limits.h> and (if available) <stdint.h> are included
160 so that the code can choose integer types of a good width. */
161
162 #ifndef __PTRDIFF_MAX__
163 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
164 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
165 # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
166 # define YY_STDINT_H
167 # endif
168 #endif
169
170 /* Narrow types that promote to a signed type and that can represent a
171 signed or unsigned integer of at least N bits. In tables they can
172 save space and decrease cache pressure. Promoting to a signed type
173 helps avoid bugs in integer arithmetic. */
174
175 #ifdef __INT_LEAST8_MAX__
176 typedef __INT_LEAST8_TYPE__ yytype_int8;
177 #elif defined YY_STDINT_H
178 typedef int_least8_t yytype_int8;
179 #else
180 typedef signed char yytype_int8;
181 #endif
182
183 #ifdef __INT_LEAST16_MAX__
184 typedef __INT_LEAST16_TYPE__ yytype_int16;
185 #elif defined YY_STDINT_H
186 typedef int_least16_t yytype_int16;
187 #else
188 typedef short yytype_int16;
189 #endif
190
191 /* Work around bug in HP-UX 11.23, which defines these macros
192 incorrectly for preprocessor constants. This workaround can likely
193 be removed in 2023, as HPE has promised support for HP-UX 11.23
194 (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
195 <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
196 #ifdef __hpux
197 # undef UINT_LEAST8_MAX
198 # undef UINT_LEAST16_MAX
199 # define UINT_LEAST8_MAX 255
200 # define UINT_LEAST16_MAX 65535
201 #endif
202
203 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
204 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
205 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
206 && UINT_LEAST8_MAX <= INT_MAX)
207 typedef uint_least8_t yytype_uint8;
208 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
209 typedef unsigned char yytype_uint8;
210 #else
211 typedef short yytype_uint8;
212 #endif
213
214 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
215 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
216 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
217 && UINT_LEAST16_MAX <= INT_MAX)
218 typedef uint_least16_t yytype_uint16;
219 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
220 typedef unsigned short yytype_uint16;
221 #else
222 typedef int yytype_uint16;
223 #endif
224
225 #ifndef YYPTRDIFF_T
226 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
227 # define YYPTRDIFF_T __PTRDIFF_TYPE__
228 # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
229 # elif defined PTRDIFF_MAX
230 # ifndef ptrdiff_t
231 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
232 # endif
233 # define YYPTRDIFF_T ptrdiff_t
234 # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
235 # else
236 # define YYPTRDIFF_T long
237 # define YYPTRDIFF_MAXIMUM LONG_MAX
238 # endif
239 #endif
240
241 #ifndef YYSIZE_T
242 # ifdef __SIZE_TYPE__
243 # define YYSIZE_T __SIZE_TYPE__
244 # elif defined size_t
245 # define YYSIZE_T size_t
246 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
247 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
248 # define YYSIZE_T size_t
249 # else
250 # define YYSIZE_T unsigned
251 # endif
252 #endif
253
254 #define YYSIZE_MAXIMUM \
255 YY_CAST (YYPTRDIFF_T, \
256 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
257 ? YYPTRDIFF_MAXIMUM \
258 : YY_CAST (YYSIZE_T, -1)))
259
260 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
261
262
263 /* Stored state numbers (used for stacks). */
264 typedef yytype_int8 yy_state_t;
265
266 /* State numbers in computations. */
267 typedef int yy_state_fast_t;
268
269 #ifndef YY_
270 # if defined YYENABLE_NLS && YYENABLE_NLS
271 # if ENABLE_NLS
272 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
273 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
274 # endif
275 # endif
276 # ifndef YY_
277 # define YY_(Msgid) Msgid
278 # endif
279 #endif
280
281
282 #ifndef YY_ATTRIBUTE_PURE
283 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
284 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
285 # else
286 # define YY_ATTRIBUTE_PURE
287 # endif
288 #endif
289
290 #ifndef YY_ATTRIBUTE_UNUSED
291 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
292 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
293 # else
294 # define YY_ATTRIBUTE_UNUSED
295 # endif
296 #endif
297
298 /* Suppress unused-variable warnings by "using" E. */
299 #if ! defined lint || defined __GNUC__
300 # define YY_USE(E) ((void) (E))
301 #else
302 # define YY_USE(E) /* empty */
303 #endif
304
305 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
306 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
307 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
308 _Pragma ("GCC diagnostic push") \
309 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
310 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
311 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
312 _Pragma ("GCC diagnostic pop")
313 #else
314 # define YY_INITIAL_VALUE(Value) Value
315 #endif
316 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
317 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
318 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
319 #endif
320 #ifndef YY_INITIAL_VALUE
321 # define YY_INITIAL_VALUE(Value) /* Nothing. */
322 #endif
323
324 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
325 # define YY_IGNORE_USELESS_CAST_BEGIN \
326 _Pragma ("GCC diagnostic push") \
327 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
328 # define YY_IGNORE_USELESS_CAST_END \
329 _Pragma ("GCC diagnostic pop")
330 #endif
331 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
332 # define YY_IGNORE_USELESS_CAST_BEGIN
333 # define YY_IGNORE_USELESS_CAST_END
334 #endif
335
336
337 #define YY_ASSERT(E) ((void) (0 && (E)))
338
339 #if !defined yyoverflow
340
341 /* The parser invokes alloca or malloc; define the necessary symbols. */
342
343 # ifdef YYSTACK_USE_ALLOCA
344 # if YYSTACK_USE_ALLOCA
345 # ifdef __GNUC__
346 # define YYSTACK_ALLOC __builtin_alloca
347 # elif defined __BUILTIN_VA_ARG_INCR
348 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
349 # elif defined _AIX
350 # define YYSTACK_ALLOC __alloca
351 # elif defined _MSC_VER
352 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
353 # define alloca _alloca
354 # else
355 # define YYSTACK_ALLOC alloca
356 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
357 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
358 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
359 # ifndef EXIT_SUCCESS
360 # define EXIT_SUCCESS 0
361 # endif
362 # endif
363 # endif
364 # endif
365 # endif
366
367 # ifdef YYSTACK_ALLOC
368 /* Pacify GCC's 'empty if-body' warning. */
369 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
370 # ifndef YYSTACK_ALLOC_MAXIMUM
371 /* The OS might guarantee only one guard page at the bottom of the stack,
372 and a page size can be as small as 4096 bytes. So we cannot safely
373 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
374 to allow for a few compiler-allocated temporary stack slots. */
375 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
376 # endif
377 # else
378 # define YYSTACK_ALLOC YYMALLOC
379 # define YYSTACK_FREE YYFREE
380 # ifndef YYSTACK_ALLOC_MAXIMUM
381 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
382 # endif
383 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
384 && ! ((defined YYMALLOC || defined malloc) \
385 && (defined YYFREE || defined free)))
386 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
387 # ifndef EXIT_SUCCESS
388 # define EXIT_SUCCESS 0
389 # endif
390 # endif
391 # ifndef YYMALLOC
392 # define YYMALLOC malloc
393 # if ! defined malloc && ! defined EXIT_SUCCESS
394 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
395 # endif
396 # endif
397 # ifndef YYFREE
398 # define YYFREE free
399 # if ! defined free && ! defined EXIT_SUCCESS
400 void free (void *); /* INFRINGES ON USER NAME SPACE */
401 # endif
402 # endif
403 # endif
404 #endif /* !defined yyoverflow */
405
406 #if (! defined yyoverflow \
407 && (! defined __cplusplus \
408 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
409
410 /* A type that is properly aligned for any stack member. */
411 union yyalloc
412 {
413 yy_state_t yyss_alloc;
414 YYSTYPE yyvs_alloc;
415 };
416
417 /* The size of the maximum gap between one aligned stack and the next. */
418 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
419
420 /* The size of an array large to enough to hold all stacks, each with
421 N elements. */
422 # define YYSTACK_BYTES(N) \
423 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
424 + YYSTACK_GAP_MAXIMUM)
425
426 # define YYCOPY_NEEDED 1
427
428 /* Relocate STACK from its old location to the new one. The
429 local variables YYSIZE and YYSTACKSIZE give the old and new number of
430 elements in the stack, and YYPTR gives the new location of the
431 stack. Advance YYPTR to a properly aligned location for the next
432 stack. */
433 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
434 do \
435 { \
436 YYPTRDIFF_T yynewbytes; \
437 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
438 Stack = &yyptr->Stack_alloc; \
439 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
440 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
441 } \
442 while (0)
443
444 #endif
445
446 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
447 /* Copy COUNT objects from SRC to DST. The source and destination do
448 not overlap. */
449 # ifndef YYCOPY
450 # if defined __GNUC__ && 1 < __GNUC__
451 # define YYCOPY(Dst, Src, Count) \
452 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
453 # else
454 # define YYCOPY(Dst, Src, Count) \
455 do \
456 { \
457 YYPTRDIFF_T yyi; \
458 for (yyi = 0; yyi < (Count); yyi++) \
459 (Dst)[yyi] = (Src)[yyi]; \
460 } \
461 while (0)
462 # endif
463 # endif
464 #endif /* !YYCOPY_NEEDED */
465
466 /* YYFINAL -- State number of the termination state. */
467 #define YYFINAL 10
468 /* YYLAST -- Last index in YYTABLE. */
469 #define YYLAST 16
470
471 /* YYNTOKENS -- Number of terminals. */
472 #define YYNTOKENS 12
473 /* YYNNTS -- Number of nonterminals. */
474 #define YYNNTS 6
475 /* YYNRULES -- Number of rules. */
476 #define YYNRULES 14
477 /* YYNSTATES -- Number of states. */
478 #define YYNSTATES 19
479
480 /* YYMAXUTOK -- Last valid token kind. */
481 #define YYMAXUTOK 260
482
483
484 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
485 as returned by yylex, with out-of-bounds checking. */
486 #define YYTRANSLATE(YYX) \
487 (0 <= (YYX) && (YYX) <= YYMAXUTOK \
488 ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
489 : YYSYMBOL_YYUNDEF)
490
491 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
492 as returned by yylex. */
493 static const yytype_int8 yytranslate[] =
494 {
495 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
496 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
497 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
498 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
499 10, 11, 7, 8, 2, 2, 2, 2, 2, 2,
500 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
501 2, 2, 2, 9, 2, 2, 2, 2, 2, 2,
502 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
505 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
506 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
507 2, 2, 2, 2, 6, 2, 2, 2, 2, 2,
508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
512 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
514 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
516 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
520 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
521 5
522 };
523
524 #if YYDEBUG
525 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
526 static const yytype_int8 yyrline[] =
527 {
528 0, 52, 52, 55, 56, 60, 61, 65, 66, 67,
529 68, 69, 73, 74, 75
530 };
531 #endif
532
533 /** Accessing symbol of state STATE. */
534 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
535
536 #if YYDEBUG || 0
537 /* The user-facing name of the symbol whose (internal) number is
538 YYSYMBOL. No bounds checking. */
539 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
540
541 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
542 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
543 static const char *const yytname[] =
544 {
545 "\"end of file\"", "error", "\"invalid token\"", "TOKEN_COUNT",
546 "TOKEN_ERROR", "TOKEN_REGEXP", "'|'", "'*'", "'+'", "'?'", "'('", "')'",
547 "$accept", "regexp", "expr", "term", "factor", "primary", YY_NULLPTR
548 };
549
550 static const char *
yysymbol_name(yysymbol_kind_t yysymbol)551 yysymbol_name (yysymbol_kind_t yysymbol)
552 {
553 return yytname[yysymbol];
554 }
555 #endif
556
557 #ifdef YYPRINT
558 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
559 (internal) symbol number NUM (which must be that of a token). */
560 static const yytype_int16 yytoknum[] =
561 {
562 0, 256, 257, 258, 259, 260, 124, 42, 43, 63,
563 40, 41
564 };
565 #endif
566
567 #define YYPACT_NINF (-5)
568
569 #define yypact_value_is_default(Yyn) \
570 ((Yyn) == YYPACT_NINF)
571
572 #define YYTABLE_NINF (-1)
573
574 #define yytable_value_is_error(Yyn) \
575 0
576
577 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
578 STATE-NUM. */
579 static const yytype_int8 yypact[] =
580 {
581 2, -5, -2, 1, -4, -5, 2, -3, -5, 4,
582 -5, 2, -5, -5, -5, -5, -5, -5, -5
583 };
584
585 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
586 Performed when YYTABLE does not specify something else to do. Zero
587 means the default is an error. */
588 static const yytype_int8 yydefact[] =
589 {
590 0, 12, 0, 0, 2, 3, 5, 7, 13, 0,
591 1, 0, 6, 11, 8, 9, 10, 14, 4
592 };
593
594 /* YYPGOTO[NTERM-NUM]. */
595 static const yytype_int8 yypgoto[] =
596 {
597 -5, -5, 11, 5, -5, -5
598 };
599
600 /* YYDEFGOTO[NTERM-NUM]. */
601 static const yytype_int8 yydefgoto[] =
602 {
603 0, 3, 4, 5, 6, 7
604 };
605
606 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
607 positive, shift that token. If negative, reduce the rule whose
608 number is the opposite. If YYTABLE_NINF, syntax error. */
609 static const yytype_int8 yytable[] =
610 {
611 13, 10, 11, 1, 14, 15, 16, 1, 2, 8,
612 11, 12, 2, 9, 0, 17, 18
613 };
614
615 static const yytype_int8 yycheck[] =
616 {
617 3, 0, 6, 5, 7, 8, 9, 5, 10, 11,
618 6, 6, 10, 2, -1, 11, 11
619 };
620
621 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
622 symbol of state STATE-NUM. */
623 static const yytype_int8 yystos[] =
624 {
625 0, 5, 10, 13, 14, 15, 16, 17, 11, 14,
626 0, 6, 15, 3, 7, 8, 9, 11, 15
627 };
628
629 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
630 static const yytype_int8 yyr1[] =
631 {
632 0, 12, 13, 14, 14, 15, 15, 16, 16, 16,
633 16, 16, 17, 17, 17
634 };
635
636 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
637 static const yytype_int8 yyr2[] =
638 {
639 0, 2, 1, 1, 3, 1, 2, 1, 2, 2,
640 2, 2, 1, 2, 3
641 };
642
643
644 enum { YYENOMEM = -2 };
645
646 #define yyerrok (yyerrstatus = 0)
647 #define yyclearin (yychar = YYEMPTY)
648
649 #define YYACCEPT goto yyacceptlab
650 #define YYABORT goto yyabortlab
651 #define YYERROR goto yyerrorlab
652
653
654 #define YYRECOVERING() (!!yyerrstatus)
655
656 #define YYBACKUP(Token, Value) \
657 do \
658 if (yychar == YYEMPTY) \
659 { \
660 yychar = (Token); \
661 yylval = (Value); \
662 YYPOPSTACK (yylen); \
663 yystate = *yyssp; \
664 goto yybackup; \
665 } \
666 else \
667 { \
668 yyerror (pattern, YY_("syntax error: cannot back up")); \
669 YYERROR; \
670 } \
671 while (0)
672
673 /* Backward compatibility with an undocumented macro.
674 Use YYerror or YYUNDEF. */
675 #define YYERRCODE YYUNDEF
676
677
678 /* Enable debugging if requested. */
679 #if YYDEBUG
680
681 # ifndef YYFPRINTF
682 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
683 # define YYFPRINTF fprintf
684 # endif
685
686 # define YYDPRINTF(Args) \
687 do { \
688 if (yydebug) \
689 YYFPRINTF Args; \
690 } while (0)
691
692 /* This macro is provided for backward compatibility. */
693 # ifndef YY_LOCATION_PRINT
694 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
695 # endif
696
697
698 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
699 do { \
700 if (yydebug) \
701 { \
702 YYFPRINTF (stderr, "%s ", Title); \
703 yy_symbol_print (stderr, \
704 Kind, Value, pattern); \
705 YYFPRINTF (stderr, "\n"); \
706 } \
707 } while (0)
708
709
710 /*-----------------------------------.
711 | Print this symbol's value on YYO. |
712 `-----------------------------------*/
713
714 static void
yy_symbol_value_print(FILE * yyo,yysymbol_kind_t yykind,YYSTYPE const * const yyvaluep,const char * & pattern)715 yy_symbol_value_print (FILE *yyo,
716 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, const char *&pattern)
717 {
718 FILE *yyoutput = yyo;
719 YY_USE (yyoutput);
720 YY_USE (pattern);
721 if (!yyvaluep)
722 return;
723 # ifdef YYPRINT
724 if (yykind < YYNTOKENS)
725 YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
726 # endif
727 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
728 YY_USE (yykind);
729 YY_IGNORE_MAYBE_UNINITIALIZED_END
730 }
731
732
733 /*---------------------------.
734 | Print this symbol on YYO. |
735 `---------------------------*/
736
737 static void
yy_symbol_print(FILE * yyo,yysymbol_kind_t yykind,YYSTYPE const * const yyvaluep,const char * & pattern)738 yy_symbol_print (FILE *yyo,
739 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, const char *&pattern)
740 {
741 YYFPRINTF (yyo, "%s %s (",
742 yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
743
744 yy_symbol_value_print (yyo, yykind, yyvaluep, pattern);
745 YYFPRINTF (yyo, ")");
746 }
747
748 /*------------------------------------------------------------------.
749 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
750 | TOP (included). |
751 `------------------------------------------------------------------*/
752
753 static void
yy_stack_print(yy_state_t * yybottom,yy_state_t * yytop)754 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
755 {
756 YYFPRINTF (stderr, "Stack now");
757 for (; yybottom <= yytop; yybottom++)
758 {
759 int yybot = *yybottom;
760 YYFPRINTF (stderr, " %d", yybot);
761 }
762 YYFPRINTF (stderr, "\n");
763 }
764
765 # define YY_STACK_PRINT(Bottom, Top) \
766 do { \
767 if (yydebug) \
768 yy_stack_print ((Bottom), (Top)); \
769 } while (0)
770
771
772 /*------------------------------------------------.
773 | Report that the YYRULE is going to be reduced. |
774 `------------------------------------------------*/
775
776 static void
yy_reduce_print(yy_state_t * yyssp,YYSTYPE * yyvsp,int yyrule,const char * & pattern)777 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
778 int yyrule, const char *&pattern)
779 {
780 int yylno = yyrline[yyrule];
781 int yynrhs = yyr2[yyrule];
782 int yyi;
783 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
784 yyrule - 1, yylno);
785 /* The symbols being reduced. */
786 for (yyi = 0; yyi < yynrhs; yyi++)
787 {
788 YYFPRINTF (stderr, " $%d = ", yyi + 1);
789 yy_symbol_print (stderr,
790 YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
791 &yyvsp[(yyi + 1) - (yynrhs)], pattern);
792 YYFPRINTF (stderr, "\n");
793 }
794 }
795
796 # define YY_REDUCE_PRINT(Rule) \
797 do { \
798 if (yydebug) \
799 yy_reduce_print (yyssp, yyvsp, Rule, pattern); \
800 } while (0)
801
802 /* Nonzero means print parse trace. It is left uninitialized so that
803 multiple parsers can coexist. */
804 int yydebug;
805 #else /* !YYDEBUG */
806 # define YYDPRINTF(Args) ((void) 0)
807 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
808 # define YY_STACK_PRINT(Bottom, Top)
809 # define YY_REDUCE_PRINT(Rule)
810 #endif /* !YYDEBUG */
811
812
813 /* YYINITDEPTH -- initial size of the parser's stacks. */
814 #ifndef YYINITDEPTH
815 # define YYINITDEPTH 200
816 #endif
817
818 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
819 if the built-in stack extension method is used).
820
821 Do not make this value too large; the results are undefined if
822 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
823 evaluated with infinite-precision integer arithmetic. */
824
825 #ifndef YYMAXDEPTH
826 # define YYMAXDEPTH 10000
827 #endif
828
829
830
831
832
833
834 /*-----------------------------------------------.
835 | Release the memory associated to this symbol. |
836 `-----------------------------------------------*/
837
838 static void
yydestruct(const char * yymsg,yysymbol_kind_t yykind,YYSTYPE * yyvaluep,const char * & pattern)839 yydestruct (const char *yymsg,
840 yysymbol_kind_t yykind, YYSTYPE *yyvaluep, const char *&pattern)
841 {
842 YY_USE (yyvaluep);
843 YY_USE (pattern);
844 if (!yymsg)
845 yymsg = "Deleting";
846 YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
847
848 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
849 YY_USE (yykind);
850 YY_IGNORE_MAYBE_UNINITIALIZED_END
851 }
852
853
854 /* Lookahead token kind. */
855 int yychar;
856
857 /* The semantic value of the lookahead symbol. */
858 YYSTYPE yylval;
859 /* Number of syntax errors so far. */
860 int yynerrs;
861
862
863
864
865 /*----------.
866 | yyparse. |
867 `----------*/
868
869 int
yyparse(const char * & pattern)870 yyparse (const char *&pattern)
871 {
872 yy_state_fast_t yystate = 0;
873 /* Number of tokens to shift before error messages enabled. */
874 int yyerrstatus = 0;
875
876 /* Refer to the stacks through separate pointers, to allow yyoverflow
877 to reallocate them elsewhere. */
878
879 /* Their size. */
880 YYPTRDIFF_T yystacksize = YYINITDEPTH;
881
882 /* The state stack: array, bottom, top. */
883 yy_state_t yyssa[YYINITDEPTH];
884 yy_state_t *yyss = yyssa;
885 yy_state_t *yyssp = yyss;
886
887 /* The semantic value stack: array, bottom, top. */
888 YYSTYPE yyvsa[YYINITDEPTH];
889 YYSTYPE *yyvs = yyvsa;
890 YYSTYPE *yyvsp = yyvs;
891
892 int yyn;
893 /* The return value of yyparse. */
894 int yyresult;
895 /* Lookahead symbol kind. */
896 yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
897 /* The variables used to return semantic value and location from the
898 action routines. */
899 YYSTYPE yyval;
900
901
902
903 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
904
905 /* The number of symbols on the RHS of the reduced rule.
906 Keep to zero when no symbol should be popped. */
907 int yylen = 0;
908
909 YYDPRINTF ((stderr, "Starting parse\n"));
910
911 yychar = YYEMPTY; /* Cause a token to be read. */
912 goto yysetstate;
913
914
915 /*------------------------------------------------------------.
916 | yynewstate -- push a new state, which is found in yystate. |
917 `------------------------------------------------------------*/
918 yynewstate:
919 /* In all cases, when you get here, the value and location stacks
920 have just been pushed. So pushing a state here evens the stacks. */
921 yyssp++;
922
923
924 /*--------------------------------------------------------------------.
925 | yysetstate -- set current state (the top of the stack) to yystate. |
926 `--------------------------------------------------------------------*/
927 yysetstate:
928 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
929 YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
930 YY_IGNORE_USELESS_CAST_BEGIN
931 *yyssp = YY_CAST (yy_state_t, yystate);
932 YY_IGNORE_USELESS_CAST_END
933 YY_STACK_PRINT (yyss, yyssp);
934
935 if (yyss + yystacksize - 1 <= yyssp)
936 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
937 goto yyexhaustedlab;
938 #else
939 {
940 /* Get the current used size of the three stacks, in elements. */
941 YYPTRDIFF_T yysize = yyssp - yyss + 1;
942
943 # if defined yyoverflow
944 {
945 /* Give user a chance to reallocate the stack. Use copies of
946 these so that the &'s don't force the real ones into
947 memory. */
948 yy_state_t *yyss1 = yyss;
949 YYSTYPE *yyvs1 = yyvs;
950
951 /* Each stack pointer address is followed by the size of the
952 data in use in that stack, in bytes. This used to be a
953 conditional around just the two extra args, but that might
954 be undefined if yyoverflow is a macro. */
955 yyoverflow (YY_("memory exhausted"),
956 &yyss1, yysize * YYSIZEOF (*yyssp),
957 &yyvs1, yysize * YYSIZEOF (*yyvsp),
958 &yystacksize);
959 yyss = yyss1;
960 yyvs = yyvs1;
961 }
962 # else /* defined YYSTACK_RELOCATE */
963 /* Extend the stack our own way. */
964 if (YYMAXDEPTH <= yystacksize)
965 goto yyexhaustedlab;
966 yystacksize *= 2;
967 if (YYMAXDEPTH < yystacksize)
968 yystacksize = YYMAXDEPTH;
969
970 {
971 yy_state_t *yyss1 = yyss;
972 union yyalloc *yyptr =
973 YY_CAST (union yyalloc *,
974 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
975 if (! yyptr)
976 goto yyexhaustedlab;
977 YYSTACK_RELOCATE (yyss_alloc, yyss);
978 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
979 # undef YYSTACK_RELOCATE
980 if (yyss1 != yyssa)
981 YYSTACK_FREE (yyss1);
982 }
983 # endif
984
985 yyssp = yyss + yysize - 1;
986 yyvsp = yyvs + yysize - 1;
987
988 YY_IGNORE_USELESS_CAST_BEGIN
989 YYDPRINTF ((stderr, "Stack size increased to %ld\n",
990 YY_CAST (long, yystacksize)));
991 YY_IGNORE_USELESS_CAST_END
992
993 if (yyss + yystacksize - 1 <= yyssp)
994 YYABORT;
995 }
996 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
997
998 if (yystate == YYFINAL)
999 YYACCEPT;
1000
1001 goto yybackup;
1002
1003
1004 /*-----------.
1005 | yybackup. |
1006 `-----------*/
1007 yybackup:
1008 /* Do appropriate processing given the current state. Read a
1009 lookahead token if we need one and don't already have one. */
1010
1011 /* First try to decide what to do without reference to lookahead token. */
1012 yyn = yypact[yystate];
1013 if (yypact_value_is_default (yyn))
1014 goto yydefault;
1015
1016 /* Not known => get a lookahead token if don't already have one. */
1017
1018 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1019 if (yychar == YYEMPTY)
1020 {
1021 YYDPRINTF ((stderr, "Reading a token\n"));
1022 yychar = yylex (pattern);
1023 }
1024
1025 if (yychar <= YYEOF)
1026 {
1027 yychar = YYEOF;
1028 yytoken = YYSYMBOL_YYEOF;
1029 YYDPRINTF ((stderr, "Now at end of input.\n"));
1030 }
1031 else if (yychar == YYerror)
1032 {
1033 /* The scanner already issued an error message, process directly
1034 to error recovery. But do not keep the error token as
1035 lookahead, it is too special and may lead us to an endless
1036 loop in error recovery. */
1037 yychar = YYUNDEF;
1038 yytoken = YYSYMBOL_YYerror;
1039 goto yyerrlab1;
1040 }
1041 else
1042 {
1043 yytoken = YYTRANSLATE (yychar);
1044 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1045 }
1046
1047 /* If the proper action on seeing token YYTOKEN is to reduce or to
1048 detect an error, take that action. */
1049 yyn += yytoken;
1050 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1051 goto yydefault;
1052 yyn = yytable[yyn];
1053 if (yyn <= 0)
1054 {
1055 if (yytable_value_is_error (yyn))
1056 goto yyerrlab;
1057 yyn = -yyn;
1058 goto yyreduce;
1059 }
1060
1061 /* Count tokens shifted since error; after three, turn off error
1062 status. */
1063 if (yyerrstatus)
1064 yyerrstatus--;
1065
1066 /* Shift the lookahead token. */
1067 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1068 yystate = yyn;
1069 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1070 *++yyvsp = yylval;
1071 YY_IGNORE_MAYBE_UNINITIALIZED_END
1072
1073 /* Discard the shifted token. */
1074 yychar = YYEMPTY;
1075 goto yynewstate;
1076
1077
1078 /*-----------------------------------------------------------.
1079 | yydefault -- do the default action for the current state. |
1080 `-----------------------------------------------------------*/
1081 yydefault:
1082 yyn = yydefact[yystate];
1083 if (yyn == 0)
1084 goto yyerrlab;
1085 goto yyreduce;
1086
1087
1088 /*-----------------------------.
1089 | yyreduce -- do a reduction. |
1090 `-----------------------------*/
1091 yyreduce:
1092 /* yyn is the number of a rule to reduce with. */
1093 yylen = yyr2[yyn];
1094
1095 /* If YYLEN is nonzero, implement the default value of the action:
1096 '$$ = $1'.
1097
1098 Otherwise, the following line sets YYVAL to garbage.
1099 This behavior is undocumented and Bison
1100 users should not rely upon it. Assigning to YYVAL
1101 unconditionally makes the parser a bit smaller, and it avoids a
1102 GCC warning that YYVAL may be used uninitialized. */
1103 yyval = yyvsp[1-yylen];
1104
1105
1106 YY_REDUCE_PRINT (yyn);
1107 switch (yyn)
1108 {
1109 case 2: /* regexp: expr */
1110 #line 52 "../lib/parse.ypp"
1111 { regexp = (yyval.regexp); }
1112 #line 1113 "lib/parse.cc"
1113 break;
1114
1115 case 4: /* expr: expr '|' term */
1116 #line 56 "../lib/parse.ypp"
1117 { (yyval.regexp) = ast_alt((yyvsp[-2].regexp), (yyvsp[0].regexp)); }
1118 #line 1119 "lib/parse.cc"
1119 break;
1120
1121 case 6: /* term: factor term */
1122 #line 61 "../lib/parse.ypp"
1123 { (yyval.regexp) = ast_cat((yyvsp[-1].regexp), (yyvsp[0].regexp)); }
1124 #line 1125 "lib/parse.cc"
1125 break;
1126
1127 case 8: /* factor: primary '*' */
1128 #line 66 "../lib/parse.ypp"
1129 { (yyval.regexp) = ast_iter((yyvsp[-1].regexp), 0, AST::MANY); }
1130 #line 1131 "lib/parse.cc"
1131 break;
1132
1133 case 9: /* factor: primary '+' */
1134 #line 67 "../lib/parse.ypp"
1135 { (yyval.regexp) = ast_iter((yyvsp[-1].regexp), 1, AST::MANY); }
1136 #line 1137 "lib/parse.cc"
1137 break;
1138
1139 case 10: /* factor: primary '?' */
1140 #line 68 "../lib/parse.ypp"
1141 { (yyval.regexp) = ast_iter((yyvsp[-1].regexp), 0, 1); }
1142 #line 1143 "lib/parse.cc"
1143 break;
1144
1145 case 11: /* factor: primary TOKEN_COUNT */
1146 #line 69 "../lib/parse.ypp"
1147 { (yyval.regexp) = ast_iter((yyvsp[-1].regexp), (yyvsp[0].bounds).min, (yyvsp[0].bounds).max); }
1148 #line 1149 "lib/parse.cc"
1149 break;
1150
1151 case 13: /* primary: '(' ')' */
1152 #line 74 "../lib/parse.ypp"
1153 { (yyval.regexp) = ast_cap(ast_nil(NOWHERE)); }
1154 #line 1155 "lib/parse.cc"
1155 break;
1156
1157 case 14: /* primary: '(' expr ')' */
1158 #line 75 "../lib/parse.ypp"
1159 { (yyval.regexp) = ast_cap((yyvsp[-1].regexp)); }
1160 #line 1161 "lib/parse.cc"
1161 break;
1162
1163
1164 #line 1165 "lib/parse.cc"
1165
1166 default: break;
1167 }
1168 /* User semantic actions sometimes alter yychar, and that requires
1169 that yytoken be updated with the new translation. We take the
1170 approach of translating immediately before every use of yytoken.
1171 One alternative is translating here after every semantic action,
1172 but that translation would be missed if the semantic action invokes
1173 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1174 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1175 incorrect destructor might then be invoked immediately. In the
1176 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1177 to an incorrect destructor call or verbose syntax error message
1178 before the lookahead is translated. */
1179 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1180
1181 YYPOPSTACK (yylen);
1182 yylen = 0;
1183
1184 *++yyvsp = yyval;
1185
1186 /* Now 'shift' the result of the reduction. Determine what state
1187 that goes to, based on the state we popped back to and the rule
1188 number reduced by. */
1189 {
1190 const int yylhs = yyr1[yyn] - YYNTOKENS;
1191 const int yyi = yypgoto[yylhs] + *yyssp;
1192 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1193 ? yytable[yyi]
1194 : yydefgoto[yylhs]);
1195 }
1196
1197 goto yynewstate;
1198
1199
1200 /*--------------------------------------.
1201 | yyerrlab -- here on detecting error. |
1202 `--------------------------------------*/
1203 yyerrlab:
1204 /* Make sure we have latest lookahead translation. See comments at
1205 user semantic actions for why this is necessary. */
1206 yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1207 /* If not already recovering from an error, report this error. */
1208 if (!yyerrstatus)
1209 {
1210 ++yynerrs;
1211 yyerror (pattern, YY_("syntax error"));
1212 }
1213
1214 if (yyerrstatus == 3)
1215 {
1216 /* If just tried and failed to reuse lookahead token after an
1217 error, discard it. */
1218
1219 if (yychar <= YYEOF)
1220 {
1221 /* Return failure if at end of input. */
1222 if (yychar == YYEOF)
1223 YYABORT;
1224 }
1225 else
1226 {
1227 yydestruct ("Error: discarding",
1228 yytoken, &yylval, pattern);
1229 yychar = YYEMPTY;
1230 }
1231 }
1232
1233 /* Else will try to reuse lookahead token after shifting the error
1234 token. */
1235 goto yyerrlab1;
1236
1237
1238 /*---------------------------------------------------.
1239 | yyerrorlab -- error raised explicitly by YYERROR. |
1240 `---------------------------------------------------*/
1241 yyerrorlab:
1242 /* Pacify compilers when the user code never invokes YYERROR and the
1243 label yyerrorlab therefore never appears in user code. */
1244 if (0)
1245 YYERROR;
1246
1247 /* Do not reclaim the symbols of the rule whose action triggered
1248 this YYERROR. */
1249 YYPOPSTACK (yylen);
1250 yylen = 0;
1251 YY_STACK_PRINT (yyss, yyssp);
1252 yystate = *yyssp;
1253 goto yyerrlab1;
1254
1255
1256 /*-------------------------------------------------------------.
1257 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1258 `-------------------------------------------------------------*/
1259 yyerrlab1:
1260 yyerrstatus = 3; /* Each real token shifted decrements this. */
1261
1262 /* Pop stack until we find a state that shifts the error token. */
1263 for (;;)
1264 {
1265 yyn = yypact[yystate];
1266 if (!yypact_value_is_default (yyn))
1267 {
1268 yyn += YYSYMBOL_YYerror;
1269 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1270 {
1271 yyn = yytable[yyn];
1272 if (0 < yyn)
1273 break;
1274 }
1275 }
1276
1277 /* Pop the current state because it cannot handle the error token. */
1278 if (yyssp == yyss)
1279 YYABORT;
1280
1281
1282 yydestruct ("Error: popping",
1283 YY_ACCESSING_SYMBOL (yystate), yyvsp, pattern);
1284 YYPOPSTACK (1);
1285 yystate = *yyssp;
1286 YY_STACK_PRINT (yyss, yyssp);
1287 }
1288
1289 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1290 *++yyvsp = yylval;
1291 YY_IGNORE_MAYBE_UNINITIALIZED_END
1292
1293
1294 /* Shift the error token. */
1295 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1296
1297 yystate = yyn;
1298 goto yynewstate;
1299
1300
1301 /*-------------------------------------.
1302 | yyacceptlab -- YYACCEPT comes here. |
1303 `-------------------------------------*/
1304 yyacceptlab:
1305 yyresult = 0;
1306 goto yyreturn;
1307
1308
1309 /*-----------------------------------.
1310 | yyabortlab -- YYABORT comes here. |
1311 `-----------------------------------*/
1312 yyabortlab:
1313 yyresult = 1;
1314 goto yyreturn;
1315
1316
1317 #if !defined yyoverflow
1318 /*-------------------------------------------------.
1319 | yyexhaustedlab -- memory exhaustion comes here. |
1320 `-------------------------------------------------*/
1321 yyexhaustedlab:
1322 yyerror (pattern, YY_("memory exhausted"));
1323 yyresult = 2;
1324 goto yyreturn;
1325 #endif
1326
1327
1328 /*-------------------------------------------------------.
1329 | yyreturn -- parsing is finished, clean up and return. |
1330 `-------------------------------------------------------*/
1331 yyreturn:
1332 if (yychar != YYEMPTY)
1333 {
1334 /* Make sure we have latest lookahead translation. See comments at
1335 user semantic actions for why this is necessary. */
1336 yytoken = YYTRANSLATE (yychar);
1337 yydestruct ("Cleanup: discarding lookahead",
1338 yytoken, &yylval, pattern);
1339 }
1340 /* Do not reclaim the symbols of the rule whose action triggered
1341 this YYABORT or YYACCEPT. */
1342 YYPOPSTACK (yylen);
1343 YY_STACK_PRINT (yyss, yyssp);
1344 while (yyssp != yyss)
1345 {
1346 yydestruct ("Cleanup: popping",
1347 YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, pattern);
1348 YYPOPSTACK (1);
1349 }
1350 #ifndef yyoverflow
1351 if (yyss != yyssa)
1352 YYSTACK_FREE (yyss);
1353 #endif
1354
1355 return yyresult;
1356 }
1357
1358 #line 78 "../lib/parse.ypp"
1359
1360
1361 #pragma GCC diagnostic pop
1362
1363 extern "C" {
1364
yyerror(const char * pattern,const char * msg)1365 void yyerror(const char *pattern, const char *msg)
1366 {
1367 fprintf(stderr, "%s (on RE %s)", msg, pattern);
1368 exit(1);
1369 }
1370
yylex(const char * & pattern)1371 int yylex(const char *&pattern)
1372 {
1373 return lex(pattern);
1374 }
1375
1376 } // extern "C"
1377
1378 namespace re2c {
1379
parse(const char * pattern)1380 const AST *parse(const char *pattern)
1381 {
1382 yyparse(pattern);
1383 return regexp;
1384 }
1385
1386 } // namespace re2c
1387