X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/d6dc4d36d1db744b060029254eaabaaa525a1c19..a339aef48a90a4d8e3b477cfcc2a07f1d5072424:/examples/variant.yy diff --git a/examples/variant.yy b/examples/variant.yy index 25f476a5..fd551cc1 100644 --- a/examples/variant.yy +++ b/examples/variant.yy @@ -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,11 +16,11 @@ */ %debug -%skeleton "lalr1.cc" +%language "c++" %defines %define api.token.constructor +%define api.value.type variant %define parse.assert -%define variant %locations %code requires // *.hh @@ -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 << "}"; } } @@ -70,8 +76,7 @@ typedef std::list strings_type; %token <::std::string> TEXT; %token NUMBER; -%printer { debug_stream () << $$; } - <::std::string> <::std::list>; +%printer { yyoutput << $$; } <*>; %token END_OF_FILE 0; %type <::std::string> item;