From e51b0a82be0ea8051f6e95dc668288c74c55ae9b Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 28 Aug 2008 13:31:56 +0200 Subject: [PATCH] Define the constructors of symbol_type in b4_symbol_constructor_definitions. The constructors are called by the make_symbol functions, which a forthcoming patch will move elsewhere. Hence the interest of putting them together. The stack_symbol_type does not need to be moved, it is used only by the parser. * data/lalr1.cc: Move symbol_type and symbol_base_type constructors into... (b4_symbol_constructor_definitions): here. Adjust. --- ChangeLog | 15 +++++ data/lalr1.cc | 154 +++++++++++++++++++++++++------------------------- 2 files changed, 92 insertions(+), 77 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1c76086c..62197542 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-11-13 Akim Demaille + + Define the constructors of symbol_type in b4_symbol_constructor_definitions. + The constructors are called by the make_symbol functions, which a + forthcoming patch will move elsewhere. Hence the interest of putting them + together. + + The stack_symbol_type does not need to be moved, it is used only by the + parser. + + * data/lalr1.cc: Move symbol_type and symbol_base_type + constructors into... + (b4_symbol_constructor_definitions): here. + Adjust. + 2008-11-13 Akim Demaille Make it easier to move the definition of yytranslate_. diff --git a/data/lalr1.cc b/data/lalr1.cc index d6a48780..3fdd33ea 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -267,11 +267,86 @@ b4_args(b4_symbol_if([$1], [has_type], ])])]) -# b4_symbol_constructor_declarations +# b4_symbol_constructor_definitions # ---------------------------------- # Define the overloaded versions of make_symbol for all the value types. m4_define([b4_symbol_constructor_definitions], -[b4_variant_if( +[[ // symbol_base_type. + template + ]b4_parser_class_name[::symbol_base_type::symbol_base_type () + : value()]b4_locations_if([ + , location()])[ + { + }]b4_locations_if([[ + + template + ]b4_parser_class_name[::symbol_base_type::symbol_base_type (const location_type& l) + : value() + , location(l) + { + }]])[ + + template + ]b4_parser_class_name[::symbol_base_type::symbol_base_type (]b4_args( + [const semantic_type& v], + b4_locations_if([const location_type& l]))[) + : value(v)]b4_locations_if([ + , location(l)])[ + { + } + + template + const Exact& + ]b4_parser_class_name[::symbol_base_type::self () const + { + return static_cast(*this); + } + + template + Exact& + ]b4_parser_class_name[::symbol_base_type::self () + { + return static_cast(*this); + } + + template + int + ]b4_parser_class_name[::symbol_base_type::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_variant_if( [ // Implementation of make_symbol for each symbol type. m4_map([b4_symbol_constructor_definition_], m4_defn([b4_symbol_numbers]))])]) @@ -948,81 +1023,6 @@ b4_percent_code_get[]dnl | Symbol types. | `---------------*/ - // symbol_base_type. - template - ]b4_parser_class_name[::symbol_base_type::symbol_base_type () - : value()]b4_locations_if([ - , location()])[ - { - }]b4_locations_if([[ - - template - ]b4_parser_class_name[::symbol_base_type::symbol_base_type (const location_type& l) - : value() - , location(l) - { - }]])[ - - template - ]b4_parser_class_name[::symbol_base_type::symbol_base_type (]b4_args( - [const semantic_type& v], - b4_locations_if([const location_type& l]))[) - : value(v)]b4_locations_if([ - , location(l)])[ - { - } - - template - const Exact& - ]b4_parser_class_name[::symbol_base_type::self () const - { - return static_cast(*this); - } - - template - Exact& - ]b4_parser_class_name[::symbol_base_type::self () - { - return static_cast(*this); - } - - template - int - ]b4_parser_class_name[::symbol_base_type::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_symbol_constructor_definitions[ // stack_symbol_type. -- 2.45.2