2 # Yacc compatible skeleton for Bison
4 # Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software
7 m4_pushdef([b4_copyright_years
],
8 [1984, 1989-1990, 2000-2015, 2018-2019])
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 <http://www.gnu.org/licenses/>.
23 m4_include(b4_skeletonsdir
/[c
.m4
])
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
,
45 [m4_fatal([invalid api
.pure value
: ]$
1)])])
51 b4_percent_define_default([[api
.push
-pull
]], [[pull
]])
52 b4_percent_define_check_values([[[[api
.push
-pull
]],
53 [[pull
]], [[push
]], [[both
]]]])
54 b4_define_flag_if([pull
]) m4_define([b4_pull_flag
], [[1]])
55 b4_define_flag_if([push
]) m4_define([b4_push_flag
], [[1]])
56 m4_case(b4_percent_define_get([[api
.push
-pull
]]),
57 [pull
], [m4_define([b4_push_flag
], [[0]])],
58 [push
], [m4_define([b4_pull_flag
], [[0]])])
60 # Handle BISON_USE_PUSH_FOR_PULL for the test suite. So that push parsing
61 # tests function as written, do not let BISON_USE_PUSH_FOR_PULL modify the
62 # behavior of Bison at all when push parsing is already requested.
63 b4_define_flag_if([use_push_for_pull
])
64 b4_use_push_for_pull_if([
65 b4_push_if([m4_define([b4_use_push_for_pull_flag
], [[0]])],
66 [m4_define([b4_push_flag
], [[1]])])])
72 b4_percent_define_default([[parse
.lac
]], [[none
]])
73 b4_percent_define_default([[parse
.lac
.es
-capacity
-initial
]], [[20]])
74 b4_percent_define_default([[parse
.lac
.memory
-trace
]], [[failures
]])
75 b4_percent_define_check_values([[[[parse
.lac
]], [[full
]], [[none
]]]],
76 [[[[parse
.lac
.memory
-trace
]],
77 [[failures
]], [[full
]]]])
78 b4_define_flag_if([lac
])
79 m4_define([b4_lac_flag
],
80 [m4_if(b4_percent_define_get([[parse
.lac
]]),
81 [none
], [[0]], [[1]])])
83 ## ---------------- ##
85 ## ---------------- ##
88 m4_define_default([b4_stack_depth_max
], [10000])
89 m4_define_default([b4_stack_depth_init
], [200])
92 # b4_yyerror_arg_loc_if(ARG)
93 # --------------------------
94 # Expand ARG iff yyerror is to be given a location as argument.
95 m4_define([b4_yyerror_arg_loc_if
],
96 [b4_locations_if([m4_case(b4_pure_flag
,
97 [1], [m4_ifset([b4_parse_param
], [$
1])],
102 # Arguments passed to yyerror: user args plus yylloc.
103 m4_define([b4_yyerror_args
],
104 [b4_yyerror_arg_loc_if([&yylloc
, ])dnl
105 m4_ifset([b4_parse_param
], [b4_args(b4_parse_param
), ])])
113 # b4_int_type(MIN, MAX)
114 # ---------------------
115 # Return the smallest int type able to handle numbers ranging from
116 # MIN to MAX (included). Overwrite the version from c.m4, which
117 # uses only C89 types, so that the user can override the shorter
118 # types, and so that pre-C89 compilers are handled correctly.
119 m4_define([b4_int_type
],
120 [m4_if(b4_ints_in($@
, [0], [255]), [1], [yytype_uint8
],
121 b4_ints_in($@
, [-128], [127]), [1], [yytype_int8
],
123 b4_ints_in($@
, [0], [65535]), [1], [yytype_uint16
],
124 b4_ints_in($@
, [-32768], [32767]), [1], [yytype_int16
],
126 m4_eval([0 <= $
1]), [1], [unsigned],
130 # b4_state_num_type(MIN, MAX)
131 # ---------------------------
132 # Likewise, but prefer 'int' to 'unsigned' for large integers.
133 m4_define([b4_state_num_type
],
134 [m4_if(b4_ints_in($@
, [0], [255]), [1], [yytype_uint8
],
135 b4_ints_in($@
, [-128], [127]), [1], [yytype_int8
],
137 b4_ints_in($@
, [0], [65535]), [1], [yytype_uint16
],
138 b4_ints_in($@
, [-32768], [32767]), [1], [yytype_int16
],
143 ## ----------------- ##
144 ## Semantic Values. ##
145 ## ----------------- ##
148 # b4_lhs_value(SYMBOL-NUM, [TYPE])
149 # --------------------------------
151 m4_define([b4_lhs_value
],
152 [b4_symbol_value(yyval
, [$
1], [$
2])])
155 # b4_rhs_value(RULE-LENGTH, POS, [SYMBOL-NUM], [TYPE])
156 # ----------------------------------------------------
158 m4_define([b4_rhs_value
],
159 [b4_symbol_value([yyvsp@
{b4_subtract([$
2], [$
1])@
}], [$
3], [$
4])])
169 m4_define([b4_lhs_location
],
173 # b4_rhs_location(RULE-LENGTH, POS)
174 # ---------------------------------
175 # Expansion of @POS, where the current rule has RULE-LENGTH symbols
177 m4_define([b4_rhs_location
],
178 [(yylsp@
{b4_subtract([$
2], [$
1])@
})])
185 # b4_declare_scanner_communication_variables
186 # ------------------------------------------
187 # Declare the variables that are global, or local to YYPARSE if
189 m4_define([b4_declare_scanner_communication_variables
], [[
190 /* The lookahead symbol. */
194 /* The semantic value of the lookahead symbol. */
195 /* Default value used for initialization, for pacifying older GCCs
196 or non-GCC compilers. */
197 YY_INITIAL_VALUE (static YYSTYPE yyval_default
;)
198 YYSTYPE yylval
YY_INITIAL_VALUE (= yyval_default
);]b4_locations_if([[
200 /* Location data for the lookahead symbol. */
201 static YYLTYPE yyloc_default
]b4_yyloc_default
[;
202 YYLTYPE yylloc
= yyloc_default
;]])],
203 [[/* The semantic value of the lookahead symbol. */
204 YYSTYPE yylval
;]b4_locations_if([[
205 /* Location data for the lookahead symbol. */
206 YYLTYPE yylloc
]b4_yyloc_default
[;]])[
207 /* Number of syntax errors so far. */
211 # b4_declare_parser_state_variables
212 # ---------------------------------
213 # Declare all the variables that are needed to maintain the parser state
214 # between calls to yypush_parse.
215 m4_define([b4_declare_parser_state_variables
], [b4_pure_if([[
216 /* Number of syntax errors so far. */
220 /* Number of tokens to shift before error messages enabled. */
223 /* The stacks and their tools:
224 'yyss': related to states.
225 'yyvs': related to semantic values.]b4_locations_if([[
226 'yyls': related to locations.]])[
228 Refer to the stacks through separate pointers, to allow yyoverflow
229 to reallocate them elsewhere. */
231 /* The state stack. */
232 yy_state_num yyssa
[YYINITDEPTH
];
236 /* The semantic value stack. */
237 YYSTYPE yyvsa
[YYINITDEPTH
];
239 YYSTYPE
*yyvsp
;]b4_locations_if([[
241 /* The location stack. */
242 YYLTYPE yylsa
[YYINITDEPTH
];
246 /* The locations where the error started and ended. */
247 YYLTYPE yyerror_range
[3];]])[
249 YYSIZE_T yystacksize
;]b4_lac_if([[
251 yy_state_num yyesa@
{]b4_percent_define_get([[parse
.lac
.es
-capacity
-initial
]])[@
};
253 YYSIZE_T yyes_capacity
;]])])
256 # _b4_declare_yyparse_push
257 # ------------------------
258 # Declaration of yyparse (and dependencies) when using the push parser
259 # (including in pull mode).
260 m4_define([_b4_declare_yyparse_push
],
261 [[#ifndef YYPUSH_MORE_DEFINED
262 # define YYPUSH_MORE_DEFINED
263 enum { YYPUSH_MORE
= 4 };
266 typedef struct ]b4_prefix
[pstate
]b4_prefix
[pstate
;
268 ]b4_pull_if([b4_function_declare([b4_prefix
[parse
]], [[int]], b4_parse_param
)
269 ])b4_function_declare([b4_prefix
[push_parse
]], [[int]],
270 [[b4_prefix
[pstate
*ps
]], [[ps
]]]b4_pure_if([,
271 [[[int pushed_char
]], [[pushed_char
]]],
272 [[b4_api_PREFIX
[STYPE
const *pushed_val
]], [[pushed_val
]]]b4_locations_if([,
273 [[b4_api_PREFIX
[LTYPE
*pushed_loc
]], [[pushed_loc
]]]])])m4_ifset([b4_parse_param
], [,
275 b4_pull_if([b4_function_declare([b4_prefix
[pull_parse
]], [[int]],
276 [[b4_prefix
[pstate
*ps
]], [[ps
]]]m4_ifset([b4_parse_param
], [,
278 b4_function_declare([b4_prefix
[pstate_new
]], [b4_prefix
[pstate
*]],
280 b4_function_declare([b4_prefix
[pstate_delete
]], [[void]],
281 [[b4_prefix
[pstate
*ps
]], [[ps
]]])dnl
284 # _b4_declare_yyparse
285 # -------------------
286 # When not the push parser.
287 m4_define([_b4_declare_yyparse
],
288 [b4_function_declare(b4_prefix
[parse
], [int], b4_parse_param
)])
293 m4_define([b4_declare_yyparse
],
294 [b4_push_if([_b4_declare_yyparse_push
],
295 [_b4_declare_yyparse
])[]dnl
299 # b4_shared_declarations
300 # ----------------------
301 # Declaration that might either go into the header (if --defines)
302 # or open coded in the parser body.
303 m4_define([b4_shared_declarations
],
304 [b4_cpp_guard_open([b4_spec_header_file
])[
306 ]b4_percent_code_get([[requires
]])[
307 ]b4_token_enums_defines
[
308 ]b4_declare_yylstype
[
310 ]b4_percent_code_get([[provides
]])[
311 ]b4_cpp_guard_close([b4_spec_header_file
])[]dnl
315 # b4_header_include_if(IF-TRUE, IF-FALSE)
316 # ---------------------------------------
317 # Run IF-TRUE if we generate an output file and api.header.include
319 m4_define([b4_header_include_if
],
320 [m4_ifval(m4_quote(b4_spec_header_file
),
321 [b4_percent_define_ifdef([[api
.header
.include
]],
326 m4_if(b4_spec_header_file
, [[y
.tab
.h
]],
327 [b4_percent_define_default([[api
.header
.include
]],
328 [["@basename(]b4_spec_header_file[@)"]])])
339 ]b4_output_begin([b4_spec_header_file
])[
340 ]b4_copyright([Bison interface
for Yacc
-like parsers in C
])[
342 ]b4_shared_declarations
[
346 b4_output_begin([b4_parser_file_name
])[
347 ]b4_copyright([Bison implementation
for Yacc
-like parsers in C
])[
348 /* C LALR(1) parser skeleton written by Richard Stallman, by
349 simplifying the original so-called "semantic" parser. */
351 /* All symbols defined below should begin with yy or YY, to avoid
352 infringing on user name space. This should be done even for local
353 variables, as they might otherwise be expanded by user macros.
354 There are some unavoidable exceptions within include files to
355 define necessary library symbols; they are noted "INFRINGES ON
356 USER NAME SPACE" below. */
360 ]b4_percent_code_get([[top
]])[]dnl
361 m4_if(b4_api_prefix
, [yy
], [],
362 [[/* Substitute the type names. */
363 #define YYSTYPE ]b4_api_PREFIX[STYPE]b4_locations_if([[
364 #define YYLTYPE ]b4_api_PREFIX[LTYPE]])])[
365 ]m4_if(b4_prefix
, [yy
], [],
366 [[/* Substitute the variable and function names. */]b4_pull_if([[
367 #define yyparse ]b4_prefix[parse]])b4_push_if([[
368 #define yypush_parse ]b4_prefix[push_parse]b4_pull_if([[
369 #define yypull_parse ]b4_prefix[pull_parse]])[
370 #define yypstate_new ]b4_prefix[pstate_new
371 #define yypstate_delete ]b4_prefix[pstate_delete
372 #define yypstate ]b4_prefix[pstate]])[
373 #define yylex ]b4_prefix[lex
374 #define yyerror ]b4_prefix[error
375 #define yydebug ]b4_prefix[debug
376 #define yynerrs ]b4_prefix[nerrs
378 #define yylval ]b4_prefix[lval
379 #define yychar ]b4_prefix[char]b4_locations_if([[
380 #define yylloc ]b4_prefix[lloc]])]))[
382 ]b4_user_pre_prologue
[
385 /* Enabling verbose error messages. */
386 #ifdef YYERROR_VERBOSE
387 # undef YYERROR_VERBOSE
388 # define YYERROR_VERBOSE 1
390 # define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
393 ]b4_header_include_if([[#include ]b4_percent_define_get([[api.header.include]])],
394 [m4_ifval(m4_quote(b4_spec_header_file
),
395 [/* Use api.header.include to #include this header
396 instead of duplicating it here. */
397 ])b4_shared_declarations
])[
399 ]b4_user_post_prologue
[
400 ]b4_percent_code_get
[]dnl
407 typedef YYTYPE_UINT8 yytype_uint8
;
409 typedef unsigned char yytype_uint8
;
413 typedef YYTYPE_INT8 yytype_int8
;
415 typedef signed char yytype_int8
;
419 typedef YYTYPE_UINT16 yytype_uint16
;
421 typedef unsigned short yytype_uint16
;
425 typedef YYTYPE_INT16 yytype_int16
;
427 typedef short yytype_int16
;
431 # ifdef __SIZE_TYPE__
432 # define YYSIZE_T __SIZE_TYPE__
433 # elif defined size_t
434 # define YYSIZE_T size_t
435 # elif ! defined YYSIZE_T
436 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
437 # define YYSIZE_T size_t
439 # define YYSIZE_T unsigned
443 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
447 typedef ]b4_state_num_type(0, m4_eval(b4_states_number
- 1))[ yy_state_num
;
451 # if defined YYENABLE_NLS && YYENABLE_NLS
453 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
454 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
458 # define YY_(Msgid) Msgid
462 ]b4_attribute_define
[
464 ]b4_parse_assert_if([[#ifdef NDEBUG
465 # define YY_ASSERT(E) ((void) (0 && (E)))
467 # include <assert.h> /* INFRINGES ON USER NAME SPACE */
468 # define YY_ASSERT(E) assert (E)
471 [[#define YY_ASSERT(E) ((void) (0 && (E)))]])[
473 #if ]b4_lac_if([[1]], [[! defined yyoverflow || YYERROR_VERBOSE]])[
475 /* The parser invokes alloca or malloc; define the necessary symbols. */]dnl
476 b4_push_if([], [b4_lac_if([], [[
478 # ifdef YYSTACK_USE_ALLOCA
479 # if YYSTACK_USE_ALLOCA
481 # define YYSTACK_ALLOC __builtin_alloca
482 # elif defined __BUILTIN_VA_ARG_INCR
483 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
485 # define YYSTACK_ALLOC __alloca
486 # elif defined _MSC_VER
487 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
488 # define alloca _alloca
490 # define YYSTACK_ALLOC alloca
491 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
492 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
493 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
494 # ifndef EXIT_SUCCESS
495 # define EXIT_SUCCESS 0
502 # ifdef YYSTACK_ALLOC
503 /* Pacify GCC's 'empty if-body' warning. */
504 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
505 # ifndef YYSTACK_ALLOC_MAXIMUM
506 /* The OS might guarantee only one guard page at the bottom of the stack,
507 and a page size can be as small as 4096 bytes. So we cannot safely
508 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
509 to allow for a few compiler-allocated temporary stack slots. */
510 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
513 # define YYSTACK_ALLOC YYMALLOC
514 # define YYSTACK_FREE YYFREE
515 # ifndef YYSTACK_ALLOC_MAXIMUM
516 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
518 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
519 && ! ((defined YYMALLOC || defined malloc) \
520 && (defined YYFREE || defined free)))
521 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
522 # ifndef EXIT_SUCCESS
523 # define EXIT_SUCCESS 0
527 # define YYMALLOC malloc
528 # if ! defined malloc && ! defined EXIT_SUCCESS
529 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
534 # if ! defined free && ! defined EXIT_SUCCESS
535 void free (void *); /* INFRINGES ON USER NAME SPACE */
539 # define YYCOPY_NEEDED 1]])[
540 #endif]b4_lac_if([], [[ /* ! defined yyoverflow || YYERROR_VERBOSE */]])[
543 #if (! defined yyoverflow \
544 && (! defined __cplusplus \
545 || (]b4_locations_if([[defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL \
546 && ]])[defined ]b4_api_PREFIX[STYPE_IS_TRIVIAL && ]b4_api_PREFIX[STYPE_IS_TRIVIAL)))
548 /* A type that is properly aligned for any stack member. */
551 yy_state_num yyss_alloc
;
552 YYSTYPE yyvs_alloc
;]b4_locations_if([
553 YYLTYPE yyls_alloc
;])[
556 /* The size of the maximum gap between one aligned stack and the next. */
557 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
559 /* The size of an array large to enough to hold all stacks, each with
562 [# define YYSTACK_BYTES(N) \
563 ((N) * (sizeof (yy_state_num) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
564 + 2 * YYSTACK_GAP_MAXIMUM)],
565 [# define YYSTACK_BYTES(N) \
566 ((N) * (sizeof (yy_state_num) + sizeof (YYSTYPE)) \
567 + YYSTACK_GAP_MAXIMUM)])[
569 # define YYCOPY_NEEDED 1
571 /* Relocate STACK from its old location to the new one. The
572 local variables YYSIZE and YYSTACKSIZE give the old and new number of
573 elements in the stack, and YYPTR gives the new location of the
574 stack. Advance YYPTR to a properly aligned location for the next
576 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
579 YYSIZE_T yynewbytes; \
580 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
581 Stack = &yyptr->Stack_alloc; \
582 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
583 yyptr += yynewbytes / sizeof (*yyptr); \
589 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
590 /* Copy COUNT objects from SRC to DST. The source and destination do
593 # if defined __GNUC__ && 1 < __GNUC__
594 # define YYCOPY(Dst, Src, Count) \
595 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
597 # define YYCOPY(Dst, Src, Count) \
601 for (yyi = 0; yyi < (Count); yyi++) \
602 (Dst)[yyi] = (Src)[yyi]; \
607 #endif /* !YYCOPY_NEEDED */
609 /* YYFINAL -- State number of the termination state. */
610 #define YYFINAL ]b4_final_state_number[
611 /* YYLAST -- Last index in YYTABLE. */
612 #define YYLAST ]b4_last[
614 /* YYNTOKENS -- Number of terminals. */
615 #define YYNTOKENS ]b4_tokens_number[
616 /* YYNNTS -- Number of nonterminals. */
617 #define YYNNTS ]b4_nterms_number[
618 /* YYNRULES -- Number of rules. */
619 #define YYNRULES ]b4_rules_number[
620 /* YYNSTATES -- Number of states. */
621 #define YYNSTATES ]b4_states_number[
623 #define YYUNDEFTOK ]b4_undef_token_number[
624 #define YYMAXUTOK ]b4_user_token_number_max[
627 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
628 as returned by yylex, with out-of-bounds checking. */
629 ]b4_api_token_raw_if(dnl
630 [[#define YYTRANSLATE(YYX) (YYX)]],
631 [[#define YYTRANSLATE(YYX) \
632 ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
634 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
635 as returned by yylex. */
636 static const ]b4_int_type_for([b4_translate
])[ yytranslate
[] =
641 #if ]b4_api_PREFIX[DEBUG
642 ]b4_integral_parser_table_define([rline
], [b4_rline
],
643 [[YYRLINE
[YYN
] -- Source line where rule number YYN was defined
.]])[
646 #if ]b4_api_PREFIX[DEBUG || YYERROR_VERBOSE || ]b4_token_table_flag[
647 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
648 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
649 static const char *const yytname
[] =
656 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
657 (internal) symbol number NUM (which must be that of a token). */
658 static const ]b4_int_type_for([b4_toknum
])[ yytoknum
[] =
664 #define YYPACT_NINF (]b4_pact_ninf[)
666 #define yypact_value_is_default(Yyn) \
667 ]b4_table_value_equals([[pact]], [[Yyn]], [b4_pact_ninf], [YYPACT_NINF])[
669 #define YYTABLE_NINF (]b4_table_ninf[)
671 #define yytable_value_is_error(Yyn) \
672 ]b4_table_value_equals([[table]], [[Yyn]], [b4_table_ninf], [YYTABLE_NINF])[
674 ]b4_parser_tables_define
[
676 #define yyerrok (yyerrstatus = 0)
677 #define yyclearin (yychar = YYEMPTY)
681 #define YYACCEPT goto yyacceptlab
682 #define YYABORT goto yyabortlab
683 #define YYERROR goto yyerrorlab
686 #define YYRECOVERING() (!!yyerrstatus)
688 #define YYBACKUP(Token, Value) \
690 if (yychar == YYEMPTY) \
694 YYPOPSTACK (yylen); \
695 yystate = *yyssp; \]b4_lac_if([[
696 YY_LAC_DISCARD ("YYBACKUP"); \
]])[
701 yyerror (]b4_yyerror_args
[YY_("syntax error: cannot back up")); \
706 /* Error token number */
708 #define YYERRCODE 256
711 ]b4_yylloc_default_define
[
712 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
715 /* Enable debugging if requested. */
716 #if ]b4_api_PREFIX[DEBUG
719 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
720 # define YYFPRINTF fprintf
723 # define YYDPRINTF(Args) \
729 ]b4_yy_location_print_define
[
731 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
735 YYFPRINTF (stderr, "%s ", Title); \
736 yy_symbol_print (stderr, \
737 Type, Value]b4_locations_if([, Location])[]b4_user_args[); \
738 YYFPRINTF (stderr, "\n"); \
742 ]b4_yy_symbol_print_define
[
744 /*------------------------------------------------------------------.
745 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
747 `------------------------------------------------------------------*/
749 ]b4_function_define([yy_stack_print
], [static void],
750 [[yy_state_num
*yybottom
], [yybottom
]],
751 [[yy_state_num
*yytop
], [yytop
]])[
753 YYFPRINTF (stderr
, "Stack now");
754 for (; yybottom
<= yytop
; yybottom
++)
755 YYFPRINTF (stderr
, " %u", (unsigned) *yybottom
);
756 YYFPRINTF (stderr
, "\n");
759 # define YY_STACK_PRINT(Bottom, Top) \
762 yy_stack_print ((Bottom), (Top)); \
766 /*------------------------------------------------.
767 | Report that the YYRULE is going to be reduced. |
768 `------------------------------------------------*/
770 ]b4_function_define([yy_reduce_print
], [static void],
771 [[yy_state_num
*yyssp
], [yyssp
]],
772 [[YYSTYPE
*yyvsp
], [yyvsp
]],
773 b4_locations_if([[[YYLTYPE
*yylsp
], [yylsp
]],
774 ])[[int yyrule
], [yyrule
]]m4_ifset([b4_parse_param
], [,
777 unsigned long yylno
= yyrline
[yyrule
];
778 int yynrhs
= yyr2
[yyrule
];
780 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
782 /* The symbols being reduced. */
783 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
785 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
786 yy_symbol_print (stderr
,
787 yystos
[yyssp
[yyi
+ 1 - yynrhs
]],
788 &]b4_rhs_value(yynrhs
, yyi
+ 1)[
789 ]b4_locations_if([, &]b4_rhs_location(yynrhs
, yyi
+ 1))[]dnl
791 YYFPRINTF (stderr
, "\n");
795 # define YY_REDUCE_PRINT(Rule) \
798 yy_reduce_print (yyssp, yyvsp, ]b4_locations_if([yylsp, ])[Rule]b4_user_args[); \
801 /* Nonzero means print parse trace. It is left uninitialized so that
802 multiple parsers can coexist. */
804 #else /* !]b4_api_PREFIX[DEBUG */
805 # define YYDPRINTF(Args)
806 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
807 # define YY_STACK_PRINT(Bottom, Top)
808 # define YY_REDUCE_PRINT(Rule)
809 #endif /* !]b4_api_PREFIX[DEBUG */
812 /* YYINITDEPTH -- initial size of the parser's stacks. */
814 # define YYINITDEPTH ]b4_stack_depth_init[
817 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
818 if the built-in stack extension method is used).
820 Do not make this value too large; the results are undefined if
821 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
822 evaluated with infinite-precision integer arithmetic. */
825 # define YYMAXDEPTH ]b4_stack_depth_max[
828 /* Given a state stack such that *YYBOTTOM is its bottom, such that
829 *YYTOP is either its top or is YYTOP_EMPTY to indicate an empty
830 stack, and such that *YYCAPACITY is the maximum number of elements it
831 can hold without a reallocation, make sure there is enough room to
832 store YYADD more elements. If not, allocate a new stack using
833 YYSTACK_ALLOC, copy the existing elements, and adjust *YYBOTTOM,
834 *YYTOP, and *YYCAPACITY to reflect the new capacity and memory
835 location. If *YYBOTTOM != YYBOTTOM_NO_FREE, then free the old stack
836 using YYSTACK_FREE. Return 0 if successful or if no reallocation is
837 required. Return 1 if memory is exhausted. */
839 yy_lac_stack_realloc (YYSIZE_T
*yycapacity
, YYSIZE_T yyadd
,
840 #if ]b4_api_PREFIX[DEBUG
841 char const *yydebug_prefix
,
842 char const *yydebug_suffix
,
844 yy_state_num
**yybottom
,
845 yy_state_num
*yybottom_no_free
,
846 yy_state_num
**yytop
, yy_state_num
*yytop_empty
)
848 YYSIZE_T yysize_old
=
849 (YYSIZE_T
) (*yytop
== yytop_empty
? 0 : *yytop
- *yybottom
+ 1);
850 YYSIZE_T yysize_new
= yysize_old
+ yyadd
;
851 if (*yycapacity
< yysize_new
)
853 YYSIZE_T yyalloc
= 2 * yysize_new
;
854 yy_state_num
*yybottom_new
;
855 /* Use YYMAXDEPTH for maximum stack size given that the stack
856 should never need to grow larger than the main state stack
857 needs to grow without LAC. */
858 if (YYMAXDEPTH
< yysize_new
)
860 YYDPRINTF ((stderr
, "%smax size exceeded%s", yydebug_prefix
,
864 if (YYMAXDEPTH
< yyalloc
)
865 yyalloc
= YYMAXDEPTH
;
867 (yy_state_num
*) YYSTACK_ALLOC (yyalloc
* sizeof *yybottom_new
);
870 YYDPRINTF ((stderr
, "%srealloc failed%s", yydebug_prefix
,
874 if (*yytop
!= yytop_empty
)
876 YYCOPY (yybottom_new
, *yybottom
, yysize_old
);
877 *yytop
= yybottom_new
+ (yysize_old
- 1);
879 if (*yybottom
!= yybottom_no_free
)
880 YYSTACK_FREE (*yybottom
);
881 *yybottom
= yybottom_new
;
882 *yycapacity
= yyalloc
;]m4_if(b4_percent_define_get([[parse
.lac
.memory
-trace
]]),
884 YYDPRINTF ((stderr
, "%srealloc to %lu%s", yydebug_prefix
,
885 (unsigned long) yyalloc
, yydebug_suffix
));]])[
890 /* Establish the initial context for the current lookahead if no initial
891 context is currently established.
893 We define a context as a snapshot of the parser stacks. We define
894 the initial context for a lookahead as the context in which the
895 parser initially examines that lookahead in order to select a
896 syntactic action. Thus, if the lookahead eventually proves
897 syntactically unacceptable (possibly in a later context reached via a
898 series of reductions), the initial context can be used to determine
899 the exact set of tokens that would be syntactically acceptable in the
900 lookahead's place. Moreover, it is the context after which any
901 further semantic actions would be erroneous because they would be
902 determined by a syntactically unacceptable token.
904 YY_LAC_ESTABLISH should be invoked when a reduction is about to be
905 performed in an inconsistent state (which, for the purposes of LAC,
906 includes consistent states that don't know they're consistent because
907 their default reductions have been disabled). Iff there is a
908 lookahead token, it should also be invoked before reporting a syntax
909 error. This latter case is for the sake of the debugging output.
911 For parse.lac=full, the implementation of YY_LAC_ESTABLISH is as
912 follows. If no initial context is currently established for the
913 current lookahead, then check if that lookahead can eventually be
914 shifted if syntactic actions continue from the current context.
915 Report a syntax error if it cannot. */
916 #define YY_LAC_ESTABLISH \
918 if (!yy_lac_established) \
920 YYDPRINTF ((stderr, \
921 "LAC: initial context established for %s\n", \
922 yytname[yytoken])); \
923 yy_lac_established = 1; \
925 int yy_lac_status = \
926 yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken); \
927 if (yy_lac_status == 2) \
928 goto yyexhaustedlab; \
929 if (yy_lac_status == 1) \
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) \
949 if (yy_lac_established) \
952 YYFPRINTF (stderr, "LAC: initial context discarded due to " \
954 yy_lac_established = 0; \
958 # define YY_LAC_DISCARD(Event) yy_lac_established = 0
961 /* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can
962 eventually (after perhaps some reductions) be shifted, return 1 if
963 not, or return 2 if memory is exhausted. As preconditions and
964 postconditions: *YYES_CAPACITY is the allocated size of the array to
965 which *YYES points, and either *YYES = YYESA or *YYES points to an
966 array allocated with YYSTACK_ALLOC. yy_lac may overwrite the
967 contents of either array, alter *YYES and *YYES_CAPACITY, and free
968 any old *YYES other than YYESA. */
970 yy_lac (yy_state_num
*yyesa
, yy_state_num
**yyes
,
971 YYSIZE_T
*yyes_capacity
, yy_state_num
*yyssp
, int yytoken
)
973 yy_state_num
*yyes_prev
= yyssp
;
974 yy_state_num
*yyesp
= yyes_prev
;
975 YYDPRINTF ((stderr
, "LAC: checking lookahead %s:", yytname
[yytoken
]));
976 if (yytoken
== YYUNDEFTOK
)
978 YYDPRINTF ((stderr
, " Always Err\n"));
983 int yyrule
= yypact
[*yyesp
];
984 if (yypact_value_is_default (yyrule
)
985 || (yyrule
+= yytoken
) < 0 || YYLAST
< yyrule
986 || yycheck
[yyrule
] != yytoken
)
988 yyrule
= yydefact
[*yyesp
];
991 YYDPRINTF ((stderr
, " Err\n"));
997 yyrule
= (int) yytable
[yyrule
];
998 if (yytable_value_is_error (yyrule
))
1000 YYDPRINTF ((stderr
, " Err\n"));
1005 YYDPRINTF ((stderr
, " S%d\n", yyrule
));
1011 YYSIZE_T yylen
= yyr2
[yyrule
];
1012 YYDPRINTF ((stderr
, " R%d", yyrule
- 1));
1013 if (yyesp
!= yyes_prev
)
1015 YYSIZE_T yysize
= (YYSIZE_T
) (yyesp
- *yyes
+ 1);
1028 yyesp
= yyes_prev
-= yylen
;
1033 const int yylhs
= yyr1
[yyrule
] - YYNTOKENS
;
1034 const int yyi
= yypgoto
[yylhs
] + (int) *yyesp
;
1035 yystate
= (0 <= yyi
&& yyi
<= YYLAST
&& yycheck
[yyi
] == *yyesp
1036 ? (int) yytable
[yyi
]
1037 : yydefgoto
[yylhs
]);
1039 if (yyesp
== yyes_prev
)
1042 *yyesp
= (yy_state_num
) yystate
;
1046 if (yy_lac_stack_realloc (yyes_capacity
, 1,
1047 #if ]b4_api_PREFIX[DEBUG
1050 yyes
, yyesa
, &yyesp
, yyes_prev
))
1052 YYDPRINTF ((stderr
, "\n"));
1055 *++yyesp
= (yy_state_num
) yystate
;
1057 YYDPRINTF ((stderr
, " G%d", yystate
));
1066 # if defined __GLIBC__ && defined _STRING_H
1067 # define yystrlen strlen
1069 /* Return the length of YYSTR. */
1070 ]b4_function_define([yystrlen
], [static YYSIZE_T
],
1071 [[const char *yystr
], [yystr
]])[
1074 for (yylen
= 0; yystr
[yylen
]; yylen
++)
1082 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1083 # define yystpcpy stpcpy
1085 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1087 ]b4_function_define([yystpcpy
], [static char *],
1088 [[char *yydest
], [yydest
]], [[const char *yysrc
], [yysrc
]])[
1091 const char *yys
= yysrc
;
1093 while ((*yyd
++ = *yys
++) != '\0')
1102 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1103 quotes and backslashes, so that it's suitable for yyerror. The
1104 heuristic is that double-quoting is unnecessary unless the string
1105 contains an apostrophe, a comma, or backslash (other than
1106 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1107 null, do not copy; instead, return the length of what the result
1110 yytnamerr (char *yyres
, const char *yystr
)
1115 char const *yyp
= yystr
;
1122 goto do_not_strip_quotes
;
1126 goto do_not_strip_quotes
;
1142 do_not_strip_quotes
: ;
1146 return yystrlen (yystr
);
1148 return (YYSIZE_T
) (yystpcpy (yyres
, yystr
) - yyres
);
1152 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1153 about the unexpected token YYTOKEN for the state stack whose top is
1154 YYSSP.]b4_lac_if([[ In order to see if a particular token T is a
1155 valid looakhead, invoke yy_lac (YYESA, YYES, YYES_CAPACITY, YYSSP, T).]])[
1157 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1158 not large enough to hold the message. In that case, also set
1159 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1160 required number of bytes is too large to store]b4_lac_if([[ or if
1161 yy_lac returned 2]])[. */
1163 yysyntax_error (YYSIZE_T
*yymsg_alloc
, char **yymsg
,
1164 ]b4_lac_if([[yy_state_num
*yyesa
, yy_state_num
**yyes
,
1165 YYSIZE_T
*yyes_capacity
, ]])[yy_state_num
*yyssp
, int yytoken
)
1167 YYSIZE_T yysize0
= yytnamerr (YY_NULLPTR
, yytname
[yytoken
]);
1168 YYSIZE_T yysize
= yysize0
;
1169 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1170 /* Internationalized format string. */
1171 const char *yyformat
= YY_NULLPTR
;
1172 /* Arguments of yyformat. */
1173 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1174 /* Number of reported tokens (one for the "unexpected", one per
1178 /* There are many possibilities here to consider:
1179 - If this state is a consistent state with a default action, then
1180 the only way this function was invoked is if the default action
1181 is an error action. In that case, don't check for expected
1182 tokens because there are none.
1183 - The only way there can be no lookahead present (in yychar) is if
1184 this state is a consistent state with a default action. Thus,
1185 detecting the absence of a lookahead is sufficient to determine
1186 that there is no unexpected or expected token to report. In that
1187 case, just report a simple "syntax error".
1188 - Don't assume there isn't a lookahead just because this state is a
1189 consistent state with a default action. There might have been a
1190 previous inconsistent state, consistent state with a non-default
1191 action, or user semantic action that manipulated yychar.]b4_lac_if([[
1192 In the first two cases, it might appear that the current syntax
1193 error should have been detected in the previous state when yy_lac
1194 was invoked. However, at that time, there might have been a
1195 different syntax error that discarded a different initial context
1196 during error recovery, leaving behind the current lookahead.]], [[
1197 - Of course, the expected token list depends on states to have
1198 correct lookahead information, and it depends on the parser not
1199 to perform extra reductions after fetching a lookahead from the
1200 scanner and before detecting a syntax error. Thus, state merging
1201 (from LALR or IELR) and default reductions corrupt the expected
1202 token list. However, the list is correct for canonical LR with
1203 one exception: it will still contain any token that will not be
1204 accepted due to an error action in a later state.]])[
1206 if (yytoken
!= YYEMPTY
)
1208 int yyn
= yypact
[*yyssp
];]b4_lac_if([[
1209 YYDPRINTF ((stderr
, "Constructing syntax error message\n"));]])[
1210 yyarg
[yycount
++] = yytname
[yytoken
];
1211 if (!yypact_value_is_default (yyn
))
1215 for (yyx
= 0; yyx
< YYNTOKENS
; ++yyx
)
1216 if (yyx
!= YYTERROR
&& yyx
!= YYUNDEFTOK
)
1219 int yy_lac_status
= yy_lac (yyesa
, yyes
, yyes_capacity
,
1221 if (yy_lac_status
== 2)
1223 if (yy_lac_status
== 1)
1226 /* Start YYX at -YYN if negative to avoid negative indexes in
1227 YYCHECK. In other words, skip the first -YYN actions for
1228 this state because they are default actions. */
1229 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1230 /* Stay within bounds of both yycheck and yytname. */
1231 int yychecklim
= YYLAST
- yyn
+ 1;
1232 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1235 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1236 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
1237 && !yytable_value_is_error (yytable
[yyx
+ yyn
]))
1239 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1245 yyarg
[yycount
++] = yytname
[yyx
];
1247 YYSIZE_T yysize1
= yysize
+ yytnamerr (YY_NULLPTR
, yytname
[yyx
]);
1248 if (yysize
<= yysize1
&& yysize1
<= YYSTACK_ALLOC_MAXIMUM
)
1255 # if ]b4_api_PREFIX[DEBUG
1257 YYFPRINTF (stderr
, "No expected tokens.\n");
1263 # define YYCASE_(N, S) \
1267 default: /* Avoid compiler warnings. */
1268 YYCASE_(0, YY_("syntax error"));
1269 YYCASE_(1, YY_("syntax error, unexpected %s"));
1270 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1271 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1272 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1273 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1278 YYSIZE_T yysize1
= yysize
+ yystrlen (yyformat
);
1279 if (yysize
<= yysize1
&& yysize1
<= YYSTACK_ALLOC_MAXIMUM
)
1285 if (*yymsg_alloc
< yysize
)
1287 *yymsg_alloc
= 2 * yysize
;
1288 if (! (yysize
<= *yymsg_alloc
1289 && *yymsg_alloc
<= YYSTACK_ALLOC_MAXIMUM
))
1290 *yymsg_alloc
= YYSTACK_ALLOC_MAXIMUM
;
1294 /* Avoid sprintf, as that infringes on the user's name space.
1295 Don't have undefined behavior even if the translation
1296 produced a string with the wrong number of "%s"s. */
1300 while ((*yyp
= *yyformat
) != '\0')
1301 if (*yyp
== '%' && yyformat
[1] == 's' && yyi
< yycount
)
1303 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1314 #endif /* YYERROR_VERBOSE */
1316 ]b4_yydestruct_define
[
1320 b4_declare_scanner_communication_variables
])[]b4_push_if([[
1323 {]b4_declare_parser_state_variables
[
1324 /* Used to determine if this is the first time this instance has
1327 };]b4_pure_if([], [[
1329 static char yypstate_allocated
= 0;]])b4_pull_if([
1331 b4_function_define([[yyparse
]], [[int]], b4_parse_param
)[
1333 return yypull_parse (YY_NULLPTR
]m4_ifset([b4_parse_param
],
1334 [[, ]b4_args(b4_parse_param
)])[);
1337 ]b4_function_define([[yypull_parse
]], [[int]],
1338 [[[yypstate
*yyps
]], [[yyps
]]]m4_ifset([b4_parse_param
], [,
1340 {]b4_pure_if([b4_locations_if([[
1341 static YYLTYPE yyloc_default
][]b4_yyloc_default
[;
1342 YYLTYPE yylloc
= yyloc_default
;]])])[
1343 yypstate
*yyps_local
;
1348 yyps_local
= yypstate_new ();
1351 yyerror (]b4_yyerror_args
[YY_("memory exhausted"));]], [[
1352 if (!yypstate_allocated
)
1353 yyerror (]b4_yyerror_args
[YY_("memory exhausted"));]])[
1360 int ]])[yychar
= ]b4_lex
[;
1362 yypush_parse (yyps_local
]b4_pure_if([[, yychar
, &yylval
]b4_locations_if([[, &yylloc
]])])m4_ifset([b4_parse_param
], [, b4_args(b4_parse_param
)])[);
1363 } while (yystatus
== YYPUSH_MORE
);
1365 yypstate_delete (yyps_local
);
1369 /* Initialize the parser data structure. */
1370 ]b4_function_define([[yypstate_new
]], [[yypstate
*]])[
1372 yypstate
*yyps
;]b4_pure_if([], [[
1373 if (yypstate_allocated
)
1374 return YY_NULLPTR
;]])[
1375 yyps
= (yypstate
*) malloc (sizeof *yyps
);
1378 yyps
->yynew
= 1;]b4_pure_if([], [[
1379 yypstate_allocated
= 1;]])[
1383 ]b4_function_define([[yypstate_delete
]], [[void]],
1384 [[[yypstate
*yyps
]], [[yyps
]]])[
1389 /* If the stack was reallocated but the parse did not complete, then the
1390 stack still needs to be freed. */
1391 if (!yyps
->yynew
&& yyps
->yyss
!= yyps
->yyssa
)
1392 YYSTACK_FREE (yyps
->yyss
);
1394 if (!yyps
->yynew
&& yyps
->yyes
!= yyps
->yyesa
)
1395 YYSTACK_FREE (yyps
->yyes
);]])[
1396 free (yyps
);]b4_pure_if([], [[
1397 yypstate_allocated
= 0;]])[
1401 #define ]b4_prefix[nerrs yyps->]b4_prefix[nerrs]])[
1402 #define yystate yyps->yystate
1403 #define yyerrstatus yyps->yyerrstatus
1404 #define yyssa yyps->yyssa
1405 #define yyss yyps->yyss
1406 #define yyssp yyps->yyssp
1407 #define yyvsa yyps->yyvsa
1408 #define yyvs yyps->yyvs
1409 #define yyvsp yyps->yyvsp]b4_locations_if([[
1410 #define yylsa yyps->yylsa
1411 #define yyls yyps->yyls
1412 #define yylsp yyps->yylsp
1413 #define yyerror_range yyps->yyerror_range]])[
1414 #define yystacksize yyps->yystacksize]b4_lac_if([[
1415 #define yyesa yyps->yyesa
1416 #define yyes yyps->yyes
1417 #define yyes_capacity yyps->yyes_capacity]])[
1424 ]b4_function_define([[yypush_parse
]], [[int]],
1425 [[[yypstate
*yyps
]], [[yyps
]]]b4_pure_if([,
1426 [[[int yypushed_char
]], [[yypushed_char
]]],
1427 [[[YYSTYPE
const *yypushed_val
]], [[yypushed_val
]]]b4_locations_if([,
1428 [[[YYLTYPE
*yypushed_loc
]], [[yypushed_loc
]]]])])m4_ifset([b4_parse_param
], [,
1429 b4_parse_param
]))], [[
1436 ]b4_function_define([yyparse
], [int], b4_parse_param
)])[
1437 {]b4_pure_if([b4_declare_scanner_communication_variables
1438 ])b4_push_if([b4_pure_if([], [[
1439 int yypushed_char
= yychar
;
1440 YYSTYPE yypushed_val
= yylval
;]b4_locations_if([[
1441 YYLTYPE yypushed_loc
= yylloc
;]])
1443 [b4_declare_parser_state_variables
1445 int yy_lac_established
= 0;]])[
1448 /* Lookahead token as an internal (translated) token number. */
1450 /* The variables used to return semantic value and location from the
1452 YYSTYPE yyval
;]b4_locations_if([[
1456 /* Buffer for error messages, and its allocated size. */
1458 char *yymsg
= yymsgbuf
;
1459 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1462 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)]b4_locations_if([, yylsp -= (N)])[)
1464 /* The number of symbols on the RHS of the reduced rule.
1465 Keep to zero when no symbol should be popped. */
1466 int yylen
= 0;]b4_push_if([[
1470 yyn
= yypact
[yystate
];
1471 goto yyread_pushed_token
;
1474 yyssp
= yyss
= yyssa
;
1475 yyvsp
= yyvs
= yyvsa
;]b4_locations_if([[
1476 yylsp
= yyls
= yylsa
;]])[
1477 yystacksize
= YYINITDEPTH
;]b4_lac_if([[
1480 yyes_capacity
= sizeof yyesa
/ sizeof *yyes
;
1481 if (YYMAXDEPTH
< yyes_capacity
)
1482 yyes_capacity
= YYMAXDEPTH
;]])[
1484 YYDPRINTF ((stderr
, "Starting parse\n"));
1489 yychar
= YYEMPTY
; /* Cause a token to be read. */
1490 ]m4_ifdef([b4_initial_action
], [
1491 b4_dollar_pushdef([m4_define([b4_dollar_dollar_used
])yylval
], [], [],
1492 [b4_push_if([b4_pure_if([*])yypushed_loc
], [yylloc
])])dnl
1493 b4_user_initial_action
1494 b4_dollar_popdef
[]dnl
1495 m4_ifdef([b4_dollar_dollar_used
],[[ yyvsp
[0] = yylval
;
1497 b4_locations_if([[ yylsp
[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc
], [yylloc
])[;
1502 /*------------------------------------------------------------.
1503 | yynewstate -- push a new state, which is found in yystate. |
1504 `------------------------------------------------------------*/
1506 /* In all cases, when you get here, the value and location stacks
1507 have just been pushed. So pushing a state here evens the stacks. */
1511 /*--------------------------------------------------------------------.
1512 | yynewstate -- set current state (the top of the stack) to yystate. |
1513 `--------------------------------------------------------------------*/
1515 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1516 YY_ASSERT (0 <= yystate
&& yystate
< YYNSTATES
);
1517 *yyssp
= (yy_state_num
) yystate
;
1519 if (yyss
+ yystacksize
- 1 <= yyssp
)
1520 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1521 goto yyexhaustedlab
;
1524 /* Get the current used size of the three stacks, in elements. */
1525 YYSIZE_T yysize
= (YYSIZE_T
) (yyssp
- yyss
+ 1);
1527 # if defined yyoverflow
1529 /* Give user a chance to reallocate the stack. Use copies of
1530 these so that the &'s don't force the real ones into
1532 yy_state_num
*yyss1
= yyss
;
1533 YYSTYPE
*yyvs1
= yyvs
;]b4_locations_if([
1534 YYLTYPE
*yyls1
= yyls
;])[
1536 /* Each stack pointer address is followed by the size of the
1537 data in use in that stack, in bytes. This used to be a
1538 conditional around just the two extra args, but that might
1539 be undefined if yyoverflow is a macro. */
1540 yyoverflow (YY_("memory exhausted"),
1541 &yyss1
, yysize
* sizeof (*yyssp
),
1542 &yyvs1
, yysize
* sizeof (*yyvsp
),]b4_locations_if([
1543 &yyls1
, yysize
* sizeof (*yylsp
),])[
1546 yyvs
= yyvs1
;]b4_locations_if([
1549 # else /* defined YYSTACK_RELOCATE */
1550 /* Extend the stack our own way. */
1551 if (YYMAXDEPTH
<= yystacksize
)
1552 goto yyexhaustedlab
;
1554 if (YYMAXDEPTH
< yystacksize
)
1555 yystacksize
= YYMAXDEPTH
;
1558 yy_state_num
*yyss1
= yyss
;
1559 union yyalloc
*yyptr
=
1560 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1562 goto yyexhaustedlab
;
1563 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1564 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);]b4_locations_if([
1565 YYSTACK_RELOCATE (yyls_alloc
, yyls
);])[
1566 # undef YYSTACK_RELOCATE
1568 YYSTACK_FREE (yyss1
);
1572 yyssp
= yyss
+ yysize
- 1;
1573 yyvsp
= yyvs
+ yysize
- 1;]b4_locations_if([
1574 yylsp
= yyls
+ yysize
- 1;])[
1576 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1577 (unsigned long) yystacksize
));
1579 if (yyss
+ yystacksize
- 1 <= yyssp
)
1582 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1584 if (yystate
== YYFINAL
)
1594 /* Do appropriate processing given the current state. Read a
1595 lookahead token if we need one and don't already have one. */
1597 /* First try to decide what to do without reference to lookahead token. */
1598 yyn
= yypact
[yystate
];
1599 if (yypact_value_is_default (yyn
))
1602 /* Not known => get a lookahead token if don't already have one. */
1604 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1605 if (yychar
== YYEMPTY
)
1608 {]b4_use_push_for_pull_if([], [[
1609 YYDPRINTF ((stderr
, "Return for a new token:\n"));]])[
1610 yyresult
= YYPUSH_MORE
;
1613 yyps
->yynew
= 0;]b4_pure_if([], [[
1614 /* Restoring the pushed token is only necessary for the first
1615 yypush_parse invocation since subsequent invocations don't overwrite
1616 it before jumping to yyread_pushed_token. */
1617 yychar
= yypushed_char
;
1618 yylval
= yypushed_val
;]b4_locations_if([[
1619 yylloc
= yypushed_loc
;]])])[
1620 yyread_pushed_token
:]])[
1621 YYDPRINTF ((stderr
, "Reading a token: "));]b4_push_if([b4_pure_if([[
1622 yychar
= yypushed_char
;
1624 yylval
= *yypushed_val
;]b4_locations_if([[
1626 yylloc
= *yypushed_loc
;]])])], [[
1627 yychar
= ]b4_lex
[;]])[
1630 if (yychar
<= YYEOF
)
1632 yychar
= yytoken
= YYEOF
;
1633 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1637 yytoken
= YYTRANSLATE (yychar
);
1638 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1641 /* If the proper action on seeing token YYTOKEN is to reduce or to
1642 detect an error, take that action. */
1644 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)]b4_lac_if([[
1650 yyn
= (int) yytable
[yyn
];
1653 if (yytable_value_is_error (yyn
))
1654 goto yyerrlab
;]b4_lac_if([[
1655 YY_LAC_ESTABLISH
;]])[
1660 /* Count tokens shifted since error; after three, turn off error
1665 /* Shift the lookahead token. */
1666 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1668 /* Discard the shifted token. */
1669 yychar
= YYEMPTY
;]b4_lac_if([[
1670 YY_LAC_DISCARD ("shift");]])[
1673 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1675 YY_IGNORE_MAYBE_UNINITIALIZED_END
]b4_locations_if([
1676 *++yylsp
= yylloc
;])[
1680 /*-----------------------------------------------------------.
1681 | yydefault -- do the default action for the current state. |
1682 `-----------------------------------------------------------*/
1684 yyn
= yydefact
[yystate
];
1690 /*-----------------------------.
1691 | yyreduce -- do a reduction. |
1692 `-----------------------------*/
1694 /* yyn is the number of a rule to reduce with. */
1697 /* If YYLEN is nonzero, implement the default value of the action:
1700 Otherwise, the following line sets YYVAL to garbage.
1701 This behavior is undocumented and Bison
1702 users should not rely upon it. Assigning to YYVAL
1703 unconditionally makes the parser a bit smaller, and it avoids a
1704 GCC warning that YYVAL may be used uninitialized. */
1705 yyval
= yyvsp
[1-yylen
];
1708 [[ /* Default location. */
1709 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);
1710 yyerror_range
[1] = yyloc
;]])[
1711 YY_REDUCE_PRINT (yyn
);]b4_lac_if([[
1713 int yychar_backup
= yychar
;
1719 if (yychar_backup
!= yychar
)
1720 YY_LAC_DISCARD ("yychar change");
1727 /* User semantic actions sometimes alter yychar, and that requires
1728 that yytoken be updated with the new translation. We take the
1729 approach of translating immediately before every use of yytoken.
1730 One alternative is translating here after every semantic action,
1731 but that translation would be missed if the semantic action invokes
1732 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1733 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1734 incorrect destructor might then be invoked immediately. In the
1735 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1736 to an incorrect destructor call or verbose syntax error message
1737 before the lookahead is translated. */
1738 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
1742 YY_STACK_PRINT (yyss
, yyssp
);
1744 *++yyvsp
= yyval
;]b4_locations_if([
1745 *++yylsp
= yyloc
;])[
1747 /* Now 'shift' the result of the reduction. Determine what state
1748 that goes to, based on the state we popped back to and the rule
1749 number reduced by. */
1751 const int yylhs
= yyr1
[yyn
] - YYNTOKENS
;
1752 const int yyi
= yypgoto
[yylhs
] + (int) *yyssp
;
1753 yystate
= (0 <= yyi
&& yyi
<= YYLAST
&& yycheck
[yyi
] == *yyssp
1754 ? (int) yytable
[yyi
]
1755 : yydefgoto
[yylhs
]);
1761 /*--------------------------------------.
1762 | yyerrlab -- here on detecting error. |
1763 `--------------------------------------*/
1765 /* Make sure we have latest lookahead translation. See comments at
1766 user semantic actions for why this is necessary. */
1767 yytoken
= yychar
== YYEMPTY
? YYEMPTY
: YYTRANSLATE (yychar
);
1769 /* If not already recovering from an error, report this error. */
1773 #if ! YYERROR_VERBOSE
1774 yyerror (]b4_yyerror_args
[YY_("syntax error"));
1776 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \]b4_lac_if([[
1777 yyesa
, &yyes
, &yyes_capacity
, \
]])[
1780 char const *yymsgp
= YY_("syntax error");
1781 int yysyntax_error_status
;]b4_lac_if([[
1782 if (yychar
!= YYEMPTY
)
1783 YY_LAC_ESTABLISH
;]])[
1784 yysyntax_error_status
= YYSYNTAX_ERROR
;
1785 if (yysyntax_error_status
== 0)
1787 else if (yysyntax_error_status
== 1)
1789 if (yymsg
!= yymsgbuf
)
1790 YYSTACK_FREE (yymsg
);
1791 yymsg
= (char *) YYSTACK_ALLOC (yymsg_alloc
);
1795 yymsg_alloc
= sizeof yymsgbuf
;
1796 yysyntax_error_status
= 2;
1800 yysyntax_error_status
= YYSYNTAX_ERROR
;
1804 yyerror (]b4_yyerror_args
[yymsgp
);
1805 if (yysyntax_error_status
== 2)
1806 goto yyexhaustedlab
;
1808 # undef YYSYNTAX_ERROR
1812 ]b4_locations_if([[ yyerror_range
[1] = yylloc
;]])[
1814 if (yyerrstatus
== 3)
1816 /* If just tried and failed to reuse lookahead token after an
1817 error, discard it. */
1819 if (yychar
<= YYEOF
)
1821 /* Return failure if at end of input. */
1822 if (yychar
== YYEOF
)
1827 yydestruct ("Error: discarding",
1828 yytoken
, &yylval
]b4_locations_if([, &yylloc
])[]b4_user_args
[);
1833 /* Else will try to reuse lookahead token after shifting the error
1838 /*---------------------------------------------------.
1839 | yyerrorlab -- error raised explicitly by YYERROR. |
1840 `---------------------------------------------------*/
1842 /* Pacify compilers when the user code never invokes YYERROR and the
1843 label yyerrorlab therefore never appears in user code. */
1847 /* Do not reclaim the symbols of the rule whose action triggered
1851 YY_STACK_PRINT (yyss
, yyssp
);
1856 /*-------------------------------------------------------------.
1857 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1858 `-------------------------------------------------------------*/
1860 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1864 yyn
= yypact
[yystate
];
1865 if (!yypact_value_is_default (yyn
))
1868 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1870 yyn
= (int) yytable
[yyn
];
1876 /* Pop the current state because it cannot handle the error token. */
1880 ]b4_locations_if([[ yyerror_range
[1] = *yylsp
;]])[
1881 yydestruct ("Error: popping",
1882 yystos
[yystate
], yyvsp
]b4_locations_if([, yylsp
])[]b4_user_args
[);
1885 YY_STACK_PRINT (yyss
, yyssp
);
1888 /* If the stack popping above didn't lose the initial context for the
1889 current lookahead token, the shift below will for sure. */
1890 YY_LAC_DISCARD ("error recovery");]])[
1892 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1894 YY_IGNORE_MAYBE_UNINITIALIZED_END
1896 yyerror_range
[2] = yylloc
;
1897 /* Using YYLLOC is tempting, but would change the location of
1898 the lookahead. YYLOC is available though. */
1899 YYLLOC_DEFAULT (yyloc
, yyerror_range
, 2);
1900 *++yylsp
= yyloc
;]])[
1902 /* Shift the error token. */
1903 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
1909 /*-------------------------------------.
1910 | yyacceptlab -- YYACCEPT comes here. |
1911 `-------------------------------------*/
1917 /*-----------------------------------.
1918 | yyabortlab -- YYABORT comes here. |
1919 `-----------------------------------*/
1925 #if ]b4_lac_if([[1]], [[!defined yyoverflow || YYERROR_VERBOSE]])[
1926 /*-------------------------------------------------.
1927 | yyexhaustedlab -- memory exhaustion comes here. |
1928 `-------------------------------------------------*/
1930 yyerror (]b4_yyerror_args
[YY_("memory exhausted"));
1936 /*-----------------------------------------------------.
1937 | yyreturn -- parsing is finished, return the result. |
1938 `-----------------------------------------------------*/
1940 if (yychar
!= YYEMPTY
)
1942 /* Make sure we have latest lookahead translation. See comments at
1943 user semantic actions for why this is necessary. */
1944 yytoken
= YYTRANSLATE (yychar
);
1945 yydestruct ("Cleanup: discarding lookahead",
1946 yytoken
, &yylval
]b4_locations_if([, &yylloc
])[]b4_user_args
[);
1948 /* Do not reclaim the symbols of the rule whose action triggered
1949 this YYABORT or YYACCEPT. */
1951 YY_STACK_PRINT (yyss
, yyssp
);
1952 while (yyssp
!= yyss
)
1954 yydestruct ("Cleanup: popping",
1955 yystos
[*yyssp
], yyvsp
]b4_locations_if([, yylsp
])[]b4_user_args
[);
1960 YYSTACK_FREE (yyss
);
1963 YYSTACK_FREE (yyes
);]])b4_push_if([[
1967 /*-----------------------------------------.
1968 | yypushreturn -- ask for the next token. |
1969 `-----------------------------------------*/
1972 if (yymsg
!= yymsgbuf
)
1973 YYSTACK_FREE (yymsg
);