-m4_popdef([b4_at_dollar])dnl
-m4_popdef([b4_dollar_dollar])dnl
-])
-
-
-# b4_symbol_case_(SYMBOL-NUM)
-# ---------------------------
-# Issue a "case NUM" for SYMBOL-NUM.
-m4_define([b4_symbol_case_],
-[ case b4_symbol([$1], [number]): // b4_symbol([$1], [tag])
-])
-
-
-# b4_type_action_(NUMS)
-# ---------------------
-# Run actions for the symbol NUMS that all have the same type-name.
-# Skip NUMS that have no type-name.
-m4_define([b4_type_action_],
-[b4_symbol_if([$1], [has_type],
-[m4_map([b4_symbol_case_], [$@])[]dnl
- b4_dollar_dollar([b4_symbol([$1], [number])],
- [b4_symbol([$1], [tag])],
- [b4_symbol([$1], [type])]);
- break;
-
-])])
-
-
-# b4_symbol_constructor_declaration_(SYMBOL-NUMBERS)
-# ----------------------------------------------------
-# Declare the overloaded version of make_symbol for the (common) type of
-# these SYMBOL-NUMBERS. Use at class-level.
-m4_define([b4_symbol_constructor_declaration_],
-[ template <token_type>
- static inline symbol_type
- make_symbol (b4_args(b4_symbol_if([$1], [has_type],
- [const b4_symbol([$1], [type])& v]),
- b4_locations_if([const location_type& l])));
-
-])
-
-# b4_symbol_constructor_declarations
-# ----------------------------------
-# Declare the overloaded versions of make_symbol for all the value types.
-# Use at class-level.
-m4_define([b4_symbol_constructor_declarations],
-[b4_variant_if([
- // Declaration of make_symbol for each value type.
-m4_map([b4_symbol_constructor_declaration_], m4_defn([b4_type_names]))])])
-
-
-
-# b4_symbol_constructor_specialization_(SYMBOL-NUMBER)
-# ----------------------------------------------------
-# Declare the specialization of make_symbol for this each SYMBOL-NUMBER.
-# Specializations cannot be declared at class-level, this must be done
-# at namespace-level.
-m4_define([b4_symbol_constructor_specialization_],
-[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
-[ template <>
- inline
- b4_parser_class_name::symbol_type
- b4_parser_class_name::make_symbol <b4_parser_class_name::token::b4_symbol([$1], [id])> (dnl
-b4_args(b4_symbol_if([$1], [has_type],
- [const b4_symbol([$1], [type])& v]),
- b4_locations_if([const location_type& l])));
-
-])])])
-
-# b4_symbol_constructor_specializations
-# -------------------------------------
-# Declare specializations of make_symbol.
-m4_define([b4_symbol_constructor_specializations],
-[b4_variant_if([
- // Specializations of make_symbol for each symbol type.
-m4_map([b4_symbol_constructor_specialization_],
- m4_defn([b4_symbol_numbers]))])dnl
-])
-
-
-
-# b4_symbol_constructor_definition_(SYMBOL-NUMBER)
-# ------------------------------------------------
-# Define make_symbol for this SYMBOL-NUMBER.
-m4_define([b4_symbol_constructor_definition_],
-[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
-[ template <>
- b4_parser_class_name::symbol_type
- b4_parser_class_name::make_symbol <b4_parser_class_name::token::b4_symbol([$1], [id])> (dnl
-b4_args(b4_symbol_if([$1], [has_type],
- [const b4_symbol([$1], [type])& v]),
- b4_locations_if([const location_type& l])))
- {
- return symbol_type (b4_args([yytranslate_ (token::b4_symbol([$1], [id]))],
- b4_symbol_if([$1], [has_type], [v]),
- b4_locations_if([l])));
- }
-
-])])])
-
-
-# b4_symbol_constructor_definitions
-# ----------------------------------
-# Define the overloaded versions of make_symbol for all the value types.
-m4_define([b4_symbol_constructor_definitions],
-[[ // symbol_base_type.
- template <typename Exact>
- ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type ()
- : value()]b4_locations_if([
- , location()])[
- {
- }]b4_locations_if([[
-
- template <typename Exact>
- ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (const location_type& l)
- : value()
- , location(l)
- {
- }]])[
-
- template <typename Exact>
- ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (]b4_args(
- [const semantic_type& v],
- b4_locations_if([const location_type& l]))[)
- : value(v)]b4_locations_if([
- , location(l)])[
- {
- }
-
- template <typename Exact>
- const Exact&
- ]b4_parser_class_name[::symbol_base_type<Exact>::self () const
- {
- return static_cast<const Exact&>(*this);
- }
-
- template <typename Exact>
- Exact&
- ]b4_parser_class_name[::symbol_base_type<Exact>::self ()
- {
- return static_cast<Exact&>(*this);
- }
-
- template <typename Exact>
- int
- ]b4_parser_class_name[::symbol_base_type<Exact>::type_get () const
- {
- return self ().type_get_ ();
- }
-
- // symbol_type.
- ]b4_parser_class_name[::symbol_type::symbol_type ()
- : super_type ()
- , type ()
- {
- }
-
- ]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
- [int t],
- b4_locations_if([const location_type& l]))[)
- : super_type (]b4_locations_if([l])[)
- , type (t)
- {
- }
-
- ]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
- [int t],
- [const semantic_type& v],
- b4_locations_if([const location_type& l]))[)
- : super_type (v]b4_locations_if([, l])[)
- , type (t)
- {
- }
-
- int
- ]b4_parser_class_name[::symbol_type::type_get_ () const
- {
- return type;
- }
-]b4_lex_symbol_if([[
- ]b4_parser_class_name[::token_type
- ]b4_parser_class_name[::symbol_type::token () const
- {
- // YYTOKNUM[NUM] -- (External) token number corresponding to the
- // (internal) symbol number NUM (which must be that of a token). */
- static
- const ]b4_int_type_for([b4_toknum])[
- yytoken_number_[] =
- {
- ]b4_toknum[
- };
- return static_cast<token_type> (yytoken_number_[type]);
- }
-]])[
-
-]b4_variant_if(
-[ // Implementation of make_symbol for each symbol type.
-m4_map([b4_symbol_constructor_definition_], m4_defn([b4_symbol_numbers]))])])
-
-
-# b4_symbol_variant(YYTYPE, YYVAL, ACTION, [ARGS])
-# ------------------------------------------------
-# Run some ACTION ("build", or "destroy") on YYVAL of symbol type
-# YYTYPE.
-m4_define([b4_symbol_variant],
-[m4_pushdef([b4_dollar_dollar],
- [$2.$3<$][3>(m4_shift3($@))])dnl
- switch ($1)
- {
-m4_map([b4_type_action_], m4_defn([b4_type_names]))[]dnl
- default:
- break;
- }
-m4_popdef([b4_dollar_dollar])dnl
-])