]> git.saurik.com Git - bison.git/blobdiff - examples/variant.yy
xml: also use "%empty" with html output
[bison.git] / examples / variant.yy
index eef2080dbabbe188c884bf21c5eae47a8e4e1665..fd551cc19ab299a9c5160f7e00f691f941fecdba 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2008-2012 Free Software Foundation, Inc.
+  Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -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 << "}";
     }
   }