yacc: fix push parser
[bison.git] / data / skeletons / yacc.c
blobafdb50856572f7e806c8ab02d9b7d6f4e12872fc
1 # -*- C -*-
2 # Yacc compatible skeleton for Bison
4 # Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software
5 # Foundation, Inc.
7 m4_pushdef([b4_copyright_years],
8 [1984, 1989-1990, 2000-2015, 2018-2021])
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.
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.
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/>.
23 m4_include(b4_skeletonsdir/[c.m4])
25 ## ---------- ##
26 ## api.pure. ##
27 ## ---------- ##
29 b4_percent_define_default([[api.pure]], [[false]])
30 b4_percent_define_check_values([[[[api.pure]],
31 [[false]], [[true]], [[]], [[full]]]])
33 m4_define([b4_pure_flag], [[0]])
34 m4_case(b4_percent_define_get([[api.pure]]),
35 [false], [m4_define([b4_pure_flag], [[0]])],
36 [true], [m4_define([b4_pure_flag], [[1]])],
37 [], [m4_define([b4_pure_flag], [[1]])],
38 [full], [m4_define([b4_pure_flag], [[2]])])
40 m4_define([b4_pure_if],
41 [m4_case(b4_pure_flag,
42 [0], [$2],
43 [1], [$1],
44 [2], [$1])])
45 [m4_fatal([invalid api.pure value: ]$1)])])
47 ## --------------- ##
48 ## api.push-pull. ##
49 ## --------------- ##
51 # b4_pull_if, b4_push_if
52 # ----------------------
53 # Whether the pull/push APIs are needed. Both can be enabled.
55 b4_percent_define_default([[api.push-pull]], [[pull]])
56 b4_percent_define_check_values([[[[api.push-pull]],
57 [[pull]], [[push]], [[both]]]])
58 b4_define_flag_if([pull]) m4_define([b4_pull_flag], [[1]])
59 b4_define_flag_if([push]) m4_define([b4_push_flag], [[1]])
60 m4_case(b4_percent_define_get([[api.push-pull]]),
61 [pull], [m4_define([b4_push_flag], [[0]])],
62 [push], [m4_define([b4_pull_flag], [[0]])])
64 # Handle BISON_USE_PUSH_FOR_PULL for the test suite. So that push parsing
65 # tests function as written, do not let BISON_USE_PUSH_FOR_PULL modify the
66 # behavior of Bison at all when push parsing is already requested.
67 b4_define_flag_if([use_push_for_pull])
68 b4_use_push_for_pull_if([
69 b4_push_if([m4_define([b4_use_push_for_pull_flag], [[0]])],
70 [m4_define([b4_push_flag], [[1]])])])
72 ## ----------- ##
73 ## parse.lac. ##
74 ## ----------- ##
76 b4_percent_define_default([[parse.lac]], [[none]])
77 b4_percent_define_default([[parse.lac.es-capacity-initial]], [[20]])
78 b4_percent_define_default([[parse.lac.memory-trace]], [[failures]])
79 b4_percent_define_check_values([[[[parse.lac]], [[full]], [[none]]]],
80 [[[[parse.lac.memory-trace]],
81 [[failures]], [[full]]]])
82 b4_define_flag_if([lac])
83 m4_define([b4_lac_flag],
84 [m4_if(b4_percent_define_get([[parse.lac]]),
85 [none], [[0]], [[1]])])
87 ## ---------------- ##
88 ## Default values. ##
89 ## ---------------- ##
91 # Stack parameters.
92 m4_define_default([b4_stack_depth_max], [10000])
93 m4_define_default([b4_stack_depth_init], [200])
96 # b4_yyerror_arg_loc_if(ARG)
97 # --------------------------
98 # Expand ARG iff yyerror is to be given a location as argument.
99 m4_define([b4_yyerror_arg_loc_if],
100 [b4_locations_if([m4_case(b4_pure_flag,
101 [1], [m4_ifset([b4_parse_param], [$1])],
102 [2], [$1])])])
104 # b4_yyerror_args
105 # ---------------
106 # Arguments passed to yyerror: user args plus yylloc.
107 m4_define([b4_yyerror_args],
108 [b4_yyerror_arg_loc_if([&yylloc, ])dnl
109 m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])])
113 ## ----------------- ##
114 ## Semantic Values. ##
115 ## ----------------- ##
118 # b4_lhs_value(SYMBOL-NUM, [TYPE])
119 # --------------------------------
120 # See README.
121 m4_define([b4_lhs_value],
122 [b4_symbol_value(yyval, [$1], [$2])])
125 # b4_rhs_value(RULE-LENGTH, POS, [SYMBOL-NUM], [TYPE])
126 # ----------------------------------------------------
127 # See README.
128 m4_define([b4_rhs_value],
129 [b4_symbol_value([yyvsp@{b4_subtract([$2], [$1])@}], [$3], [$4])])
132 ## ----------- ##
133 ## Locations. ##
134 ## ----------- ##
136 # b4_lhs_location()
137 # -----------------
138 # Expansion of @$.
139 # Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar".
140 m4_define([b4_lhs_location],
141 [(yyloc)])
144 # b4_rhs_location(RULE-LENGTH, POS)
145 # ---------------------------------
146 # Expansion of @POS, where the current rule has RULE-LENGTH symbols
147 # on RHS.
148 # Overparenthetized to avoid obscure problems with "foo$$bar = foo$1bar".
149 m4_define([b4_rhs_location],
150 [(yylsp@{b4_subtract([$2], [$1])@})])
153 ## -------------- ##
154 ## Declarations. ##
155 ## -------------- ##
157 # b4_declare_scanner_communication_variables
158 # ------------------------------------------
159 # Declare the variables that are global, or local to YYPARSE if
160 # pure-parser.
161 m4_define([b4_declare_scanner_communication_variables], [[
162 /* Lookahead token kind. */
163 int yychar;
165 ]b4_pure_if([[
166 /* The semantic value of the lookahead symbol. */
167 /* Default value used for initialization, for pacifying older GCCs
168 or non-GCC compilers. */
169 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
170 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);]b4_locations_if([[
172 /* Location data for the lookahead symbol. */
173 static YYLTYPE yyloc_default]b4_yyloc_default[;
174 YYLTYPE yylloc = yyloc_default;]])],
175 [[/* The semantic value of the lookahead symbol. */
176 YYSTYPE yylval;]b4_locations_if([[
177 /* Location data for the lookahead symbol. */
178 YYLTYPE yylloc]b4_yyloc_default[;]])[
179 /* Number of syntax errors so far. */
180 int yynerrs;]])])
183 # b4_declare_parser_state_variables([INIT])
184 # -----------------------------------------
185 # Declare all the variables that are needed to maintain the parser state
186 # between calls to yypush_parse.
187 # If INIT is non-null, initialize these variables.
188 m4_define([b4_declare_parser_state_variables],
189 [b4_pure_if([[
190 /* Number of syntax errors so far. */
191 int yynerrs]m4_ifval([$1], [ = 0])[;
192 ]])[
193 yy_state_fast_t yystate]m4_ifval([$1], [ = 0])[;
194 /* Number of tokens to shift before error messages enabled. */
195 int yyerrstatus]m4_ifval([$1], [ = 0])[;
197 /* Refer to the stacks through separate pointers, to allow yyoverflow
198 to reallocate them elsewhere. */
200 /* Their size. */
201 YYPTRDIFF_T yystacksize]m4_ifval([$1], [ = YYINITDEPTH])[;
203 /* The state stack: array, bottom, top. */
204 yy_state_t yyssa[YYINITDEPTH];
205 yy_state_t *yyss]m4_ifval([$1], [ = yyssa])[;
206 yy_state_t *yyssp]m4_ifval([$1], [ = yyss])[;
208 /* The semantic value stack: array, bottom, top. */
209 YYSTYPE yyvsa[YYINITDEPTH];
210 YYSTYPE *yyvs]m4_ifval([$1], [ = yyvsa])[;
211 YYSTYPE *yyvsp]m4_ifval([$1], [ = yyvs])[;]b4_locations_if([[
213 /* The location stack: array, bottom, top. */
214 YYLTYPE yylsa[YYINITDEPTH];
215 YYLTYPE *yyls]m4_ifval([$1], [ = yylsa])[;
216 YYLTYPE *yylsp]m4_ifval([$1], [ = yyls])[;]])[]b4_lac_if([[
218 yy_state_t yyesa@{]b4_percent_define_get([[parse.lac.es-capacity-initial]])[@};
219 yy_state_t *yyes]m4_ifval([$1], [ = yyesa])[;
220 YYPTRDIFF_T yyes_capacity][]m4_ifval([$1],
221 [m4_do([ = b4_percent_define_get([[parse.lac.es-capacity-initial]]) < YYMAXDEPTH],
222 [ ? b4_percent_define_get([[parse.lac.es-capacity-initial]])],
223 [ : YYMAXDEPTH])])[;]])])
226 m4_define([b4_macro_define],
227 [[#]define $1 $2])
229 m4_define([b4_macro_undef],
230 [[#]undef $1])
232 m4_define([b4_pstate_macro_define],
233 [b4_macro_define([$1], [yyps->$1])])
235 # b4_parse_state_variable_macros(b4_macro_define|b4_macro_undef)
236 # --------------------------------------------------------------
237 m4_define([b4_parse_state_variable_macros],
238 [b4_pure_if([$1([b4_prefix[]nerrs])])
239 $1([yystate])
240 $1([yyerrstatus])
241 $1([yyssa])
242 $1([yyss])
243 $1([yyssp])
244 $1([yyvsa])
245 $1([yyvs])
246 $1([yyvsp])[]b4_locations_if([
247 $1([yylsa])
248 $1([yyls])
249 $1([yylsp])])
250 $1([yystacksize])[]b4_lac_if([
251 $1([yyesa])
252 $1([yyes])
253 $1([yyes_capacity])])])
258 # _b4_declare_yyparse_push
259 # ------------------------
260 # Declaration of yyparse (and dependencies) when using the push parser
261 # (including in pull mode).
262 m4_define([_b4_declare_yyparse_push],
263 [[#ifndef YYPUSH_MORE_DEFINED
264 # define YYPUSH_MORE_DEFINED
265 enum { YYPUSH_MORE = 4 };
266 #endif
268 typedef struct ]b4_prefix[pstate ]b4_prefix[pstate;
270 ]b4_pull_if([[
271 int ]b4_prefix[parse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[);]])[
272 int ]b4_prefix[push_parse (]b4_prefix[pstate *ps]b4_pure_if([[,
273 int pushed_char, ]b4_api_PREFIX[STYPE const *pushed_val]b4_locations_if([[, ]b4_api_PREFIX[LTYPE *pushed_loc]])])b4_user_formals[);
274 ]b4_pull_if([[int ]b4_prefix[pull_parse (]b4_prefix[pstate *ps]b4_user_formals[);]])[
275 ]b4_prefix[pstate *]b4_prefix[pstate_new (void);
276 void ]b4_prefix[pstate_delete (]b4_prefix[pstate *ps);
279 # _b4_declare_yyparse
280 # -------------------
281 # When not the push parser.
282 m4_define([_b4_declare_yyparse],
283 [[int ]b4_prefix[parse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[);]])
286 # b4_declare_yyparse
287 # ------------------
288 m4_define([b4_declare_yyparse],
289 [b4_push_if([_b4_declare_yyparse_push],
290 [_b4_declare_yyparse])[]dnl
294 # b4_shared_declarations
295 # ----------------------
296 # Declaration that might either go into the header (if --defines)
297 # or open coded in the parser body.
298 m4_define([b4_shared_declarations],
299 [b4_cpp_guard_open([b4_spec_mapped_header_file])[
300 ]b4_declare_yydebug[
301 ]b4_percent_code_get([[requires]])[
302 ]b4_token_enums_defines[
303 ]b4_declare_yylstype[
304 ]b4_declare_yyparse[
305 ]b4_percent_code_get([[provides]])[
306 ]b4_cpp_guard_close([b4_spec_mapped_header_file])[]dnl
310 # b4_header_include_if(IF-TRUE, IF-FALSE)
311 # ---------------------------------------
312 # Run IF-TRUE if we generate an output file and api.header.include
313 # is defined.
314 m4_define([b4_header_include_if],
315 [m4_ifval(m4_quote(b4_spec_header_file),
316 [b4_percent_define_ifdef([[api.header.include]],
317 [$1],
318 [$2])],
319 [$2])])
321 m4_if(b4_spec_header_file, [y.tab.h], [],
322 [b4_percent_define_default([[api.header.include]],
323 [["@basename(]b4_spec_header_file[@)"]])])
328 ## -------------- ##
329 ## Output files. ##
330 ## -------------- ##
333 b4_defines_if([[
334 ]b4_output_begin([b4_spec_header_file])[
335 ]b4_copyright([Bison interface for Yacc-like parsers in C])[
336 ]b4_disclaimer[
337 ]b4_shared_declarations[
338 ]b4_output_end[
339 ]])# b4_defines_if
341 b4_output_begin([b4_parser_file_name])[
342 ]b4_copyright([Bison implementation for Yacc-like parsers in C])[
343 /* C LALR(1) parser skeleton written by Richard Stallman, by
344 simplifying the original so-called "semantic" parser. */
346 ]b4_disclaimer[
347 /* All symbols defined below should begin with yy or YY, to avoid
348 infringing on user name space. This should be done even for local
349 variables, as they might otherwise be expanded by user macros.
350 There are some unavoidable exceptions within include files to
351 define necessary library symbols; they are noted "INFRINGES ON
352 USER NAME SPACE" below. */
354 ]b4_identification[
355 ]b4_percent_code_get([[top]])[]dnl
356 m4_if(b4_api_prefix, [yy], [],
357 [[/* Substitute the type names. */
358 #define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
359 #define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
360 ]m4_if(b4_prefix, [yy], [],
361 [[/* Substitute the variable and function names. */]b4_pull_if([[
362 #define yyparse ]b4_prefix[parse]])b4_push_if([[
363 #define yypush_parse ]b4_prefix[push_parse]b4_pull_if([[
364 #define yypull_parse ]b4_prefix[pull_parse]])[
365 #define yypstate_new ]b4_prefix[pstate_new
366 #define yypstate_clear ]b4_prefix[pstate_clear
367 #define yypstate_delete ]b4_prefix[pstate_delete
368 #define yypstate ]b4_prefix[pstate]])[
369 #define yylex ]b4_prefix[lex
370 #define yyerror ]b4_prefix[error
371 #define yydebug ]b4_prefix[debug
372 #define yynerrs ]b4_prefix[nerrs]]b4_pure_if([], [[
373 #define yylval ]b4_prefix[lval
374 #define yychar ]b4_prefix[char]b4_locations_if([[
375 #define yylloc ]b4_prefix[lloc]])]))[
377 ]b4_user_pre_prologue[
378 ]b4_cast_define[
379 ]b4_null_define[
381 ]b4_header_include_if([[#include ]b4_percent_define_get([[api.header.include]])],
382 [m4_ifval(m4_quote(b4_spec_header_file),
383 [/* Use api.header.include to #include this header
384 instead of duplicating it here. */
385 ])b4_shared_declarations])[
386 ]b4_declare_symbol_enum[
388 ]b4_user_post_prologue[
389 ]b4_percent_code_get[
390 ]b4_c99_int_type_define[
392 ]b4_sizes_types_define[
394 /* Stored state numbers (used for stacks). */
395 typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ yy_state_t;
397 /* State numbers in computations. */
398 typedef int yy_state_fast_t;
400 #ifndef YY_
401 # if defined YYENABLE_NLS && YYENABLE_NLS
402 # if ENABLE_NLS
403 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
404 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
405 # endif
406 # endif
407 # ifndef YY_
408 # define YY_(Msgid) Msgid
409 # endif
410 #endif
411 ]b4_has_translations_if([
412 #ifndef N_
413 # define N_(Msgid) Msgid
414 #endif
417 ]b4_attribute_define[
419 ]b4_parse_assert_if([[#ifdef NDEBUG
420 # define YY_ASSERT(E) ((void) (0 && (E)))
421 #else
422 # include <assert.h> /* INFRINGES ON USER NAME SPACE */
423 # define YY_ASSERT(E) assert (E)
424 #endif
426 [[#define YY_ASSERT(E) ((void) (0 && (E)))]])[
428 #if ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[
430 /* The parser invokes alloca or malloc; define the necessary symbols. */]dnl
431 b4_push_if([], [b4_lac_if([], [[
433 # ifdef YYSTACK_USE_ALLOCA
434 # if YYSTACK_USE_ALLOCA
435 # ifdef __GNUC__
436 # define YYSTACK_ALLOC __builtin_alloca
437 # elif defined __BUILTIN_VA_ARG_INCR
438 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
439 # elif defined _AIX
440 # define YYSTACK_ALLOC __alloca
441 # elif defined _MSC_VER
442 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
443 # define alloca _alloca
444 # else
445 # define YYSTACK_ALLOC alloca
446 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
447 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
448 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
449 # ifndef EXIT_SUCCESS
450 # define EXIT_SUCCESS 0
451 # endif
452 # endif
453 # endif
454 # endif
455 # endif]])])[
457 # ifdef YYSTACK_ALLOC
458 /* Pacify GCC's 'empty if-body' warning. */
459 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
460 # ifndef YYSTACK_ALLOC_MAXIMUM
461 /* The OS might guarantee only one guard page at the bottom of the stack,
462 and a page size can be as small as 4096 bytes. So we cannot safely
463 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
464 to allow for a few compiler-allocated temporary stack slots. */
465 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
466 # endif
467 # else
468 # define YYSTACK_ALLOC YYMALLOC
469 # define YYSTACK_FREE YYFREE
470 # ifndef YYSTACK_ALLOC_MAXIMUM
471 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
472 # endif
473 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
474 && ! ((defined YYMALLOC || defined malloc) \
475 && (defined YYFREE || defined free)))
476 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
477 # ifndef EXIT_SUCCESS
478 # define EXIT_SUCCESS 0
479 # endif
480 # endif
481 # ifndef YYMALLOC
482 # define YYMALLOC malloc
483 # if ! defined malloc && ! defined EXIT_SUCCESS
484 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
485 # endif
486 # endif
487 # ifndef YYFREE
488 # define YYFREE free
489 # if ! defined free && ! defined EXIT_SUCCESS
490 void free (void *); /* INFRINGES ON USER NAME SPACE */
491 # endif
492 # endif
493 # endif]b4_lac_if([[
494 # define YYCOPY_NEEDED 1]])[
495 #endif /* ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[ */
497 #if (! defined yyoverflow \
498 && (! defined __cplusplus \
499 || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
500 && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL)))
502 /* A type that is properly aligned for any stack member. */
503 union yyalloc
505 yy_state_t yyss_alloc;
506 YYSTYPE yyvs_alloc;]b4_locations_if([
507 YYLTYPE yyls_alloc;])[
510 /* The size of the maximum gap between one aligned stack and the next. */
511 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
513 /* The size of an array large to enough to hold all stacks, each with
514 N elements. */
515 ]b4_locations_if(
516 [# define YYSTACK_BYTES(N) \
517 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \
518 + YYSIZEOF (YYLTYPE)) \
519 + 2 * YYSTACK_GAP_MAXIMUM)],
520 [# define YYSTACK_BYTES(N) \
521 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
522 + YYSTACK_GAP_MAXIMUM)])[
524 # define YYCOPY_NEEDED 1
526 /* Relocate STACK from its old location to the new one. The
527 local variables YYSIZE and YYSTACKSIZE give the old and new number of
528 elements in the stack, and YYPTR gives the new location of the
529 stack. Advance YYPTR to a properly aligned location for the next
530 stack. */
531 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
532 do \
534 YYPTRDIFF_T yynewbytes; \
535 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
536 Stack = &yyptr->Stack_alloc; \
537 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
538 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
540 while (0)
542 #endif
544 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
545 /* Copy COUNT objects from SRC to DST. The source and destination do
546 not overlap. */
547 # ifndef YYCOPY
548 # if defined __GNUC__ && 1 < __GNUC__
549 # define YYCOPY(Dst, Src, Count) \
550 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
551 # else
552 # define YYCOPY(Dst, Src, Count) \
553 do \
555 YYPTRDIFF_T yyi; \
556 for (yyi = 0; yyi < (Count); yyi++) \
557 (Dst)[yyi] = (Src)[yyi]; \
559 while (0)
560 # endif
561 # endif
562 #endif /* !YYCOPY_NEEDED */
564 /* YYFINAL -- State number of the termination state. */
565 #define YYFINAL ]b4_final_state_number[
566 /* YYLAST -- Last index in YYTABLE. */
567 #define YYLAST ]b4_last[
569 /* YYNTOKENS -- Number of terminals. */
570 #define YYNTOKENS ]b4_tokens_number[
571 /* YYNNTS -- Number of nonterminals. */
572 #define YYNNTS ]b4_nterms_number[
573 /* YYNRULES -- Number of rules. */
574 #define YYNRULES ]b4_rules_number[
575 /* YYNSTATES -- Number of states. */
576 #define YYNSTATES ]b4_states_number[
578 /* YYMAXUTOK -- Last valid token kind. */
579 #define YYMAXUTOK ]b4_code_max[
582 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
583 as returned by yylex, with out-of-bounds checking. */
584 ]b4_api_token_raw_if(dnl
585 [[#define YYTRANSLATE(YYX) YY_CAST (yysymbol_kind_t, YYX)]],
586 [[#define YYTRANSLATE(YYX) \
587 (0 <= (YYX) && (YYX) <= YYMAXUTOK \
588 ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
589 : ]b4_symbol_prefix[YYUNDEF)
591 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
592 as returned by yylex. */
593 static const ]b4_int_type_for([b4_translate])[ yytranslate[] =
595 ]b4_translate[
596 };]])[
598 #if ]b4_api_PREFIX[DEBUG
599 ]b4_integral_parser_table_define([rline], [b4_rline],
600 [[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
601 #endif
603 /** Accessing symbol of state STATE. */
604 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
606 #if ]b4_parse_error_case([simple], [b4_api_PREFIX[DEBUG || ]b4_token_table_flag], [[1]])[
607 /* The user-facing name of the symbol whose (internal) number is
608 YYSYMBOL. No bounds checking. */
609 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
611 ]b4_parse_error_bmatch([simple\|verbose],
612 [[/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
613 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
614 static const char *const yytname[] =
616 ]b4_tname[
619 static const char *
620 yysymbol_name (yysymbol_kind_t yysymbol)
622 return yytname[yysymbol];
623 }]],
624 [[static const char *
625 yysymbol_name (yysymbol_kind_t yysymbol)
627 static const char *const yy_sname[] =
629 ]b4_symbol_names[
630 };]b4_has_translations_if([[
631 /* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
632 internationalizable. */
633 static ]b4_int_type_for([b4_translatable])[ yytranslatable[] =
635 ]b4_translatable[
637 return (yysymbol < YYNTOKENS && yytranslatable[yysymbol]
638 ? _(yy_sname[yysymbol])
639 : yy_sname[yysymbol]);]], [[
640 return yy_sname[yysymbol];]])[
641 }]])[
642 #endif
644 #ifdef YYPRINT
645 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
646 (internal) symbol number NUM (which must be that of a token). */
647 static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
649 ]b4_toknum[
651 #endif
653 #define YYPACT_NINF (]b4_pact_ninf[)
655 #define yypact_value_is_default(Yyn) \
656 ]b4_table_value_equals([[pact]], [[Yyn]], [b4_pact_ninf], [YYPACT_NINF])[
658 #define YYTABLE_NINF (]b4_table_ninf[)
660 #define yytable_value_is_error(Yyn) \
661 ]b4_table_value_equals([[table]], [[Yyn]], [b4_table_ninf], [YYTABLE_NINF])[
663 ]b4_parser_tables_define[
665 enum { YYENOMEM = -2 };
667 #define yyerrok (yyerrstatus = 0)
668 #define yyclearin (yychar = ]b4_symbol(-2, id)[)
670 #define YYACCEPT goto yyacceptlab
671 #define YYABORT goto yyabortlab
672 #define YYERROR goto yyerrorlab
675 #define YYRECOVERING() (!!yyerrstatus)
677 #define YYBACKUP(Token, Value) \
678 do \
679 if (yychar == ]b4_symbol(-2, id)[) \
681 yychar = (Token); \
682 yylval = (Value); \
683 YYPOPSTACK (yylen); \
684 yystate = *yyssp; \]b4_lac_if([[
685 YY_LAC_DISCARD ("YYBACKUP"); \]])[
686 goto yybackup; \
688 else \
690 yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
691 YYERROR; \
693 while (0)
695 /* Backward compatibility with an undocumented macro.
696 Use ]b4_symbol(1, id)[ or ]b4_symbol(2, id)[. */
697 #define YYERRCODE ]b4_symbol(2, id)[
698 ]b4_locations_if([[
699 ]b4_yylloc_default_define[
700 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
701 ]])[
703 /* Enable debugging if requested. */
704 #if ]b4_api_PREFIX[DEBUG
706 # ifndef YYFPRINTF
707 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
708 # define YYFPRINTF fprintf
709 # endif
711 # define YYDPRINTF(Args) \
712 do { \
713 if (yydebug) \
714 YYFPRINTF Args; \
715 } while (0)
717 ]b4_yy_location_print_define[
719 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
720 do { \
721 if (yydebug) \
723 YYFPRINTF (stderr, "%s ", Title); \
724 yy_symbol_print (stderr, \
725 Kind, Value]b4_locations_if([, Location])[]b4_user_args[); \
726 YYFPRINTF (stderr, "\n"); \
728 } while (0)
730 ]b4_yy_symbol_print_define[
732 /*------------------------------------------------------------------.
733 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
734 | TOP (included). |
735 `------------------------------------------------------------------*/
737 static void
738 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
740 YYFPRINTF (stderr, "Stack now");
741 for (; yybottom <= yytop; yybottom++)
743 int yybot = *yybottom;
744 YYFPRINTF (stderr, " %d", yybot);
746 YYFPRINTF (stderr, "\n");
749 # define YY_STACK_PRINT(Bottom, Top) \
750 do { \
751 if (yydebug) \
752 yy_stack_print ((Bottom), (Top)); \
753 } while (0)
756 /*------------------------------------------------.
757 | Report that the YYRULE is going to be reduced. |
758 `------------------------------------------------*/
760 static void
761 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,]b4_locations_if([[ YYLTYPE *yylsp,]])[
762 int yyrule]b4_user_formals[)
764 int yylno = yyrline[yyrule];
765 int yynrhs = yyr2[yyrule];
766 int yyi;
767 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
768 yyrule - 1, yylno);
769 /* The symbols being reduced. */
770 for (yyi = 0; yyi < yynrhs; yyi++)
772 YYFPRINTF (stderr, " $%d = ", yyi + 1);
773 yy_symbol_print (stderr,
774 YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
775 &]b4_rhs_value(yynrhs, yyi + 1)[]b4_locations_if([,
776 &]b4_rhs_location(yynrhs, yyi + 1))[]b4_user_args[);
777 YYFPRINTF (stderr, "\n");
781 # define YY_REDUCE_PRINT(Rule) \
782 do { \
783 if (yydebug) \
784 yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
785 } while (0)
787 /* Nonzero means print parse trace. It is left uninitialized so that
788 multiple parsers can coexist. */
789 int yydebug;
790 #else /* !]b4_api_PREFIX[DEBUG */
791 # define YYDPRINTF(Args) ((void) 0)
792 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
793 # define YY_STACK_PRINT(Bottom, Top)
794 # define YY_REDUCE_PRINT(Rule)
795 #endif /* !]b4_api_PREFIX[DEBUG */
798 /* YYINITDEPTH -- initial size of the parser's stacks. */
799 #ifndef YYINITDEPTH
800 # define YYINITDEPTH ]b4_stack_depth_init[
801 #endif
803 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
804 if the built-in stack extension method is used).
806 Do not make this value too large; the results are undefined if
807 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
808 evaluated with infinite-precision integer arithmetic. */
810 #ifndef YYMAXDEPTH
811 # define YYMAXDEPTH ]b4_stack_depth_max[
812 #endif]b4_push_if([[
813 /* Parser data structure. */
814 struct yypstate
815 {]b4_declare_parser_state_variables[
816 /* Whether this instance has not started parsing yet.
817 * If 2, it corresponds to a finished parsing. */
818 int yynew;
819 };]b4_pure_if([], [[
821 /* Whether the only allowed instance of yypstate is allocated. */
822 static char yypstate_allocated = 0;]])])[
823 ]b4_lac_if([[
825 /* Given a state stack such that *YYBOTTOM is its bottom, such that
826 *YYTOP is either its top or is YYTOP_EMPTY to indicate an empty
827 stack, and such that *YYCAPACITY is the maximum number of elements it
828 can hold without a reallocation, make sure there is enough room to
829 store YYADD more elements. If not, allocate a new stack using
830 YYSTACK_ALLOC, copy the existing elements, and adjust *YYBOTTOM,
831 *YYTOP, and *YYCAPACITY to reflect the new capacity and memory
832 location. If *YYBOTTOM != YYBOTTOM_NO_FREE, then free the old stack
833 using YYSTACK_FREE. Return 0 if successful or if no reallocation is
834 required. Return YYENOMEM if memory is exhausted. */
835 static int
836 yy_lac_stack_realloc (YYPTRDIFF_T *yycapacity, YYPTRDIFF_T yyadd,
837 #if ]b4_api_PREFIX[DEBUG
838 char const *yydebug_prefix,
839 char const *yydebug_suffix,
840 #endif
841 yy_state_t **yybottom,
842 yy_state_t *yybottom_no_free,
843 yy_state_t **yytop, yy_state_t *yytop_empty)
845 YYPTRDIFF_T yysize_old =
846 *yytop == yytop_empty ? 0 : *yytop - *yybottom + 1;
847 YYPTRDIFF_T yysize_new = yysize_old + yyadd;
848 if (*yycapacity < yysize_new)
850 YYPTRDIFF_T yyalloc = 2 * yysize_new;
851 yy_state_t *yybottom_new;
852 /* Use YYMAXDEPTH for maximum stack size given that the stack
853 should never need to grow larger than the main state stack
854 needs to grow without LAC. */
855 if (YYMAXDEPTH < yysize_new)
857 YYDPRINTF ((stderr, "%smax size exceeded%s", yydebug_prefix,
858 yydebug_suffix));
859 return YYENOMEM;
861 if (YYMAXDEPTH < yyalloc)
862 yyalloc = YYMAXDEPTH;
863 yybottom_new =
864 YY_CAST (yy_state_t *,
865 YYSTACK_ALLOC (YY_CAST (YYSIZE_T,
866 yyalloc * YYSIZEOF (*yybottom_new))));
867 if (!yybottom_new)
869 YYDPRINTF ((stderr, "%srealloc failed%s", yydebug_prefix,
870 yydebug_suffix));
871 return YYENOMEM;
873 if (*yytop != yytop_empty)
875 YYCOPY (yybottom_new, *yybottom, yysize_old);
876 *yytop = yybottom_new + (yysize_old - 1);
878 if (*yybottom != yybottom_no_free)
879 YYSTACK_FREE (*yybottom);
880 *yybottom = yybottom_new;
881 *yycapacity = yyalloc;]m4_if(b4_percent_define_get([[parse.lac.memory-trace]]),
882 [full], [[
883 YY_IGNORE_USELESS_CAST_BEGIN
884 YYDPRINTF ((stderr, "%srealloc to %ld%s", yydebug_prefix,
885 YY_CAST (long, yyalloc), yydebug_suffix));
886 YY_IGNORE_USELESS_CAST_END]])[
888 return 0;
891 /* Establish the initial context for the current lookahead if no initial
892 context is currently established.
894 We define a context as a snapshot of the parser stacks. We define
895 the initial context for a lookahead as the context in which the
896 parser initially examines that lookahead in order to select a
897 syntactic action. Thus, if the lookahead eventually proves
898 syntactically unacceptable (possibly in a later context reached via a
899 series of reductions), the initial context can be used to determine
900 the exact set of tokens that would be syntactically acceptable in the
901 lookahead's place. Moreover, it is the context after which any
902 further semantic actions would be erroneous because they would be
903 determined by a syntactically unacceptable token.
905 YY_LAC_ESTABLISH should be invoked when a reduction is about to be
906 performed in an inconsistent state (which, for the purposes of LAC,
907 includes consistent states that don't know they're consistent because
908 their default reductions have been disabled). Iff there is a
909 lookahead token, it should also be invoked before reporting a syntax
910 error. This latter case is for the sake of the debugging output.
912 For parse.lac=full, the implementation of YY_LAC_ESTABLISH is as
913 follows. If no initial context is currently established for the
914 current lookahead, then check if that lookahead can eventually be
915 shifted if syntactic actions continue from the current context.
916 Report a syntax error if it cannot. */
917 #define YY_LAC_ESTABLISH \
918 do { \
919 if (!yy_lac_established) \
921 YYDPRINTF ((stderr, \
922 "LAC: initial context established for %s\n", \
923 yysymbol_name (yytoken))); \
924 yy_lac_established = 1; \
925 switch (yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken)) \
927 case YYENOMEM: \
928 goto yyexhaustedlab; \
929 case 1: \
930 goto yyerrlab; \
933 } while (0)
935 /* Discard any previous initial lookahead context because of Event,
936 which may be a lookahead change or an invalidation of the currently
937 established initial context for the current lookahead.
939 The most common example of a lookahead change is a shift. An example
940 of both cases is syntax error recovery. That is, a syntax error
941 occurs when the lookahead is syntactically erroneous for the
942 currently established initial context, so error recovery manipulates
943 the parser stacks to try to find a new initial context in which the
944 current lookahead is syntactically acceptable. If it fails to find
945 such a context, it discards the lookahead. */
946 #if ]b4_api_PREFIX[DEBUG
947 # define YY_LAC_DISCARD(Event) \
948 do { \
949 if (yy_lac_established) \
951 YYDPRINTF ((stderr, "LAC: initial context discarded due to " \
952 Event "\n")); \
953 yy_lac_established = 0; \
955 } while (0)
956 #else
957 # define YY_LAC_DISCARD(Event) yy_lac_established = 0
958 #endif
960 /* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can
961 eventually (after perhaps some reductions) be shifted, return 1 if
962 not, or return YYENOMEM if memory is exhausted. As preconditions and
963 postconditions: *YYES_CAPACITY is the allocated size of the array to
964 which *YYES points, and either *YYES = YYESA or *YYES points to an
965 array allocated with YYSTACK_ALLOC. yy_lac may overwrite the
966 contents of either array, alter *YYES and *YYES_CAPACITY, and free
967 any old *YYES other than YYESA. */
968 static int
969 yy_lac (yy_state_t *yyesa, yy_state_t **yyes,
970 YYPTRDIFF_T *yyes_capacity, yy_state_t *yyssp, yysymbol_kind_t yytoken)
972 yy_state_t *yyes_prev = yyssp;
973 yy_state_t *yyesp = yyes_prev;
974 /* Reduce until we encounter a shift and thereby accept the token. */
975 YYDPRINTF ((stderr, "LAC: checking lookahead %s:", yysymbol_name (yytoken)));
976 if (yytoken == ]b4_symbol_prefix[YYUNDEF)
978 YYDPRINTF ((stderr, " Always Err\n"));
979 return 1;
981 while (1)
983 int yyrule = yypact[+*yyesp];
984 if (yypact_value_is_default (yyrule)
985 || (yyrule += yytoken) < 0 || YYLAST < yyrule
986 || yycheck[yyrule] != yytoken)
988 /* Use the default action. */
989 yyrule = yydefact[+*yyesp];
990 if (yyrule == 0)
992 YYDPRINTF ((stderr, " Err\n"));
993 return 1;
996 else
998 /* Use the action from yytable. */
999 yyrule = yytable[yyrule];
1000 if (yytable_value_is_error (yyrule))
1002 YYDPRINTF ((stderr, " Err\n"));
1003 return 1;
1005 if (0 < yyrule)
1007 YYDPRINTF ((stderr, " S%d\n", yyrule));
1008 return 0;
1010 yyrule = -yyrule;
1012 /* By now we know we have to simulate a reduce. */
1013 YYDPRINTF ((stderr, " R%d", yyrule - 1));
1015 /* Pop the corresponding number of values from the stack. */
1016 YYPTRDIFF_T yylen = yyr2[yyrule];
1017 /* First pop from the LAC stack as many tokens as possible. */
1018 if (yyesp != yyes_prev)
1020 YYPTRDIFF_T yysize = yyesp - *yyes + 1;
1021 if (yylen < yysize)
1023 yyesp -= yylen;
1024 yylen = 0;
1026 else
1028 yyesp = yyes_prev;
1029 yylen -= yysize;
1032 /* Only afterwards look at the main stack. */
1033 if (yylen)
1034 yyesp = yyes_prev -= yylen;
1036 /* Push the resulting state of the reduction. */
1038 yy_state_fast_t yystate;
1040 const int yylhs = yyr1[yyrule] - YYNTOKENS;
1041 const int yyi = yypgoto[yylhs] + *yyesp;
1042 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
1043 ? yytable[yyi]
1044 : yydefgoto[yylhs]);
1046 if (yyesp == yyes_prev)
1048 yyesp = *yyes;
1049 YY_IGNORE_USELESS_CAST_BEGIN
1050 *yyesp = YY_CAST (yy_state_t, yystate);
1051 YY_IGNORE_USELESS_CAST_END
1053 else
1055 if (yy_lac_stack_realloc (yyes_capacity, 1,
1056 #if ]b4_api_PREFIX[DEBUG
1057 " (", ")",
1058 #endif
1059 yyes, yyesa, &yyesp, yyes_prev))
1061 YYDPRINTF ((stderr, "\n"));
1062 return YYENOMEM;
1064 YY_IGNORE_USELESS_CAST_BEGIN
1065 *++yyesp = YY_CAST (yy_state_t, yystate);
1066 YY_IGNORE_USELESS_CAST_END
1068 YYDPRINTF ((stderr, " G%d", yystate));
1071 }]])[
1073 ]b4_parse_error_case([simple], [],
1074 [[/* Context of a parse error. */
1075 typedef struct
1076 {]b4_push_if([[
1077 yypstate* yyps;]], [[
1078 yy_state_t *yyssp;]b4_lac_if([[
1079 yy_state_t *yyesa;
1080 yy_state_t **yyes;
1081 YYPTRDIFF_T *yyes_capacity;]])])[
1082 yysymbol_kind_t yytoken;]b4_locations_if([[
1083 YYLTYPE *yylloc;]])[
1084 } yypcontext_t;
1086 /* Put in YYARG at most YYARGN of the expected tokens given the
1087 current YYCTX, and return the number of tokens stored in YYARG. If
1088 YYARG is null, return the number of expected tokens (guaranteed to
1089 be less than YYNTOKENS). Return YYENOMEM on memory exhaustion.
1090 Return 0 if there are more than YYARGN expected tokens, yet fill
1091 YYARG up to YYARGN. */]b4_push_if([[
1092 static int
1093 yypstate_expected_tokens (yypstate *yyps,
1094 yysymbol_kind_t yyarg[], int yyargn)]], [[
1095 static int
1096 yypcontext_expected_tokens (const yypcontext_t *yyctx,
1097 yysymbol_kind_t yyarg[], int yyargn)]])[
1099 /* Actual size of YYARG. */
1100 int yycount = 0;
1101 ]b4_lac_if([[
1102 int yyx;
1103 for (yyx = 0; yyx < YYNTOKENS; ++yyx)
1105 yysymbol_kind_t yysym = YY_CAST (yysymbol_kind_t, yyx);
1106 if (yysym != ]b4_symbol(1, kind)[ && yysym != ]b4_symbol_prefix[YYUNDEF)
1107 switch (yy_lac (]b4_push_if([[yyps->yyesa, &yyps->yyes, &yyps->yyes_capacity, yyps->yyssp, yysym]],
1108 [[yyctx->yyesa, yyctx->yyes, yyctx->yyes_capacity, yyctx->yyssp, yysym]])[))
1110 case YYENOMEM:
1111 return YYENOMEM;
1112 case 1:
1113 continue;
1114 default:
1115 if (!yyarg)
1116 ++yycount;
1117 else if (yycount == yyargn)
1118 return 0;
1119 else
1120 yyarg[yycount++] = yysym;
1122 }]],
1123 [[ int yyn = yypact@{+*]b4_push_if([yyps], [yyctx])[->yyssp@};
1124 if (!yypact_value_is_default (yyn))
1126 /* Start YYX at -YYN if negative to avoid negative indexes in
1127 YYCHECK. In other words, skip the first -YYN actions for
1128 this state because they are default actions. */
1129 int yyxbegin = yyn < 0 ? -yyn : 0;
1130 /* Stay within bounds of both yycheck and yytname. */
1131 int yychecklim = YYLAST - yyn + 1;
1132 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1133 int yyx;
1134 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1135 if (yycheck[yyx + yyn] == yyx && yyx != ]b4_symbol(1, kind)[
1136 && !yytable_value_is_error (yytable[yyx + yyn]))
1138 if (!yyarg)
1139 ++yycount;
1140 else if (yycount == yyargn)
1141 return 0;
1142 else
1143 yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);
1145 }]])[
1146 if (yyarg && yycount == 0 && 0 < yyargn)
1147 yyarg[0] = ]b4_symbol(-2, kind)[;
1148 return yycount;
1151 ]b4_push_if([[
1152 /* Similar to the previous function. */
1153 static int
1154 yypcontext_expected_tokens (const yypcontext_t *yyctx,
1155 yysymbol_kind_t yyarg[], int yyargn)
1157 return yypstate_expected_tokens (yyctx->yyps, yyarg, yyargn);
1158 }]])[
1159 ]])[
1161 ]b4_parse_error_bmatch(
1162 [custom],
1163 [[/* The kind of the lookahead of this context. */
1164 static yysymbol_kind_t
1165 yypcontext_token (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
1167 static yysymbol_kind_t
1168 yypcontext_token (const yypcontext_t *yyctx)
1170 return yyctx->yytoken;
1173 ]b4_locations_if([[/* The location of the lookahead of this context. */
1174 static YYLTYPE *
1175 yypcontext_location (const yypcontext_t *yyctx) YY_ATTRIBUTE_UNUSED;
1177 static YYLTYPE *
1178 yypcontext_location (const yypcontext_t *yyctx)
1180 return yyctx->yylloc;
1181 }]])[
1183 /* User defined function to report a syntax error. */
1184 static int
1185 yyreport_syntax_error (const yypcontext_t *yyctx]b4_user_formals[);]],
1186 [detailed\|verbose],
1187 [[#ifndef yystrlen
1188 # if defined __GLIBC__ && defined _STRING_H
1189 # define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
1190 # else
1191 /* Return the length of YYSTR. */
1192 static YYPTRDIFF_T
1193 yystrlen (const char *yystr)
1195 YYPTRDIFF_T yylen;
1196 for (yylen = 0; yystr[yylen]; yylen++)
1197 continue;
1198 return yylen;
1200 # endif
1201 #endif
1203 #ifndef yystpcpy
1204 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1205 # define yystpcpy stpcpy
1206 # else
1207 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1208 YYDEST. */
1209 static char *
1210 yystpcpy (char *yydest, const char *yysrc)
1212 char *yyd = yydest;
1213 const char *yys = yysrc;
1215 while ((*yyd++ = *yys++) != '\0')
1216 continue;
1218 return yyd - 1;
1220 # endif
1221 #endif
1223 ]b4_parse_error_case(
1224 [verbose],
1225 [[#ifndef yytnamerr
1226 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1227 quotes and backslashes, so that it's suitable for yyerror. The
1228 heuristic is that double-quoting is unnecessary unless the string
1229 contains an apostrophe, a comma, or backslash (other than
1230 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1231 null, do not copy; instead, return the length of what the result
1232 would have been. */
1233 static YYPTRDIFF_T
1234 yytnamerr (char *yyres, const char *yystr)
1236 if (*yystr == '"')
1238 YYPTRDIFF_T yyn = 0;
1239 char const *yyp = yystr;
1240 for (;;)
1241 switch (*++yyp)
1243 case '\'':
1244 case ',':
1245 goto do_not_strip_quotes;
1247 case '\\':
1248 if (*++yyp != '\\')
1249 goto do_not_strip_quotes;
1250 else
1251 goto append;
1253 append:
1254 default:
1255 if (yyres)
1256 yyres[yyn] = *yyp;
1257 yyn++;
1258 break;
1260 case '"':
1261 if (yyres)
1262 yyres[yyn] = '\0';
1263 return yyn;
1265 do_not_strip_quotes: ;
1268 if (yyres)
1269 return yystpcpy (yyres, yystr) - yyres;
1270 else
1271 return yystrlen (yystr);
1273 #endif
1274 ]])[
1276 static int
1277 yy_syntax_error_arguments (const yypcontext_t *yyctx,
1278 yysymbol_kind_t yyarg[], int yyargn)
1280 /* Actual size of YYARG. */
1281 int yycount = 0;
1282 /* There are many possibilities here to consider:
1283 - If this state is a consistent state with a default action, then
1284 the only way this function was invoked is if the default action
1285 is an error action. In that case, don't check for expected
1286 tokens because there are none.
1287 - The only way there can be no lookahead present (in yychar) is if
1288 this state is a consistent state with a default action. Thus,
1289 detecting the absence of a lookahead is sufficient to determine
1290 that there is no unexpected or expected token to report. In that
1291 case, just report a simple "syntax error".
1292 - Don't assume there isn't a lookahead just because this state is a
1293 consistent state with a default action. There might have been a
1294 previous inconsistent state, consistent state with a non-default
1295 action, or user semantic action that manipulated yychar.]b4_lac_if([[
1296 In the first two cases, it might appear that the current syntax
1297 error should have been detected in the previous state when yy_lac
1298 was invoked. However, at that time, there might have been a
1299 different syntax error that discarded a different initial context
1300 during error recovery, leaving behind the current lookahead.]], [[
1301 - Of course, the expected token list depends on states to have
1302 correct lookahead information, and it depends on the parser not
1303 to perform extra reductions after fetching a lookahead from the
1304 scanner and before detecting a syntax error. Thus, state merging
1305 (from LALR or IELR) and default reductions corrupt the expected
1306 token list. However, the list is correct for canonical LR with
1307 one exception: it will still contain any token that will not be
1308 accepted due to an error action in a later state.]])[
1310 if (yyctx->yytoken != ]b4_symbol(-2, kind)[)
1312 int yyn;]b4_lac_if([[
1313 YYDPRINTF ((stderr, "Constructing syntax error message\n"));]])[
1314 if (yyarg)
1315 yyarg[yycount] = yyctx->yytoken;
1316 ++yycount;
1317 yyn = yypcontext_expected_tokens (yyctx,
1318 yyarg ? yyarg + 1 : yyarg, yyargn - 1);
1319 if (yyn == YYENOMEM)
1320 return YYENOMEM;]b4_lac_if([[
1321 else if (yyn == 0)
1322 YYDPRINTF ((stderr, "No expected tokens.\n"));]])[
1323 else
1324 yycount += yyn;
1326 return yycount;
1329 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1330 about the unexpected token YYTOKEN for the state stack whose top is
1331 YYSSP.]b4_lac_if([[ In order to see if a particular token T is a
1332 valid looakhead, invoke yy_lac (YYESA, YYES, YYES_CAPACITY, YYSSP, T).]])[
1334 Return 0 if *YYMSG was successfully written. Return -1 if *YYMSG is
1335 not large enough to hold the message. In that case, also set
1336 *YYMSG_ALLOC to the required number of bytes. Return YYENOMEM if the
1337 required number of bytes is too large to store]b4_lac_if([[ or if
1338 yy_lac returned YYENOMEM]])[. */
1339 static int
1340 yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
1341 const yypcontext_t *yyctx)
1343 enum { YYARGS_MAX = 5 };
1344 /* Internationalized format string. */
1345 const char *yyformat = YY_NULLPTR;
1346 /* Arguments of yyformat: reported tokens (one for the "unexpected",
1347 one per "expected"). */
1348 yysymbol_kind_t yyarg[YYARGS_MAX];
1349 /* Cumulated lengths of YYARG. */
1350 YYPTRDIFF_T yysize = 0;
1352 /* Actual size of YYARG. */
1353 int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX);
1354 if (yycount == YYENOMEM)
1355 return YYENOMEM;
1357 switch (yycount)
1359 #define YYCASE_(N, S) \
1360 case N: \
1361 yyformat = S; \
1362 break
1363 default: /* Avoid compiler warnings. */
1364 YYCASE_(0, YY_("syntax error"));
1365 YYCASE_(1, YY_("syntax error, unexpected %s"));
1366 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1367 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1368 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1369 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1370 #undef YYCASE_
1373 /* Compute error message size. Don't count the "%s"s, but reserve
1374 room for the terminator. */
1375 yysize = yystrlen (yyformat) - 2 * yycount + 1;
1377 int yyi;
1378 for (yyi = 0; yyi < yycount; ++yyi)
1380 YYPTRDIFF_T yysize1
1381 = yysize + ]b4_parse_error_case(
1382 [verbose], [[yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]])]],
1383 [[yystrlen (yysymbol_name (yyarg[yyi]))]]);[
1384 if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1385 yysize = yysize1;
1386 else
1387 return YYENOMEM;
1391 if (*yymsg_alloc < yysize)
1393 *yymsg_alloc = 2 * yysize;
1394 if (! (yysize <= *yymsg_alloc
1395 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1396 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1397 return -1;
1400 /* Avoid sprintf, as that infringes on the user's name space.
1401 Don't have undefined behavior even if the translation
1402 produced a string with the wrong number of "%s"s. */
1404 char *yyp = *yymsg;
1405 int yyi = 0;
1406 while ((*yyp = *yyformat) != '\0')
1407 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1408 {]b4_parse_error_case([verbose], [[
1409 yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);]], [[
1410 yyp = yystpcpy (yyp, yysymbol_name (yyarg[yyi++]));]])[
1411 yyformat += 2;
1413 else
1415 ++yyp;
1416 ++yyformat;
1419 return 0;
1421 ]])[
1423 ]b4_yydestruct_define[
1425 ]b4_pure_if([], [b4_declare_scanner_communication_variables])[
1427 ]b4_push_if([b4_pull_if([[
1430 yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)
1432 yypstate *yyps = yypstate_new ();
1433 if (!yyps)
1434 {]b4_pure_if([b4_locations_if([[
1435 static YYLTYPE yyloc_default][]b4_yyloc_default[;
1436 YYLTYPE yylloc = yyloc_default;]])[
1437 yyerror (]b4_yyerror_args[YY_("memory exhausted"));]], [[
1438 if (!yypstate_allocated)
1439 yyerror (]b4_yyerror_args[YY_("memory exhausted"));]])[
1440 return 2;
1442 int yystatus = yypull_parse (yyps]b4_user_args[);
1443 yypstate_delete (yyps);
1444 return yystatus;
1448 yypull_parse (yypstate *yyps]b4_user_formals[)
1450 YY_ASSERT (yyps);]b4_pure_if([b4_locations_if([[
1451 static YYLTYPE yyloc_default][]b4_yyloc_default[;
1452 YYLTYPE yylloc = yyloc_default;]])])[
1453 int yystatus;
1454 do {
1455 ]b4_pure_if([[ YYSTYPE yylval;
1456 int ]])[yychar = ]b4_lex[;
1457 yystatus = yypush_parse (yyps]b4_pure_if([[, yychar, &yylval]b4_locations_if([[, &yylloc]])])m4_ifset([b4_parse_param], [, b4_args(b4_parse_param)])[);
1458 } while (yystatus == YYPUSH_MORE);
1459 return yystatus;
1460 }]])[
1462 ]b4_parse_state_variable_macros([b4_pstate_macro_define])[
1464 /* Initialize the parser data structure. */
1465 static void
1466 yypstate_clear (yypstate *yyps)
1468 yynerrs = 0;
1469 yystate = 0;
1470 yyerrstatus = 0;
1472 yyssp = yyss;
1473 yyvsp = yyvs;]b4_locations_if([[
1474 yylsp = yyls;]])[
1476 /* Initialize the state stack, in case yypcontext_expected_tokens is
1477 called before the first call to yyparse. */
1478 *yyssp = 0;
1479 yyps->yynew = 1;
1482 /* Initialize the parser data structure. */
1483 yypstate *
1484 yypstate_new (void)
1486 yypstate *yyps;]b4_pure_if([], [[
1487 if (yypstate_allocated)
1488 return YY_NULLPTR;]])[
1489 yyps = YY_CAST (yypstate *, YYMALLOC (sizeof *yyps));
1490 if (!yyps)
1491 return YY_NULLPTR;]b4_pure_if([], [[
1492 yypstate_allocated = 1;]])[
1493 yystacksize = YYINITDEPTH;
1494 yyss = yyssa;
1495 yyvs = yyvsa;]b4_locations_if([[
1496 yyls = yylsa;]])[]b4_lac_if([[
1497 yyes = yyesa;
1498 yyes_capacity = ]b4_percent_define_get([[parse.lac.es-capacity-initial]])[;
1499 if (YYMAXDEPTH < yyes_capacity)
1500 yyes_capacity = YYMAXDEPTH;]])[
1501 yypstate_clear (yyps);
1502 return yyps;
1505 void
1506 yypstate_delete (yypstate *yyps)
1508 if (yyps)
1510 #ifndef yyoverflow
1511 /* If the stack was reallocated but the parse did not complete, then the
1512 stack still needs to be freed. */
1513 if (yyss != yyssa)
1514 YYSTACK_FREE (yyss);
1515 #endif]b4_lac_if([[
1516 if (yyes != yyesa)
1517 YYSTACK_FREE (yyes);]])[
1518 YYFREE (yyps);]b4_pure_if([], [[
1519 yypstate_allocated = 0;]])[
1522 ]])[
1524 ]b4_push_if([[
1525 /*---------------.
1526 | yypush_parse. |
1527 `---------------*/
1530 yypush_parse (yypstate *yyps]b4_pure_if([[,
1531 int yypushed_char, YYSTYPE const *yypushed_val]b4_locations_if([[, YYLTYPE *yypushed_loc]])])b4_user_formals[)]],
1533 /*----------.
1534 | yyparse. |
1535 `----------*/
1538 yyparse (]m4_ifset([b4_parse_param], [b4_formals(b4_parse_param)], [void])[)]])[
1539 {]b4_pure_if([b4_declare_scanner_communication_variables
1540 ])b4_push_if([b4_pure_if([], [[
1541 int yypushed_char = yychar;
1542 YYSTYPE yypushed_val = yylval;]b4_locations_if([[
1543 YYLTYPE yypushed_loc = yylloc;]])
1544 ])],
1545 [b4_declare_parser_state_variables([init])
1546 ])b4_lac_if([[
1547 /* Whether LAC context is established. A Boolean. */
1548 int yy_lac_established = 0;]])[
1549 int yyn;
1550 /* The return value of yyparse. */
1551 int yyresult;
1552 /* Lookahead symbol kind. */
1553 yysymbol_kind_t yytoken = ]b4_symbol(-2, kind)[;
1554 /* The variables used to return semantic value and location from the
1555 action routines. */
1556 YYSTYPE yyval;]b4_locations_if([[
1557 YYLTYPE yyloc;
1559 /* The locations where the error started and ended. */
1560 YYLTYPE yyerror_range[3];]])[
1562 ]b4_parse_error_bmatch([detailed\|verbose],
1563 [[ /* Buffer for error messages, and its allocated size. */
1564 char yymsgbuf[128];
1565 char *yymsg = yymsgbuf;
1566 YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;]])[
1568 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[)
1570 /* The number of symbols on the RHS of the reduced rule.
1571 Keep to zero when no symbol should be popped. */
1572 int yylen = 0;]b4_push_if([[
1574 switch (yyps->yynew)
1576 case 0:
1577 yyn = yypact[yystate];
1578 goto yyread_pushed_token;
1580 case 2:
1581 yypstate_clear (yyps);
1582 break;
1584 default:
1585 break;
1586 }]])[
1588 YYDPRINTF ((stderr, "Starting parse\n"));
1590 yychar = ]b4_symbol(-2, id)[; /* Cause a token to be read. */
1591 ]m4_ifdef([b4_initial_action], [
1592 b4_dollar_pushdef([m4_define([b4_dollar_dollar_used])yylval], [], [],
1593 [b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])])dnl
1594 b4_user_initial_action
1595 b4_dollar_popdef[]dnl
1596 m4_ifdef([b4_dollar_dollar_used],[[ yyvsp[0] = yylval;
1597 ]])])dnl
1598 b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yylloc])[;
1599 ]])dnl
1600 [ goto yysetstate;
1603 /*------------------------------------------------------------.
1604 | yynewstate -- push a new state, which is found in yystate. |
1605 `------------------------------------------------------------*/
1606 yynewstate:
1607 /* In all cases, when you get here, the value and location stacks
1608 have just been pushed. So pushing a state here evens the stacks. */
1609 yyssp++;
1612 /*--------------------------------------------------------------------.
1613 | yysetstate -- set current state (the top of the stack) to yystate. |
1614 `--------------------------------------------------------------------*/
1615 yysetstate:
1616 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1617 YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1618 YY_IGNORE_USELESS_CAST_BEGIN
1619 *yyssp = YY_CAST (yy_state_t, yystate);
1620 YY_IGNORE_USELESS_CAST_END
1621 YY_STACK_PRINT (yyss, yyssp);
1623 if (yyss + yystacksize - 1 <= yyssp)
1624 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1625 goto yyexhaustedlab;
1626 #else
1628 /* Get the current used size of the three stacks, in elements. */
1629 YYPTRDIFF_T yysize = yyssp - yyss + 1;
1631 # if defined yyoverflow
1633 /* Give user a chance to reallocate the stack. Use copies of
1634 these so that the &'s don't force the real ones into
1635 memory. */
1636 yy_state_t *yyss1 = yyss;
1637 YYSTYPE *yyvs1 = yyvs;]b4_locations_if([
1638 YYLTYPE *yyls1 = yyls;])[
1640 /* Each stack pointer address is followed by the size of the
1641 data in use in that stack, in bytes. This used to be a
1642 conditional around just the two extra args, but that might
1643 be undefined if yyoverflow is a macro. */
1644 yyoverflow (YY_("memory exhausted"),
1645 &yyss1, yysize * YYSIZEOF (*yyssp),
1646 &yyvs1, yysize * YYSIZEOF (*yyvsp),]b4_locations_if([
1647 &yyls1, yysize * YYSIZEOF (*yylsp),])[
1648 &yystacksize);
1649 yyss = yyss1;
1650 yyvs = yyvs1;]b4_locations_if([
1651 yyls = yyls1;])[
1653 # else /* defined YYSTACK_RELOCATE */
1654 /* Extend the stack our own way. */
1655 if (YYMAXDEPTH <= yystacksize)
1656 goto yyexhaustedlab;
1657 yystacksize *= 2;
1658 if (YYMAXDEPTH < yystacksize)
1659 yystacksize = YYMAXDEPTH;
1662 yy_state_t *yyss1 = yyss;
1663 union yyalloc *yyptr =
1664 YY_CAST (union yyalloc *,
1665 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1666 if (! yyptr)
1667 goto yyexhaustedlab;
1668 YYSTACK_RELOCATE (yyss_alloc, yyss);
1669 YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
1670 YYSTACK_RELOCATE (yyls_alloc, yyls);])[
1671 # undef YYSTACK_RELOCATE
1672 if (yyss1 != yyssa)
1673 YYSTACK_FREE (yyss1);
1675 # endif
1677 yyssp = yyss + yysize - 1;
1678 yyvsp = yyvs + yysize - 1;]b4_locations_if([
1679 yylsp = yyls + yysize - 1;])[
1681 YY_IGNORE_USELESS_CAST_BEGIN
1682 YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1683 YY_CAST (long, yystacksize)));
1684 YY_IGNORE_USELESS_CAST_END
1686 if (yyss + yystacksize - 1 <= yyssp)
1687 YYABORT;
1689 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1691 if (yystate == YYFINAL)
1692 YYACCEPT;
1694 goto yybackup;
1697 /*-----------.
1698 | yybackup. |
1699 `-----------*/
1700 yybackup:
1701 /* Do appropriate processing given the current state. Read a
1702 lookahead token if we need one and don't already have one. */
1704 /* First try to decide what to do without reference to lookahead token. */
1705 yyn = yypact[yystate];
1706 if (yypact_value_is_default (yyn))
1707 goto yydefault;
1709 /* Not known => get a lookahead token if don't already have one. */
1711 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1712 if (yychar == ]b4_symbol(-2, id)[)
1713 {]b4_push_if([[
1714 if (!yyps->yynew)
1715 {]b4_use_push_for_pull_if([], [[
1716 YYDPRINTF ((stderr, "Return for a new token:\n"));]])[
1717 yyresult = YYPUSH_MORE;
1718 goto yypushreturn;
1720 yyps->yynew = 0;]b4_pure_if([], [[
1721 /* Restoring the pushed token is only necessary for the first
1722 yypush_parse invocation since subsequent invocations don't overwrite
1723 it before jumping to yyread_pushed_token. */
1724 yychar = yypushed_char;
1725 yylval = yypushed_val;]b4_locations_if([[
1726 yylloc = yypushed_loc;]])])[
1727 yyread_pushed_token:]])[
1728 YYDPRINTF ((stderr, "Reading a token\n"));]b4_push_if([b4_pure_if([[
1729 yychar = yypushed_char;
1730 if (yypushed_val)
1731 yylval = *yypushed_val;]b4_locations_if([[
1732 if (yypushed_loc)
1733 yylloc = *yypushed_loc;]])])], [[
1734 yychar = ]b4_lex[;]])[
1737 if (yychar <= ]b4_symbol(0, [id])[)
1739 yychar = ]b4_symbol(0, [id])[;
1740 yytoken = ]b4_symbol(0, [kind])[;
1741 YYDPRINTF ((stderr, "Now at end of input.\n"));
1743 else if (yychar == ]b4_symbol(1, [id])[)
1745 /* The scanner already issued an error message, process directly
1746 to error recovery. But do not keep the error token as
1747 lookahead, it is too special and may lead us to an endless
1748 loop in error recovery. */
1749 yychar = ]b4_symbol(2, [id])[;
1750 yytoken = ]b4_symbol(1, [kind])[;]b4_locations_if([[
1751 yyerror_range[1] = yylloc;]])[
1752 goto yyerrlab1;
1754 else
1756 yytoken = YYTRANSLATE (yychar);
1757 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1760 /* If the proper action on seeing token YYTOKEN is to reduce or to
1761 detect an error, take that action. */
1762 yyn += yytoken;
1763 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)]b4_lac_if([[
1765 YY_LAC_ESTABLISH;
1766 goto yydefault;
1767 }]], [[
1768 goto yydefault;]])[
1769 yyn = yytable[yyn];
1770 if (yyn <= 0)
1772 if (yytable_value_is_error (yyn))
1773 goto yyerrlab;]b4_lac_if([[
1774 YY_LAC_ESTABLISH;]])[
1775 yyn = -yyn;
1776 goto yyreduce;
1779 /* Count tokens shifted since error; after three, turn off error
1780 status. */
1781 if (yyerrstatus)
1782 yyerrstatus--;
1784 /* Shift the lookahead token. */
1785 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1786 yystate = yyn;
1787 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1788 *++yyvsp = yylval;
1789 YY_IGNORE_MAYBE_UNINITIALIZED_END]b4_locations_if([
1790 *++yylsp = yylloc;])[
1792 /* Discard the shifted token. */
1793 yychar = ]b4_symbol(-2, id)[;]b4_lac_if([[
1794 YY_LAC_DISCARD ("shift");]])[
1795 goto yynewstate;
1798 /*-----------------------------------------------------------.
1799 | yydefault -- do the default action for the current state. |
1800 `-----------------------------------------------------------*/
1801 yydefault:
1802 yyn = yydefact[yystate];
1803 if (yyn == 0)
1804 goto yyerrlab;
1805 goto yyreduce;
1808 /*-----------------------------.
1809 | yyreduce -- do a reduction. |
1810 `-----------------------------*/
1811 yyreduce:
1812 /* yyn is the number of a rule to reduce with. */
1813 yylen = yyr2[yyn];
1815 /* If YYLEN is nonzero, implement the default value of the action:
1816 '$$ = $1'.
1818 Otherwise, the following line sets YYVAL to garbage.
1819 This behavior is undocumented and Bison
1820 users should not rely upon it. Assigning to YYVAL
1821 unconditionally makes the parser a bit smaller, and it avoids a
1822 GCC warning that YYVAL may be used uninitialized. */
1823 yyval = yyvsp[1-yylen];
1825 ]b4_locations_if(
1826 [[ /* Default location. */
1827 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1828 yyerror_range[1] = yyloc;]])[
1829 YY_REDUCE_PRINT (yyn);]b4_lac_if([[
1831 int yychar_backup = yychar;
1832 switch (yyn)
1834 ]b4_user_actions[
1835 default: break;
1837 if (yychar_backup != yychar)
1838 YY_LAC_DISCARD ("yychar change");
1839 }]], [[
1840 switch (yyn)
1842 ]b4_user_actions[
1843 default: break;
1844 }]])[
1845 /* User semantic actions sometimes alter yychar, and that requires
1846 that yytoken be updated with the new translation. We take the
1847 approach of translating immediately before every use of yytoken.
1848 One alternative is translating here after every semantic action,
1849 but that translation would be missed if the semantic action invokes
1850 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1851 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1852 incorrect destructor might then be invoked immediately. In the
1853 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1854 to an incorrect destructor call or verbose syntax error message
1855 before the lookahead is translated. */
1856 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1858 YYPOPSTACK (yylen);
1859 yylen = 0;
1861 *++yyvsp = yyval;]b4_locations_if([
1862 *++yylsp = yyloc;])[
1864 /* Now 'shift' the result of the reduction. Determine what state
1865 that goes to, based on the state we popped back to and the rule
1866 number reduced by. */
1868 const int yylhs = yyr1[yyn] - YYNTOKENS;
1869 const int yyi = yypgoto[yylhs] + *yyssp;
1870 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1871 ? yytable[yyi]
1872 : yydefgoto[yylhs]);
1875 goto yynewstate;
1878 /*--------------------------------------.
1879 | yyerrlab -- here on detecting error. |
1880 `--------------------------------------*/
1881 yyerrlab:
1882 /* Make sure we have latest lookahead translation. See comments at
1883 user semantic actions for why this is necessary. */
1884 yytoken = yychar == ]b4_symbol(-2, id)[ ? ]b4_symbol(-2, kind)[ : YYTRANSLATE (yychar);
1885 /* If not already recovering from an error, report this error. */
1886 if (!yyerrstatus)
1888 ++yynerrs;
1889 ]b4_parse_error_case(
1890 [custom],
1891 [[ {
1892 yypcontext_t yyctx
1893 = {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[};]b4_lac_if([[
1894 if (yychar != ]b4_symbol(-2, id)[)
1895 YY_LAC_ESTABLISH;]])[
1896 if (yyreport_syntax_error (&yyctx]m4_ifset([b4_parse_param],
1897 [[, ]b4_args(b4_parse_param)])[) == 2)
1898 goto yyexhaustedlab;
1899 }]],
1900 [simple],
1901 [[ yyerror (]b4_yyerror_args[YY_("syntax error"));]],
1902 [[ {
1903 yypcontext_t yyctx
1904 = {]b4_push_if([[yyps]], [[yyssp]b4_lac_if([[, yyesa, &yyes, &yyes_capacity]])])[, yytoken]b4_locations_if([[, &yylloc]])[};
1905 char const *yymsgp = YY_("syntax error");
1906 int yysyntax_error_status;]b4_lac_if([[
1907 if (yychar != ]b4_symbol(-2, id)[)
1908 YY_LAC_ESTABLISH;]])[
1909 yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
1910 if (yysyntax_error_status == 0)
1911 yymsgp = yymsg;
1912 else if (yysyntax_error_status == -1)
1914 if (yymsg != yymsgbuf)
1915 YYSTACK_FREE (yymsg);
1916 yymsg = YY_CAST (char *,
1917 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
1918 if (yymsg)
1920 yysyntax_error_status
1921 = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
1922 yymsgp = yymsg;
1924 else
1926 yymsg = yymsgbuf;
1927 yymsg_alloc = sizeof yymsgbuf;
1928 yysyntax_error_status = YYENOMEM;
1931 yyerror (]b4_yyerror_args[yymsgp);
1932 if (yysyntax_error_status == YYENOMEM)
1933 goto yyexhaustedlab;
1934 }]])[
1936 ]b4_locations_if([[
1937 yyerror_range[1] = yylloc;]])[
1938 if (yyerrstatus == 3)
1940 /* If just tried and failed to reuse lookahead token after an
1941 error, discard it. */
1943 if (yychar <= ]b4_symbol(0, [id])[)
1945 /* Return failure if at end of input. */
1946 if (yychar == ]b4_symbol(0, [id])[)
1947 YYABORT;
1949 else
1951 yydestruct ("Error: discarding",
1952 yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
1953 yychar = ]b4_symbol(-2, id)[;
1957 /* Else will try to reuse lookahead token after shifting the error
1958 token. */
1959 goto yyerrlab1;
1962 /*---------------------------------------------------.
1963 | yyerrorlab -- error raised explicitly by YYERROR. |
1964 `---------------------------------------------------*/
1965 yyerrorlab:
1966 /* Pacify compilers when the user code never invokes YYERROR and the
1967 label yyerrorlab therefore never appears in user code. */
1968 if (0)
1969 YYERROR;
1971 /* Do not reclaim the symbols of the rule whose action triggered
1972 this YYERROR. */
1973 YYPOPSTACK (yylen);
1974 yylen = 0;
1975 YY_STACK_PRINT (yyss, yyssp);
1976 yystate = *yyssp;
1977 goto yyerrlab1;
1980 /*-------------------------------------------------------------.
1981 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1982 `-------------------------------------------------------------*/
1983 yyerrlab1:
1984 yyerrstatus = 3; /* Each real token shifted decrements this. */
1986 /* Pop stack until we find a state that shifts the error token. */
1987 for (;;)
1989 yyn = yypact[yystate];
1990 if (!yypact_value_is_default (yyn))
1992 yyn += ]b4_symbol(1, kind)[;
1993 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == ]b4_symbol(1, kind)[)
1995 yyn = yytable[yyn];
1996 if (0 < yyn)
1997 break;
2001 /* Pop the current state because it cannot handle the error token. */
2002 if (yyssp == yyss)
2003 YYABORT;
2005 ]b4_locations_if([[ yyerror_range[1] = *yylsp;]])[
2006 yydestruct ("Error: popping",
2007 YY_ACCESSING_SYMBOL (yystate), yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
2008 YYPOPSTACK (1);
2009 yystate = *yyssp;
2010 YY_STACK_PRINT (yyss, yyssp);
2011 }]b4_lac_if([[
2013 /* If the stack popping above didn't lose the initial context for the
2014 current lookahead token, the shift below will for sure. */
2015 YY_LAC_DISCARD ("error recovery");]])[
2017 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2018 *++yyvsp = yylval;
2019 YY_IGNORE_MAYBE_UNINITIALIZED_END
2020 ]b4_locations_if([[
2021 yyerror_range[2] = yylloc;
2022 ++yylsp;
2023 YYLLOC_DEFAULT (*yylsp, yyerror_range, 2);]])[
2025 /* Shift the error token. */
2026 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
2028 yystate = yyn;
2029 goto yynewstate;
2032 /*-------------------------------------.
2033 | yyacceptlab -- YYACCEPT comes here. |
2034 `-------------------------------------*/
2035 yyacceptlab:
2036 yyresult = 0;
2037 goto yyreturn;
2040 /*-----------------------------------.
2041 | yyabortlab -- YYABORT comes here. |
2042 `-----------------------------------*/
2043 yyabortlab:
2044 yyresult = 1;
2045 goto yyreturn;
2048 #if ]b4_lac_if([[1]], [b4_parse_error_case([simple], [[!defined yyoverflow]], [[1]])])[
2049 /*-------------------------------------------------.
2050 | yyexhaustedlab -- memory exhaustion comes here. |
2051 `-------------------------------------------------*/
2052 yyexhaustedlab:
2053 yyerror (]b4_yyerror_args[YY_("memory exhausted"));
2054 yyresult = 2;
2055 goto yyreturn;
2056 #endif
2059 /*-------------------------------------------------------.
2060 | yyreturn -- parsing is finished, clean up and return. |
2061 `-------------------------------------------------------*/
2062 yyreturn:
2063 if (yychar != ]b4_symbol(-2, id)[)
2065 /* Make sure we have latest lookahead translation. See comments at
2066 user semantic actions for why this is necessary. */
2067 yytoken = YYTRANSLATE (yychar);
2068 yydestruct ("Cleanup: discarding lookahead",
2069 yytoken, &yylval]b4_locations_if([, &yylloc])[]b4_user_args[);
2071 /* Do not reclaim the symbols of the rule whose action triggered
2072 this YYABORT or YYACCEPT. */
2073 YYPOPSTACK (yylen);
2074 YY_STACK_PRINT (yyss, yyssp);
2075 while (yyssp != yyss)
2077 yydestruct ("Cleanup: popping",
2078 YY_ACCESSING_SYMBOL (+*yyssp), yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
2079 YYPOPSTACK (1);
2080 }]b4_push_if([[
2081 yyps->yynew = 2;
2082 goto yypushreturn;
2085 /*-------------------------.
2086 | yypushreturn -- return. |
2087 `-------------------------*/
2088 yypushreturn:]], [[
2089 #ifndef yyoverflow
2090 if (yyss != yyssa)
2091 YYSTACK_FREE (yyss);
2092 #endif]b4_lac_if([[
2093 if (yyes != yyesa)
2094 YYSTACK_FREE (yyes);]])])[
2095 ]b4_parse_error_bmatch([detailed\|verbose],
2096 [[ if (yymsg != yymsgbuf)
2097 YYSTACK_FREE (yymsg);]])[
2098 return yyresult;
2100 ]b4_push_if([b4_parse_state_variable_macros([b4_macro_undef])])[
2101 ]b4_percent_code_get([[epilogue]])[]dnl
2102 b4_epilogue[]dnl
2103 b4_output_end