mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 17:53:02 +00:00
examples: improve the output of the "variant" example
* examples/variant.yy: Improve the printing of lists.
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
%debug
|
%debug
|
||||||
%skeleton "lalr1.cc"
|
%language "c++"
|
||||||
%defines
|
%defines
|
||||||
%define api.token.constructor
|
%define api.token.constructor
|
||||||
%define api.value.type variant
|
%define api.value.type variant
|
||||||
@@ -48,11 +48,17 @@ typedef std::list<std::string> strings_type;
|
|||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
std::ostream&
|
std::ostream&
|
||||||
operator<< (std::ostream& o, const strings_type& s)
|
operator<< (std::ostream& o, const strings_type& ss)
|
||||||
{
|
{
|
||||||
std::copy (s.begin (), s.end (),
|
o << "(" << &ss << ") {";
|
||||||
std::ostream_iterator<strings_type::value_type> (o, "\n"));
|
const char *sep = "";
|
||||||
return o;
|
for (strings_type::const_iterator i = ss.begin(), end = ss.end();
|
||||||
|
i != end; ++i)
|
||||||
|
{
|
||||||
|
o << sep << *i;
|
||||||
|
sep = ", ";
|
||||||
|
}
|
||||||
|
return o << "}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user