1 # C++ skeleton for Bison
3 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 # Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 m4_include(b4_pkgdatadir
/[c
++.m4
])
22 # b4_integral_parser_table_declare(TABLE-NAME, CONTENT, COMMENT)
23 # --------------------------------------------------------------
24 # Declare "parser::yy<TABLE-NAME>_" which contents is CONTENT.
25 m4_define([b4_integral_parser_table_declare
],
26 [m4_ifval([$
3], [b4_c_comment([$
3], [ ])
28 static const b4_int_type_for([$
2]) yy$
1_
[[]];dnl
31 # b4_integral_parser_table_define(TABLE-NAME, CONTENT, COMMENT)
32 # ---------------------------------------------
33 # Define "parser::yy<TABLE-NAME>_" which contents is CONTENT.
34 m4_define([b4_integral_parser_table_define
],
35 [ const b4_int_type_for([$
2])
36 b4_parser_class_name::yy$
1_
[[]] =
43 # b4_symbol_value_template(VAL, [TYPE])
44 # -------------------------------------
45 # Same as b4_symbol_value, but used in a template method. It makes
46 # a difference when using variants.
47 m4_copy([b4_symbol_value
], [b4_symbol_value_template
])
50 # b4_lex_symbol_if([IF-YYLEX-RETURNS-A-COMPLETE-SYMBOL], [IF-NOT])
51 # ----------------------------------------------------------------
52 m4_define([b4_lex_symbol_if
],
53 [b4_percent_define_ifdef([[lex_symbol]], [$
1], [$
2])])
56 # b4_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
57 # ------------------------------------------------
58 m4_define([b4_assert_if
],
59 [b4_percent_define_ifdef([[assert]], [$
1], [$
2])])
62 # b4_lhs_value([TYPE])
63 # --------------------
64 # Expansion of $<TYPE>$.
65 m4_define([b4_lhs_value
],
66 [b4_symbol_value([yylhs
.value
], [$
1])])
72 m4_define([b4_lhs_location
],
76 # b4_rhs_data(RULE-LENGTH, NUM)
77 # -----------------------------
78 # Return the data corresponding to the symbol #NUM, where the current
79 # rule has RULE-LENGTH symbols on RHS.
80 m4_define([b4_rhs_data
],
81 [yystack_@
{b4_subtract($@
)@
}])
84 # b4_rhs_state(RULE-LENGTH, NUM)
85 # ------------------------------
86 # The state corresponding to the symbol #NUM, where the current
87 # rule has RULE-LENGTH symbols on RHS.
88 m4_define([b4_rhs_state
],
89 [b4_rhs_data([$
1], [$
2]).state
])
92 # b4_rhs_value(RULE-LENGTH, NUM, [TYPE])
93 # --------------------------------------
94 # Expansion of $<TYPE>NUM, where the current rule has RULE-LENGTH
96 m4_define([b4_rhs_value
],
97 [b4_symbol_value([b4_rhs_data([$
1], [$
2]).value
], [$
3])])
100 # b4_rhs_location(RULE-LENGTH, NUM)
101 # ---------------------------------
102 # Expansion of @NUM, where the current rule has RULE-LENGTH symbols
104 m4_define([b4_rhs_location
],
105 [b4_rhs_data([$
1], [$
2]).location
])
108 # b4_symbol_action(SYMBOL-NUM, KIND)
109 # ----------------------------------
110 # Run the action KIND (destructor or printer) for SYMBOL-NUM.
111 # Same as in C, but using references instead of pointers.
112 m4_define([b4_symbol_action
],
113 [b4_symbol_if([$
1], [has_$
2],
114 [m4_pushdef([b4_dollar_dollar
],
115 [b4_symbol_value_template([yysym
.value
],
116 b4_symbol_if([$
1], [has_type
],
117 [b4_symbol([$
1], [type
])]))])dnl
118 m4_pushdef([b4_at_dollar
], [yysym
.location
])dnl
119 b4_symbol_case_([$
1])
120 b4_syncline([b4_symbol([$
1], [$
2_line
])], ["b4_symbol([$1], [$2_file])"])
121 b4_symbol([$
1], [$
2])
122 b4_syncline([@oline@
], [@ofile@
])
125 m4_popdef([b4_at_dollar
])dnl
126 m4_popdef([b4_dollar_dollar
])dnl
129 # b4_symbol_constructor_declaration_(SYMBOL-NUMBER)
130 # -------------------------------------------------
131 # Declare the overloaded version of make_symbol for the (common) type of
132 # these SYMBOL-NUMBERS. Use at class-level.
133 m4_define([b4_symbol_constructor_declaration_
],
134 [b4_symbol_if([$
1], [is_token
], [b4_symbol_if([$
1], [has_id
],
137 make_
[]b4_symbol_([$
1], [id
]) (dnl
138 b4_args(b4_symbol_if([$
1], [has_type
],
139 [const b4_symbol([$
1], [type
])& v
]),
140 b4_locations_if([const location_type
& l
])));
145 # b4_symbol_constructor_declarations
146 # ----------------------------------
147 # Declare symbol constructors for all the value types.
148 # Use at class-level.
149 m4_define([b4_symbol_constructor_declarations
],
151 // Symbol constructors declarations.
152 b4_symbol_foreach([b4_symbol_constructor_declaration_
])])])
156 # b4_symbol_constructor_definition_(SYMBOL-NUMBER)
157 # ------------------------------------------------
158 # Define symbol constructor for this SYMBOL-NUMBER.
159 m4_define([b4_symbol_constructor_definition_
],
160 [b4_symbol_if([$
1], [is_token
], [b4_symbol_if([$
1], [has_id
],
161 [ b4_parser_class_name::symbol_type
162 b4_parser_class_name::make_
[]b4_symbol_([$
1], [id
]) (dnl
163 b4_args(b4_symbol_if([$
1], [has_type
],
164 [const b4_symbol([$
1], [type
])& v
]),
165 b4_locations_if([const location_type
& l
])))
167 return symbol_type (b4_args([yytranslate_ (token::b4_symbol([$
1], [id
]))],
168 b4_symbol_if([$
1], [has_type
], [v
]),
169 b4_locations_if([l
])));
175 # b4_symbol_constructor_definitions
176 # ----------------------------------
177 # Define the overloaded versions of make_symbol for all the value types.
178 m4_define([b4_symbol_constructor_definitions
],
180 // Implementation of make_symbol for each symbol type.
181 b4_symbol_foreach([b4_symbol_constructor_definition_
])])])
184 # b4_yytranslate_definition
185 # -------------------------
186 # Define yytranslate_. Sometimes we want it in the header file,
187 # sometimes the cc file suffices.
188 m4_define([b4_yytranslate_definition
],
189 [[ // Symbol number corresponding to token number t.
190 ]b4_parser_class_name
[::token_number_type
191 ]b4_parser_class_name
[::yytranslate_ (]b4_lex_symbol_if([token_type
],
195 const token_number_type
200 const unsigned int user_token_number_max_
= ]b4_user_token_number_max
[;
201 const token_number_type undef_token_
= ]b4_undef_token_number
[;
203 if (static_cast<int>(t
) <= yyeof_
)
205 else if (static_cast<unsigned int> (t
) <= user_token_number_max_
)
206 return translate_table
[t
];
213 m4_pushdef([b4_copyright_years
],
214 [2002, 2003, 2004, 2005, 2006, 2007, 2008])
216 m4_define([b4_parser_class_name
],
217 [b4_percent_define_get([[parser_class_name]])])
219 # The header is mandatory.
221 [b4_fatal([b4_skeleton
[: using %%defines is mandatory
]])])
224 [# Backward compatibility.
225 m4_define([b4_location_constructors
])
226 m4_include(b4_pkgdatadir
/[location
.cc
])])
227 m4_include(b4_pkgdatadir
/[stack
.hh
])
228 b4_variant_if([m4_include(b4_pkgdatadir
/[variant
.hh
])])
230 # We do want M4 expansion after # for CPP macros.
233 @
output(b4_spec_defines_file@
)@
234 b4_copyright([Skeleton interface
for Bison
LALR(1) parsers in C
++])
235 dnl FIXME
: This is wrong
, we want computed header guards
.
237 /* C++ LALR(1) parser skeleton written by Akim Demaille. */
239 #ifndef PARSER_HEADER_H
240 # define PARSER_HEADER_H
242 ]b4_percent_code_get([[requires]])[
244 ]b4_assert_if([#include <cassert>])[
250 ]b4_locations_if([ class position
;
252 ]b4_variant_if([b4_variant_definition
])[
255 ]b4_locations_if([#include "location.hh"])[
257 /* Enabling traces. */
259 # define YYDEBUG ]b4_debug_flag[
262 /* Enabling verbose error messages. */
263 #ifdef YYERROR_VERBOSE
264 # undef YYERROR_VERBOSE
265 # define YYERROR_VERBOSE 1
267 # define YYERROR_VERBOSE ]b4_error_verbose_flag[
270 /* Enabling the token table. */
271 #ifndef YYTOKEN_TABLE
272 # define YYTOKEN_TABLE ]b4_token_table[
275 ]b4_locations_if([dnl
276 [/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
277 If N is 0, then set CURRENT to the empty location which ends
278 the previous symbol: RHS[0] (always defined). */
280 #ifndef YYLLOC_DEFAULT
281 # define YYLLOC_DEFAULT(Current, Rhs, N) \
285 (Current).begin = (Rhs)[1].location.begin; \
286 (Current).end = (Rhs)[N].location.end; \
290 (Current).begin = (Current).end = (Rhs)[0].location.end; \
298 class ]b4_parser_class_name
[
301 ]b4_public_types_declare
[
302 ]b4_symbol_constructor_declarations
[
303 /// Build a parser object.
304 ]b4_parser_class_name
[ (]b4_parse_param_decl
[);
305 virtual ~]b4_parser_class_name
[ ();
308 /// \returns 0 iff parsing succeeded.
309 virtual int parse ();
312 /// The current debugging stream.
313 std::ostream
& debug_stream () const;
314 /// Set the current debugging stream.
315 void set_debug_stream (std::ostream
&);
317 /// Type for debugging levels.
318 typedef int debug_level_type
;
319 /// The current debugging level.
320 debug_level_type
debug_level () const;
321 /// Set the current debugging level.
322 void set_debug_level (debug_level_type l
);
325 /// Report a syntax error.]b4_locations_if([
326 /// \param loc where the syntax error is found.])[
327 /// \param msg a description of the syntax error.
328 virtual void error (]b4_locations_if([const location_type
& loc
, ])[const std::string
& msg
);
331 /// Generate an error message.
332 /// \param state the state where the error occurred.
333 /// \param tok the lookahead token.
334 virtual std::string
yysyntax_error_ (int yystate
, int tok
);
337 typedef int state_type
;
339 /// Internal symbol numbers.
340 typedef ]b4_int_type_for([b4_translate
])[ token_number_type
;
341 static const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
)[ yypact_ninf_
;
342 static const ]b4_int_type(b4_table_ninf
, b4_table_ninf
)[ yytable_ninf_
;
345 ]b4_parser_tables_declare
[
347 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
348 /// For a symbol, its name in clear.
349 static const char* const yytname_
[];
350 #endif]b4_error_verbose_if([
352 /// Convert the symbol name \a n to a form suitable for a diagnostic.
353 static std::string
yytnamerr_ (const char *n
);])[
356 ]b4_integral_parser_table_declare([rline
], [b4_rline
],
357 [YYRLINE
[YYN
] -- Source line where rule number YYN was defined
.])[
358 /// Report on the debug stream that the rule \a r is going to be reduced.
359 virtual void yy_reduce_print_ (int r
);
360 /// Print the state stack on the debug stream.
361 virtual void yystack_print_ ();
365 std::ostream
* yycdebug_
;
368 /// Convert a scanner token number \a t to a symbol number.
369 static inline token_number_type
yytranslate_ (]b4_lex_symbol_if([token_type
], [int])[ t
);
372 /// \brief Display a symbol type, value and location.
373 /// \param yyo The output stream.
374 /// \param yysym The symbol.
375 template <typename Exact
>
376 void yy_print_ (std::ostream
& yyo
,
377 const symbol_base_type
<Exact
>& yysym
) const;
380 /// \brief Reclaim the memory associated to a symbol.
381 /// \param yymsg Why this token is reclaimed.
382 /// If null, print nothing.
383 /// \param s The symbol.
384 template <typename Exact
>
385 inline void yy_destroy_ (const char* yymsg
,
386 symbol_base_type
<Exact
>& yysym
) const;
389 /// Element of the stack: a state and its attributes.
390 struct stack_symbol_type
: symbol_base_type
<stack_symbol_type
>
392 /// The parent class.
393 typedef symbol_base_type
<stack_symbol_type
> super_type
;
395 /// Default constructor.
396 inline stack_symbol_type ();
399 inline stack_symbol_type (]b4_args([state_type s
],
400 [const semantic_type
& v
],
401 b4_locations_if([const location_type
& l
]))[);
406 /// Return the type corresponding to this state.
407 inline int type_get_ () const;
411 typedef stack
<stack_symbol_type
> stack_type
;
416 /// Push a new state on the stack.
417 /// \param m a debug message to display
418 /// if null, no trace is output.
419 /// \param s the symbol
420 /// \warning the contents of \a s.value is stolen.
421 inline void yypush_ (const char* m
, stack_symbol_type
& s
);
423 /// Push a new look ahead token on the state on the stack.
424 /// \param m a debug message to display
425 /// if null, no trace is output.
426 /// \param s the state
427 /// \param sym the symbol (for its value and location).
428 /// \warning the contents of \a s.value is stolen.
429 inline void yypush_ (const char* m
, state_type s
, symbol_type
& sym
);
431 /// Pop \a n symbols the three stacks.
432 inline void yypop_ (unsigned int n
= 1);
438 yylast_
= ]b4_last
[, //< Last index in yytable_.
439 yynnts_
= ]b4_nterms_number
[, //< Number of nonterminal symbols.
441 yyfinal_
= ]b4_final_state_number
[, //< Termination state number.
444 yyntokens_
= ]b4_tokens_number
[, //< Number of tokens.
447 ]b4_parse_param_vars
[
450 ]b4_lex_symbol_if([b4_yytranslate_definition
451 b4_public_types_define
452 b4_symbol_constructor_definitions
])[
455 ]b4_percent_define_flag_if([[global_tokens_and_yystype]],
456 [b4_token_defines(b4_tokens
)
459 /* Redirection for backward compatibility. */
460 # define YYSTYPE b4_namespace_ref::b4_parser_class_name::semantic_type
463 b4_percent_code_get([[provides]])[]dnl
465 [#endif /* ! defined PARSER_HEADER_H */]
466 @
output(b4_parser_file_name@
)@
467 b4_copyright([Skeleton implementation
for Bison
LALR(1) parsers in C
++])
468 b4_percent_code_get([[top]])[]dnl
469 m4_if(b4_prefix
, [yy
], [],
471 // Take the name prefix into account.
472 #define yylex b4_prefix[]lex])[
474 /* First part of user declarations. */
475 ]b4_user_pre_prologue
[
477 #include "@basename(]b4_spec_defines_file[@)"
479 /* User implementation prologue. */
480 ]b4_user_post_prologue
481 b4_percent_code_get
[]dnl
486 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
487 # define YY_(msgid) dgettext ("bison-runtime", msgid)
491 # define YY_(msgid) msgid
495 /* Suppress unused-variable warnings by "using" E. */
496 #define YYUSE(e) ((void) (e))
498 /* Enable debugging if requested. */
501 /* A pseudo ostream that takes yydebug_ into account. */
502 # define YYCDEBUG if (yydebug_) (*yycdebug_)
504 # define YY_SYMBOL_PRINT(Title, Symbol) \
508 *yycdebug_ << Title << ' '; \
509 yy_print_ (*yycdebug_, Symbol); \
510 *yycdebug_ << std::endl; \
514 # define YY_REDUCE_PRINT(Rule) \
517 yy_reduce_print_ (Rule); \
520 # define YY_STACK_PRINT() \
528 # define YYCDEBUG if (false) std::cerr
529 # define YY_SYMBOL_PRINT(Title, Symbol) static_cast<void>(0)
530 # define YY_REDUCE_PRINT(Rule) static_cast<void>(0)
531 # define YY_STACK_PRINT() static_cast<void>(0)
533 #endif /* !YYDEBUG */
535 #define yyerrok (yyerrstatus_ = 0)
536 #define yyclearin (yyempty = true)
538 #define YYACCEPT goto yyacceptlab
539 #define YYABORT goto yyabortlab
540 #define YYERROR goto yyerrorlab
541 #define YYRECOVERING() (!!yyerrstatus_)
543 ]b4_namespace_open
[]b4_error_verbose_if([[
545 /* Return YYSTR after stripping away unnecessary quotes and
546 backslashes, so that it's suitable for yyerror. The heuristic is
547 that double-quoting is unnecessary unless the string contains an
548 apostrophe, a comma, or backslash (other than backslash-backslash).
549 YYSTR is taken from yytname. */
551 ]b4_parser_class_name
[::yytnamerr_ (const char *yystr
)
555 std::string yyr
= "";
556 char const *yyp
= yystr
;
563 goto do_not_strip_quotes
;
567 goto do_not_strip_quotes
;
576 do_not_strip_quotes
: ;
583 /// Build a parser object.
584 ]b4_parser_class_name::b4_parser_class_name
[ (]b4_parse_param_decl
[)]m4_ifset([b4_parse_param
], [
587 ]m4_ifset([b4_parse_param
], [ ], [ :])[yydebug_ (false),
588 yycdebug_ (&std::cerr
)]m4_ifset([b4_parse_param
], [,])[
589 #endif]b4_parse_param_cons[
593 ]b4_parser_class_name::~b4_parser_class_name
[ ()
602 ]b4_lex_symbol_if([], [b4_public_types_define
603 b4_symbol_constructor_definitions
])[
605 // stack_symbol_type.
606 ]b4_parser_class_name
[::stack_symbol_type::stack_symbol_type ()
612 ]b4_parser_class_name
[::stack_symbol_type::stack_symbol_type (]b4_args(
614 [const semantic_type
& v
],
615 b4_locations_if([const location_type
& l
]))[)
616 : super_type (v
]b4_locations_if([, l
])[)
622 ]b4_parser_class_name
[::stack_symbol_type::type_get_ () const
624 return yystos_
[state
];
628 template <typename Exact
>
630 ]b4_parser_class_name
[::yy_destroy_ (const char* yymsg
,
631 symbol_base_type
<Exact
>& yysym
) const
633 int yytype
= yysym
.type_get ();
636 YY_SYMBOL_PRINT (yymsg
, yysym
);
641 ]b4_symbol_foreach([b4_symbol_destructor
])dnl
647 b4_symbol_variant([[yytype]], [[yysym
.value
]], [[template destroy]])])[
651 template <typename Exact
>
653 ]b4_parser_class_name
[::yy_print_ (std::ostream
& yyo
,
654 const symbol_base_type
<Exact
>& yysym
) const
656 int yytype
= yysym
.type_get ();
657 yyo
<< (yytype
< yyntokens_
? "token" : "nterm")
658 << ' ' << yytname_
[yytype
] << " ("]b4_locations_if([
659 << yysym
.location
<< ": "])[;
662 ]b4_symbol_foreach([b4_symbol_printer
])dnl
671 ]b4_parser_class_name
[::yypush_ (const char* m
, state_type s
,
675 YY_SYMBOL_PRINT (m
, sym
);
677 [[ yystack_
.push (stack_symbol_type (]b4_args(
680 b4_locations_if([sym
.location
]))[));
681 ]b4_symbol_variant([[yystos_
[s
]]], [[yystack_
[0].value
]],
682 [build
], [sym
.value
])],
683 [[ yystack_
.push (stack_symbol_type (]b4_args(
686 b4_locations_if([sym
.location
]))[));]])[
690 ]b4_parser_class_name
[::yypush_ (const char* m
, stack_symbol_type
& s
)
693 YY_SYMBOL_PRINT (m
, s
);
695 [[ yystack_
.push (stack_symbol_type (]b4_args(
698 b4_locations_if([s
.location
]))[));
699 ]b4_symbol_variant([[yystos_
[s
.state
]]], [[yystack_
[0].value
]],
700 [build
], [s
.value
])],
701 [ yystack_
.push (s
);])[
705 ]b4_parser_class_name
[::yypop_ (unsigned int n
)
712 ]b4_parser_class_name
[::debug_stream () const
718 ]b4_parser_class_name
[::set_debug_stream (std::ostream
& o
)
724 ]b4_parser_class_name
[::debug_level_type
725 ]b4_parser_class_name
[::debug_level () const
731 ]b4_parser_class_name
[::set_debug_level (debug_level_type l
)
738 ]b4_parser_class_name
[::parse ()
740 /// Whether yyla contains a lookahead.
748 /* Error handling. */
750 int yyerrstatus_
= 0;
752 /// The lookahead symbol.
753 symbol_type yyla
;]b4_locations_if([[
755 /// The locations where the error started and ended.
756 stack_symbol_type yyerror_range
[2];]])[
759 stack_symbol_type yylhs
;
761 /// The return value of parse().
764 YYCDEBUG
<< "Starting parse" << std::endl
;
766 ]m4_ifdef([b4_initial_action
], [
767 m4_pushdef([b4_at_dollar
], [yyla
.location
])dnl
768 m4_pushdef([b4_dollar_dollar
], [yyla
.value
])dnl
769 /* User initialization code. */
770 b4_user_initial_action
771 m4_popdef([b4_dollar_dollar
])dnl
772 m4_popdef([b4_at_dollar
])])dnl
774 [ /* Initialize the stack. The initial state will be set in
775 yynewstate, since the latter expects the semantical and the
776 location values to have been already stored, initialize these
777 stacks with a primary value. */
778 yystack_
= stack_type (0);
779 yypush_ (0, 0, yyla
);
781 // A new state was pushed on the stack.
782 // Invariant: yystate == yystack_[0].state, i.e.,
783 // yystate was just pushed onto the state stack.
785 YYCDEBUG
<< "Entering state " << yystate
<< std::endl
;
788 if (yystate
== yyfinal_
)
796 /* Try to take a decision without lookahead. */
797 yyn
= yypact_
[yystate
];
798 if (yyn
== yypact_ninf_
)
801 /* Read a lookahead token. */
804 YYCDEBUG
<< "Reading a token: ";
806 [ yyla
= b4_c_function_call([yylex
], [symbol_type
],
807 m4_ifdef([b4_lex_param
], b4_lex_param
));],
808 [ yyla
.type
= yytranslate_ (b4_c_function_call([yylex
], [int],
809 [[YYSTYPE
*], [&yyla
.value
]][]dnl
810 b4_locations_if([, [[location
*], [&yyla
.location
]]])dnl
811 m4_ifdef([b4_lex_param
], [, ]b4_lex_param
)));])[
814 YY_SYMBOL_PRINT ("Next token is", yyla
);
816 /* If the proper action on seeing token YYLA.TYPE is to reduce or
817 to detect an error, take that action. */
819 if (yyn
< 0 || yylast_
< yyn
|| yycheck_
[yyn
] != yyla
.type
)
822 /* Reduce or error. */
826 if (yyn
== 0 || yyn
== yytable_ninf_
)
832 /* Discard the token being shifted. */
835 /* Count tokens shifted since error; after three, turn off error
840 /* Shift the lookahead token. */
842 yypush_ ("Shifting", yystate
, yyla
);
845 /*-----------------------------------------------------------.
846 | yydefault -- do the default action for the current state. |
847 `-----------------------------------------------------------*/
849 yyn
= yydefact_
[yystate
];
854 /*-----------------------------.
855 | yyreduce -- Do a reduction. |
856 `-----------------------------*/
858 yylen
= yyr2_
[yyn
];]b4_variant_if([
859 /* Variants are always initialized to an empty instance of the
860 correct type. The default $$=$1 action is NOT applied when using
862 ]b4_symbol_variant([[yyr1_@
{yyn@
}]], [yylhs
.value
], [build
]),[
863 /* If YYLEN is nonzero, implement the default value of the action:
864 `$$ = $1'. Otherwise, use the top of the stack.
866 Otherwise, the following line sets YYLHS.VALUE to garbage.
867 This behavior is undocumented and Bison
868 users should not rely upon it. */
870 yylhs
.value
= yystack_@
{yylen
- 1@
}.value
;
872 yylhs
.value
= yystack_@
{0@
}.value
;])[
873 ]b4_locations_if([dnl
875 // Compute the default @@$.
877 slice
<stack_symbol_type
, stack_type
> slice (yystack_
, yylen
);
878 YYLLOC_DEFAULT (yylhs
.location
, slice
, yylen
);
881 // Perform the reduction.
882 YY_REDUCE_PRINT (yyn
);
889 // Compute post-reduction state.
891 yystate
= yypgoto_
[yyn
- yyntokens_
] + yystack_
[yylen
].state
;
892 if (0 <= yystate
&& yystate
<= yylast_
893 && yycheck_
[yystate
] == yystack_
[yylen
].state
)
894 yystate
= yytable_
[yystate
];
896 yystate
= yydefgoto_
[yyn
- yyntokens_
];
897 yylhs
.state
= yystate
;
898 YY_SYMBOL_PRINT ("-> $$ =", yylhs
);
900 // Destroy the rhs symbols.
901 for (int i
= 0; i
< yylen
; ++i
)
902 // Destroy a variant which value may have been swapped with
903 // yylhs.value (for instance if the action was "std::swap($$,
904 // $1)"). The value of yylhs.value (hence possibly one of these
905 // rhs symbols) depends on the default contruction for this
906 // type. In the case of pointers for instance, no
907 // initialization is done, so the value is junk. Therefore do
908 // not try to report the value of symbols about to be destroyed
909 // in the debug trace, it's possibly junk. Hence yymsg = 0.
910 // Besides, that keeps exactly the same traces as with the other
912 yy_destroy_ (0, yystack_
[i
]);]])[
918 /* Shift the result of the reduction. */
922 /*--------------------------------------.
923 | yyerrlab -- here on detecting error. |
924 `--------------------------------------*/
926 /* If not already recovering from an error, report this error. */
930 error (]b4_args(b4_locations_if([yyla
.location
]),
931 [yysyntax_error_ (yystate
, yyla
.type
)])[);
935 yyerror_range
[0].location
= yyla
.location
;]])[
936 if (yyerrstatus_
== 3)
938 /* If just tried and failed to reuse lookahead token after an
939 error, discard it. */
941 /* Return failure if at end of input. */
942 if (yyla
.type
== yyeof_
)
946 yy_destroy_ ("Error: discarding", yyla
);
951 /* Else will try to reuse lookahead token after shifting the error
956 /*---------------------------------------------------.
957 | yyerrorlab -- error raised explicitly by YYERROR. |
958 `---------------------------------------------------*/
961 /* Pacify compilers like GCC when the user code never invokes
962 YYERROR and the label yyerrorlab therefore never appears in user
968 yyerror_range
[0].location
= yystack_
[yylen
- 1].location
;]])[
969 /* Do not reclaim the symbols of the rule which action triggered
973 yystate
= yystack_
[0].state
;
976 /*-------------------------------------------------------------.
977 | yyerrlab1 -- common code for both syntax error and YYERROR. |
978 `-------------------------------------------------------------*/
980 yyerrstatus_
= 3; /* Each real token shifted decrements this. */
982 stack_symbol_type error_token
;
985 yyn
= yypact_
[yystate
];
986 if (yyn
!= yypact_ninf_
)
989 if (0 <= yyn
&& yyn
<= yylast_
&& yycheck_
[yyn
] == yyterror_
)
997 // Pop the current state because it cannot handle the error token.
998 if (yystack_
.size () == 1)
1001 yyerror_range
[0].location
= yystack_
[0].location
;]])[
1002 yy_destroy_ ("Error: popping", yystack_
[0]);
1004 yystate
= yystack_
[0].state
;
1008 yyerror_range
[1].location
= yyla
.location
;
1009 YYLLOC_DEFAULT (error_token
.location
, (yyerror_range
- 1), 2);]])[
1011 /* Shift the error token. */
1012 error_token
.state
= yystate
= yyn
;
1013 yypush_ ("Shifting", error_token
);
1029 yy_destroy_ ("Cleanup: discarding lookahead", yyla
);
1031 /* Do not reclaim the symbols of the rule which action triggered
1032 this YYABORT or YYACCEPT. */
1034 while (yystack_
.size () != 1)
1036 yy_destroy_ ("Cleanup: popping", yystack_
[0]);
1043 // Generate an error message.
1045 ]b4_parser_class_name
[::yysyntax_error_ (]dnl
1046 b4_error_verbose_if([int yystate
, int yytoken
],
1049 std::string yyres
;]b4_error_verbose_if([[
1050 int yyn
= yypact_
[yystate
];
1051 if (yypact_ninf_
< yyn
&& yyn
<= yylast_
)
1053 /* Start YYX at -YYN if negative to avoid negative indexes in
1055 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1057 /* Stay within bounds of both yycheck and yytname. */
1058 int yychecklim
= yylast_
- yyn
+ 1;
1059 int yyxend
= yychecklim
< yyntokens_
? yychecklim
: yyntokens_
;
1061 // Number of reported tokens (one for the "unexpected", one per
1065 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1066 // Arguments of yyformat.
1067 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1068 yyarg
[yycount
++] = yytname_
[yytoken
];
1069 for (int yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1070 if (yycheck_
[yyx
+ yyn
] == yyx
&& yyx
!= yyterror_
)
1072 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1078 yyarg
[yycount
++] = yytname_
[yyx
];
1081 char const* yyformat
= 0;
1084 #define YYCASE_(N, S) \
1088 YYCASE_(1, YY_("syntax error, unexpected %s"));
1089 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1090 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1091 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1092 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1097 for (char const* yyp
= yyformat
; *yyp
; ++yyp
)
1098 if (yyp
[0] == '%' && yyp
[1] == 's' && yyi
< yycount
)
1100 yyres
+= yytnamerr_ (yyarg
[yyi
++]);
1108 [ yyres
= YY_("syntax error");
1113 const ]b4_int_type(b4_pact_ninf
, b4_pact_ninf
) b4_parser_class_name::yypact_ninf_
= b4_pact_ninf
[;
1115 const ]b4_int_type(b4_table_ninf
, b4_table_ninf
) b4_parser_class_name::yytable_ninf_
= b4_table_ninf
[;
1117 ]b4_parser_tables_define
[
1119 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
1120 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1121 First, the terminals, then, starting at \a yyntokens_, nonterminals. */
1123 const ]b4_parser_class_name
[::yytname_
[] =
1130 ]b4_integral_parser_table_define([rline
], [b4_rline
])[
1132 // Print the state stack on the debug stream.
1134 ]b4_parser_class_name
[::yystack_print_ ()
1136 *yycdebug_
<< "Stack now";
1137 for (stack_type::const_iterator
1138 i
= yystack_
.begin (),
1139 i_end
= yystack_
.end ();
1141 *yycdebug_
<< ' ' << i
->state
;
1142 *yycdebug_
<< std::endl
;
1145 // Report on the debug stream that the rule \a yyrule is going to be reduced.
1147 ]b4_parser_class_name
[::yy_reduce_print_ (int yyrule
)
1149 unsigned int yylno
= yyrline_
[yyrule
];
1150 int yynrhs
= yyr2_
[yyrule
];
1151 /* Print the symbols being reduced, and their result. */
1152 *yycdebug_
<< "Reducing stack by rule " << yyrule
- 1
1153 << " (line " << yylno
<< "):" << std::endl
;
1154 /* The symbols being reduced. */
1155 for (int yyi
= 0; yyi
< yynrhs
; yyi
++)
1156 YY_SYMBOL_PRINT (" $" << yyi
+ 1 << " =",
1157 ]b4_rhs_data(yynrhs
, yyi
+ 1)[);
1161 ]b4_lex_symbol_if([], [b4_yytranslate_definition
])[
1162 ]b4_namespace_close
[
1165 m4_popdef([b4_copyright_years
])dnl