Ruby  3.4.0dev (2024-12-06 revision 892c46283a5ea4179500d951c9d4866c0051f27b)
yacc.c
1 <%# b4_generated_by -%>
2 /* A Bison parser, made by Lrama <%= Lrama::VERSION %>. */
3 
4 <%# b4_copyright -%>
5 /* Bison implementation for Yacc-like parsers in C
6 
7  Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
8  Inc.
9 
10  This program is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program. If not, see <https://www.gnu.org/licenses/>. */
22 
23 /* As a special exception, you may create a larger work that contains
24  part or all of the Bison parser skeleton and distribute that work
25  under terms of your choice, so long as that work isn't itself a
26  parser generator using the skeleton or a modified version thereof
27  as a parser skeleton. Alternatively, if you modify or redistribute
28  the parser skeleton itself, you may (at your option) remove this
29  special exception, which will cause the skeleton and the resulting
30  Bison output files to be licensed under the GNU General Public
31  License without this special exception.
32 
33  This special exception was added by the Free Software Foundation in
34  version 2.2 of Bison. */
35 
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37  simplifying the original so-called "semantic" parser. */
38 
39 <%# b4_disclaimer -%>
40 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
41  especially those whose name start with YY_ or yy_. They are
42  private implementation details that can be changed or removed. */
43 
44 /* All symbols defined below should begin with yy or YY, to avoid
45  infringing on user name space. This should be done even for local
46  variables, as they might otherwise be expanded by user macros.
47  There are some unavoidable exceptions within include files to
48  define necessary library symbols; they are noted "INFRINGES ON
49  USER NAME SPACE" below. */
50 
51 <%# b4_identification -%>
52 /* Identify Bison output, and Bison version. */
53 #define YYBISON 30802
54 
55 /* Bison version string. */
56 #define YYBISON_VERSION "3.8.2"
57 
58 /* Skeleton name. */
59 #define YYSKELETON_NAME "<%= output.template_basename %>"
60 
61 /* Pure parsers. */
62 #define YYPURE 1
63 
64 /* Push parsers. */
65 #define YYPUSH 0
66 
67 /* Pull parsers. */
68 #define YYPULL 1
69 
70 
71 <%# b4_user_pre_prologue -%>
72 <%- if output.aux.prologue -%>
73 /* First part of user prologue. */
74 #line <%= output.aux.prologue_first_lineno %> "<%= output.grammar_file_path %>"
75 <%= output.aux.prologue %>
76 #line [@oline@] [@ofile@]
77 <%- end -%>
78 
79 <%# b4_cast_define -%>
80 # ifndef YY_CAST
81 # ifdef __cplusplus
82 # define YY_CAST(Type, Val) static_cast<Type> (Val)
83 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
84 # else
85 # define YY_CAST(Type, Val) ((Type) (Val))
86 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
87 # endif
88 # endif
89 <%# b4_null_define -%>
90 # ifndef YY_NULLPTR
91 # if defined __cplusplus
92 # if 201103L <= __cplusplus
93 # define YY_NULLPTR nullptr
94 # else
95 # define YY_NULLPTR 0
96 # endif
97 # else
98 # define YY_NULLPTR ((void*)0)
99 # endif
100 # endif
101 
102 <%# b4_header_include_if -%>
103 <%- if output.include_header -%>
104 #include "<%= output.include_header %>"
105 <%- else -%>
106 /* Use api.header.include to #include this header
107  instead of duplicating it here. */
108 <%= output.render_partial("bison/_yacc.h") %>
109 <%- end -%>
110 <%# b4_declare_symbol_enum -%>
111 /* Symbol kind. */
112 enum yysymbol_kind_t
113 {
114 <%= output.symbol_enum -%>
115 };
116 typedef enum yysymbol_kind_t yysymbol_kind_t;
117 
118 
119 
120 
121 <%# b4_user_post_prologue -%>
122 <%# b4_c99_int_type_define -%>
123 #ifdef short
124 # undef short
125 #endif
126 
127 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
128  <limits.h> and (if available) <stdint.h> are included
129  so that the code can choose integer types of a good width. */
130 
131 #ifndef __PTRDIFF_MAX__
132 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
133 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
134 # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
135 # define YY_STDINT_H
136 # endif
137 #endif
138 
139 /* Narrow types that promote to a signed type and that can represent a
140  signed or unsigned integer of at least N bits. In tables they can
141  save space and decrease cache pressure. Promoting to a signed type
142  helps avoid bugs in integer arithmetic. */
143 
144 #ifdef __INT_LEAST8_MAX__
145 typedef __INT_LEAST8_TYPE__ yytype_int8;
146 #elif defined YY_STDINT_H
147 typedef int_least8_t yytype_int8;
148 #else
149 typedef signed char yytype_int8;
150 #endif
151 
152 #ifdef __INT_LEAST16_MAX__
153 typedef __INT_LEAST16_TYPE__ yytype_int16;
154 #elif defined YY_STDINT_H
155 typedef int_least16_t yytype_int16;
156 #else
157 typedef short yytype_int16;
158 #endif
159 
160 /* Work around bug in HP-UX 11.23, which defines these macros
161  incorrectly for preprocessor constants. This workaround can likely
162  be removed in 2023, as HPE has promised support for HP-UX 11.23
163  (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
164  <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
165 #ifdef __hpux
166 # undef UINT_LEAST8_MAX
167 # undef UINT_LEAST16_MAX
168 # define UINT_LEAST8_MAX 255
169 # define UINT_LEAST16_MAX 65535
170 #endif
171 
172 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
173 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
174 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
175  && UINT_LEAST8_MAX <= INT_MAX)
176 typedef uint_least8_t yytype_uint8;
177 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
178 typedef unsigned char yytype_uint8;
179 #else
180 typedef short yytype_uint8;
181 #endif
182 
183 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
184 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
185 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
186  && UINT_LEAST16_MAX <= INT_MAX)
187 typedef uint_least16_t yytype_uint16;
188 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
189 typedef unsigned short yytype_uint16;
190 #else
191 typedef int yytype_uint16;
192 #endif
193 
194 <%# b4_sizes_types_define -%>
195 #ifndef YYPTRDIFF_T
196 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
197 # define YYPTRDIFF_T __PTRDIFF_TYPE__
198 # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
199 # elif defined PTRDIFF_MAX
200 # ifndef ptrdiff_t
201 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
202 # endif
203 # define YYPTRDIFF_T ptrdiff_t
204 # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
205 # else
206 # define YYPTRDIFF_T long
207 # define YYPTRDIFF_MAXIMUM LONG_MAX
208 # endif
209 #endif
210 
211 #ifndef YYSIZE_T
212 # ifdef __SIZE_TYPE__
213 # define YYSIZE_T __SIZE_TYPE__
214 # elif defined size_t
215 # define YYSIZE_T size_t
216 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
217 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
218 # define YYSIZE_T size_t
219 # else
220 # define YYSIZE_T unsigned
221 # endif
222 #endif
223 
224 #define YYSIZE_MAXIMUM \
225  YY_CAST (YYPTRDIFF_T, \
226  (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
227  ? YYPTRDIFF_MAXIMUM \
228  : YY_CAST (YYSIZE_T, -1)))
229 
230 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
231 
232 
233 /* Stored state numbers (used for stacks). */
234 typedef <%= output.int_type_for([output.yynstates - 1]) %> yy_state_t;
235 
236 /* State numbers in computations. */
237 typedef int yy_state_fast_t;
238 
239 #ifndef YY_
240 # if defined YYENABLE_NLS && YYENABLE_NLS
241 # if ENABLE_NLS
242 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
243 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
244 # endif
245 # endif
246 # ifndef YY_
247 # define YY_(Msgid) Msgid
248 # endif
249 #endif
250 
251 
252 <%# b4_attribute_define -%>
253 #ifndef YY_ATTRIBUTE_PURE
254 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
255 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
256 # else
257 # define YY_ATTRIBUTE_PURE
258 # endif
259 #endif
260 
261 #ifndef YY_ATTRIBUTE_UNUSED
262 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
263 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
264 # else
265 # define YY_ATTRIBUTE_UNUSED
266 # endif
267 #endif
268 
269 /* Suppress unused-variable warnings by "using" E. */
270 #if ! defined lint || defined __GNUC__
271 # define YY_USE(E) ((void) (E))
272 #else
273 # define YY_USE(E) /* empty */
274 #endif
275 
276 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
277 #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
278 # if __GNUC__ * 100 + __GNUC_MINOR__ < 407
279 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
280  _Pragma ("GCC diagnostic push") \
281  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
282 # else
283 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
284  _Pragma ("GCC diagnostic push") \
285  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
286  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
287 # endif
288 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
289  _Pragma ("GCC diagnostic pop")
290 #else
291 # define YY_INITIAL_VALUE(Value) Value
292 #endif
293 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
294 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
295 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
296 #endif
297 #ifndef YY_INITIAL_VALUE
298 # define YY_INITIAL_VALUE(Value) /* Nothing. */
299 #endif
300 
301 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
302 # define YY_IGNORE_USELESS_CAST_BEGIN \
303  _Pragma ("GCC diagnostic push") \
304  _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
305 # define YY_IGNORE_USELESS_CAST_END \
306  _Pragma ("GCC diagnostic pop")
307 #endif
308 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
309 # define YY_IGNORE_USELESS_CAST_BEGIN
310 # define YY_IGNORE_USELESS_CAST_END
311 #endif
312 
313 
314 #define YY_ASSERT(E) ((void) (0 && (E)))
315 
316 #if 1
317 
318 /* The parser invokes alloca or malloc; define the necessary symbols. */
319 
320 # ifdef YYSTACK_USE_ALLOCA
321 # if YYSTACK_USE_ALLOCA
322 # ifdef __GNUC__
323 # define YYSTACK_ALLOC __builtin_alloca
324 # elif defined __BUILTIN_VA_ARG_INCR
325 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
326 # elif defined _AIX
327 # define YYSTACK_ALLOC __alloca
328 # elif defined _MSC_VER
329 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
330 # define alloca _alloca
331 # else
332 # define YYSTACK_ALLOC alloca
333 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
334 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
335  /* Use EXIT_SUCCESS as a witness for stdlib.h. */
336 # ifndef EXIT_SUCCESS
337 # define EXIT_SUCCESS 0
338 # endif
339 # endif
340 # endif
341 # endif
342 # endif
343 
344 # ifdef YYSTACK_ALLOC
345  /* Pacify GCC's 'empty if-body' warning. */
346 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
347 # ifndef YYSTACK_ALLOC_MAXIMUM
348  /* The OS might guarantee only one guard page at the bottom of the stack,
349  and a page size can be as small as 4096 bytes. So we cannot safely
350  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
351  to allow for a few compiler-allocated temporary stack slots. */
352 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
353 # endif
354 # else
355 # define YYSTACK_ALLOC YYMALLOC
356 # define YYSTACK_FREE YYFREE
357 # ifndef YYSTACK_ALLOC_MAXIMUM
358 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
359 # endif
360 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
361  && ! ((defined YYMALLOC || defined malloc) \
362  && (defined YYFREE || defined free)))
363 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
364 # ifndef EXIT_SUCCESS
365 # define EXIT_SUCCESS 0
366 # endif
367 # endif
368 # ifndef YYMALLOC
369 # define YYMALLOC malloc
370 # if ! defined malloc && ! defined EXIT_SUCCESS
371 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
372 # endif
373 # endif
374 # ifndef YYFREE
375 # define YYFREE free
376 # if ! defined free && ! defined EXIT_SUCCESS
377 void free (void *); /* INFRINGES ON USER NAME SPACE */
378 # endif
379 # endif
380 # endif
381 #endif /* 1 */
382 
383 #if (! defined yyoverflow \
384  && (! defined __cplusplus \
385  || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
386  && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
387 
388 /* A type that is properly aligned for any stack member. */
389 union yyalloc
390 {
391  yy_state_t yyss_alloc;
392  YYSTYPE yyvs_alloc;
393  YYLTYPE yyls_alloc;
394 };
395 
396 /* The size of the maximum gap between one aligned stack and the next. */
397 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
398 
399 /* The size of an array large to enough to hold all stacks, each with
400  N elements. */
401 # define YYSTACK_BYTES(N) \
402  ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \
403  + YYSIZEOF (YYLTYPE)) \
404  + 2 * YYSTACK_GAP_MAXIMUM)
405 
406 # define YYCOPY_NEEDED 1
407 
408 /* Relocate STACK from its old location to the new one. The
409  local variables YYSIZE and YYSTACKSIZE give the old and new number of
410  elements in the stack, and YYPTR gives the new location of the
411  stack. Advance YYPTR to a properly aligned location for the next
412  stack. */
413 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
414  do \
415  { \
416  YYPTRDIFF_T yynewbytes; \
417  YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
418  Stack = &yyptr->Stack_alloc; \
419  yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
420  yyptr += yynewbytes / YYSIZEOF (*yyptr); \
421  } \
422  while (0)
423 
424 #endif
425 
426 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
427 /* Copy COUNT objects from SRC to DST. The source and destination do
428  not overlap. */
429 # ifndef YYCOPY
430 # if defined __GNUC__ && 1 < __GNUC__
431 # define YYCOPY(Dst, Src, Count) \
432  __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
433 # else
434 # define YYCOPY(Dst, Src, Count) \
435  do \
436  { \
437  YYPTRDIFF_T yyi; \
438  for (yyi = 0; yyi < (Count); yyi++) \
439  (Dst)[yyi] = (Src)[yyi]; \
440  } \
441  while (0)
442 # endif
443 # endif
444 #endif /* !YYCOPY_NEEDED */
445 
446 /* YYFINAL -- State number of the termination state. */
447 #define YYFINAL <%= output.yyfinal %>
448 /* YYLAST -- Last index in YYTABLE. */
449 #define YYLAST <%= output.yylast %>
450 
451 /* YYNTOKENS -- Number of terminals. */
452 #define YYNTOKENS <%= output.yyntokens %>
453 /* YYNNTS -- Number of nonterminals. */
454 #define YYNNTS <%= output.yynnts %>
455 /* YYNRULES -- Number of rules. */
456 #define YYNRULES <%= output.yynrules %>
457 /* YYNSTATES -- Number of states. */
458 #define YYNSTATES <%= output.yynstates %>
459 
460 /* YYMAXUTOK -- Last valid token kind. */
461 #define YYMAXUTOK <%= output.yymaxutok %>
462 
463 
464 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
465  as returned by yylex, with out-of-bounds checking. */
466 #define YYTRANSLATE(YYX) \
467  (0 <= (YYX) && (YYX) <= YYMAXUTOK \
468  ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
469  : YYSYMBOL_YYUNDEF)
470 
471 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
472  as returned by yylex. */
473 static const <%= output.int_type_for(output.context.yytranslate) %> yytranslate[] =
474 {
475 <%= output.yytranslate %>
476 };
477 
478 <%- if output.error_recovery -%>
479 /* YYTRANSLATE_INVERTED[SYMBOL-NUM] -- Token number corresponding to SYMBOL-NUM */
480 static const <%= output.int_type_for(output.context.yytranslate_inverted) %> yytranslate_inverted[] =
481 {
482 <%= output.yytranslate_inverted %>
483 };
484 <%- end -%>
485 #if YYDEBUG
486 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
487 static const <%= output.int_type_for(output.context.yyrline) %> yyrline[] =
488 {
489 <%= output.yyrline %>
490 };
491 #endif
492 
494 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
495 
496 #if 1
497 /* The user-facing name of the symbol whose (internal) number is
498  YYSYMBOL. No bounds checking. */
499 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
500 
501 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
502  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
503 static const char *const yytname[] =
504 {
505 <%= output.yytname %>
506 };
507 
508 static const char *
509 yysymbol_name (yysymbol_kind_t yysymbol)
510 {
511  return yytname[yysymbol];
512 }
513 #endif
514 
515 #define YYPACT_NINF (<%= output.yypact_ninf %>)
516 
517 #define yypact_value_is_default(Yyn) \
518  <%= output.table_value_equals(output.context.yypact, "Yyn", output.yypact_ninf, "YYPACT_NINF") %>
519 
520 #define YYTABLE_NINF (<%= output.yytable_ninf %>)
521 
522 #define yytable_value_is_error(Yyn) \
523  <%= output.table_value_equals(output.context.yytable, "Yyn", output.yytable_ninf, "YYTABLE_NINF") %>
524 
525 <%# b4_parser_tables_define -%>
526 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
527  STATE-NUM. */
528 static const <%= output.int_type_for(output.context.yypact) %> yypact[] =
529 {
530 <%= output.int_array_to_string(output.context.yypact) %>
531 };
532 
533 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
534  Performed when YYTABLE does not specify something else to do. Zero
535  means the default is an error. */
536 static const <%= output.int_type_for(output.context.yydefact) %> yydefact[] =
537 {
538 <%= output.int_array_to_string(output.context.yydefact) %>
539 };
540 
541 /* YYPGOTO[NTERM-NUM]. */
542 static const <%= output.int_type_for(output.context.yypgoto) %> yypgoto[] =
543 {
544 <%= output.int_array_to_string(output.context.yypgoto) %>
545 };
546 
547 /* YYDEFGOTO[NTERM-NUM]. */
548 static const <%= output.int_type_for(output.context.yydefgoto) %> yydefgoto[] =
549 {
550 <%= output.int_array_to_string(output.context.yydefgoto) %>
551 };
552 
553 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
554  positive, shift that token. If negative, reduce the rule whose
555  number is the opposite. If YYTABLE_NINF, syntax error. */
556 static const <%= output.int_type_for(output.context.yytable) %> yytable[] =
557 {
558 <%= output.int_array_to_string(output.context.yytable) %>
559 };
560 
561 static const <%= output.int_type_for(output.context.yycheck) %> yycheck[] =
562 {
563 <%= output.int_array_to_string(output.context.yycheck) %>
564 };
565 
566 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
567  state STATE-NUM. */
568 static const <%= output.int_type_for(output.context.yystos) %> yystos[] =
569 {
570 <%= output.int_array_to_string(output.context.yystos) %>
571 };
572 
573 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
574 static const <%= output.int_type_for(output.context.yyr1) %> yyr1[] =
575 {
576 <%= output.int_array_to_string(output.context.yyr1) %>
577 };
578 
579 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
580 static const <%= output.int_type_for(output.context.yyr2) %> yyr2[] =
581 {
582 <%= output.int_array_to_string(output.context.yyr2) %>
583 };
584 
585 
586 enum { YYENOMEM = -2 };
587 
588 #define yyerrok (yyerrstatus = 0)
589 #define yyclearin (yychar = YYEMPTY)
590 
591 #define YYACCEPT goto yyacceptlab
592 #define YYABORT goto yyabortlab
593 #define YYERROR goto yyerrorlab
594 #define YYNOMEM goto yyexhaustedlab
595 
596 
597 #define YYRECOVERING() (!!yyerrstatus)
598 
599 #define YYBACKUP(Token, Value) \
600  do \
601  if (yychar == YYEMPTY) \
602  { \
603  yychar = (Token); \
604  yylval = (Value); \
605  YYPOPSTACK (yylen); \
606  yystate = *yyssp; \
607  goto yybackup; \
608  } \
609  else \
610  { \
611  yyerror (<%= output.yyerror_args %>, YY_("syntax error: cannot back up")); \
612  YYERROR; \
613  } \
614  while (0)
615 
616 /* Backward compatibility with an undocumented macro.
617  Use YYerror or YYUNDEF. */
618 #define YYERRCODE YYUNDEF
619 
620 <%# b4_yylloc_default_define -%>
621 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
622  If N is 0, then set CURRENT to the empty location which ends
623  the previous symbol: RHS[0] (always defined). */
624 
625 #ifndef YYLLOC_DEFAULT
626 # define YYLLOC_DEFAULT(Current, Rhs, N) \
627  do \
628  if (N) \
629  { \
630  (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
631  (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
632  (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
633  (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
634  } \
635  else \
636  { \
637  (Current).first_line = (Current).last_line = \
638  YYRHSLOC (Rhs, 0).last_line; \
639  (Current).first_column = (Current).last_column = \
640  YYRHSLOC (Rhs, 0).last_column; \
641  } \
642  while (0)
643 #endif
644 
645 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
646 
647 
648 /* Enable debugging if requested. */
649 #if YYDEBUG
650 
651 # ifndef YYFPRINTF
652 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
653 # define YYFPRINTF fprintf
654 # endif
655 
656 # define YYDPRINTF(Args) \
657 do { \
658  if (yydebug) \
659  YYFPRINTF Args; \
660 } while (0)
661 
662 
663 <%# b4_yylocation_print_define -%>
664 /* YYLOCATION_PRINT -- Print the location on the stream.
665  This macro was not mandated originally: define only if we know
666  we won't break user code: when these are the locations we know. */
667 
668 # ifndef YYLOCATION_PRINT
669 
670 # if defined YY_LOCATION_PRINT
671 
672  /* Temporary convenience wrapper in case some people defined the
673  undocumented and private YY_LOCATION_PRINT macros. */
674 # define YYLOCATION_PRINT(File, Loc<%= output.user_args %>) YY_LOCATION_PRINT(File, *(Loc)<%= output.user_args %>)
675 
676 # elif defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
677 
678 /* Print *YYLOCP on YYO. Private, do not rely on its existence. */
679 
680 YY_ATTRIBUTE_UNUSED
681 static int
682 yy_location_print_ (FILE *yyo, YYLTYPE const * const yylocp)
683 {
684  int res = 0;
685  int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
686  if (0 <= yylocp->first_line)
687  {
688  res += YYFPRINTF (yyo, "%d", yylocp->first_line);
689  if (0 <= yylocp->first_column)
690  res += YYFPRINTF (yyo, ".%d", yylocp->first_column);
691  }
692  if (0 <= yylocp->last_line)
693  {
694  if (yylocp->first_line < yylocp->last_line)
695  {
696  res += YYFPRINTF (yyo, "-%d", yylocp->last_line);
697  if (0 <= end_col)
698  res += YYFPRINTF (yyo, ".%d", end_col);
699  }
700  else if (0 <= end_col && yylocp->first_column < end_col)
701  res += YYFPRINTF (yyo, "-%d", end_col);
702  }
703  return res;
704 }
705 
706 # define YYLOCATION_PRINT yy_location_print_
707 
708  /* Temporary convenience wrapper in case some people defined the
709  undocumented and private YY_LOCATION_PRINT macros. */
710 # define YY_LOCATION_PRINT(File, Loc<%= output.user_args %>) YYLOCATION_PRINT(File, &(Loc)<%= output.user_args %>)
711 
712 # else
713 
714 # define YYLOCATION_PRINT(File, Loc<%= output.user_args %>) ((void) 0)
715  /* Temporary convenience wrapper in case some people defined the
716  undocumented and private YY_LOCATION_PRINT macros. */
717 # define YY_LOCATION_PRINT YYLOCATION_PRINT
718 
719 # endif
720 # endif /* !defined YYLOCATION_PRINT */
721 
722 
723 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location<%= output.user_args %>) \
724 do { \
725  if (yydebug) \
726  { \
727  YYFPRINTF (stderr, "%s ", Title); \
728  yy_symbol_print (stderr, \
729  Kind, Value, Location<%= output.user_args %>); \
730  YYFPRINTF (stderr, "\n"); \
731  } \
732 } while (0)
733 
734 
735 <%# b4_yy_symbol_print_define -%>
736 /*-----------------------------------.
737 | Print this symbol's value on YYO. |
738 `-----------------------------------*/
739 
740 static void
741 yy_symbol_value_print (FILE *yyo,
742  yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp<%= output.user_formals %>)
743 {
744  FILE *yyoutput = yyo;
745 <%= output.parse_param_use("yyoutput", "yylocationp") %>
746  if (!yyvaluep)
747  return;
748  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
749 <%# b4_symbol_actions(printer) -%>
750 switch (yykind)
751  {
752 <%= output.symbol_actions_for_printer -%>
753  default:
754  break;
755  }
756  YY_IGNORE_MAYBE_UNINITIALIZED_END
757 }
758 
759 
760 /*---------------------------.
761 | Print this symbol on YYO. |
762 `---------------------------*/
763 
764 static void
765 yy_symbol_print (FILE *yyo,
766  yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp<%= output.user_formals %>)
767 {
768  YYFPRINTF (yyo, "%s %s (",
769  yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
770 
771  YYLOCATION_PRINT (yyo, yylocationp<%= output.user_args %>);
772  YYFPRINTF (yyo, ": ");
773  yy_symbol_value_print (yyo, yykind, yyvaluep, yylocationp<%= output.user_args %>);
774  YYFPRINTF (yyo, ")");
775 }
776 
777 /*------------------------------------------------------------------.
778 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
779 | TOP (included). |
780 `------------------------------------------------------------------*/
781 
782 static void
783 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop<%= output.user_formals %>)
784 {
785  YYFPRINTF (stderr, "Stack now");
786  for (; yybottom <= yytop; yybottom++)
787  {
788  int yybot = *yybottom;
789  YYFPRINTF (stderr, " %d", yybot);
790  }
791  YYFPRINTF (stderr, "\n");
792 }
793 
794 # define YY_STACK_PRINT(Bottom, Top<%= output.user_args %>) \
795 do { \
796  if (yydebug) \
797  yy_stack_print ((Bottom), (Top)<%= output.user_args %>); \
798 } while (0)
799 
800 
801 /*------------------------------------------------.
802 | Report that the YYRULE is going to be reduced. |
803 `------------------------------------------------*/
804 
805 static void
806 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, YYLTYPE *yylsp,
807  int yyrule<%= output.user_formals %>)
808 {
809  int yylno = yyrline[yyrule];
810  int yynrhs = yyr2[yyrule];
811  int yyi;
812  YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
813  yyrule - 1, yylno);
814  /* The symbols being reduced. */
815  for (yyi = 0; yyi < yynrhs; yyi++)
816  {
817  YYFPRINTF (stderr, " $%d = ", yyi + 1);
818  yy_symbol_print (stderr,
819  YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
820  &yyvsp[(yyi + 1) - (yynrhs)],
821  &(yylsp[(yyi + 1) - (yynrhs)])<%= output.user_args %>);
822  YYFPRINTF (stderr, "\n");
823  }
824 }
825 
826 # define YY_REDUCE_PRINT(Rule<%= output.user_args %>) \
827 do { \
828  if (yydebug) \
829  yy_reduce_print (yyssp, yyvsp, yylsp, Rule<%= output.user_args %>); \
830 } while (0)
831 
832 /* Nonzero means print parse trace. It is left uninitialized so that
833  multiple parsers can coexist. */
834 #ifndef yydebug
835 int yydebug;
836 #endif
837 #else /* !YYDEBUG */
838 # define YYDPRINTF(Args) ((void) 0)
839 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location<%= output.user_args %>)
840 # define YY_STACK_PRINT(Bottom, Top<%= output.user_args %>)
841 # define YY_REDUCE_PRINT(Rule<%= output.user_args %>)
842 #endif /* !YYDEBUG */
843 
844 
845 /* YYINITDEPTH -- initial size of the parser's stacks. */
846 #ifndef YYINITDEPTH
847 # define YYINITDEPTH 200
848 #endif
849 
850 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
851  if the built-in stack extension method is used).
852 
853  Do not make this value too large; the results are undefined if
854  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
855  evaluated with infinite-precision integer arithmetic. */
856 
857 #ifndef YYMAXDEPTH
858 # define YYMAXDEPTH 10000
859 #endif
860 
861 
862 /* Context of a parse error. */
863 typedef struct
864 {
865  yy_state_t *yyssp;
866  yysymbol_kind_t yytoken;
867  YYLTYPE *yylloc;
868 } yypcontext_t;
869 
870 /* Put in YYARG at most YYARGN of the expected tokens given the
871  current YYCTX, and return the number of tokens stored in YYARG. If
872  YYARG is null, return the number of expected tokens (guaranteed to
873  be less than YYNTOKENS). Return YYENOMEM on memory exhaustion.
874  Return 0 if there are more than YYARGN expected tokens, yet fill
875  YYARG up to YYARGN. */
876 static int
877 yypcontext_expected_tokens (const yypcontext_t *yyctx,
878  yysymbol_kind_t yyarg[], int yyargn)
879 {
880  /* Actual size of YYARG. */
881  int yycount = 0;
882  int yyn = yypact[+*yyctx->yyssp];
883  if (!yypact_value_is_default (yyn))
884  {
885  /* Start YYX at -YYN if negative to avoid negative indexes in
886  YYCHECK. In other words, skip the first -YYN actions for
887  this state because they are default actions. */
888  int yyxbegin = yyn < 0 ? -yyn : 0;
889  /* Stay within bounds of both yycheck and yytname. */
890  int yychecklim = YYLAST - yyn + 1;
891  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
892  int yyx;
893  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
894  if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_YYerror
895  && !yytable_value_is_error (yytable[yyx + yyn]))
896  {
897  if (!yyarg)
898  ++yycount;
899  else if (yycount == yyargn)
900  return 0;
901  else
902  yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);
903  }
904  }
905  if (yyarg && yycount == 0 && 0 < yyargn)
906  yyarg[0] = YYSYMBOL_YYEMPTY;
907  return yycount;
908 }
909 
910 
911 
912 
913 #ifndef yystrlen
914 # if defined __GLIBC__ && defined _STRING_H
915 # define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
916 # else
917 /* Return the length of YYSTR. */
918 static YYPTRDIFF_T
919 yystrlen (const char *yystr)
920 {
921  YYPTRDIFF_T yylen;
922  for (yylen = 0; yystr[yylen]; yylen++)
923  continue;
924  return yylen;
925 }
926 # endif
927 #endif
928 
929 #ifndef yystpcpy
930 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
931 # define yystpcpy stpcpy
932 # else
933 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
934  YYDEST. */
935 static char *
936 yystpcpy (char *yydest, const char *yysrc)
937 {
938  char *yyd = yydest;
939  const char *yys = yysrc;
940 
941  while ((*yyd++ = *yys++) != '\0')
942  continue;
943 
944  return yyd - 1;
945 }
946 # endif
947 #endif
948 
949 #ifndef yytnamerr
950 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
951  quotes and backslashes, so that it's suitable for yyerror. The
952  heuristic is that double-quoting is unnecessary unless the string
953  contains an apostrophe, a comma, or backslash (other than
954  backslash-backslash). YYSTR is taken from yytname. If YYRES is
955  null, do not copy; instead, return the length of what the result
956  would have been. */
957 static YYPTRDIFF_T
958 yytnamerr (char *yyres, const char *yystr)
959 {
960  if (*yystr == '"')
961  {
962  YYPTRDIFF_T yyn = 0;
963  char const *yyp = yystr;
964  for (;;)
965  switch (*++yyp)
966  {
967  case '\'':
968  case ',':
969  goto do_not_strip_quotes;
970 
971  case '\\':
972  if (*++yyp != '\\')
973  goto do_not_strip_quotes;
974  else
975  goto append;
976 
977  append:
978  default:
979  if (yyres)
980  yyres[yyn] = *yyp;
981  yyn++;
982  break;
983 
984  case '"':
985  if (yyres)
986  yyres[yyn] = '\0';
987  return yyn;
988  }
989  do_not_strip_quotes: ;
990  }
991 
992  if (yyres)
993  return yystpcpy (yyres, yystr) - yyres;
994  else
995  return yystrlen (yystr);
996 }
997 #endif
998 
999 
1000 static int
1001 yy_syntax_error_arguments (const yypcontext_t *yyctx,
1002  yysymbol_kind_t yyarg[], int yyargn)
1003 {
1004  /* Actual size of YYARG. */
1005  int yycount = 0;
1006  /* There are many possibilities here to consider:
1007  - If this state is a consistent state with a default action, then
1008  the only way this function was invoked is if the default action
1009  is an error action. In that case, don't check for expected
1010  tokens because there are none.
1011  - The only way there can be no lookahead present (in yychar) is if
1012  this state is a consistent state with a default action. Thus,
1013  detecting the absence of a lookahead is sufficient to determine
1014  that there is no unexpected or expected token to report. In that
1015  case, just report a simple "syntax error".
1016  - Don't assume there isn't a lookahead just because this state is a
1017  consistent state with a default action. There might have been a
1018  previous inconsistent state, consistent state with a non-default
1019  action, or user semantic action that manipulated yychar.
1020  - Of course, the expected token list depends on states to have
1021  correct lookahead information, and it depends on the parser not
1022  to perform extra reductions after fetching a lookahead from the
1023  scanner and before detecting a syntax error. Thus, state merging
1024  (from LALR or IELR) and default reductions corrupt the expected
1025  token list. However, the list is correct for canonical LR with
1026  one exception: it will still contain any token that will not be
1027  accepted due to an error action in a later state.
1028  */
1029  if (yyctx->yytoken != YYSYMBOL_YYEMPTY)
1030  {
1031  int yyn;
1032  if (yyarg)
1033  yyarg[yycount] = yyctx->yytoken;
1034  ++yycount;
1035  yyn = yypcontext_expected_tokens (yyctx,
1036  yyarg ? yyarg + 1 : yyarg, yyargn - 1);
1037  if (yyn == YYENOMEM)
1038  return YYENOMEM;
1039  else
1040  yycount += yyn;
1041  }
1042  return yycount;
1043 }
1044 
1045 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1046  about the unexpected token YYTOKEN for the state stack whose top is
1047  YYSSP.
1048 
1049  Return 0 if *YYMSG was successfully written. Return -1 if *YYMSG is
1050  not large enough to hold the message. In that case, also set
1051  *YYMSG_ALLOC to the required number of bytes. Return YYENOMEM if the
1052  required number of bytes is too large to store. */
1053 static int
1054 yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
1055  const yypcontext_t *yyctx<%= output.user_formals %>)
1056 {
1057  enum { YYARGS_MAX = 5 };
1058  /* Internationalized format string. */
1059  const char *yyformat = YY_NULLPTR;
1060  /* Arguments of yyformat: reported tokens (one for the "unexpected",
1061  one per "expected"). */
1062  yysymbol_kind_t yyarg[YYARGS_MAX];
1063  /* Cumulated lengths of YYARG. */
1064  YYPTRDIFF_T yysize = 0;
1065 
1066  /* Actual size of YYARG. */
1067  int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX);
1068  if (yycount == YYENOMEM)
1069  return YYENOMEM;
1070 
1071  switch (yycount)
1072  {
1073 #define YYCASE_(N, S) \
1074  case N: \
1075  yyformat = S; \
1076  break
1077  default: /* Avoid compiler warnings. */
1078  YYCASE_(0, YY_("syntax error"));
1079  YYCASE_(1, YY_("syntax error, unexpected %s"));
1080  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1081  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1082  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1083  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1084 #undef YYCASE_
1085  }
1086 
1087  /* Compute error message size. Don't count the "%s"s, but reserve
1088  room for the terminator. */
1089  yysize = yystrlen (yyformat) - 2 * yycount + 1;
1090  {
1091  int yyi;
1092  for (yyi = 0; yyi < yycount; ++yyi)
1093  {
1094  YYPTRDIFF_T yysize1
1095  = yysize + yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]]);
1096  if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1097  yysize = yysize1;
1098  else
1099  return YYENOMEM;
1100  }
1101  }
1102 
1103  if (*yymsg_alloc < yysize)
1104  {
1105  *yymsg_alloc = 2 * yysize;
1106  if (! (yysize <= *yymsg_alloc
1107  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1108  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1109  return -1;
1110  }
1111 
1112  /* Avoid sprintf, as that infringes on the user's name space.
1113  Don't have undefined behavior even if the translation
1114  produced a string with the wrong number of "%s"s. */
1115  {
1116  char *yyp = *yymsg;
1117  int yyi = 0;
1118  while ((*yyp = *yyformat) != '\0')
1119  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1120  {
1121  yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);
1122  yyformat += 2;
1123  }
1124  else
1125  {
1126  ++yyp;
1127  ++yyformat;
1128  }
1129  }
1130  return 0;
1131 }
1132 
1133 <%# b4_yydestruct_define %>
1134 /*-----------------------------------------------.
1135 | Release the memory associated to this symbol. |
1136 `-----------------------------------------------*/
1137 
1138 static void
1139 yydestruct (const char *yymsg,
1140  yysymbol_kind_t yykind, YYSTYPE *yyvaluep, YYLTYPE *yylocationp<%= output.user_formals %>)
1141 {
1142 <%= output.parse_param_use("yyvaluep", "yylocationp") %>
1143  if (!yymsg)
1144  yymsg = "Deleting";
1145  YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp<%= output.user_args %>);
1146 
1147  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1148  switch (yykind)
1149  {
1150 <%= output.symbol_actions_for_destructor -%>
1151  default:
1152  break;
1153  }
1154  YY_IGNORE_MAYBE_UNINITIALIZED_END
1155 }
1156 
1157 
1158 
1159 <%- if output.error_recovery -%>
1160 #ifndef YYMAXREPAIR
1161 # define YYMAXREPAIR(<%= output.parse_param_name %>) (3)
1162 #endif
1163 
1164 #ifndef YYERROR_RECOVERY_ENABLED
1165 # define YYERROR_RECOVERY_ENABLED(<%= output.parse_param_name %>) (1)
1166 #endif
1167 
1168 enum yy_repair_type {
1169  inserting,
1170  deleting,
1171  shifting,
1172 };
1173 
1174 struct yy_repair {
1175  enum yy_repair_type type;
1176  yysymbol_kind_t term;
1177 };
1178 typedef struct yy_repair yy_repair;
1179 
1180 struct yy_repairs {
1181  /* For debug */
1182  int id;
1183  /* For breadth-first traversing */
1184  struct yy_repairs *next;
1185  YYPTRDIFF_T stack_length;
1186  /* Bottom of states */
1187  yy_state_t *states;
1188  /* Top of states */
1189  yy_state_t *state;
1190  /* repair length */
1191  int repair_length;
1192  /* */
1193  struct yy_repairs *prev_repair;
1194  struct yy_repair repair;
1195 };
1196 typedef struct yy_repairs yy_repairs;
1197 
1198 struct yy_term {
1199  yysymbol_kind_t kind;
1200  YYSTYPE value;
1201  YYLTYPE location;
1202 };
1203 typedef struct yy_term yy_term;
1204 
1206  int id;
1207  int length;
1208  yy_term terms[];
1209 };
1210 typedef struct yy_repair_terms yy_repair_terms;
1211 
1212 static void
1213 yy_error_token_initialize (yysymbol_kind_t yykind, YYSTYPE * const yyvaluep, YYLTYPE * const yylocationp<%= output.user_formals %>)
1214 {
1215  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1216 switch (yykind)
1217  {
1218 <%= output.symbol_actions_for_error_token -%>
1219  default:
1220  break;
1221  }
1222  YY_IGNORE_MAYBE_UNINITIALIZED_END
1223 }
1224 
1225 static yy_repair_terms *
1226 yy_create_repair_terms(yy_repairs *reps<%= output.user_formals %>)
1227 {
1228  yy_repairs *r = reps;
1229  yy_repair_terms *rep_terms;
1230  int count = 0;
1231 
1232  while (r->prev_repair)
1233  {
1234  count++;
1235  r = r->prev_repair;
1236  }
1237 
1238  rep_terms = (yy_repair_terms *) YYMALLOC (sizeof (yy_repair_terms) + sizeof (yy_term) * count);
1239  rep_terms->id = reps->id;
1240  rep_terms->length = count;
1241 
1242  r = reps;
1243  while (r->prev_repair)
1244  {
1245  rep_terms->terms[count-1].kind = r->repair.term;
1246  count--;
1247  r = r->prev_repair;
1248  }
1249 
1250  return rep_terms;
1251 }
1252 
1253 static void
1254 yy_print_repairs(yy_repairs *reps<%= output.user_formals %>)
1255 {
1256  yy_repairs *r = reps;
1257 
1258  YYDPRINTF ((stderr,
1259  "id: %d, repair_length: %d, repair_state: %d, prev_repair_id: %d\n",
1260  reps->id, reps->repair_length, *reps->state, reps->prev_repair->id));
1261 
1262  while (r->prev_repair)
1263  {
1264  YYDPRINTF ((stderr, "%s ", yysymbol_name (r->repair.term)));
1265  r = r->prev_repair;
1266  }
1267 
1268  YYDPRINTF ((stderr, "\n"));
1269 }
1270 
1271 static void
1272 yy_print_repair_terms(yy_repair_terms *rep_terms<%= output.user_formals %>)
1273 {
1274  for (int i = 0; i < rep_terms->length; i++)
1275  YYDPRINTF ((stderr, "%s ", yysymbol_name (rep_terms->terms[i].kind)));
1276 
1277  YYDPRINTF ((stderr, "\n"));
1278 }
1279 
1280 static void
1281 yy_free_repairs(yy_repairs *reps<%= output.user_formals %>)
1282 {
1283  while (reps)
1284  {
1285  yy_repairs *r = reps;
1286  reps = reps->next;
1287  YYFREE (r->states);
1288  YYFREE (r);
1289  }
1290 }
1291 
1292 static int
1293 yy_process_repairs(yy_repairs *reps, yysymbol_kind_t token)
1294 {
1295  int yyn;
1296  int yystate = *reps->state;
1297  int yylen = 0;
1298  yysymbol_kind_t yytoken = token;
1299 
1300  goto yyrecover_backup;
1301 
1302 yyrecover_newstate:
1303  // TODO: check reps->stack_length
1304  reps->state += 1;
1305  *reps->state = (yy_state_t) yystate;
1306 
1307 
1308 yyrecover_backup:
1309  yyn = yypact[yystate];
1310  if (yypact_value_is_default (yyn))
1311  goto yyrecover_default;
1312 
1313  /* "Reading a token" */
1314  if (yytoken == YYSYMBOL_YYEMPTY)
1315  return 1;
1316 
1317  yyn += yytoken;
1318  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1319  goto yyrecover_default;
1320  yyn = yytable[yyn];
1321  if (yyn <= 0)
1322  {
1323  if (yytable_value_is_error (yyn))
1324  goto yyrecover_errlab;
1325  yyn = -yyn;
1326  goto yyrecover_reduce;
1327  }
1328 
1329  /* shift */
1330  yystate = yyn;
1331  yytoken = YYSYMBOL_YYEMPTY;
1332  goto yyrecover_newstate;
1333 
1334 
1335 yyrecover_default:
1336  yyn = yydefact[yystate];
1337  if (yyn == 0)
1338  goto yyrecover_errlab;
1339  goto yyrecover_reduce;
1340 
1341 
1342 yyrecover_reduce:
1343  yylen = yyr2[yyn];
1344  /* YYPOPSTACK */
1345  reps->state -= yylen;
1346  yylen = 0;
1347 
1348  {
1349  const int yylhs = yyr1[yyn] - YYNTOKENS;
1350  const int yyi = yypgoto[yylhs] + *reps->state;
1351  yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *reps->state
1352  ? yytable[yyi]
1353  : yydefgoto[yylhs]);
1354  }
1355 
1356  goto yyrecover_newstate;
1357 
1358 yyrecover_errlab:
1359  return 0;
1360 }
1361 
1362 static yy_repair_terms *
1363 yyrecover(yy_state_t *yyss, yy_state_t *yyssp, int yychar<%= output.user_formals %>)
1364 {
1365  yysymbol_kind_t yytoken = YYTRANSLATE (yychar);
1366  yy_repair_terms *rep_terms = YY_NULLPTR;
1367  int count = 0;
1368 
1369  yy_repairs *head = (yy_repairs *) YYMALLOC (sizeof (yy_repairs));
1370  yy_repairs *current = head;
1371  yy_repairs *tail = head;
1372  YYPTRDIFF_T stack_length = yyssp - yyss + 1;
1373 
1374  head->id = count;
1375  head->next = 0;
1376  head->stack_length = stack_length;
1377  head->states = (yy_state_t *) YYMALLOC (sizeof (yy_state_t) * (stack_length));
1378  head->state = head->states + (yyssp - yyss);
1379  YYCOPY (head->states, yyss, stack_length);
1380  head->repair_length = 0;
1381  head->prev_repair = 0;
1382 
1383  stack_length = (stack_length * 2 > 100) ? (stack_length * 2) : 100;
1384  count++;
1385 
1386  while (current)
1387  {
1388  int yystate = *current->state;
1389  int yyn = yypact[yystate];
1390  /* See also: yypcontext_expected_tokens */
1391  if (!yypact_value_is_default (yyn))
1392  {
1393  int yyxbegin = yyn < 0 ? -yyn : 0;
1394  int yychecklim = YYLAST - yyn + 1;
1395  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1396  int yyx;
1397  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1398  {
1399  if (yyx != YYSYMBOL_YYerror)
1400  {
1401  if (current->repair_length + 1 > YYMAXREPAIR(<%= output.parse_param_name %>))
1402  continue;
1403 
1404  yy_repairs *reps = (yy_repairs *) YYMALLOC (sizeof (yy_repairs));
1405  reps->id = count;
1406  reps->next = 0;
1407  reps->stack_length = stack_length;
1408  reps->states = (yy_state_t *) YYMALLOC (sizeof (yy_state_t) * (stack_length));
1409  reps->state = reps->states + (current->state - current->states);
1410  YYCOPY (reps->states, current->states, current->state - current->states + 1);
1411  reps->repair_length = current->repair_length + 1;
1412  reps->prev_repair = current;
1413  reps->repair.type = inserting;
1414  reps->repair.term = (yysymbol_kind_t) yyx;
1415 
1416  /* Process PDA assuming next token is yyx */
1417  if (! yy_process_repairs (reps, (yysymbol_kind_t)yyx))
1418  {
1419  YYFREE (reps);
1420  continue;
1421  }
1422 
1423  tail->next = reps;
1424  tail = reps;
1425  count++;
1426 
1427  if (yyx == yytoken)
1428  {
1429  rep_terms = yy_create_repair_terms (current<%= output.user_args %>);
1430  YYDPRINTF ((stderr, "repair_terms found. id: %d, length: %d\n", rep_terms->id, rep_terms->length));
1431  yy_print_repairs (current<%= output.user_args %>);
1432  yy_print_repair_terms (rep_terms<%= output.user_args %>);
1433 
1434  goto done;
1435  }
1436 
1437  YYDPRINTF ((stderr,
1438  "New repairs is enqueued. count: %d, yystate: %d, yyx: %d\n",
1439  count, yystate, yyx));
1440  yy_print_repairs (reps<%= output.user_args %>);
1441  }
1442  }
1443  }
1444 
1445  current = current->next;
1446  }
1447 
1448 done:
1449 
1450  yy_free_repairs(head<%= output.user_args %>);
1451 
1452  if (!rep_terms)
1453  {
1454  YYDPRINTF ((stderr, "repair_terms not found\n"));
1455  }
1456 
1457  return rep_terms;
1458 }
1459 <%- end -%>
1460 
1461 
1462 
1463 /*----------.
1464 | yyparse. |
1465 `----------*/
1466 
1467 int
1468 yyparse (<%= output.parse_param %>)
1469 {
1470 <%# b4_declare_scanner_communication_variables -%>
1471 /* Lookahead token kind. */
1472 int yychar;
1473 
1474 
1475 /* The semantic value of the lookahead symbol. */
1476 /* Default value used for initialization, for pacifying older GCCs
1477  or non-GCC compilers. */
1478 #ifdef __cplusplus
1479 static const YYSTYPE yyval_default = {};
1480 (void) yyval_default;
1481 #else
1482 YY_INITIAL_VALUE (static const YYSTYPE yyval_default;)
1483 #endif
1484 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1485 
1486 /* Location data for the lookahead symbol. */
1487 static const YYLTYPE yyloc_default
1488 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1489  = { 1, 1, 1, 1 }
1490 # endif
1491 ;
1492 YYLTYPE yylloc = yyloc_default;
1493 
1494 <%# b4_declare_parser_state_variables -%>
1495  /* Number of syntax errors so far. */
1496  int yynerrs = 0;
1497  YY_USE (yynerrs); /* Silence compiler warning. */
1498 
1499  yy_state_fast_t yystate = 0;
1500  /* Number of tokens to shift before error messages enabled. */
1501  int yyerrstatus = 0;
1502 
1503  /* Refer to the stacks through separate pointers, to allow yyoverflow
1504  to reallocate them elsewhere. */
1505 
1506  /* Their size. */
1507  YYPTRDIFF_T yystacksize = YYINITDEPTH;
1508 
1509  /* The state stack: array, bottom, top. */
1510  yy_state_t yyssa[YYINITDEPTH];
1511  yy_state_t *yyss = yyssa;
1512  yy_state_t *yyssp = yyss;
1513 
1514  /* The semantic value stack: array, bottom, top. */
1515  YYSTYPE yyvsa[YYINITDEPTH];
1516  YYSTYPE *yyvs = yyvsa;
1517  YYSTYPE *yyvsp = yyvs;
1518 
1519  /* The location stack: array, bottom, top. */
1520  YYLTYPE yylsa[YYINITDEPTH];
1521  YYLTYPE *yyls = yylsa;
1522  YYLTYPE *yylsp = yyls;
1523 
1524  int yyn;
1525  /* The return value of yyparse. */
1526  int yyresult;
1527  /* Lookahead symbol kind. */
1528  yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1529  /* The variables used to return semantic value and location from the
1530  action routines. */
1531  YYSTYPE yyval;
1532  YYLTYPE yyloc;
1533 
1534  /* The locations where the error started and ended. */
1535  YYLTYPE yyerror_range[3];
1536 <%- if output.error_recovery -%>
1537  yy_repair_terms *rep_terms = 0;
1538  yy_term term_backup;
1539  int rep_terms_index;
1540  int yychar_backup;
1541 <%- end -%>
1542 
1543  /* Buffer for error messages, and its allocated size. */
1544  char yymsgbuf[128];
1545  char *yymsg = yymsgbuf;
1546  YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
1547 
1548 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1549 
1550  /* The number of symbols on the RHS of the reduced rule.
1551  Keep to zero when no symbol should be popped. */
1552  int yylen = 0;
1553 
1554  YYDPRINTF ((stderr, "Starting parse\n"));
1555 
1556  yychar = YYEMPTY; /* Cause a token to be read. */
1557 
1558 
1559 <%# b4_user_initial_action -%>
1560 <%= output.user_initial_action("/* User initialization code. */") %>
1561 #line [@oline@] [@ofile@]
1562 
1563  yylsp[0] = yylloc;
1564  goto yysetstate;
1565 
1566 
1567 /*------------------------------------------------------------.
1568 | yynewstate -- push a new state, which is found in yystate. |
1569 `------------------------------------------------------------*/
1570 yynewstate:
1571  /* In all cases, when you get here, the value and location stacks
1572  have just been pushed. So pushing a state here evens the stacks. */
1573  yyssp++;
1574 
1575 
1576 /*--------------------------------------------------------------------.
1577 | yysetstate -- set current state (the top of the stack) to yystate. |
1578 `--------------------------------------------------------------------*/
1579 yysetstate:
1580  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1581  YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1582  YY_IGNORE_USELESS_CAST_BEGIN
1583  *yyssp = YY_CAST (yy_state_t, yystate);
1584  YY_IGNORE_USELESS_CAST_END
1585  YY_STACK_PRINT (yyss, yyssp<%= output.user_args %>);
1586 
1587  if (yyss + yystacksize - 1 <= yyssp)
1588 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1589  YYNOMEM;
1590 #else
1591  {
1592  /* Get the current used size of the three stacks, in elements. */
1593  YYPTRDIFF_T yysize = yyssp - yyss + 1;
1594 
1595 # if defined yyoverflow
1596  {
1597  /* Give user a chance to reallocate the stack. Use copies of
1598  these so that the &'s don't force the real ones into
1599  memory. */
1600  yy_state_t *yyss1 = yyss;
1601  YYSTYPE *yyvs1 = yyvs;
1602  YYLTYPE *yyls1 = yyls;
1603 
1604  /* Each stack pointer address is followed by the size of the
1605  data in use in that stack, in bytes. This used to be a
1606  conditional around just the two extra args, but that might
1607  be undefined if yyoverflow is a macro. */
1608  yyoverflow (YY_("memory exhausted"),
1609  &yyss1, yysize * YYSIZEOF (*yyssp),
1610  &yyvs1, yysize * YYSIZEOF (*yyvsp),
1611  &yyls1, yysize * YYSIZEOF (*yylsp),
1612  &yystacksize);
1613  yyss = yyss1;
1614  yyvs = yyvs1;
1615  yyls = yyls1;
1616  }
1617 # else /* defined YYSTACK_RELOCATE */
1618  /* Extend the stack our own way. */
1619  if (YYMAXDEPTH <= yystacksize)
1620  YYNOMEM;
1621  yystacksize *= 2;
1622  if (YYMAXDEPTH < yystacksize)
1623  yystacksize = YYMAXDEPTH;
1624 
1625  {
1626  yy_state_t *yyss1 = yyss;
1627  union yyalloc *yyptr =
1628  YY_CAST (union yyalloc *,
1629  YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1630  if (! yyptr)
1631  YYNOMEM;
1632  YYSTACK_RELOCATE (yyss_alloc, yyss);
1633  YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1634  YYSTACK_RELOCATE (yyls_alloc, yyls);
1635 # undef YYSTACK_RELOCATE
1636  if (yyss1 != yyssa)
1637  YYSTACK_FREE (yyss1);
1638  }
1639 # endif
1640 
1641  yyssp = yyss + yysize - 1;
1642  yyvsp = yyvs + yysize - 1;
1643  yylsp = yyls + yysize - 1;
1644 
1645  YY_IGNORE_USELESS_CAST_BEGIN
1646  YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1647  YY_CAST (long, yystacksize)));
1648  YY_IGNORE_USELESS_CAST_END
1649 
1650  if (yyss + yystacksize - 1 <= yyssp)
1651  YYABORT;
1652  }
1653 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1654 
1655 
1656  if (yystate == YYFINAL)
1657  YYACCEPT;
1658 
1659  goto yybackup;
1660 
1661 
1662 /*-----------.
1663 | yybackup. |
1664 `-----------*/
1665 yybackup:
1666  /* Do appropriate processing given the current state. Read a
1667  lookahead token if we need one and don't already have one. */
1668 
1669  /* First try to decide what to do without reference to lookahead token. */
1670  yyn = yypact[yystate];
1671  if (yypact_value_is_default (yyn))
1672  goto yydefault;
1673 
1674  /* Not known => get a lookahead token if don't already have one. */
1675 
1676 <%- if output.error_recovery -%>
1677  if (YYERROR_RECOVERY_ENABLED(<%= output.parse_param_name %>))
1678  {
1679  if (yychar == YYEMPTY && rep_terms)
1680  {
1681 
1682  if (rep_terms_index < rep_terms->length)
1683  {
1684  YYDPRINTF ((stderr, "An error recovery token is used\n"));
1685  yy_term term = rep_terms->terms[rep_terms_index];
1686  yytoken = term.kind;
1687  yylval = term.value;
1688  yylloc = term.location;
1689  yychar = yytranslate_inverted[yytoken];
1690  YY_SYMBOL_PRINT ("Next error recovery token is", yytoken, &yylval, &yylloc<%= output.user_args %>);
1691  rep_terms_index++;
1692  }
1693  else
1694  {
1695  YYDPRINTF ((stderr, "Error recovery is completed\n"));
1696  yytoken = term_backup.kind;
1697  yylval = term_backup.value;
1698  yylloc = term_backup.location;
1699  yychar = yychar_backup;
1700  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc<%= output.user_args %>);
1701 
1702  YYFREE (rep_terms);
1703  rep_terms = 0;
1704  yychar_backup = 0;
1705  }
1706  }
1707  }
1708 <%- end -%>
1709  /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1710  if (yychar == YYEMPTY)
1711  {
1712  YYDPRINTF ((stderr, "Reading a token\n"));
1713  yychar = yylex <%= output.yylex_formals %>;
1714  }
1715 
1716  if (yychar <= <%= output.eof_symbol.id.s_value %>)
1717  {
1718  yychar = <%= output.eof_symbol.id.s_value %>;
1719  yytoken = <%= output.eof_symbol.enum_name %>;
1720  YYDPRINTF ((stderr, "Now at end of input.\n"));
1721  }
1722  else if (yychar == <%= output.error_symbol.id.s_value %>)
1723  {
1724  /* The scanner already issued an error message, process directly
1725  to error recovery. But do not keep the error token as
1726  lookahead, it is too special and may lead us to an endless
1727  loop in error recovery. */
1728  yychar = <%= output.undef_symbol.id.s_value %>;
1729  yytoken = <%= output.error_symbol.enum_name %>;
1730  yyerror_range[1] = yylloc;
1731  goto yyerrlab1;
1732  }
1733  else
1734  {
1735  yytoken = YYTRANSLATE (yychar);
1736  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc<%= output.user_args %>);
1737  }
1738 
1739  /* If the proper action on seeing token YYTOKEN is to reduce or to
1740  detect an error, take that action. */
1741  yyn += yytoken;
1742  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1743  goto yydefault;
1744  yyn = yytable[yyn];
1745  if (yyn <= 0)
1746  {
1747  if (yytable_value_is_error (yyn))
1748  goto yyerrlab;
1749  yyn = -yyn;
1750  goto yyreduce;
1751  }
1752 
1753  /* Count tokens shifted since error; after three, turn off error
1754  status. */
1755  if (yyerrstatus)
1756  yyerrstatus--;
1757 
1758  /* Shift the lookahead token. */
1759  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc<%= output.user_args %>);
1760  yystate = yyn;
1761  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1762  *++yyvsp = yylval;
1763  YY_IGNORE_MAYBE_UNINITIALIZED_END
1764  *++yylsp = yylloc;
1765 <%= output.after_shift_function("/* %after-shift code. */") %>
1766 
1767  /* Discard the shifted token. */
1768  yychar = YYEMPTY;
1769  goto yynewstate;
1770 
1771 
1772 /*-----------------------------------------------------------.
1773 | yydefault -- do the default action for the current state. |
1774 `-----------------------------------------------------------*/
1775 yydefault:
1776  yyn = yydefact[yystate];
1777  if (yyn == 0)
1778  goto yyerrlab;
1779  goto yyreduce;
1780 
1781 
1782 /*-----------------------------.
1783 | yyreduce -- do a reduction. |
1784 `-----------------------------*/
1785 yyreduce:
1786  /* yyn is the number of a rule to reduce with. */
1787  yylen = yyr2[yyn];
1788 
1789  /* If YYLEN is nonzero, implement the default value of the action:
1790  '$$ = $1'.
1791 
1792  Otherwise, the following line sets YYVAL to garbage.
1793  This behavior is undocumented and Bison
1794  users should not rely upon it. Assigning to YYVAL
1795  unconditionally makes the parser a bit smaller, and it avoids a
1796  GCC warning that YYVAL may be used uninitialized. */
1797  yyval = yyvsp[1-yylen];
1798 <%= output.before_reduce_function("/* %before-reduce function. */") %>
1799 
1800  /* Default location. */
1801  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1802  yyerror_range[1] = yyloc;
1803  YY_REDUCE_PRINT (yyn<%= output.user_args %>);
1804  switch (yyn)
1805  {
1806 <%= output.user_actions -%>
1807 
1808  default: break;
1809  }
1810  /* User semantic actions sometimes alter yychar, and that requires
1811  that yytoken be updated with the new translation. We take the
1812  approach of translating immediately before every use of yytoken.
1813  One alternative is translating here after every semantic action,
1814  but that translation would be missed if the semantic action invokes
1815  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1816  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1817  incorrect destructor might then be invoked immediately. In the
1818  case of YYERROR or YYBACKUP, subsequent parser actions might lead
1819  to an incorrect destructor call or verbose syntax error message
1820  before the lookahead is translated. */
1821  YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc<%= output.user_args %>);
1822 
1823  YYPOPSTACK (yylen);
1824 <%= output.after_reduce_function("/* %after-reduce function. */") %>
1825  yylen = 0;
1826 
1827  *++yyvsp = yyval;
1828  *++yylsp = yyloc;
1829 
1830  /* Now 'shift' the result of the reduction. Determine what state
1831  that goes to, based on the state we popped back to and the rule
1832  number reduced by. */
1833  {
1834  const int yylhs = yyr1[yyn] - YYNTOKENS;
1835  const int yyi = yypgoto[yylhs] + *yyssp;
1836  yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1837  ? yytable[yyi]
1838  : yydefgoto[yylhs]);
1839  }
1840 
1841  goto yynewstate;
1842 
1843 
1844 /*--------------------------------------.
1845 | yyerrlab -- here on detecting error. |
1846 `--------------------------------------*/
1847 yyerrlab:
1848  /* Make sure we have latest lookahead translation. See comments at
1849  user semantic actions for why this is necessary. */
1850  yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1851  /* If not already recovering from an error, report this error. */
1852  if (!yyerrstatus)
1853  {
1854  ++yynerrs;
1855  {
1856  yypcontext_t yyctx
1857  = {yyssp, yytoken, &yylloc};
1858  char const *yymsgp = YY_("syntax error");
1859  int yysyntax_error_status;
1860  yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx<%= output.user_args %>);
1861  if (yysyntax_error_status == 0)
1862  yymsgp = yymsg;
1863  else if (yysyntax_error_status == -1)
1864  {
1865  if (yymsg != yymsgbuf)
1866  YYSTACK_FREE (yymsg);
1867  yymsg = YY_CAST (char *,
1868  YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
1869  if (yymsg)
1870  {
1871  yysyntax_error_status
1872  = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx<%= output.user_args %>);
1873  yymsgp = yymsg;
1874  }
1875  else
1876  {
1877  yymsg = yymsgbuf;
1878  yymsg_alloc = sizeof yymsgbuf;
1879  yysyntax_error_status = YYENOMEM;
1880  }
1881  }
1882  yyerror (<%= output.yyerror_args %>, yymsgp);
1883  if (yysyntax_error_status == YYENOMEM)
1884  YYNOMEM;
1885  }
1886  }
1887 
1888  yyerror_range[1] = yylloc;
1889  if (yyerrstatus == 3)
1890  {
1891  /* If just tried and failed to reuse lookahead token after an
1892  error, discard it. */
1893 
1894  if (yychar <= <%= output.eof_symbol.id.s_value %>)
1895  {
1896  /* Return failure if at end of input. */
1897  if (yychar == <%= output.eof_symbol.id.s_value %>)
1898  YYABORT;
1899  }
1900  else
1901  {
1902  yydestruct ("Error: discarding",
1903  yytoken, &yylval, &yylloc<%= output.user_args %>);
1904  yychar = YYEMPTY;
1905  }
1906  }
1907 
1908  /* Else will try to reuse lookahead token after shifting the error
1909  token. */
1910  goto yyerrlab1;
1911 
1912 
1913 /*---------------------------------------------------.
1914 | yyerrorlab -- error raised explicitly by YYERROR. |
1915 `---------------------------------------------------*/
1916 yyerrorlab:
1917  /* Pacify compilers when the user code never invokes YYERROR and the
1918  label yyerrorlab therefore never appears in user code. */
1919  if (0)
1920  YYERROR;
1921  ++yynerrs;
1922 
1923  /* Do not reclaim the symbols of the rule whose action triggered
1924  this YYERROR. */
1925  YYPOPSTACK (yylen);
1926 <%= output.after_pop_stack_function("yylen", "/* %after-pop-stack function. */") %>
1927  yylen = 0;
1928  YY_STACK_PRINT (yyss, yyssp<%= output.user_args %>);
1929  yystate = *yyssp;
1930  goto yyerrlab1;
1931 
1932 
1933 /*-------------------------------------------------------------.
1934 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1935 `-------------------------------------------------------------*/
1936 yyerrlab1:
1937 <%- if output.error_recovery -%>
1938  if (YYERROR_RECOVERY_ENABLED(<%= output.parse_param_name %>))
1939  {
1940  rep_terms = yyrecover (yyss, yyssp, yychar<%= output.user_args %>);
1941  if (rep_terms)
1942  {
1943  for (int i = 0; i < rep_terms->length; i++)
1944  {
1945  yy_term *term = &rep_terms->terms[i];
1946  yy_error_token_initialize (term->kind, &term->value, &term->location<%= output.user_args %>);
1947  }
1948 
1949  yychar_backup = yychar;
1950  /* Can be packed into (the tail of) rep_terms? */
1951  term_backup.kind = yytoken;
1952  term_backup.value = yylval;
1953  term_backup.location = yylloc;
1954  rep_terms_index = 0;
1955  yychar = YYEMPTY;
1956 
1957  goto yybackup;
1958  }
1959  }
1960 <%- end -%>
1961  yyerrstatus = 3; /* Each real token shifted decrements this. */
1962 
1963  /* Pop stack until we find a state that shifts the error token. */
1964  for (;;)
1965  {
1966  yyn = yypact[yystate];
1967  if (!yypact_value_is_default (yyn))
1968  {
1969  yyn += YYSYMBOL_YYerror;
1970  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1971  {
1972  yyn = yytable[yyn];
1973  if (0 < yyn)
1974  break;
1975  }
1976  }
1977 
1978  /* Pop the current state because it cannot handle the error token. */
1979  if (yyssp == yyss)
1980  YYABORT;
1981 
1982  yyerror_range[1] = *yylsp;
1983  yydestruct ("Error: popping",
1984  YY_ACCESSING_SYMBOL (yystate), yyvsp, yylsp<%= output.user_args %>);
1985  YYPOPSTACK (1);
1986 <%= output.after_pop_stack_function(1, "/* %after-pop-stack function. */") %>
1987  yystate = *yyssp;
1988  YY_STACK_PRINT (yyss, yyssp<%= output.user_args %>);
1989  }
1990 
1991  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1992  *++yyvsp = yylval;
1993  YY_IGNORE_MAYBE_UNINITIALIZED_END
1994 
1995  yyerror_range[2] = yylloc;
1996  ++yylsp;
1997  YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);
1998 
1999  /* Shift the error token. */
2000  YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp<%= output.user_args %>);
2001 <%= output.after_shift_error_token_function("/* %after-shift-error-token code. */") %>
2002 
2003  yystate = yyn;
2004  goto yynewstate;
2005 
2006 
2007 /*-------------------------------------.
2008 | yyacceptlab -- YYACCEPT comes here. |
2009 `-------------------------------------*/
2010 yyacceptlab:
2011  yyresult = 0;
2012  goto yyreturnlab;
2013 
2014 
2015 /*-----------------------------------.
2016 | yyabortlab -- YYABORT comes here. |
2017 `-----------------------------------*/
2018 yyabortlab:
2019  yyresult = 1;
2020  goto yyreturnlab;
2021 
2022 
2023 /*-----------------------------------------------------------.
2024 | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
2025 `-----------------------------------------------------------*/
2026 yyexhaustedlab:
2027  yyerror (<%= output.yyerror_args %>, YY_("memory exhausted"));
2028  yyresult = 2;
2029  goto yyreturnlab;
2030 
2031 
2032 /*----------------------------------------------------------.
2033 | yyreturnlab -- parsing is finished, clean up and return. |
2034 `----------------------------------------------------------*/
2035 yyreturnlab:
2036  if (yychar != YYEMPTY)
2037  {
2038  /* Make sure we have latest lookahead translation. See comments at
2039  user semantic actions for why this is necessary. */
2040  yytoken = YYTRANSLATE (yychar);
2041  yydestruct ("Cleanup: discarding lookahead",
2042  yytoken, &yylval, &yylloc<%= output.user_args %>);
2043  }
2044  /* Do not reclaim the symbols of the rule whose action triggered
2045  this YYABORT or YYACCEPT. */
2046  YYPOPSTACK (yylen);
2047  YY_STACK_PRINT (yyss, yyssp<%= output.user_args %>);
2048  while (yyssp != yyss)
2049  {
2050  yydestruct ("Cleanup: popping",
2051  YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, yylsp<%= output.user_args %>);
2052  YYPOPSTACK (1);
2053  }
2054 #ifndef yyoverflow
2055  if (yyss != yyssa)
2056  YYSTACK_FREE (yyss);
2057 #endif
2058  if (yymsg != yymsgbuf)
2059  YYSTACK_FREE (yymsg);
2060  return yyresult;
2061 }
2062 
2063 <%# b4_percent_code_get([[epilogue]]) -%>
2064 <%- if output.aux.epilogue -%>
2065 #line <%= output.aux.epilogue_first_lineno - 1 %> "<%= output.grammar_file_path %>"
2066 <%= output.aux.epilogue -%>
2067 <%- end -%>
2068 
Definition: parse.h:226
Definition: yacc.c:1198
Definition: parse.h:192