[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/7] examples: improve the output of the "variant" example
From: |
Akim Demaille |
Subject: |
[PATCH 3/7] examples: improve the output of the "variant" example |
Date: |
Thu, 19 Sep 2013 16:26:03 +0200 |
* examples/variant.yy: Improve the printing of lists.
---
examples/variant.yy | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/examples/variant.yy b/examples/variant.yy
index 9413cbc..fd551cc 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<std::string> 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<strings_type::value_type> (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 << "}";
}
}
--
1.8.4
- [PATCH 0/7] {maint} minor issues, Akim Demaille, 2013/09/19
- [PATCH 1/7] tests: remove stray debugging traces, Akim Demaille, 2013/09/19
- [PATCH 3/7] examples: improve the output of the "variant" example,
Akim Demaille <=
- [PATCH 4/7] glr: better use of tracing macros, Akim Demaille, 2013/09/19
- [PATCH 6/7] glr: shorten scopes, Akim Demaille, 2013/09/19
- [PATCH 2/7] variant: remove useless assertion, Akim Demaille, 2013/09/19
- [PATCH 7/7] glr: more assertions, Akim Demaille, 2013/09/19
- [PATCH 5/7] glr: formatting changes, Akim Demaille, 2013/09/19