bison-patches
[Top][All Lists]
Advanced

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

variant: indent better the generated code


From: Akim Demaille
Subject: variant: indent better the generated code
Date: Sun, 9 Sep 2018 10:32:53 +0200

More patches extracted from my WIP on move semantics.  Now, I think it’s
mature, I will submit it soon.

FTR, the diff on the generated examples/variant.hh here (no differences
on variant.cc) with the last too commits is:

--- _build/7d/examples/variant.hh       2018-09-09 10:09:13.987769528 +0200
+++ _build/8s/examples/variant.hh       2018-09-09 10:13:29.657106152 +0200
@@ -368,20 +368,11 @@
       basic_symbol (const basic_symbol& other);
 
       /// Constructor for valueless symbols, and symbols from each type.
+      basic_symbol (typename Base::kind_type t, const location_type& l);
+      basic_symbol (typename Base::kind_type t, const ::std::string& v, const 
location_type& l);
+      basic_symbol (typename Base::kind_type t, const 
::std::vector<std::string>& v, const location_type& l);
+      basic_symbol (typename Base::kind_type t, const int& v, const 
location_type& l);
 
-  basic_symbol (typename Base::kind_type t, const location_type& l);
-
-  basic_symbol (typename Base::kind_type t, const ::std::string& v, const 
location_type& l);
-
-  basic_symbol (typename Base::kind_type t, const ::std::vector<std::string>& 
v, const location_type& l);
-
-  basic_symbol (typename Base::kind_type t, const int& v, const location_type& 
l);
-
-
-      /// Constructor for symbols with semantic value.
-      basic_symbol (typename Base::kind_type t,
-                    const semantic_type& v,
-                    const location_type& l);
 
       /// Destroy the symbol.
       ~basic_symbol ();
@@ -759,36 +750,8 @@
 
   }
 
-  template <typename Base>
-  parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const 
semantic_type& v, const location_type& l)
-    : Base (t)
-    , value ()
-    , location (l)
-  {
-    (void) v;
-    switch (this->type_get ())
-    {
-      case 3: // TEXT
-      case 8: // item
-        value.copy< ::std::string > (v);
-        break;
-
-      case 7: // list
-        value.copy< ::std::vector<std::string> > (v);
-        break;
-
-      case 4: // NUMBER
-        value.copy< int > (v);
-        break;
-
-      default:
-        break;
-    }
-}
-
 
   // Implementation of basic_symbol constructor for each type.
-
   template <typename Base>
   parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const 
location_type& l)
     : Base (t)
@@ -817,6 +780,7 @@
   {}
 
 
+
   template <typename Base>
   parser::basic_symbol<Base>::~basic_symbol ()
   {
@@ -972,7 +936,7 @@
 
 
 } // yy
-#line 976 "examples/variant.hh" // lalr1.cc:383
+#line 940 "examples/variant.hh" // lalr1.cc:383
 
 
 
—————————————————————————————————————————————————————————————————————

commit 1c104444cd45a563d92eecf6d6f3a05c4b20fce5
Author: Akim Demaille <address@hidden>
Date:   Sun Sep 9 10:20:01 2018 +0200

    variant: indent better the generated code
    
    * data/variant.hh (b4_basic_symbol_constructor_declare)
    (b4_basic_symbol_constructor_define): here.

diff --git a/data/variant.hh b/data/variant.hh
index a4db750a..a10d9447 100644
--- a/data/variant.hh
+++ b/data/variant.hh
@@ -333,8 +333,7 @@ b4_join(b4_symbol_if([$1], [has_type],
 # -----------------------------------
 # Generate a constructor declaration for basic_symbol from given type.
 m4_define([b4_basic_symbol_constructor_declare],
-[[
-  basic_symbol (]b4_join(
+[[      basic_symbol (]b4_join(
           [typename Base::kind_type t],
           b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[& v]),
           b4_locations_if([const location_type& l]))[);
@@ -344,8 +343,7 @@ m4_define([b4_basic_symbol_constructor_declare],
 # ----------------------------------
 # Generate a constructor implementation for basic_symbol from given type.
 m4_define([b4_basic_symbol_constructor_define],
-[[
-  template <typename Base>
+[[  template <typename Base>
   ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
           [typename Base::kind_type t],
           b4_symbol_if([$1], [has_type], const b4_symbol([$1], [type])[& v]),
@@ -354,6 +352,7 @@ m4_define([b4_basic_symbol_constructor_define],
     , value (v)])[]b4_locations_if([
     , location (l)])[
   {}
+
 ]])
 
 # b4_symbol_constructor_define




reply via email to

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