xref: /aosp_15_r20/prebuilts/build-tools/common/bison/skeletons/lalr1.cc (revision cda5da8d549138a6648c5ee6d7a49cf8f4a657be)
1 # C++ skeleton for Bison
2 
3 # Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc.
4 
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 
18 m4_include(b4_skeletonsdir/[c++.m4])
19 
20 # api.value.type=variant is valid.
21 m4_define([b4_value_type_setup_variant])
22 
23 # parse.lac
24 b4_percent_define_default([[parse.lac]], [[none]])
25 b4_percent_define_check_values([[[[parse.lac]], [[full]], [[none]]]])
26 b4_define_flag_if([lac])
27 m4_define([b4_lac_flag],
28           [m4_if(b4_percent_define_get([[parse.lac]]),
29                  [none], [[0]], [[1]])])
30 
31 
32 # b4_tname_if(TNAME-NEEDED, TNAME-NOT-NEEDED)
33 # -------------------------------------------
34 m4_define([b4_tname_if],
35 [m4_case(b4_percent_define_get([[parse.error]]),
36          [verbose],         [$1],
37          [b4_token_table_if([$1],
38                             [$2])])])
39 
40 
41 # b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
42 # --------------------------------------------------------------
43 # Declare "parser::yy<TABLE-NAME>_" whose contents is CONTENT.
44 m4_define([b4_integral_parser_table_declare],
45 [m4_ifval([$3], [b4_comment([$3], [    ])
46 ])dnl
47     static const b4_int_type_for([$2]) yy$1_[[]];dnl
48 ])
49 
50 # b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
51 # -------------------------------------------------------------
52 # Define "parser::yy<TABLE-NAME>_" whose contents is CONTENT.
53 m4_define([b4_integral_parser_table_define],
54 [  const b4_int_type_for([$2])
55   b4_parser_class::yy$1_[[]] =
56   {
57   $2
58   };dnl
59 ])
60 
61 
62 # b4_symbol_kind(NUM)
63 # -------------------
64 m4_define([b4_symbol_kind],
65 [symbol_kind::b4_symbol_kind_base($@)])
66 
67 
68 # b4_symbol_value_template(VAL, SYMBOL-NUM, [TYPE])
69 # -------------------------------------------------
70 # Same as b4_symbol_value, but used in a template method.  It makes
71 # a difference when using variants.  Note that b4_value_type_setup_union
72 # overrides b4_symbol_value, so we must override it again.
73 m4_copy([b4_symbol_value], [b4_symbol_value_template])
74 m4_append([b4_value_type_setup_union],
75 [m4_copy_force([b4_symbol_value_union], [b4_symbol_value_template])])
76 
77 # b4_lhs_value(SYMBOL-NUM, [TYPE])
78 # --------------------------------
79 # See README.
80 m4_define([b4_lhs_value],
81 [b4_symbol_value([yylhs.value], [$1], [$2])])
82 
83 
84 # b4_lhs_location()
85 # -----------------
86 # Expansion of @$.
87 m4_define([b4_lhs_location],
88 [yylhs.location])
89 
90 
91 # b4_rhs_data(RULE-LENGTH, POS)
92 # -----------------------------
93 # See README.
94 m4_define([b4_rhs_data],
95 [yystack_@{b4_subtract($@)@}])
96 
97 
98 # b4_rhs_state(RULE-LENGTH, POS)
99 # ------------------------------
100 # The state corresponding to the symbol #POS, where the current
101 # rule has RULE-LENGTH symbols on RHS.
102 m4_define([b4_rhs_state],
103 [b4_rhs_data([$1], [$2]).state])
104 
105 
106 # b4_rhs_value(RULE-LENGTH, POS, SYMBOL-NUM, [TYPE])
107 # --------------------------------------------------
108 # See README.
109 m4_define([_b4_rhs_value],
110 [b4_symbol_value([b4_rhs_data([$1], [$2]).value], [$3], [$4])])
111 
112 m4_define([b4_rhs_value],
113 [b4_percent_define_ifdef([api.value.automove],
114                          [YY_MOVE (_b4_rhs_value($@))],
115                          [_b4_rhs_value($@)])])
116 
117 
118 # b4_rhs_location(RULE-LENGTH, POS)
119 # ---------------------------------
120 # Expansion of @POS, where the current rule has RULE-LENGTH symbols
121 # on RHS.
122 m4_define([b4_rhs_location],
123 [b4_rhs_data([$1], [$2]).location])
124 
125 
126 # b4_symbol_action(SYMBOL-NUM, KIND)
127 # ----------------------------------
128 # Run the action KIND (destructor or printer) for SYMBOL-NUM.
129 # Same as in C, but using references instead of pointers.
130 m4_define([b4_symbol_action],
131 [b4_symbol_if([$1], [has_$2],
132 [m4_pushdef([b4_symbol_value], m4_defn([b4_symbol_value_template]))[]dnl
133 b4_dollar_pushdef([yysym.value],
134                   [$1],
135                   [],
136                   [yysym.location])dnl
137       _b4_symbol_case([$1])[]dnl
138 b4_syncline([b4_symbol([$1], [$2_line])], [b4_symbol([$1], [$2_file])])dnl
139         b4_symbol([$1], [$2])
140 b4_syncline([@oline@], [@ofile@])dnl
141         break;
142 
143 m4_popdef([b4_symbol_value])[]dnl
144 b4_dollar_popdef[]dnl
145 ])])
146 
147 
148 # b4_yylex
149 # --------
150 # Call yylex.
151 m4_define([b4_yylex],
152 [b4_token_ctor_if(
153 [b4_function_call([yylex],
154                   [symbol_type], m4_ifdef([b4_lex_param], b4_lex_param))],
155 [b4_function_call([yylex], [int],
156                   [[value_type *], [&yyla.value]][]dnl
157 b4_locations_if([, [[location_type *], [&yyla.location]]])dnl
158 m4_ifdef([b4_lex_param], [, ]b4_lex_param))])])
159 
160 
161 m4_pushdef([b4_copyright_years],
162            [2002-2015, 2018-2021])
163 
164 m4_define([b4_parser_class],
165           [b4_percent_define_get([[api.parser.class]])])
166 
167 b4_bison_locations_if([# Backward compatibility.
168    m4_define([b4_location_constructors])
169    m4_include(b4_skeletonsdir/[location.cc])])
170 m4_include(b4_skeletonsdir/[stack.hh])
171 b4_variant_if([m4_include(b4_skeletonsdir/[variant.hh])])
172 
173 
174 # b4_shared_declarations(hh|cc)
175 # -----------------------------
176 # Declaration that might either go into the header (if --header, $1 = hh)
177 # or in the implementation file.
178 m4_define([b4_shared_declarations],
179 [b4_percent_code_get([[requires]])[
180 ]b4_parse_assert_if([# include <cassert>])[
181 # include <cstdlib> // std::abort
182 # include <iostream>
183 # include <stdexcept>
184 # include <string>
185 # include <vector>
186 
187 ]b4_cxx_portability[
188 ]m4_ifdef([b4_location_include],
189           [[# include ]b4_location_include])[
190 ]b4_variant_if([b4_variant_includes])[
191 
192 ]b4_attribute_define[
193 ]b4_cast_define[
194 ]b4_null_define[
195 
196 ]b4_YYDEBUG_define[
197 
198 ]b4_namespace_open[
199 
200 ]b4_bison_locations_if([m4_ifndef([b4_location_file],
201                                   [b4_location_define])])[
202 
203   /// A Bison parser.
204   class ]b4_parser_class[
205   {
206   public:
207 ]b4_public_types_declare[
208 ]b4_symbol_type_define[
209     /// Build a parser object.
210     ]b4_parser_class[ (]b4_parse_param_decl[);
211     virtual ~]b4_parser_class[ ();
212 
213 #if 201103L <= YY_CPLUSPLUS
214     /// Non copyable.
215     ]b4_parser_class[ (const ]b4_parser_class[&) = delete;
216     /// Non copyable.
217     ]b4_parser_class[& operator= (const ]b4_parser_class[&) = delete;
218 #endif
219 
220     /// Parse.  An alias for parse ().
221     /// \returns  0 iff parsing succeeded.
222     int operator() ();
223 
224     /// Parse.
225     /// \returns  0 iff parsing succeeded.
226     virtual int parse ();
227 
228 #if ]b4_api_PREFIX[DEBUG
229     /// The current debugging stream.
230     std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
231     /// Set the current debugging stream.
232     void set_debug_stream (std::ostream &);
233 
234     /// Type for debugging levels.
235     typedef int debug_level_type;
236     /// The current debugging level.
237     debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
238     /// Set the current debugging level.
239     void set_debug_level (debug_level_type l);
240 #endif
241 
242     /// Report a syntax error.]b4_locations_if([[
243     /// \param loc    where the syntax error is found.]])[
244     /// \param msg    a description of the syntax error.
245     virtual void error (]b4_locations_if([[const location_type& loc, ]])[const std::string& msg);
246 
247     /// Report a syntax error.
248     void error (const syntax_error& err);
249 
250 ]b4_parse_error_bmatch(
251 [custom\|detailed],
252 [[    /// The user-facing name of the symbol whose (internal) number is
253     /// YYSYMBOL.  No bounds checking.
254     static const char *symbol_name (symbol_kind_type yysymbol);]],
255 [simple],
256 [[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
257     /// The user-facing name of the symbol whose (internal) number is
258     /// YYSYMBOL.  No bounds checking.
259     static const char *symbol_name (symbol_kind_type yysymbol);
260 #endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
261 ]],
262 [verbose],
263 [[    /// The user-facing name of the symbol whose (internal) number is
264     /// YYSYMBOL.  No bounds checking.
265     static std::string symbol_name (symbol_kind_type yysymbol);]])[
266 
267 ]b4_token_constructor_define[
268 ]b4_parse_error_bmatch([custom\|detailed\|verbose], [[
269     class context
270     {
271     public:
272       context (const ]b4_parser_class[& yyparser, const symbol_type& yyla);
273       const symbol_type& lookahead () const YY_NOEXCEPT { return yyla_; }
274       symbol_kind_type token () const YY_NOEXCEPT { return yyla_.kind (); }]b4_locations_if([[
275       const location_type& location () const YY_NOEXCEPT { return yyla_.location; }
276 ]])[
277       /// Put in YYARG at most YYARGN of the expected tokens, and return the
278       /// number of tokens stored in YYARG.  If YYARG is null, return the
279       /// number of expected tokens (guaranteed to be less than YYNTOKENS).
280       int expected_tokens (symbol_kind_type yyarg[], int yyargn) const;
281 
282     private:
283       const ]b4_parser_class[& yyparser_;
284       const symbol_type& yyla_;
285     };
286 ]])[
287   private:
288 #if YY_CPLUSPLUS < 201103L
289     /// Non copyable.
290     ]b4_parser_class[ (const ]b4_parser_class[&);
291     /// Non copyable.
292     ]b4_parser_class[& operator= (const ]b4_parser_class[&);
293 #endif
294 ]b4_lac_if([[
295     /// Check the lookahead yytoken.
296     /// \returns  true iff the token will be eventually shifted.
297     bool yy_lac_check_ (symbol_kind_type yytoken) const;
298     /// Establish the initial context if no initial context currently exists.
299     /// \returns  true iff the token will be eventually shifted.
300     bool yy_lac_establish_ (symbol_kind_type yytoken);
301     /// Discard any previous initial lookahead context because of event.
302     /// \param event  the event which caused the lookahead to be discarded.
303     ///               Only used for debbuging output.
304     void yy_lac_discard_ (const char* event);]])[
305 
306     /// Stored state numbers (used for stacks).
307     typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ state_type;
308 ]b4_parse_error_bmatch(
309 [custom], [[
310     /// Report a syntax error
311     /// \param yyctx     the context in which the error occurred.
312     void report_syntax_error (const context& yyctx) const;]],
313 [detailed\|verbose], [[
314     /// The arguments of the error message.
315     int yy_syntax_error_arguments_ (const context& yyctx,
316                                     symbol_kind_type yyarg[], int yyargn) const;
317 
318     /// Generate an error message.
319     /// \param yyctx     the context in which the error occurred.
320     virtual std::string yysyntax_error_ (const context& yyctx) const;]])[
321     /// Compute post-reduction state.
322     /// \param yystate   the current state
323     /// \param yysym     the nonterminal to push on the stack
324     static state_type yy_lr_goto_state_ (state_type yystate, int yysym);
325 
326     /// Whether the given \c yypact_ value indicates a defaulted state.
327     /// \param yyvalue   the value to check
328     static bool yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT;
329 
330     /// Whether the given \c yytable_ value indicates a syntax error.
331     /// \param yyvalue   the value to check
332     static bool yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT;
333 
334     static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
335     static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
336 
337     /// Convert a scanner token kind \a t to a symbol kind.
338     /// In theory \a t should be a token_kind_type, but character literals
339     /// are valid, yet not members of the token_kind_type enum.
340     static symbol_kind_type yytranslate_ (int t) YY_NOEXCEPT;
341 
342 ]b4_parse_error_bmatch(
343 [simple],
344 [[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
345     /// For a symbol, its name in clear.
346     static const char* const yytname_[];
347 #endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
348 ]],
349 [verbose],
350 [[    /// Convert the symbol name \a n to a form suitable for a diagnostic.
351     static std::string yytnamerr_ (const char *yystr);
352 
353     /// For a symbol, its name in clear.
354     static const char* const yytname_[];
355 ]])[
356 
357     // Tables.
358 ]b4_parser_tables_declare[
359 
360 #if ]b4_api_PREFIX[DEBUG
361 ]b4_integral_parser_table_declare([rline], [b4_rline],
362      [[YYRLINE[YYN] -- Source line where rule number YYN was defined.]])[
363     /// Report on the debug stream that the rule \a r is going to be reduced.
364     virtual void yy_reduce_print_ (int r) const;
365     /// Print the state stack on the debug stream.
366     virtual void yy_stack_print_ () const;
367 
368     /// Debugging level.
369     int yydebug_;
370     /// Debug stream.
371     std::ostream* yycdebug_;
372 
373     /// \brief Display a symbol kind, value and location.
374     /// \param yyo    The output stream.
375     /// \param yysym  The symbol.
376     template <typename Base>
377     void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
378 #endif
379 
380     /// \brief Reclaim the memory associated to a symbol.
381     /// \param yymsg     Why this token is reclaimed.
382     ///                  If null, print nothing.
383     /// \param yysym     The symbol.
384     template <typename Base>
385     void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
386 
387   private:
388     /// Type access provider for state based symbols.
389     struct by_state
390     {
391       /// Default constructor.
392       by_state () YY_NOEXCEPT;
393 
394       /// The symbol kind as needed by the constructor.
395       typedef state_type kind_type;
396 
397       /// Constructor.
398       by_state (kind_type s) YY_NOEXCEPT;
399 
400       /// Copy constructor.
401       by_state (const by_state& that) YY_NOEXCEPT;
402 
403       /// Record that this symbol is empty.
404       void clear () YY_NOEXCEPT;
405 
406       /// Steal the symbol kind from \a that.
407       void move (by_state& that);
408 
409       /// The symbol kind (corresponding to \a state).
410       /// \a ]b4_symbol(empty, kind)[ when empty.
411       symbol_kind_type kind () const YY_NOEXCEPT;
412 
413       /// The state number used to denote an empty symbol.
414       /// We use the initial state, as it does not have a value.
415       enum { empty_state = 0 };
416 
417       /// The state.
418       /// \a empty when empty.
419       state_type state;
420     };
421 
422     /// "Internal" symbol: element of the stack.
423     struct stack_symbol_type : basic_symbol<by_state>
424     {
425       /// Superclass.
426       typedef basic_symbol<by_state> super_type;
427       /// Construct an empty symbol.
428       stack_symbol_type ();
429       /// Move or copy construction.
430       stack_symbol_type (YY_RVREF (stack_symbol_type) that);
431       /// Steal the contents from \a sym to build this.
432       stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym);
433 #if YY_CPLUSPLUS < 201103L
434       /// Assignment, needed by push_back by some old implementations.
435       /// Moves the contents of that.
436       stack_symbol_type& operator= (stack_symbol_type& that);
437 
438       /// Assignment, needed by push_back by other implementations.
439       /// Needed by some other old implementations.
440       stack_symbol_type& operator= (const stack_symbol_type& that);
441 #endif
442     };
443 
444 ]b4_stack_define[
445 
446     /// Stack type.
447     typedef stack<stack_symbol_type> stack_type;
448 
449     /// The stack.
450     stack_type yystack_;]b4_lac_if([[
451     /// The stack for LAC.
452     /// Logically, the yy_lac_stack's lifetime is confined to the function
453     /// yy_lac_check_. We just store it as a member of this class to hold
454     /// on to the memory and to avoid frequent reallocations.
455     /// Since yy_lac_check_ is const, this member must be mutable.
456     mutable std::vector<state_type> yylac_stack_;
457     /// Whether an initial LAC context was established.
458     bool yy_lac_established_;
459 ]])[
460 
461     /// Push a new state on the stack.
462     /// \param m    a debug message to display
463     ///             if null, no trace is output.
464     /// \param sym  the symbol
465     /// \warning the contents of \a s.value is stolen.
466     void yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym);
467 
468     /// Push a new look ahead token on the state on the stack.
469     /// \param m    a debug message to display
470     ///             if null, no trace is output.
471     /// \param s    the state
472     /// \param sym  the symbol (for its value and location).
473     /// \warning the contents of \a sym.value is stolen.
474     void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
475 
476     /// Pop \a n symbols from the stack.
477     void yypop_ (int n = 1) YY_NOEXCEPT;
478 
479     /// Constants.
480     enum
481     {
482       yylast_ = ]b4_last[,     ///< Last index in yytable_.
483       yynnts_ = ]b4_nterms_number[,  ///< Number of nonterminal symbols.
484       yyfinal_ = ]b4_final_state_number[ ///< Termination state number.
485     };
486 
487 ]b4_parse_param_vars[
488 ]b4_percent_code_get([[yy_bison_internal_hook]])[
489   };
490 
491 ]b4_token_ctor_if([b4_yytranslate_define([$1])[
492 ]b4_public_types_define([$1])])[
493 ]b4_namespace_close[
494 
495 ]b4_percent_code_get([[provides]])[
496 ]])[
497 
498 
499 ## -------------- ##
500 ## Output files.  ##
501 ## -------------- ##
502 
503 # ------------- #
504 # Header file.  #
505 # ------------- #
506 
507 ]b4_header_if([[
508 ]b4_output_begin([b4_spec_header_file])[
509 ]b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])[
510 
511 /**
512  ** \file ]b4_spec_mapped_header_file[
513  ** Define the ]b4_namespace_ref[::parser class.
514  */
515 
516 // C++ LALR(1) parser skeleton written by Akim Demaille.
517 
518 ]b4_disclaimer[
519 ]b4_cpp_guard_open([b4_spec_mapped_header_file])[
520 ]b4_shared_declarations(hh)[
521 ]b4_cpp_guard_close([b4_spec_mapped_header_file])[
522 ]b4_output_end[
523 ]])[
524 
525 
526 # --------------------- #
527 # Implementation file.  #
528 # --------------------- #
529 
530 ]b4_output_begin([b4_parser_file_name])[
531 ]b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])[
532 ]b4_disclaimer[
533 ]b4_percent_code_get([[top]])[]dnl
534 m4_if(b4_prefix, [yy], [],
535 [
536 // Take the name prefix into account.
537 [#]define yylex   b4_prefix[]lex])[
538 
539 ]b4_user_pre_prologue[
540 
541 ]b4_header_if([[#include "@basename(]b4_spec_header_file[@)"]],
542                [b4_shared_declarations([cc])])[
543 
544 ]b4_user_post_prologue[
545 ]b4_percent_code_get[
546 
547 #ifndef YY_
548 # if defined YYENABLE_NLS && YYENABLE_NLS
549 #  if ENABLE_NLS
550 #   include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
551 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
552 #  endif
553 # endif
554 # ifndef YY_
555 #  define YY_(msgid) msgid
556 # endif
557 #endif
558 ]b4_has_translations_if([
559 #ifndef N_
560 # define N_(Msgid) Msgid
561 #endif
562 ])[
563 
564 // Whether we are compiled with exception support.
565 #ifndef YY_EXCEPTIONS
566 # if defined __GNUC__ && !defined __EXCEPTIONS
567 #  define YY_EXCEPTIONS 0
568 # else
569 #  define YY_EXCEPTIONS 1
570 # endif
571 #endif
572 
573 ]b4_locations_if([dnl
574 [#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
575 ]b4_yylloc_default_define])[
576 
577 // Enable debugging if requested.
578 #if ]b4_api_PREFIX[DEBUG
579 
580 // A pseudo ostream that takes yydebug_ into account.
581 # define YYCDEBUG if (yydebug_) (*yycdebug_)
582 
583 # define YY_SYMBOL_PRINT(Title, Symbol)         \
584   do {                                          \
585     if (yydebug_)                               \
586     {                                           \
587       *yycdebug_ << Title << ' ';               \
588       yy_print_ (*yycdebug_, Symbol);           \
589       *yycdebug_ << '\n';                       \
590     }                                           \
591   } while (false)
592 
593 # define YY_REDUCE_PRINT(Rule)          \
594   do {                                  \
595     if (yydebug_)                       \
596       yy_reduce_print_ (Rule);          \
597   } while (false)
598 
599 # define YY_STACK_PRINT()               \
600   do {                                  \
601     if (yydebug_)                       \
602       yy_stack_print_ ();                \
603   } while (false)
604 
605 #else // !]b4_api_PREFIX[DEBUG
606 
607 # define YYCDEBUG if (false) std::cerr
608 # define YY_SYMBOL_PRINT(Title, Symbol)  YY_USE (Symbol)
609 # define YY_REDUCE_PRINT(Rule)           static_cast<void> (0)
610 # define YY_STACK_PRINT()                static_cast<void> (0)
611 
612 #endif // !]b4_api_PREFIX[DEBUG
613 
614 #define yyerrok         (yyerrstatus_ = 0)
615 #define yyclearin       (yyla.clear ())
616 
617 #define YYACCEPT        goto yyacceptlab
618 #define YYABORT         goto yyabortlab
619 #define YYERROR         goto yyerrorlab
620 #define YYRECOVERING()  (!!yyerrstatus_)
621 
622 ]b4_namespace_open[
623   /// Build a parser object.
624   ]b4_parser_class::b4_parser_class[ (]b4_parse_param_decl[)
625 #if ]b4_api_PREFIX[DEBUG
626     : yydebug_ (false),
627       yycdebug_ (&std::cerr)]b4_lac_if([,], [m4_ifset([b4_parse_param], [,])])[
628 #else
629 ]b4_lac_if([    :], [m4_ifset([b4_parse_param], [    :])])[
630 #endif]b4_lac_if([[
631       yy_lac_established_ (false)]m4_ifset([b4_parse_param], [,])])[]b4_parse_param_cons[
632   {}
633 
634   ]b4_parser_class::~b4_parser_class[ ()
635   {}
636 
637   ]b4_parser_class[::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
638   {}
639 
640   /*---------.
641   | symbol.  |
642   `---------*/
643 
644 ]b4_token_ctor_if([], [b4_public_types_define([cc])])[
645 
646   // by_state.
647   ]b4_parser_class[::by_state::by_state () YY_NOEXCEPT
648     : state (empty_state)
649   {}
650 
651   ]b4_parser_class[::by_state::by_state (const by_state& that) YY_NOEXCEPT
652     : state (that.state)
653   {}
654 
655   void
656   ]b4_parser_class[::by_state::clear () YY_NOEXCEPT
657   {
658     state = empty_state;
659   }
660 
661   void
662   ]b4_parser_class[::by_state::move (by_state& that)
663   {
664     state = that.state;
665     that.clear ();
666   }
667 
668   ]b4_parser_class[::by_state::by_state (state_type s) YY_NOEXCEPT
669     : state (s)
670   {}
671 
672   ]b4_parser_class[::symbol_kind_type
673   ]b4_parser_class[::by_state::kind () const YY_NOEXCEPT
674   {
675     if (state == empty_state)
676       return ]b4_symbol(empty, kind)[;
677     else
678       return YY_CAST (symbol_kind_type, yystos_[+state]);
679   }
680 
681   ]b4_parser_class[::stack_symbol_type::stack_symbol_type ()
682   {}
683 
684   ]b4_parser_class[::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that)
685     : super_type (YY_MOVE (that.state)]b4_variant_if([], [, YY_MOVE (that.value)])b4_locations_if([, YY_MOVE (that.location)])[)
686   {]b4_variant_if([
687     b4_symbol_variant([that.kind ()],
688                       [value], [YY_MOVE_OR_COPY], [YY_MOVE (that.value)])])[
689 #if 201103L <= YY_CPLUSPLUS
690     // that is emptied.
691     that.state = empty_state;
692 #endif
693   }
694 
695   ]b4_parser_class[::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that)
696     : super_type (s]b4_variant_if([], [, YY_MOVE (that.value)])[]b4_locations_if([, YY_MOVE (that.location)])[)
697   {]b4_variant_if([
698     b4_symbol_variant([that.kind ()],
699                       [value], [move], [YY_MOVE (that.value)])])[
700     // that is emptied.
701     that.kind_ = ]b4_symbol(empty, kind)[;
702   }
703 
704 #if YY_CPLUSPLUS < 201103L
705   ]b4_parser_class[::stack_symbol_type&
706   ]b4_parser_class[::stack_symbol_type::operator= (const stack_symbol_type& that)
707   {
708     state = that.state;
709     ]b4_variant_if([b4_symbol_variant([that.kind ()],
710                                       [value], [copy], [that.value])],
711                    [[value = that.value;]])[]b4_locations_if([
712     location = that.location;])[
713     return *this;
714   }
715 
716   ]b4_parser_class[::stack_symbol_type&
717   ]b4_parser_class[::stack_symbol_type::operator= (stack_symbol_type& that)
718   {
719     state = that.state;
720     ]b4_variant_if([b4_symbol_variant([that.kind ()],
721                                       [value], [move], [that.value])],
722                    [[value = that.value;]])[]b4_locations_if([
723     location = that.location;])[
724     // that is emptied.
725     that.state = empty_state;
726     return *this;
727   }
728 #endif
729 
730   template <typename Base>
731   void
732   ]b4_parser_class[::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
733   {
734     if (yymsg)
735       YY_SYMBOL_PRINT (yymsg, yysym);]b4_variant_if([], [
736 
737     // User destructor.
738     b4_symbol_actions([destructor], [yysym.kind ()])])[
739   }
740 
741 #if ]b4_api_PREFIX[DEBUG
742   template <typename Base>
743   void
744   ]b4_parser_class[::yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const
745   {
746     std::ostream& yyoutput = yyo;
747     YY_USE (yyoutput);
748     if (yysym.empty ())
749       yyo << "empty symbol";
750     else
751       {
752         symbol_kind_type yykind = yysym.kind ();
753         yyo << (yykind < YYNTOKENS ? "token" : "nterm")
754             << ' ' << yysym.name () << " ("]b4_locations_if([
755             << yysym.location << ": "])[;
756         ]b4_symbol_actions([printer])[
757         yyo << ')';
758       }
759   }
760 #endif
761 
762   void
763   ]b4_parser_class[::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
764   {
765     if (m)
766       YY_SYMBOL_PRINT (m, sym);
767     yystack_.push (YY_MOVE (sym));
768   }
769 
770   void
771   ]b4_parser_class[::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
772   {
773 #if 201103L <= YY_CPLUSPLUS
774     yypush_ (m, stack_symbol_type (s, std::move (sym)));
775 #else
776     stack_symbol_type ss (s, sym);
777     yypush_ (m, ss);
778 #endif
779   }
780 
781   void
782   ]b4_parser_class[::yypop_ (int n) YY_NOEXCEPT
783   {
784     yystack_.pop (n);
785   }
786 
787 #if ]b4_api_PREFIX[DEBUG
788   std::ostream&
789   ]b4_parser_class[::debug_stream () const
790   {
791     return *yycdebug_;
792   }
793 
794   void
795   ]b4_parser_class[::set_debug_stream (std::ostream& o)
796   {
797     yycdebug_ = &o;
798   }
799 
800 
801   ]b4_parser_class[::debug_level_type
802   ]b4_parser_class[::debug_level () const
803   {
804     return yydebug_;
805   }
806 
807   void
808   ]b4_parser_class[::set_debug_level (debug_level_type l)
809   {
810     yydebug_ = l;
811   }
812 #endif // ]b4_api_PREFIX[DEBUG
813 
814   ]b4_parser_class[::state_type
815   ]b4_parser_class[::yy_lr_goto_state_ (state_type yystate, int yysym)
816   {
817     int yyr = yypgoto_[yysym - YYNTOKENS] + yystate;
818     if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
819       return yytable_[yyr];
820     else
821       return yydefgoto_[yysym - YYNTOKENS];
822   }
823 
824   bool
825   ]b4_parser_class[::yy_pact_value_is_default_ (int yyvalue) YY_NOEXCEPT
826   {
827     return yyvalue == yypact_ninf_;
828   }
829 
830   bool
831   ]b4_parser_class[::yy_table_value_is_error_ (int yyvalue) YY_NOEXCEPT
832   {
833     return yyvalue == yytable_ninf_;
834   }
835 
836   int
837   ]b4_parser_class[::operator() ()
838   {
839     return parse ();
840   }
841 
842   int
843   ]b4_parser_class[::parse ()
844   {
845     int yyn;
846     /// Length of the RHS of the rule being reduced.
847     int yylen = 0;
848 
849     // Error handling.
850     int yynerrs_ = 0;
851     int yyerrstatus_ = 0;
852 
853     /// The lookahead symbol.
854     symbol_type yyla;]b4_locations_if([[
855 
856     /// The locations where the error started and ended.
857     stack_symbol_type yyerror_range[3];]])[
858 
859     /// The return value of parse ().
860     int yyresult;]b4_lac_if([[
861 
862     // Discard the LAC context in case there still is one left from a
863     // previous invocation.
864     yy_lac_discard_ ("init");]])[
865 
866 #if YY_EXCEPTIONS
867     try
868 #endif // YY_EXCEPTIONS
869       {
870     YYCDEBUG << "Starting parse\n";
871 
872 ]m4_ifdef([b4_initial_action], [
873 b4_dollar_pushdef([yyla.value], [], [], [yyla.location])dnl
874     b4_user_initial_action
875 b4_dollar_popdef])[]dnl
876 
877   [  /* Initialize the stack.  The initial state will be set in
878        yynewstate, since the latter expects the semantical and the
879        location values to have been already stored, initialize these
880        stacks with a primary value.  */
881     yystack_.clear ();
882     yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
883 
884   /*-----------------------------------------------.
885   | yynewstate -- push a new symbol on the stack.  |
886   `-----------------------------------------------*/
887   yynewstate:
888     YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n';
889     YY_STACK_PRINT ();
890 
891     // Accept?
892     if (yystack_[0].state == yyfinal_)
893       YYACCEPT;
894 
895     goto yybackup;
896 
897 
898   /*-----------.
899   | yybackup.  |
900   `-----------*/
901   yybackup:
902     // Try to take a decision without lookahead.
903     yyn = yypact_[+yystack_[0].state];
904     if (yy_pact_value_is_default_ (yyn))
905       goto yydefault;
906 
907     // Read a lookahead token.
908     if (yyla.empty ())
909       {
910         YYCDEBUG << "Reading a token\n";
911 #if YY_EXCEPTIONS
912         try
913 #endif // YY_EXCEPTIONS
914           {]b4_token_ctor_if([[
915             symbol_type yylookahead (]b4_yylex[);
916             yyla.move (yylookahead);]], [[
917             yyla.kind_ = yytranslate_ (]b4_yylex[);]])[
918           }
919 #if YY_EXCEPTIONS
920         catch (const syntax_error& yyexc)
921           {
922             YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
923             error (yyexc);
924             goto yyerrlab1;
925           }
926 #endif // YY_EXCEPTIONS
927       }
928     YY_SYMBOL_PRINT ("Next token is", yyla);
929 
930     if (yyla.kind () == ]b4_symbol(error, kind)[)
931     {
932       // The scanner already issued an error message, process directly
933       // to error recovery.  But do not keep the error token as
934       // lookahead, it is too special and may lead us to an endless
935       // loop in error recovery. */
936       yyla.kind_ = ]b4_symbol(undef, kind)[;
937       goto yyerrlab1;
938     }
939 
940     /* If the proper action on seeing token YYLA.TYPE is to reduce or
941        to detect an error, take that action.  */
942     yyn += yyla.kind ();
943     if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind ())
944       {]b4_lac_if([[
945         if (!yy_lac_establish_ (yyla.kind ()))
946           goto yyerrlab;]])[
947         goto yydefault;
948       }
949 
950     // Reduce or error.
951     yyn = yytable_[yyn];
952     if (yyn <= 0)
953       {
954         if (yy_table_value_is_error_ (yyn))
955           goto yyerrlab;]b4_lac_if([[
956         if (!yy_lac_establish_ (yyla.kind ()))
957           goto yyerrlab;
958 ]])[
959         yyn = -yyn;
960         goto yyreduce;
961       }
962 
963     // Count tokens shifted since error; after three, turn off error status.
964     if (yyerrstatus_)
965       --yyerrstatus_;
966 
967     // Shift the lookahead token.
968     yypush_ ("Shifting", state_type (yyn), YY_MOVE (yyla));]b4_lac_if([[
969     yy_lac_discard_ ("shift");]])[
970     goto yynewstate;
971 
972 
973   /*-----------------------------------------------------------.
974   | yydefault -- do the default action for the current state.  |
975   `-----------------------------------------------------------*/
976   yydefault:
977     yyn = yydefact_[+yystack_[0].state];
978     if (yyn == 0)
979       goto yyerrlab;
980     goto yyreduce;
981 
982 
983   /*-----------------------------.
984   | yyreduce -- do a reduction.  |
985   `-----------------------------*/
986   yyreduce:
987     yylen = yyr2_[yyn];
988     {
989       stack_symbol_type yylhs;
990       yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]);]b4_variant_if([[
991       /* Variants are always initialized to an empty instance of the
992          correct type. The default '$$ = $1' action is NOT applied
993          when using variants.  */
994       ]b4_symbol_variant([[yyr1_@{yyn@}]], [yylhs.value], [emplace])], [[
995       /* If YYLEN is nonzero, implement the default value of the
996          action: '$$ = $1'.  Otherwise, use the top of the stack.
997 
998          Otherwise, the following line sets YYLHS.VALUE to garbage.
999          This behavior is undocumented and Bison users should not rely
1000          upon it.  */
1001       if (yylen)
1002         yylhs.value = yystack_@{yylen - 1@}.value;
1003       else
1004         yylhs.value = yystack_@{0@}.value;]])[
1005 ]b4_locations_if([dnl
1006 [
1007       // Default location.
1008       {
1009         stack_type::slice range (yystack_, yylen);
1010         YYLLOC_DEFAULT (yylhs.location, range, yylen);
1011         yyerror_range[1].location = yylhs.location;
1012       }]])[
1013 
1014       // Perform the reduction.
1015       YY_REDUCE_PRINT (yyn);
1016 #if YY_EXCEPTIONS
1017       try
1018 #endif // YY_EXCEPTIONS
1019         {
1020           switch (yyn)
1021             {
1022 ]b4_user_actions[
1023             default:
1024               break;
1025             }
1026         }
1027 #if YY_EXCEPTIONS
1028       catch (const syntax_error& yyexc)
1029         {
1030           YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
1031           error (yyexc);
1032           YYERROR;
1033         }
1034 #endif // YY_EXCEPTIONS
1035       YY_SYMBOL_PRINT ("-> $$ =", yylhs);
1036       yypop_ (yylen);
1037       yylen = 0;
1038 
1039       // Shift the result of the reduction.
1040       yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
1041     }
1042     goto yynewstate;
1043 
1044 
1045   /*--------------------------------------.
1046   | yyerrlab -- here on detecting error.  |
1047   `--------------------------------------*/
1048   yyerrlab:
1049     // If not already recovering from an error, report this error.
1050     if (!yyerrstatus_)
1051       {
1052         ++yynerrs_;]b4_parse_error_case(
1053                   [simple], [[
1054         std::string msg = YY_("syntax error");
1055         error (]b4_join(b4_locations_if([yyla.location]), [[YY_MOVE (msg)]])[);]],
1056                   [custom], [[
1057         context yyctx (*this, yyla);
1058         report_syntax_error (yyctx);]],
1059                   [[
1060         context yyctx (*this, yyla);
1061         std::string msg = yysyntax_error_ (yyctx);
1062         error (]b4_join(b4_locations_if([yyla.location]), [[YY_MOVE (msg)]])[);]])[
1063       }
1064 
1065 ]b4_locations_if([[
1066     yyerror_range[1].location = yyla.location;]])[
1067     if (yyerrstatus_ == 3)
1068       {
1069         /* If just tried and failed to reuse lookahead token after an
1070            error, discard it.  */
1071 
1072         // Return failure if at end of input.
1073         if (yyla.kind () == ]b4_symbol(eof, kind)[)
1074           YYABORT;
1075         else if (!yyla.empty ())
1076           {
1077             yy_destroy_ ("Error: discarding", yyla);
1078             yyla.clear ();
1079           }
1080       }
1081 
1082     // Else will try to reuse lookahead token after shifting the error token.
1083     goto yyerrlab1;
1084 
1085 
1086   /*---------------------------------------------------.
1087   | yyerrorlab -- error raised explicitly by YYERROR.  |
1088   `---------------------------------------------------*/
1089   yyerrorlab:
1090     /* Pacify compilers when the user code never invokes YYERROR and
1091        the label yyerrorlab therefore never appears in user code.  */
1092     if (false)
1093       YYERROR;
1094 
1095     /* Do not reclaim the symbols of the rule whose action triggered
1096        this YYERROR.  */
1097     yypop_ (yylen);
1098     yylen = 0;
1099     YY_STACK_PRINT ();
1100     goto yyerrlab1;
1101 
1102 
1103   /*-------------------------------------------------------------.
1104   | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1105   `-------------------------------------------------------------*/
1106   yyerrlab1:
1107     yyerrstatus_ = 3;   // Each real token shifted decrements this.
1108     // Pop stack until we find a state that shifts the error token.
1109     for (;;)
1110       {
1111         yyn = yypact_[+yystack_[0].state];
1112         if (!yy_pact_value_is_default_ (yyn))
1113           {
1114             yyn += ]b4_symbol(error, kind)[;
1115             if (0 <= yyn && yyn <= yylast_
1116                 && yycheck_[yyn] == ]b4_symbol(error, kind)[)
1117               {
1118                 yyn = yytable_[yyn];
1119                 if (0 < yyn)
1120                   break;
1121               }
1122           }
1123 
1124         // Pop the current state because it cannot handle the error token.
1125         if (yystack_.size () == 1)
1126           YYABORT;
1127 ]b4_locations_if([[
1128         yyerror_range[1].location = yystack_[0].location;]])[
1129         yy_destroy_ ("Error: popping", yystack_[0]);
1130         yypop_ ();
1131         YY_STACK_PRINT ();
1132       }
1133     {
1134       stack_symbol_type error_token;
1135 ]b4_locations_if([[
1136       yyerror_range[2].location = yyla.location;
1137       YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);]])[
1138 
1139       // Shift the error token.]b4_lac_if([[
1140       yy_lac_discard_ ("error recovery");]])[
1141       error_token.state = state_type (yyn);
1142       yypush_ ("Shifting", YY_MOVE (error_token));
1143     }
1144     goto yynewstate;
1145 
1146 
1147   /*-------------------------------------.
1148   | yyacceptlab -- YYACCEPT comes here.  |
1149   `-------------------------------------*/
1150   yyacceptlab:
1151     yyresult = 0;
1152     goto yyreturn;
1153 
1154 
1155   /*-----------------------------------.
1156   | yyabortlab -- YYABORT comes here.  |
1157   `-----------------------------------*/
1158   yyabortlab:
1159     yyresult = 1;
1160     goto yyreturn;
1161 
1162 
1163   /*-----------------------------------------------------.
1164   | yyreturn -- parsing is finished, return the result.  |
1165   `-----------------------------------------------------*/
1166   yyreturn:
1167     if (!yyla.empty ())
1168       yy_destroy_ ("Cleanup: discarding lookahead", yyla);
1169 
1170     /* Do not reclaim the symbols of the rule whose action triggered
1171        this YYABORT or YYACCEPT.  */
1172     yypop_ (yylen);
1173     YY_STACK_PRINT ();
1174     while (1 < yystack_.size ())
1175       {
1176         yy_destroy_ ("Cleanup: popping", yystack_[0]);
1177         yypop_ ();
1178       }
1179 
1180     return yyresult;
1181   }
1182 #if YY_EXCEPTIONS
1183     catch (...)
1184       {
1185         YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
1186         // Do not try to display the values of the reclaimed symbols,
1187         // as their printers might throw an exception.
1188         if (!yyla.empty ())
1189           yy_destroy_ (YY_NULLPTR, yyla);
1190 
1191         while (1 < yystack_.size ())
1192           {
1193             yy_destroy_ (YY_NULLPTR, yystack_[0]);
1194             yypop_ ();
1195           }
1196         throw;
1197       }
1198 #endif // YY_EXCEPTIONS
1199   }
1200 
1201   void
1202   ]b4_parser_class[::error (const syntax_error& yyexc)
1203   {
1204     error (]b4_join(b4_locations_if([yyexc.location]),
1205                     [[yyexc.what ()]])[);
1206   }
1207 
1208 ]b4_parse_error_bmatch([custom\|detailed],
1209 [[  const char *
1210   ]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
1211   {
1212     static const char *const yy_sname[] =
1213     {
1214     ]b4_symbol_names[
1215     };]b4_has_translations_if([[
1216     /* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
1217        internationalizable.  */
1218     static ]b4_int_type_for([b4_translatable])[ yytranslatable[] =
1219     {
1220     ]b4_translatable[
1221     };
1222     return (yysymbol < YYNTOKENS && yytranslatable[yysymbol]
1223             ? _(yy_sname[yysymbol])
1224             : yy_sname[yysymbol]);]], [[
1225     return yy_sname[yysymbol];]])[
1226   }
1227 ]],
1228 [simple],
1229 [[#if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
1230   const char *
1231   ]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
1232   {
1233     return yytname_[yysymbol];
1234   }
1235 #endif // #if ]b4_api_PREFIX[DEBUG || ]b4_token_table_flag[
1236 ]],
1237 [verbose],
1238 [[  /* Return YYSTR after stripping away unnecessary quotes and
1239      backslashes, so that it's suitable for yyerror.  The heuristic is
1240      that double-quoting is unnecessary unless the string contains an
1241      apostrophe, a comma, or backslash (other than backslash-backslash).
1242      YYSTR is taken from yytname.  */
1243   std::string
1244   ]b4_parser_class[::yytnamerr_ (const char *yystr)
1245   {
1246     if (*yystr == '"')
1247       {
1248         std::string yyr;
1249         char const *yyp = yystr;
1250 
1251         for (;;)
1252           switch (*++yyp)
1253             {
1254             case '\'':
1255             case ',':
1256               goto do_not_strip_quotes;
1257 
1258             case '\\':
1259               if (*++yyp != '\\')
1260                 goto do_not_strip_quotes;
1261               else
1262                 goto append;
1263 
1264             append:
1265             default:
1266               yyr += *yyp;
1267               break;
1268 
1269             case '"':
1270               return yyr;
1271             }
1272       do_not_strip_quotes: ;
1273       }
1274 
1275     return yystr;
1276   }
1277 
1278   std::string
1279   ]b4_parser_class[::symbol_name (symbol_kind_type yysymbol)
1280   {
1281     return yytnamerr_ (yytname_[yysymbol]);
1282   }
1283 ]])[
1284 
1285 ]b4_parse_error_bmatch([custom\|detailed\|verbose], [[
1286   // ]b4_parser_class[::context.
1287   ]b4_parser_class[::context::context (const ]b4_parser_class[& yyparser, const symbol_type& yyla)
1288     : yyparser_ (yyparser)
1289     , yyla_ (yyla)
1290   {}
1291 
1292   int
1293   ]b4_parser_class[::context::expected_tokens (symbol_kind_type yyarg[], int yyargn) const
1294   {
1295     // Actual number of expected tokens
1296     int yycount = 0;
1297 ]b4_lac_if([[
1298 #if ]b4_api_PREFIX[DEBUG
1299     // Execute LAC once. We don't care if it is successful, we
1300     // only do it for the sake of debugging output.
1301     if (!yyparser_.yy_lac_established_)
1302       yyparser_.yy_lac_check_ (yyla_.kind ());
1303 #endif
1304 
1305     for (int yyx = 0; yyx < YYNTOKENS; ++yyx)
1306       {
1307         symbol_kind_type yysym = YY_CAST (symbol_kind_type, yyx);
1308         if (yysym != ]b4_symbol(error, kind)[
1309             && yysym != ]b4_symbol(undef, kind)[
1310             && yyparser_.yy_lac_check_ (yysym))
1311           {
1312             if (!yyarg)
1313               ++yycount;
1314             else if (yycount == yyargn)
1315               return 0;
1316             else
1317               yyarg[yycount++] = yysym;
1318           }
1319       }]], [[
1320     const int yyn = yypact_[+yyparser_.yystack_[0].state];
1321     if (!yy_pact_value_is_default_ (yyn))
1322       {
1323         /* Start YYX at -YYN if negative to avoid negative indexes in
1324            YYCHECK.  In other words, skip the first -YYN actions for
1325            this state because they are default actions.  */
1326         const int yyxbegin = yyn < 0 ? -yyn : 0;
1327         // Stay within bounds of both yycheck and yytname.
1328         const int yychecklim = yylast_ - yyn + 1;
1329         const int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1330         for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
1331           if (yycheck_[yyx + yyn] == yyx && yyx != ]b4_symbol(error, kind)[
1332               && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
1333             {
1334               if (!yyarg)
1335                 ++yycount;
1336               else if (yycount == yyargn)
1337                 return 0;
1338               else
1339                 yyarg[yycount++] = YY_CAST (symbol_kind_type, yyx);
1340             }
1341       }
1342 ]])[
1343     if (yyarg && yycount == 0 && 0 < yyargn)
1344       yyarg[0] = ]b4_symbol(empty, kind)[;
1345     return yycount;
1346   }
1347 
1348 ]])[
1349 
1350 ]b4_lac_if([[
1351   bool
1352   ]b4_parser_class[::yy_lac_check_ (symbol_kind_type yytoken) const
1353   {
1354     // Logically, the yylac_stack's lifetime is confined to this function.
1355     // Clear it, to get rid of potential left-overs from previous call.
1356     yylac_stack_.clear ();
1357     // Reduce until we encounter a shift and thereby accept the token.
1358 #if ]b4_api_PREFIX[DEBUG
1359     YYCDEBUG << "LAC: checking lookahead " << symbol_name (yytoken) << ':';
1360 #endif
1361     std::ptrdiff_t lac_top = 0;
1362     while (true)
1363       {
1364         state_type top_state = (yylac_stack_.empty ()
1365                                 ? yystack_[lac_top].state
1366                                 : yylac_stack_.back ());
1367         int yyrule = yypact_[+top_state];
1368         if (yy_pact_value_is_default_ (yyrule)
1369             || (yyrule += yytoken) < 0 || yylast_ < yyrule
1370             || yycheck_[yyrule] != yytoken)
1371           {
1372             // Use the default action.
1373             yyrule = yydefact_[+top_state];
1374             if (yyrule == 0)
1375               {
1376                 YYCDEBUG << " Err\n";
1377                 return false;
1378               }
1379           }
1380         else
1381           {
1382             // Use the action from yytable.
1383             yyrule = yytable_[yyrule];
1384             if (yy_table_value_is_error_ (yyrule))
1385               {
1386                 YYCDEBUG << " Err\n";
1387                 return false;
1388               }
1389             if (0 < yyrule)
1390               {
1391                 YYCDEBUG << " S" << yyrule << '\n';
1392                 return true;
1393               }
1394             yyrule = -yyrule;
1395           }
1396         // By now we know we have to simulate a reduce.
1397         YYCDEBUG << " R" << yyrule - 1;
1398         // Pop the corresponding number of values from the stack.
1399         {
1400           std::ptrdiff_t yylen = yyr2_[yyrule];
1401           // First pop from the LAC stack as many tokens as possible.
1402           std::ptrdiff_t lac_size = std::ptrdiff_t (yylac_stack_.size ());
1403           if (yylen < lac_size)
1404             {
1405               yylac_stack_.resize (std::size_t (lac_size - yylen));
1406               yylen = 0;
1407             }
1408           else if (lac_size)
1409             {
1410               yylac_stack_.clear ();
1411               yylen -= lac_size;
1412             }
1413           // Only afterwards look at the main stack.
1414           // We simulate popping elements by incrementing lac_top.
1415           lac_top += yylen;
1416         }
1417         // Keep top_state in sync with the updated stack.
1418         top_state = (yylac_stack_.empty ()
1419                      ? yystack_[lac_top].state
1420                      : yylac_stack_.back ());
1421         // Push the resulting state of the reduction.
1422         state_type state = yy_lr_goto_state_ (top_state, yyr1_[yyrule]);
1423         YYCDEBUG << " G" << int (state);
1424         yylac_stack_.push_back (state);
1425       }
1426   }
1427 
1428   // Establish the initial context if no initial context currently exists.
1429   bool
1430   ]b4_parser_class[::yy_lac_establish_ (symbol_kind_type yytoken)
1431   {
1432     /* Establish the initial context for the current lookahead if no initial
1433        context is currently established.
1434 
1435        We define a context as a snapshot of the parser stacks.  We define
1436        the initial context for a lookahead as the context in which the
1437        parser initially examines that lookahead in order to select a
1438        syntactic action.  Thus, if the lookahead eventually proves
1439        syntactically unacceptable (possibly in a later context reached via a
1440        series of reductions), the initial context can be used to determine
1441        the exact set of tokens that would be syntactically acceptable in the
1442        lookahead's place.  Moreover, it is the context after which any
1443        further semantic actions would be erroneous because they would be
1444        determined by a syntactically unacceptable token.
1445 
1446        yy_lac_establish_ should be invoked when a reduction is about to be
1447        performed in an inconsistent state (which, for the purposes of LAC,
1448        includes consistent states that don't know they're consistent because
1449        their default reductions have been disabled).
1450 
1451        For parse.lac=full, the implementation of yy_lac_establish_ is as
1452        follows.  If no initial context is currently established for the
1453        current lookahead, then check if that lookahead can eventually be
1454        shifted if syntactic actions continue from the current context.  */
1455     if (yy_lac_established_)
1456       return true;
1457     else
1458       {
1459 #if ]b4_api_PREFIX[DEBUG
1460         YYCDEBUG << "LAC: initial context established for "
1461                  << symbol_name (yytoken) << '\n';
1462 #endif
1463         yy_lac_established_ = true;
1464         return yy_lac_check_ (yytoken);
1465       }
1466   }
1467 
1468   // Discard any previous initial lookahead context.
1469   void
1470   ]b4_parser_class[::yy_lac_discard_ (const char* event)
1471   {
1472    /* Discard any previous initial lookahead context because of Event,
1473       which may be a lookahead change or an invalidation of the currently
1474       established initial context for the current lookahead.
1475 
1476       The most common example of a lookahead change is a shift.  An example
1477       of both cases is syntax error recovery.  That is, a syntax error
1478       occurs when the lookahead is syntactically erroneous for the
1479       currently established initial context, so error recovery manipulates
1480       the parser stacks to try to find a new initial context in which the
1481       current lookahead is syntactically acceptable.  If it fails to find
1482       such a context, it discards the lookahead.  */
1483     if (yy_lac_established_)
1484       {
1485         YYCDEBUG << "LAC: initial context discarded due to "
1486                  << event << '\n';
1487         yy_lac_established_ = false;
1488       }
1489   }]])[
1490 
1491 ]b4_parse_error_bmatch([detailed\|verbose], [[
1492   int
1493   ]b4_parser_class[::yy_syntax_error_arguments_ (const context& yyctx,
1494                                                  symbol_kind_type yyarg[], int yyargn) const
1495   {
1496     /* There are many possibilities here to consider:
1497        - If this state is a consistent state with a default action, then
1498          the only way this function was invoked is if the default action
1499          is an error action.  In that case, don't check for expected
1500          tokens because there are none.
1501        - The only way there can be no lookahead present (in yyla) is
1502          if this state is a consistent state with a default action.
1503          Thus, detecting the absence of a lookahead is sufficient to
1504          determine that there is no unexpected or expected token to
1505          report.  In that case, just report a simple "syntax error".
1506        - Don't assume there isn't a lookahead just because this state is
1507          a consistent state with a default action.  There might have
1508          been a previous inconsistent state, consistent state with a
1509          non-default action, or user semantic action that manipulated
1510          yyla.  (However, yyla is currently not documented for users.)]b4_lac_if([[
1511          In the first two cases, it might appear that the current syntax
1512          error should have been detected in the previous state when
1513          yy_lac_check was invoked.  However, at that time, there might
1514          have been a different syntax error that discarded a different
1515          initial context during error recovery, leaving behind the
1516          current lookahead.]], [[
1517        - Of course, the expected token list depends on states to have
1518          correct lookahead information, and it depends on the parser not
1519          to perform extra reductions after fetching a lookahead from the
1520          scanner and before detecting a syntax error.  Thus, state merging
1521          (from LALR or IELR) and default reductions corrupt the expected
1522          token list.  However, the list is correct for canonical LR with
1523          one exception: it will still contain any token that will not be
1524          accepted due to an error action in a later state.]])[
1525     */
1526 
1527     if (!yyctx.lookahead ().empty ())
1528       {
1529         if (yyarg)
1530           yyarg[0] = yyctx.token ();
1531         int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1);
1532         return yyn + 1;
1533       }
1534     return 0;
1535   }
1536 
1537   // Generate an error message.
1538   std::string
1539   ]b4_parser_class[::yysyntax_error_ (const context& yyctx) const
1540   {
1541     // Its maximum.
1542     enum { YYARGS_MAX = 5 };
1543     // Arguments of yyformat.
1544     symbol_kind_type yyarg[YYARGS_MAX];
1545     int yycount = yy_syntax_error_arguments_ (yyctx, yyarg, YYARGS_MAX);
1546 
1547     char const* yyformat = YY_NULLPTR;
1548     switch (yycount)
1549       {
1550 #define YYCASE_(N, S)                         \
1551         case N:                               \
1552           yyformat = S;                       \
1553         break
1554       default: // Avoid compiler warnings.
1555         YYCASE_ (0, YY_("syntax error"));
1556         YYCASE_ (1, YY_("syntax error, unexpected %s"));
1557         YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s"));
1558         YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1559         YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1560         YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1561 #undef YYCASE_
1562       }
1563 
1564     std::string yyres;
1565     // Argument number.
1566     std::ptrdiff_t yyi = 0;
1567     for (char const* yyp = yyformat; *yyp; ++yyp)
1568       if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
1569         {
1570           yyres += symbol_name (yyarg[yyi++]);
1571           ++yyp;
1572         }
1573       else
1574         yyres += *yyp;
1575     return yyres;
1576   }]])[
1577 
1578 
1579   const ]b4_int_type(b4_pact_ninf, b4_pact_ninf) b4_parser_class::yypact_ninf_ = b4_pact_ninf[;
1580 
1581   const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class::yytable_ninf_ = b4_table_ninf[;
1582 
1583 ]b4_parser_tables_define[
1584 
1585 ]b4_parse_error_bmatch([simple\|verbose],
1586 [[#if ]b4_api_PREFIX[DEBUG]b4_tname_if([[ || 1]])[
1587   // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1588   // First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
1589   const char*
1590   const ]b4_parser_class[::yytname_[] =
1591   {
1592   ]b4_tname[
1593   };
1594 #endif
1595 ]])[
1596 
1597 #if ]b4_api_PREFIX[DEBUG][
1598 ]b4_integral_parser_table_define([rline], [b4_rline])[
1599 
1600   void
1601   ]b4_parser_class[::yy_stack_print_ () const
1602   {
1603     *yycdebug_ << "Stack now";
1604     for (stack_type::const_iterator
1605            i = yystack_.begin (),
1606            i_end = yystack_.end ();
1607          i != i_end; ++i)
1608       *yycdebug_ << ' ' << int (i->state);
1609     *yycdebug_ << '\n';
1610   }
1611 
1612   void
1613   ]b4_parser_class[::yy_reduce_print_ (int yyrule) const
1614   {
1615     int yylno = yyrline_[yyrule];
1616     int yynrhs = yyr2_[yyrule];
1617     // Print the symbols being reduced, and their result.
1618     *yycdebug_ << "Reducing stack by rule " << yyrule - 1
1619                << " (line " << yylno << "):\n";
1620     // The symbols being reduced.
1621     for (int yyi = 0; yyi < yynrhs; yyi++)
1622       YY_SYMBOL_PRINT ("   $" << yyi + 1 << " =",
1623                        ]b4_rhs_data(yynrhs, yyi + 1)[);
1624   }
1625 #endif // ]b4_api_PREFIX[DEBUG
1626 
1627 ]b4_token_ctor_if([], [b4_yytranslate_define([cc])])[
1628 ]b4_namespace_close[
1629 ]b4_epilogue[]dnl
1630 b4_output_end
1631 
1632 
1633 m4_popdef([b4_copyright_years])dnl
1634