bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Define the constructors of symbol_type in b4_symbol_constructor_


From: Akim Demaille
Subject: [PATCH] Define the constructors of symbol_type in b4_symbol_constructor_definitions.
Date: Thu, 13 Nov 2008 05:44:53 -0000

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 1c76086..6219754 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2008-11-13  Akim Demaille  <address@hidden>
 
+       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  <address@hidden>
+
        Make it easier to move the definition of yytranslate_.
        Forthcoming changes will make it possible to use yytranslate_
        from outside the parser implementation file.
diff --git a/data/lalr1.cc b/data/lalr1.cc
index d6a4878..3fdd33e 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 <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_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 <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_symbol_constructor_definitions[
 
   // stack_symbol_type.
-- 
1.6.0.2.588.g3102





reply via email to

[Prev in Thread] Current Thread [Next in Thread]