Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61291 - in trunk/libs/spirit/example/scheme: detail output test
From: hartmut.kaiser_at_[hidden]
Date: 2010-04-15 10:38:02


Author: hkaiser
Date: 2010-04-15 10:38:00 EDT (Thu, 15 Apr 2010)
New Revision: 61291
URL: http://svn.boost.org/trac/boost/changeset/61291

Log:
Spirit: fixed utree generator to support reference nodes
Text files modified:
   trunk/libs/spirit/example/scheme/detail/utree_detail3.hpp | 12 ++++++++++++
   trunk/libs/spirit/example/scheme/output/sexpr.hpp | 11 +++++++++++
   trunk/libs/spirit/example/scheme/test/utree_test.cpp | 2 +-
   3 files changed, 24 insertions(+), 1 deletions(-)

Modified: trunk/libs/spirit/example/scheme/detail/utree_detail3.hpp
==============================================================================
--- trunk/libs/spirit/example/scheme/detail/utree_detail3.hpp (original)
+++ trunk/libs/spirit/example/scheme/detail/utree_detail3.hpp 2010-04-15 10:38:00 EDT (Thu, 15 Apr 2010)
@@ -34,6 +34,7 @@
             utree_type::list_type);
         SCHEME_GET_UTREE_TYPE(boost::iterator_range<utree::const_iterator>,
             utree_type::list_type);
+ SCHEME_GET_UTREE_TYPE(utree, utree_type::reference_type);
 
 #undef SCHEME_GET_UTREE_TYPE
 
@@ -140,6 +141,17 @@
                 return type(x.s.str(), x.s.size());
             }
         };
+
+ template <>
+ struct get_impl<utree>
+ {
+ typedef utree const& type;
+ static type call(utree const& x)
+ {
+ return (x.which() == scheme::utree_type::reference_type) ?
+ x.deref() : x;
+ }
+ };
     }
 }
 

Modified: trunk/libs/spirit/example/scheme/output/sexpr.hpp
==============================================================================
--- trunk/libs/spirit/example/scheme/output/sexpr.hpp (original)
+++ trunk/libs/spirit/example/scheme/output/sexpr.hpp 2010-04-15 10:38:00 EDT (Thu, 15 Apr 2010)
@@ -129,6 +129,14 @@
         typedef scheme::binary_string compatible_type;
         typedef mpl::int_<scheme::utree_type::binary_type> distance;
     };
+
+ template <>
+ struct compute_compatible_component_variant<scheme::utree, scheme::utree>
+ : mpl::true_
+ {
+ typedef scheme::utree compatible_type;
+ typedef mpl::int_<scheme::utree_type::reference_type> distance;
+ };
 }}}
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -165,6 +173,7 @@
                       | byte_str
                       | list
                       | nil_
+ | ref_
                       ;
 
             list = '(' << *start << ')';
@@ -173,6 +182,7 @@
             symbol = string;
             byte_str = 'b' << *right_align(2, '0')[hex2];
             nil_ = eps << "<nil>";
+ ref_ = start;
         }
 
         typedef boost::iterator_range<utree::const_iterator> utree_list;
@@ -183,6 +193,7 @@
         rule<OutputIterator, utf8_string_range()> string_;
         rule<OutputIterator, binary_range()> byte_str;
         rule<OutputIterator, nil()> nil_;
+ rule<OutputIterator, space_type, utree()> ref_;
     };
 }}
 

Modified: trunk/libs/spirit/example/scheme/test/utree_test.cpp
==============================================================================
--- trunk/libs/spirit/example/scheme/test/utree_test.cpp (original)
+++ trunk/libs/spirit/example/scheme/test/utree_test.cpp 2010-04-15 10:38:00 EDT (Thu, 15 Apr 2010)
@@ -17,7 +17,7 @@
 {
     std::stringstream s;
     s << val;
- BOOST_ASSERT(s.str() == expected);
+ BOOST_ASSERT(s.str() == expected + " ");
 }
 
 int main()


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk