mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
Use string_cast in the bench.
* etc/bench.pl.in (generate_grammar_list): Define and use string_cast.
This commit is contained in:
@@ -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>
|
2008-11-11 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
Replace yychar with a Boolean.
|
Replace yychar with a Boolean.
|
||||||
|
|||||||
@@ -615,6 +615,17 @@ static yy::parser::token_type yylex(yy::parser::semantic_type* yylval);
|
|||||||
#else
|
#else
|
||||||
# define IF_ONE_STAGE_BUILD(True, False) False
|
# define IF_ONE_STAGE_BUILD(True, False) False
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Conversion to string.
|
||||||
|
template <typename T>
|
||||||
|
inline
|
||||||
|
std::string
|
||||||
|
string_cast (const T& t)
|
||||||
|
{
|
||||||
|
std::ostringstream o;
|
||||||
|
o << t;
|
||||||
|
return o.str ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@@ -636,11 +647,7 @@ result:
|
|||||||
text:
|
text:
|
||||||
/* nothing */ { /* This will generate an empty string */ }
|
/* nothing */ { /* This will generate an empty string */ }
|
||||||
| text TEXT { std::swap ($$, $2); }
|
| text TEXT { std::swap ($$, $2); }
|
||||||
| text NUMBER {
|
| text NUMBER { $$ = string_cast($2); }
|
||||||
std::ostringstream ss;
|
|
||||||
ss << ' ' << $2;
|
|
||||||
$$ = ss.str();
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@@ -664,12 +671,7 @@ result:
|
|||||||
text:
|
text:
|
||||||
/* nothing */ { $$ = new std::string; }
|
/* nothing */ { $$ = new std::string; }
|
||||||
| text TEXT { delete $1; $$ = $2; }
|
| text TEXT { delete $1; $$ = $2; }
|
||||||
| text NUMBER {
|
| text NUMBER { delete $1; $$ = new std::string (string_cast ($2)); }
|
||||||
delete $1;
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << ' ' << $2;
|
|
||||||
$$ = new std::string (ss.str());
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user