]> git.saurik.com Git - bison.git/commitdiff
Use string_cast in the bench.
authorAkim Demaille <demaille@gostai.com>
Mon, 18 Aug 2008 20:53:15 +0000 (22:53 +0200)
committerAkim Demaille <demaille@gostai.com>
Tue, 11 Nov 2008 14:39:28 +0000 (15:39 +0100)
* etc/bench.pl.in (generate_grammar_list): Define and use
string_cast.

ChangeLog
etc/bench.pl.in

index 41c2490808244067e6838e22644822c61d09c4d6..4216d4297a9f84b6d9d90e796b522f097e35fd09 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-11  Akim Demaille  <demaille@gostai.com>
+
+       Use string_cast in the bench.
+       * etc/bench.pl.in (generate_grammar_list): Define and use
+       string_cast.
+
 2008-11-11  Akim Demaille  <demaille@gostai.com>
 
        Replace yychar with a Boolean.
index 0e5362901e4cc3ccbaa227dee0ea82c07f0f70f8..1ee98b7f75c7b1d8ffd403ab09b4555e079b76a1 100755 (executable)
@@ -615,6 +615,17 @@ static yy::parser::token_type yylex(yy::parser::semantic_type* yylval);
 #else
 # define IF_ONE_STAGE_BUILD(True, False) False
 #endif
+
+  // Conversion to string.
+  template <typename T>
+    inline
+    std::string
+    string_cast (const T& t)
+  {
+    std::ostringstream o;
+    o << t;
+    return o.str ();
+  }
 }
 EOF
 
@@ -636,11 +647,7 @@ result:
 text:
   /* nothing */                { /* This will generate an empty string */ }
 | text TEXT            { std::swap ($$, $2); }
-| text NUMBER          {
-                         std::ostringstream ss;
-                         ss << ' ' << $2;
-                         $$ = ss.str();
-                        }
+| text NUMBER          { $$ = string_cast($2); }
 ;
 EOF
     }
@@ -664,12 +671,7 @@ result:
 text:
   /* nothing */                { $$ = new std::string; }
 | text TEXT            { delete $1; $$ = $2; }
-| text NUMBER          {
-                          delete $1;
-                          std::ostringstream ss;
-                         ss << ' ' << $2;
-                         $$ = new std::string (ss.str());
-                        }
+| text NUMBER          { delete $1; $$ = new std::string (string_cast ($2)); }
 ;
 EOF
     }