diff options
author | Akim Demaille <demaille@gostai.com> | 2008-08-18 22:53:15 +0200 |
---|---|---|
committer | Akim Demaille <demaille@gostai.com> | 2008-11-11 15:39:28 +0100 |
commit | 918eb7c5ae9ec56d998fe931cc437cb626fe5cb4 (patch) | |
tree | 0934a55aaf70955cf582cc74c9de2002e0f9d4d1 /etc | |
parent | 39be90223b73a42d249f99cdf283c4ab46a10a21 (diff) | |
download | bison-918eb7c5ae9ec56d998fe931cc437cb626fe5cb4.tar.gz |
Use string_cast in the bench.
* etc/bench.pl.in (generate_grammar_list): Define and use
string_cast.
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/bench.pl.in | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/etc/bench.pl.in b/etc/bench.pl.in index 0e536290..1ee98b7f 100755 --- a/etc/bench.pl.in +++ b/etc/bench.pl.in @@ -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 } |