From: Akim Demaille Date: Thu, 19 Sep 2013 13:20:22 +0000 (+0200) Subject: examples: improve the output of the "variant" example X-Git-Tag: v3.0.1~29 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/b51cf830a6cb513ca8e357321307997672d6d6b0 examples: improve the output of the "variant" example * examples/variant.yy: Improve the printing of lists. --- diff --git a/examples/variant.yy b/examples/variant.yy index 9413cbcf..fd551cc1 100644 --- a/examples/variant.yy +++ b/examples/variant.yy @@ -16,7 +16,7 @@ */ %debug -%skeleton "lalr1.cc" +%language "c++" %defines %define api.token.constructor %define api.value.type variant @@ -48,11 +48,17 @@ typedef std::list strings_type; namespace std { std::ostream& - operator<< (std::ostream& o, const strings_type& s) + operator<< (std::ostream& o, const strings_type& ss) { - std::copy (s.begin (), s.end (), - std::ostream_iterator (o, "\n")); - return o; + o << "(" << &ss << ") {"; + const char *sep = ""; + for (strings_type::const_iterator i = ss.begin(), end = ss.end(); + i != end; ++i) + { + o << sep << *i; + sep = ", "; + } + return o << "}"; } }