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