Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63628 - in branches/release: . boost boost/algorithm/string boost/archive boost/bimap boost/detail boost/filesystem boost/functional/hash boost/fusion boost/gil boost/graph boost/integer boost/interprocess boost/intrusive boost/msm boost/numeric/ublas boost/program_options boost/property_tree boost/python boost/serialization boost/signals boost/signals2 boost/spirit boost/spirit/home boost/spirit/home/karma boost/spirit/home/karma/detail boost/spirit/home/qi/detail boost/spirit/home/support boost/system boost/thread boost/utility boost/uuid boost/variant boost/wave libs libs/array/test libs/bimap libs/filesystem libs/functional/hash libs/fusion libs/graph_parallel libs/integer libs/interprocess libs/intrusive libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/msm libs/numeric/ublas libs/numeric/ublas/doc libs/property_tree libs/python libs/serialization libs/signals libs/signals2 libs/spirit libs/spirit/classic/example libs/spirit/doc libs/spirit/example libs/spirit/example/scheme libs/spirit/example/scheme/detail libs/spirit/example/scheme/input libs/spirit/example/scheme/output libs/spirit/example/scheme/qi libs/spirit/example/scheme/test libs/spirit/example/scheme/test/parse_qiexpr libs/spirit/phoenix libs/spirit/test libs/spirit/test/qi libs/static_assert libs/system libs/thread libs/timer libs/utility libs/utility/swap/test libs/uuid libs/wave status tools tools/bcp tools/jam tools/regression tools/release tools/wave
From: hartmut.kaiser_at_[hidden]
Date: 2010-07-04 15:45:52


Author: hkaiser
Date: 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
New Revision: 63628
URL: http://svn.boost.org/trac/boost/changeset/63628

Log:
Spirit: merging from trunk upto rev. 61266
Added:
   branches/release/libs/spirit/example/scheme/detail/scheme_composite_call.hpp
      - copied unchanged from r61238, /trunk/libs/spirit/example/scheme/detail/scheme_composite_call.hpp
   branches/release/libs/spirit/example/scheme/detail/scheme_function_call.hpp
      - copied, changed from r61191, /trunk/libs/spirit/example/scheme/detail/scheme_function_call.hpp
   branches/release/libs/spirit/example/scheme/qi/
      - copied from r61266, /trunk/libs/spirit/example/scheme/qi/
   branches/release/libs/spirit/example/scheme/qi/parse_qiexpr.hpp
      - copied unchanged from r61266, /trunk/libs/spirit/example/scheme/qi/parse_qiexpr.hpp
   branches/release/libs/spirit/example/scheme/qi/parse_qiexpr_impl.hpp
      - copied unchanged from r61266, /trunk/libs/spirit/example/scheme/qi/parse_qiexpr_impl.hpp
   branches/release/libs/spirit/example/scheme/qi/qiexpr_parser.hpp
      - copied unchanged from r61266, /trunk/libs/spirit/example/scheme/qi/qiexpr_parser.hpp
   branches/release/libs/spirit/example/scheme/scheme_intrinsics.hpp
      - copied unchanged from r61262, /trunk/libs/spirit/example/scheme/scheme_intrinsics.hpp
   branches/release/libs/spirit/example/scheme/todo.txt
      - copied unchanged from r61266, /trunk/libs/spirit/example/scheme/todo.txt
   branches/release/libs/spirit/example/scheme/utree_io.hpp
      - copied unchanged from r61230, /trunk/libs/spirit/example/scheme/utree_io.hpp
Removed:
   branches/release/libs/spirit/example/scheme/input/parse_qiexpr.hpp
   branches/release/libs/spirit/example/scheme/input/parse_qiexpr_impl.hpp
   branches/release/libs/spirit/example/scheme/input/qiexpr.hpp
Properties modified:
   branches/release/ (props changed)
   branches/release/INSTALL (props changed)
   branches/release/LICENSE_1_0.txt (props changed)
   branches/release/boost/ (props changed)
   branches/release/boost-build.jam (props changed)
   branches/release/boost.css (props changed)
   branches/release/boost.png (props changed)
   branches/release/boost/algorithm/string/ (props changed)
   branches/release/boost/archive/ (props changed)
   branches/release/boost/bimap/ (props changed)
   branches/release/boost/detail/ (props changed)
   branches/release/boost/filesystem/ (props changed)
   branches/release/boost/functional/hash/ (props changed)
   branches/release/boost/fusion/ (props changed)
   branches/release/boost/gil/ (props changed)
   branches/release/boost/graph/ (props changed)
   branches/release/boost/integer/ (props changed)
   branches/release/boost/interprocess/ (props changed)
   branches/release/boost/intrusive/ (props changed)
   branches/release/boost/msm/ (props changed)
   branches/release/boost/numeric/ublas/ (props changed)
   branches/release/boost/program_options/ (props changed)
   branches/release/boost/property_tree/ (props changed)
   branches/release/boost/python/ (props changed)
   branches/release/boost/serialization/ (props changed)
   branches/release/boost/serialization/factory.hpp (props changed)
   branches/release/boost/signals/ (props changed)
   branches/release/boost/signals2/ (props changed)
   branches/release/boost/spirit/ (props changed)
   branches/release/boost/spirit/home/ (props changed)
   branches/release/boost/spirit/home/karma/ (props changed)
   branches/release/boost/spirit/home/support/attributes.hpp (contents, props changed)
   branches/release/boost/system/ (props changed)
   branches/release/boost/thread/ (props changed)
   branches/release/boost/thread.hpp (props changed)
   branches/release/boost/utility/ (props changed)
   branches/release/boost/utility/value_init.hpp (props changed)
   branches/release/boost/uuid/ (props changed)
   branches/release/boost/variant/ (props changed)
   branches/release/boost/wave/ (props changed)
   branches/release/bootstrap.bat (props changed)
   branches/release/bootstrap.sh (props changed)
   branches/release/index.htm (props changed)
   branches/release/libs/ (props changed)
   branches/release/libs/array/test/array0.cpp (props changed)
   branches/release/libs/bimap/ (props changed)
   branches/release/libs/filesystem/ (props changed)
   branches/release/libs/functional/hash/ (props changed)
   branches/release/libs/fusion/ (props changed)
   branches/release/libs/graph_parallel/ (props changed)
   branches/release/libs/integer/ (props changed)
   branches/release/libs/interprocess/ (props changed)
   branches/release/libs/intrusive/ (props changed)
   branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
   branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
   branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
   branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
   branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
   branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
   branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
   branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
   branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
   branches/release/libs/msm/ (props changed)
   branches/release/libs/numeric/ublas/ (props changed)
   branches/release/libs/numeric/ublas/doc/ (props changed)
   branches/release/libs/property_tree/ (props changed)
   branches/release/libs/python/ (props changed)
   branches/release/libs/serialization/ (props changed)
   branches/release/libs/signals/ (props changed)
   branches/release/libs/signals2/ (props changed)
   branches/release/libs/spirit/ (props changed)
   branches/release/libs/spirit/classic/example/ (props changed)
   branches/release/libs/spirit/doc/ (props changed)
   branches/release/libs/spirit/example/ (props changed)
   branches/release/libs/spirit/phoenix/ (props changed)
   branches/release/libs/spirit/test/ (props changed)
   branches/release/libs/spirit/test/qi/optional.cpp (props changed)
   branches/release/libs/static_assert/ (props changed)
   branches/release/libs/system/ (props changed)
   branches/release/libs/thread/ (props changed)
   branches/release/libs/timer/ (props changed)
   branches/release/libs/utility/ (props changed)
   branches/release/libs/utility/swap.html (props changed)
   branches/release/libs/utility/swap/test/std_bitset.cpp (props changed)
   branches/release/libs/utility/value_init.htm (props changed)
   branches/release/libs/utility/value_init_test.cpp (props changed)
   branches/release/libs/uuid/ (props changed)
   branches/release/libs/wave/ (props changed)
   branches/release/rst.css (props changed)
   branches/release/status/ (props changed)
   branches/release/status/Jamfile.v2 (props changed)
   branches/release/tools/ (props changed)
   branches/release/tools/bcp/ (props changed)
   branches/release/tools/jam/ (props changed)
   branches/release/tools/regression/ (props changed)
   branches/release/tools/release/ (props changed)
   branches/release/tools/wave/ (props changed)
Text files modified:
   branches/release/boost/spirit/home/karma/detail/alternative_function.hpp | 8
   branches/release/boost/spirit/home/karma/generate_attr.hpp | 2
   branches/release/boost/spirit/home/qi/detail/alternative_function.hpp | 4
   branches/release/boost/spirit/home/support/attributes.hpp | 34 +-
   branches/release/libs/spirit/doc/spirit2.qbk | 2
   branches/release/libs/spirit/example/scheme/detail/scheme_function_call.hpp | 6
   branches/release/libs/spirit/example/scheme/detail/utree_detail1.hpp | 7
   branches/release/libs/spirit/example/scheme/detail/utree_detail2.hpp | 40 ++--
   branches/release/libs/spirit/example/scheme/detail/utree_detail3.hpp | 41 ++++
   branches/release/libs/spirit/example/scheme/input/parse_sexpr.hpp | 18 +
   branches/release/libs/spirit/example/scheme/input/parse_sexpr_impl.hpp | 40 +++
   branches/release/libs/spirit/example/scheme/input/sexpr.hpp | 2
   branches/release/libs/spirit/example/scheme/output/generate_sexpr.hpp | 16 +
   branches/release/libs/spirit/example/scheme/output/generate_sexpr_impl.hpp | 50 ++++-
   branches/release/libs/spirit/example/scheme/output/sexpr.hpp | 32 +-
   branches/release/libs/spirit/example/scheme/scheme_compiler.hpp | 160 +++++++++++------
   branches/release/libs/spirit/example/scheme/scheme_interpreter.hpp | 358 +++++++++++++++++++++++++++++++++------
   branches/release/libs/spirit/example/scheme/test/parse_qiexpr/generate_sexpr_to_ostream.cpp | 16 +
   branches/release/libs/spirit/example/scheme/test/parse_qiexpr/input.txt | 33 +++
   branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qi_test.cpp | 3
   branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qiexpr.cpp | 4
   branches/release/libs/spirit/example/scheme/test/scheme.cpp | 28 ++-
   branches/release/libs/spirit/example/scheme/test/scheme_test.scm | 23 ++
   branches/release/libs/spirit/example/scheme/test/utree_test.cpp | 87 ++++----
   branches/release/libs/spirit/example/scheme/utree.hpp | 50 ++--
   branches/release/libs/spirit/example/scheme/utree_operators.hpp | 159 +++++++++--------
   26 files changed, 851 insertions(+), 372 deletions(-)

Modified: branches/release/boost/spirit/home/karma/detail/alternative_function.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/detail/alternative_function.hpp (original)
+++ branches/release/boost/spirit/home/karma/detail/alternative_function.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -77,7 +77,7 @@
     template <typename Component, typename Attribute, typename Expected>
     struct alternative_generate<Component, Attribute, Expected
       , typename enable_if<
- traits::compute_compatible_component<Expected, Attribute> >::type>
+ traits::compute_compatible_component<Expected, Attribute, karma::domain> >::type>
     {
         template <typename OutputIterator, typename Context, typename Delimiter>
         static bool
@@ -88,7 +88,7 @@
             component; // suppresses warning: C4100: 'component' : unreferenced formal parameter
 #endif
             return call(component, sink, ctx, d, attr
- , spirit::traits::not_is_variant<Attribute>());
+ , spirit::traits::not_is_variant<Attribute, karma::domain>());
         }
 
         template <typename OutputIterator, typename Context, typename Delimiter>
@@ -111,7 +111,7 @@
             component; // suppresses warning: C4100: 'component' : unreferenced formal parameter
 #endif
             typedef
- traits::compute_compatible_component<Expected, Attribute>
+ traits::compute_compatible_component<Expected, Attribute, domain>
             component_type;
 
             typedef typename component_type::distance distance_type;
@@ -195,4 +195,4 @@
 
 }}}}
 
-#endif
+#endif
\ No newline at end of file

Modified: branches/release/boost/spirit/home/karma/generate_attr.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/generate_attr.hpp (original)
+++ branches/release/boost/spirit/home/karma/generate_attr.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -199,7 +199,7 @@
       , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& attr))
     {
         OutputIterator sink = sink_;
- return karma::generate_delimited(sink, expr, delimiter,
+ return karma::generate_delimited(sink, expr, delimiter
           , delimit_flag::dont_predelimit, BOOST_PP_ENUM_PARAMS(N, attr));
     }
 

Modified: branches/release/boost/spirit/home/qi/detail/alternative_function.hpp
==============================================================================
--- branches/release/boost/spirit/home/qi/detail/alternative_function.hpp (original)
+++ branches/release/boost/spirit/home/qi/detail/alternative_function.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -59,8 +59,8 @@
             // return true if the parser succeeds
             return call(component,
                 mpl::and_<
- spirit::traits::not_is_variant<Attribute>,
- spirit::traits::not_is_optional<Attribute>
+ spirit::traits::not_is_variant<Attribute, qi::domain>,
+ spirit::traits::not_is_optional<Attribute, qi::domain>
>());
         }
 

Modified: branches/release/boost/spirit/home/support/attributes.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/attributes.hpp (original)
+++ branches/release/boost/spirit/home/support/attributes.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -67,19 +67,19 @@
>::type>
       : mpl::true_ {};
 
- template <typename T>
+ template <typename T, typename Domain>
     struct not_is_variant
       : mpl::true_
     {};
 
- template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
- struct not_is_variant<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
+ template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Domain>
+ struct not_is_variant<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Domain>
       : mpl::false_
     {};
 
- template <typename T>
- struct not_is_variant<boost::optional<T> >
- : not_is_variant<T>
+ template <typename T, typename Domain>
+ struct not_is_variant<boost::optional<T>, Domain>
+ : not_is_variant<T, Domain>
     {};
 
     // we treat every type as if it where the variant (as this meta function is
@@ -153,31 +153,31 @@
         compatible_type;
     };
 
- template <typename Expected, typename Attribute>
+ template <typename Expected, typename Attribute, typename Domain>
     struct compute_compatible_component
       : compute_compatible_component_variant<Expected, Attribute
- , typename spirit::traits::not_is_variant<Attribute>::type> {};
+ , typename spirit::traits::not_is_variant<Attribute, Domain>::type> {};
 
- template <typename Expected>
- struct compute_compatible_component<Expected, unused_type>
+ template <typename Expected, typename Domain>
+ struct compute_compatible_component<Expected, unused_type, Domain>
       : mpl::false_ {};
 
- template <typename Attribute>
- struct compute_compatible_component<unused_type, Attribute>
+ template <typename Attribute, typename Domain>
+ struct compute_compatible_component<unused_type, Attribute, Domain>
       : mpl::false_ {};
 
- template <>
- struct compute_compatible_component<unused_type, unused_type>
+ template <typename Domain>
+ struct compute_compatible_component<unused_type, unused_type, Domain>
       : mpl::false_ {};
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename T>
+ template <typename T, typename Domain>
     struct not_is_optional
       : mpl::true_
     {};
 
- template <typename T>
- struct not_is_optional<boost::optional<T> >
+ template <typename T, typename Domain>
+ struct not_is_optional<boost::optional<T>, Domain>
       : mpl::false_
     {};
 

Modified: branches/release/libs/spirit/doc/spirit2.qbk
==============================================================================
--- branches/release/libs/spirit/doc/spirit2.qbk (original)
+++ branches/release/libs/spirit/doc/spirit2.qbk 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -53,7 +53,7 @@
 [def __ragel__ [@http://www.cs.queensu.ca/~thurston/ragel/ Ragel]]
 
 [def __boost_variant__ [@http://www.boost.org/doc/html/variant.html Boost.Variant]]
-[def __boost_iterator_range__ [@boost:/libs/range/doc/utility_class.html#iter_range `boost::iterator_range`]]
+[def __boost_iterator_range__ [@boost:/libs/range/doc/html/range/utilities/iterator_range.html `boost::iterator_range`]]
 [def __boost_bind__ [@boost:/libs/bind/index.html Boost.Bind]]
 [def __boost_lambda__ [@boost:/libs/lambda/index.html Boost.Lambda]]
 [def __boost_tuples__ [@boost:/libs/tuple/index.html Boost.Tuples]]

Copied: branches/release/libs/spirit/example/scheme/detail/scheme_function_call.hpp (from r61191, /trunk/libs/spirit/example/scheme/detail/scheme_function_call.hpp)
==============================================================================
--- /trunk/libs/spirit/example/scheme/detail/scheme_function_call.hpp (original)
+++ branches/release/libs/spirit/example/scheme/detail/scheme_function_call.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -13,7 +13,7 @@
 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
 #include <boost/preprocessor/repetition/repeat.hpp>
 
-#define SCHEME_PUSH_ELEMENT(z, n, _) elements.push_back(_##n);
+#define SCHEME_PUSH_ELEMENT(z, n, _) elements[n] = _##n;
 
 #define BOOST_PP_ITERATION_PARAMS_1 \
     (3, (3, BOOST_PP_DEC(SCHEME_COMPOSITE_LIMIT), \
@@ -36,9 +36,9 @@
     template <BOOST_PP_ENUM_PARAMS(N, typename A)>
     utree operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& _)) const
     {
- utree elements;
+ boost::array<utree, N> elements;
         BOOST_PP_REPEAT(N, SCHEME_PUSH_ELEMENT, _);
- return f(elements);
+ return f(get_range(elements));
     }
 
 #undef N

Modified: branches/release/libs/spirit/example/scheme/detail/utree_detail1.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/detail/utree_detail1.hpp (original)
+++ branches/release/libs/spirit/example/scheme/detail/utree_detail1.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -7,13 +7,6 @@
 #if !defined(BOOST_SPIRIT_UTREE_DETAIL1)
 #define BOOST_SPIRIT_UTREE_DETAIL1
 
-#if defined(BOOST_MSVC)
-# pragma warning(push)
-# pragma warning(disable: 4804)
-# pragma warning(disable: 4805)
-# pragma warning(disable: 4244)
-#endif
-
 #include <boost/type_traits/alignment_of.hpp>
 
 namespace scheme { namespace detail

Modified: branches/release/libs/spirit/example/scheme/detail/utree_detail2.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/detail/utree_detail2.hpp (original)
+++ branches/release/libs/spirit/example/scheme/detail/utree_detail2.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -7,6 +7,11 @@
 #if !defined(BOOST_SPIRIT_UTREE_DETAIL2)
 #define BOOST_SPIRIT_UTREE_DETAIL2
 
+#if defined(BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable: 4800)
+#endif
+
 namespace scheme { namespace detail
 {
     inline char& fast_string::info()
@@ -186,6 +191,7 @@
     inline void list::copy(list const& other)
     {
         first = last = 0;
+ size = 0;
         node* p = other.first;
         while (p != 0)
         {
@@ -375,9 +381,6 @@
 
                 case type::reference_type:
                     return apply(*x.p, f);
-
- case type::function_type:
- return f(x.f);
             }
         }
 
@@ -431,9 +434,6 @@
 
                 case type::reference_type:
                     return apply(*x.p, y, f);
-
- case type::function_type:
- return visit_impl::apply(y, detail::bind(f, x.f));
             }
         }
     };
@@ -514,12 +514,6 @@
         set_type(type::reference_type);
     }
 
- inline utree::utree(function_ptr fptr)
- : f(fptr)
- {
- set_type(type::function_type);
- }
-
     inline utree::utree(utree const& other)
     {
         copy(other);
@@ -605,14 +599,6 @@
         return *this;
     }
 
- inline utree& utree::operator=(function_ptr fptr)
- {
- free();
- f = fptr;
- set_type(type::function_type);
- return *this;
- }
-
     template <typename F>
     typename F::result_type
     inline utree::visit(utree const& x, F f)
@@ -952,6 +938,20 @@
         l.default_construct();
         set_type(type::list_type);
     }
+
+ inline utree& utree::deref()
+ {
+ return (get_type() == type::reference_type) ? *p : *this;
+ }
+
+ inline utree const& utree::deref() const
+ {
+ return (get_type() == type::reference_type) ? *p : *this;
+ }
 }
 
+#if defined(BOOST_MSVC)
+# pragma warning(pop)
+#endif
+
 #endif

Modified: branches/release/libs/spirit/example/scheme/detail/utree_detail3.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/detail/utree_detail3.hpp (original)
+++ branches/release/libs/spirit/example/scheme/detail/utree_detail3.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -26,7 +26,9 @@
         SCHEME_GET_UTREE_TYPE(int, utree_type::int_type);
         SCHEME_GET_UTREE_TYPE(double, utree_type::double_type);
         SCHEME_GET_UTREE_TYPE(utf8_string_range, utree_type::string_type);
+ SCHEME_GET_UTREE_TYPE(utf8_string, utree_type::string_type);
         SCHEME_GET_UTREE_TYPE(utf8_symbol_range, utree_type::symbol_type);
+ SCHEME_GET_UTREE_TYPE(utf8_symbol, utree_type::string_type);
         SCHEME_GET_UTREE_TYPE(binary_range, utree_type::binary_type);
         SCHEME_GET_UTREE_TYPE(boost::iterator_range<utree::iterator>,
             utree_type::list_type);
@@ -100,6 +102,16 @@
         };
 
         template <>
+ struct get_impl<utf8_string>
+ {
+ typedef utf8_string type;
+ static type call(utree const& x)
+ {
+ return type(x.s.str(), x.s.size());
+ }
+ };
+
+ template <>
         struct get_impl<utf8_symbol_range>
         {
             typedef utf8_symbol_range type;
@@ -110,6 +122,16 @@
         };
 
         template <>
+ struct get_impl<utf8_symbol>
+ {
+ typedef utf8_symbol type;
+ static type call(utree const& x)
+ {
+ return type(x.s.str(), x.s.size());
+ }
+ };
+
+ template <>
         struct get_impl<binary_range>
         {
             typedef binary_range type;
@@ -119,15 +141,24 @@
             }
         };
     }
+}
 
+///////////////////////////////////////////////////////////////////////////////
+namespace boost
+{
     template <typename T>
- typename detail::get_impl<T>::type
- get(utree const& x)
+ typename scheme::detail::get_impl<T>::type
+ get(scheme::utree const& x)
     {
- if (x.which() != detail::get_utree_type<T>::value)
- throw boost::bad_get();
+ if (x.which() !=
+ (scheme::utree_type::info)scheme::detail::get_utree_type<T>::value)
+ {
+ if (x.which() == scheme::utree_type::reference_type)
+ return get<T>(x.deref());
 
- return detail::get_impl<T>::call(x);
+ throw boost::bad_get();
+ }
+ return scheme::detail::get_impl<T>::call(x);
     }
 }
 

Deleted: branches/release/libs/spirit/example/scheme/input/parse_qiexpr.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/input/parse_qiexpr.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,19 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#if !defined(BOOST_SPIRIT_PARSE_QIEXPR)
-#define BOOST_SPIRIT_PARSE_QIEXPR
-
-#include "../utree.hpp"
-
-namespace scheme { namespace input
-{
- template <typename String>
- bool parse_qiexpr(String const& str, utree& result);
-}}
-
-#endif
-
-

Deleted: branches/release/libs/spirit/example/scheme/input/parse_qiexpr_impl.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/input/parse_qiexpr_impl.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,33 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#if !defined(BOOST_SPIRIT_PARSE_QIEXPR_IMPL)
-#define BOOST_SPIRIT_PARSE_QIEXPR_IMPL
-
-#include <iostream>
-#include <boost/spirit/include/support_istream_iterator.hpp>
-#include <boost/spirit/include/qi_parse.hpp>
-
-#include "../input/qiexpr.hpp"
-#include "../input/parse_qiexpr.hpp"
-
-namespace scheme { namespace input
-{
- ///////////////////////////////////////////////////////////////////////////
- template <typename String>
- bool parse_qiexpr(String const& str, utree& result)
- {
- typedef typename String::const_iterator iterator_type;
-
- scheme::input::qiexpr<iterator_type> p;
- scheme::input::qiexpr_white_space<iterator_type> ws;
-
- return phrase_parse(str.begin(), str.end(), p, ws, result);
- }
-}}
-
-#endif
-
-

Modified: branches/release/libs/spirit/example/scheme/input/parse_sexpr.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/input/parse_sexpr.hpp (original)
+++ branches/release/libs/spirit/example/scheme/input/parse_sexpr.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -8,14 +8,24 @@
 
 #include "../utree.hpp"
 #include "../input/sexpr.hpp"
+#include <iosfwd>
+#include <string>
 
 namespace scheme { namespace input
 {
- template <typename InputStream>
- bool parse_sexpr(InputStream& is, utree& result);
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Char>
+ bool parse_sexpr(std::basic_istream<Char>& is, utree& result);
+
+ template <typename Char>
+ bool parse_sexpr_list(std::basic_istream<Char>& is, utree& result);
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Char>
+ bool parse_sexpr(std::basic_string<Char>& str, utree& result);
 
- template <typename InputStream>
- bool parse_sexpr_list(InputStream& is, utree& result);
+ template <typename Char>
+ bool parse_sexpr_list(std::basic_string<Char>& str, utree& result);
 }}
 
 #endif

Modified: branches/release/libs/spirit/example/scheme/input/parse_sexpr_impl.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/input/parse_sexpr_impl.hpp (original)
+++ branches/release/libs/spirit/example/scheme/input/parse_sexpr_impl.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -7,6 +7,7 @@
 #define BOOST_SPIRIT_PARSE_SEXPR_IMPL
 
 #include <iostream>
+#include <string>
 #include <boost/spirit/include/support_istream_iterator.hpp>
 #include <boost/spirit/include/qi_parse.hpp>
 
@@ -16,38 +17,65 @@
 namespace scheme { namespace input
 {
     ///////////////////////////////////////////////////////////////////////////
- template <typename InputStream>
- bool parse_sexpr(InputStream& is, utree& result)
+ template <typename Char>
+ bool parse_sexpr(std::basic_istream<Char>& is, utree& result)
     {
         // no white space skipping in the stream!
         is.unsetf(std::ios::skipws);
 
- typedef boost::spirit::basic_istream_iterator<char> iterator_type;
+ typedef boost::spirit::basic_istream_iterator<Char> iterator_type;
         iterator_type first(is);
         iterator_type last;
 
         scheme::input::sexpr<iterator_type> p;
         scheme::input::sexpr_white_space<iterator_type> ws;
 
+ using boost::spirit::qi::phrase_parse;
         return phrase_parse(first, last, p, ws, result);
     }
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename InputStream>
- bool parse_sexpr_list(InputStream& is, utree& result)
+ template <typename Char>
+ bool parse_sexpr_list(std::basic_istream<Char>& is, utree& result)
     {
         // no white space skipping in the stream!
         is.unsetf(std::ios::skipws);
 
- typedef boost::spirit::basic_istream_iterator<char> iterator_type;
+ typedef boost::spirit::basic_istream_iterator<Char> iterator_type;
         iterator_type first(is);
         iterator_type last;
 
         scheme::input::sexpr<iterator_type> p;
         scheme::input::sexpr_white_space<iterator_type> ws;
 
+ using boost::spirit::qi::phrase_parse;
         return phrase_parse(first, last, +p, ws, result);
     }
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Char>
+ bool parse_sexpr(std::basic_string<Char>& str, utree& result)
+ {
+ typedef typename std::basic_string<Char>::const_iterator iterator_type;
+
+ scheme::input::sexpr<iterator_type> p;
+ scheme::input::sexpr_white_space<iterator_type> ws;
+
+ using boost::spirit::qi::phrase_parse;
+ return phrase_parse(str.begin(), str.end(), p, ws, result);
+ }
+
+ template <typename Char>
+ bool parse_sexpr_list(std::basic_string<Char>& str, utree& result)
+ {
+ typedef typename std::basic_string<Char>::const_iterator iterator_type;
+
+ scheme::input::sexpr<iterator_type> p;
+ scheme::input::sexpr_white_space<iterator_type> ws;
+
+ using boost::spirit::qi::phrase_parse;
+ return phrase_parse(str.begin(), str.end(), +p, ws, result);
+ }
 }}
 
 #endif

Deleted: branches/release/libs/spirit/example/scheme/input/qiexpr.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/input/qiexpr.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
+++ (empty file)
@@ -1,127 +0,0 @@
-// Copyright (c) 2001-2010 Hartmut Kaiser
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#if !defined(BOOST_SPIRIT_QIEXPR)
-#define BOOST_SPIRIT_QIEXPR
-
-#include <string>
-
-#include <boost/cstdint.hpp>
-#include <boost/detail/iterator.hpp>
-#include <boost/spirit/include/qi.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_stl.hpp>
-
-#include "../utree.hpp"
-#include "../utree_operators.hpp"
-#include "string.hpp"
-
-namespace scheme { namespace input
-{
- using boost::spirit::ascii::space;
- using boost::spirit::qi::grammar;
- using boost::spirit::qi::rule;
- using boost::spirit::qi::symbols;
- using boost::spirit::qi::eol;
- using boost::spirit::qi::_val;
- using boost::spirit::qi::_1;
- using boost::phoenix::push_back;
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename Iterator>
- struct qiexpr_white_space : grammar<Iterator>
- {
- qiexpr_white_space() : qiexpr_white_space::base_type(start)
- {
- start =
- space // tab/space/cr/lf
- | "//" >> *(char_ - eol) >> eol // comments
- | "/*" >> *(char_ - "*/") >> "*/"
- ;
-
-// start.name("ws"); debug(start);
- }
-
- rule<Iterator> start;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // a list of names for all supported parser primitives taking no parameters
- static char const* const primitives0[] =
- {
- "char_"
- , "long_long", "long_", "int_", "short_"
- , "ulong_long", "ulong_", "uint_", "ushort_"
- , "bool_", "true_", "false_"
- , "long_double", "double_", "float_"
- , 0
- };
-
- // a list of names for all supported parser primitives taking 1 parameter
- static char const* const primitives1[] =
- {
- "char_", "lit", "string"
- , 0
- };
-
- // a list of names for all supported parser primitives taking 2 parameter
- static char const* const primitives2[] =
- {
- "char_"
- , 0
- };
-
- ///////////////////////////////////////////////////////////////////////////
- template <typename Iterator>
- struct qiexpr : grammar<Iterator, qiexpr_white_space<Iterator>, utree()>
- {
- typedef typename boost::detail::iterator_traits<Iterator>::value_type
- char_type;
-
- qiexpr() : qiexpr::base_type(start)
- {
- start = *expr;
-
- expr =
- primitive2 >> '(' >> literal >> ',' >> literal >> ')'
- | primitive1 >> '(' >> literal >> ')'
- | primitive0 // taking no parameter
- ;
-
- literal =
- string_lit [ push_back(_val, _1) ]
- | string_lit.char_lit [ push_back(_val, _1) ]
- ;
-
- // fill the symbol tables with all known primitive parser names
- for (char const* const* p = primitives0; *p; ++p)
- {
- utree l;
- l.push_back(utf8_symbol(*p));
- primitive0.add(*p, l);
- }
-
- for (char const* const* p = primitives1; *p; ++p)
- {
- utree l;
- l.push_back(utf8_symbol(*p));
- primitive1.add(*p, l);
- }
-
- for (char const* const* p = primitives2; *p; ++p)
- {
- utree l;
- l.push_back(utf8_symbol(*p));
- primitive2.add(*p, l);
- }
- }
-
- rule<Iterator, qiexpr_white_space<Iterator>, utree()> start, expr, literal;
- symbols<char_type, utree> primitive0, primitive1, primitive2;
- scheme::input::string<Iterator> string_lit;
- };
-}}
-
-#endif

Modified: branches/release/libs/spirit/example/scheme/input/sexpr.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/input/sexpr.hpp (original)
+++ branches/release/libs/spirit/example/scheme/input/sexpr.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -74,7 +74,7 @@
                     | symbol
                     ;
 
- char const* exclude = " ();\"\0-\31\127";
+ std::string exclude = std::string(" ();\"\x01-\x1f\x7f") + '\0';
             symbol = lexeme[+(~char_(exclude))];
 
             integer = lexeme[no_case["0x"] >> hex]

Modified: branches/release/libs/spirit/example/scheme/output/generate_sexpr.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/output/generate_sexpr.hpp (original)
+++ branches/release/libs/spirit/example/scheme/output/generate_sexpr.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -12,12 +12,20 @@
 namespace scheme { namespace output
 {
     ///////////////////////////////////////////////////////////////////////////
- template <typename OutputStream>
- bool generate_sexpr(OutputStream& os, utree const& tree);
+ template <typename Char>
+ bool generate_sexpr(std::basic_ostream<Char>& os, utree const& tree);
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename OutputStream>
- bool generate_sexpr_list(OutputStream& os, utree const& tree);
+ template <typename Char>
+ bool generate_sexpr_list(std::basic_ostream<Char>& os, utree const& tree);
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Char>
+ bool generate_sexpr(std::basic_string<Char>& os, utree const& tree);
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Char>
+ bool generate_sexpr_list(std::basic_string<Char>& os, utree const& tree);
 }}
 
 #endif

Modified: branches/release/libs/spirit/example/scheme/output/generate_sexpr_impl.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/output/generate_sexpr_impl.hpp (original)
+++ branches/release/libs/spirit/example/scheme/output/generate_sexpr_impl.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -17,30 +17,62 @@
 namespace scheme { namespace output
 {
     ///////////////////////////////////////////////////////////////////////////
- template <typename OutputStream>
- bool generate_sexpr(OutputStream& os, utree const& tree)
+ template <typename Char>
+ bool generate_sexpr(std::basic_ostream<Char>& os, utree const& tree)
     {
         typedef boost::spirit::ostream_iterator output_iterator_type;
- using boost::spirit::karma::space;
 
- output_iterator_type sink(os);
+ using boost::spirit::karma::space;
+ using boost::spirit::karma::generate_delimited;
 
         scheme::output::sexpr<output_iterator_type> g;
- return generate_delimited(sink, g, space, tree);
+
+ return generate_delimited(output_iterator_type(os), g, space, tree);
     }
 
     ///////////////////////////////////////////////////////////////////////////
- template <typename OutputStream>
- bool generate_sexpr_list(OutputStream& os, utree const& tree)
+ template <typename Char>
+ bool generate_sexpr_list(std::basic_ostream<Char>& os, utree const& tree)
     {
         typedef boost::spirit::ostream_iterator output_iterator_type;
+
         using boost::spirit::karma::space;
         using boost::spirit::karma::eol;
+ using boost::spirit::karma::generate_delimited;
+
+ scheme::output::sexpr<output_iterator_type> g;
+
+ return generate_delimited(output_iterator_type(os), g % eol, space, tree);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Char>
+ bool generate_sexpr(std::basic_string<Char>& os, utree const& tree)
+ {
+ typedef std::basic_string<Char> string_type;
+ typedef std::back_insert_iterator<string_type> output_iterator_type;
 
- output_iterator_type sink(os);
+ using boost::spirit::karma::space;
+ using boost::spirit::karma::generate_delimited;
 
         scheme::output::sexpr<output_iterator_type> g;
- return generate_delimited(sink, g % eol, space, tree);
+ return generate_delimited(output_iterator_type(os), g, space, tree);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Char>
+ bool generate_sexpr_list(std::basic_string<Char>& os, utree const& tree)
+ {
+ typedef std::basic_string<Char> string_type;
+ typedef std::back_insert_iterator<string_type> output_iterator_type;
+
+ using boost::spirit::karma::space;
+ using boost::spirit::karma::eol;
+ using boost::spirit::karma::generate_delimited;
+
+ scheme::output::sexpr<output_iterator_type> g;
+
+ return generate_delimited(output_iterator_type(os), g % eol, space, tree);
     }
 }}
 

Modified: branches/release/libs/spirit/example/scheme/output/sexpr.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/output/sexpr.hpp (original)
+++ branches/release/libs/spirit/example/scheme/output/sexpr.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -6,25 +6,22 @@
 #if !defined(SCHEME_OUTPUT_SEXPR_MAR_8_2010_829AM)
 #define SCHEME_OUTPUT_SEXPR_MAR_8_2010_829AM
 
+#include "../utree.hpp"
+#include "../detail/utree_detail3.hpp"
+
 #include <string>
 
 #include <boost/cstdint.hpp>
 #include <boost/mpl/bool.hpp>
 #include <boost/spirit/include/karma.hpp>
 
-#include "../utree.hpp"
-#include "../detail/utree_detail3.hpp"
-
 ///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace traits
 {
     // the specialization below tells Spirit to handle scheme::utree as if it
- // where a 'real' variant
- template <typename T>
- struct not_is_variant;
-
+ // where a 'real' variant (in the context of karma)
     template <>
- struct not_is_variant<scheme::utree>
+ struct not_is_variant<scheme::utree, karma::domain>
       : mpl::false_ {};
 
     // The specializations below tell Spirit to verify whether an attribute
@@ -143,12 +140,15 @@
     using boost::spirit::karma::double_;
     using boost::spirit::karma::int_;
     using boost::spirit::karma::char_;
+ using boost::spirit::karma::string;
     using boost::spirit::karma::bool_;
     using boost::spirit::karma::eps;
     using boost::spirit::karma::space_type;
     using boost::spirit::karma::uint_generator;
-
- typedef boost::uint32_t uchar; // a unicode code point
+ using boost::spirit::karma::verbatim;
+ using boost::spirit::karma::delimit;
+ using boost::spirit::karma::hex;
+ using boost::spirit::karma::right_align;
 
     template <typename OutputIterator>
     struct sexpr : grammar<OutputIterator, space_type, utree()>
@@ -160,7 +160,7 @@
             start = double_
                       | int_
                       | bool_
- | string
+ | string_
                       | symbol
                       | byte_str
                       | list
@@ -169,10 +169,10 @@
 
             list = '(' << *start << ')';
 
- string = '"' << *char_ << '"';
- symbol = *char_;
- byte_str = 'b' << *hex2;
- nil_ = eps;
+ string_ = '"' << string << '"';
+ symbol = string;
+ byte_str = 'b' << *right_align(2, '0')[hex2];
+ nil_ = eps << "<nil>";
         }
 
         typedef boost::iterator_range<utree::const_iterator> utree_list;
@@ -180,7 +180,7 @@
         rule<OutputIterator, space_type, utree()> start;
         rule<OutputIterator, space_type, utree_list()> list;
         rule<OutputIterator, utf8_symbol_range()> symbol;
- rule<OutputIterator, utf8_string_range()> string;
+ rule<OutputIterator, utf8_string_range()> string_;
         rule<OutputIterator, binary_range()> byte_str;
         rule<OutputIterator, nil()> nil_;
     };

Modified: branches/release/libs/spirit/example/scheme/scheme_compiler.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/scheme_compiler.hpp (original)
+++ branches/release/libs/spirit/example/scheme/scheme_compiler.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -1,47 +1,44 @@
-/*=============================================================================
+/*=============================================================================
     Copyright (c) 2001-2010 Joel de Guzman
 
     Distributed under the Boost Software License, Version 1.0. (See accompanying
     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 =============================================================================*/
-#if !defined(BOOST_SPIRIT_SCHEME_INTERPRETER)
-#define BOOST_SPIRIT_SCHEME_INTERPRETERnamespace scheme
+#if !defined(BOOST_SPIRIT_SCHEME_COMPILER)
+#define BOOST_SPIRIT_SCHEME_COMPILER
 
 #include <vector>
 #include <map>
 #include <boost/bind.hpp>
 
+#include "scheme_intrinsics.hpp"
+#include "scheme_interpreter.hpp"
+
 namespace scheme
 {
 ///////////////////////////////////////////////////////////////////////////////
-// Utilities
+// The environment
 ///////////////////////////////////////////////////////////////////////////////
- inline std::string get_symbol(utree const& s)
- {
- utf8_symbol_range symbol = s.as<utf8_symbol_range>();
- return std::string(symbol.begin(), symbol.end());
- }
+ typedef boost::function<actor(actor_list const&)> compiled_function;
 
-///////////////////////////////////////////////////////////////////////////////
-// The compiler
-///////////////////////////////////////////////////////////////////////////////
- class environment
+ class compiler_environment
     {
     public:
 
         environment(environment* parent = 0)
           : outer(parent) {}
 
- void define(std::string const& name, function_compiler const& def)
+ template <typename Function>
+ void define(std::string const& name, Function const& f)
         {
- // $$$ use exceptions here $$$
+ // $$$ use exceptions here? $$$
             BOOST_ASSERT(definitions.find(name) == definitions.end());
- definitions[name] = def;
+ definitions[name] = compiled_function(f);
         }
 
- function_compiler* find(std::string const& name)
+ compiled_function* find(std::string const& name)
         {
- std::map<std::string, function_compiler>::iterator
+ std::map<std::string, compiled_function>::iterator
                 i = definitions.find(name);
             if (i != definitions.end())
                 return &i->second;
@@ -55,126 +52,175 @@
     private:
 
         environment* outer;
- std::map<std::string, function_compiler> definitions;
+ std::map<std::string, compiled_function> definitions;
     };
 
- actor compile(utree const& ast, environment& env);
+///////////////////////////////////////////////////////////////////////////////
+// The compiler
+///////////////////////////////////////////////////////////////////////////////
+ actor compile(
+ utree const& ast, environment& env, actor_list& fragments);
+
+ struct external_function : composite<external_function>
+ {
+ // we must hold f by reference because functions can be recursive
+ boost::reference_wrapper<actor const> f;
+
+ external_function(actor const& f)
+ : f(f) {}
+
+ using base_type::operator();
+ actor operator()(actor_list const& elements) const
+ {
+ return actor(lambda_function(f, elements));
+ }
+ };
 
     struct compiler
     {
- typedef function result_type;
+ typedef actor result_type;
+ environment& env;
+ actor_list& fragments;
 
- mutable environment& env;
- compiler(environment& env)
- : env(env)
+ compiler(environment& env, actor_list& fragments)
+ : env(env), fragments(fragments)
         {
         }
 
- function operator()(nil) const
+ actor operator()(nil) const
         {
             return scheme::val(utree());
         }
 
         template <typename T>
- function operator()(T const& val) const
+ actor operator()(T const& val) const
         {
             return scheme::val(utree(val));
         }
 
- function operator()(utf8_symbol_range const& str) const
+ actor operator()(utf8_symbol_range const& str) const
         {
             std::string name(str.begin(), str.end());
-
- if (function_compiler* mf = env.find(name))
+ if (compiled_function* mf = env.find(name))
             {
- function_list flist;
+ actor_list flist;
                 return (*mf)(flist);
             }
             // $$$ throw? $$$
- return function();
+ BOOST_ASSERT(false);
+ return actor();
         }
 
- void define_function(
- std::string const& name,
+ actor make_lambda(
             std::vector<std::string> const& args,
             utree const& body) const
         {
- environment local_env(env);
+ environment local_env(&this->env);
             for (std::size_t i = 0; i < args.size(); ++i)
                 local_env.define(args[i], boost::bind(arg, i));
- env.define(name,
- function_composer(lambda(compile(body, local_env), args.size())));
+ return compile(body, local_env, fragments);
         }
 
- void define_nullary_function(
+ void define_function(
             std::string const& name,
+ std::vector<std::string> const& args,
             utree const& body) const
         {
- env.define(name,
- function_composer(lambda(compile(body, env), 0)));
+ fragments.push_back(actor());
+ actor& f = fragments.back();
+ env.define(name, external_function(f));
+ f = make_lambda(args, body);
         }
 
         template <typename Iterator>
- function operator()(boost::iterator_range<Iterator> const& range) const
+ actor operator()(boost::iterator_range<Iterator> const& range) const
         {
             std::string name(get_symbol(*range.begin()));
 
             if (name == "define")
             {
+ std::string fname;
+ std::vector<std::string> args;
+
                 Iterator i = range.begin(); ++i;
                 if (i->which() == utree_type::list_type)
                 {
- // a function
+ // (define (f x) ...body...)
                     utree const& decl = *i++;
                     Iterator di = decl.begin();
- std::string fname(get_symbol(*di++));
- std::vector<std::string> args;
+ fname = get_symbol(*di++);
                     while (di != decl.end())
                         args.push_back(get_symbol(*di++));
- define_function(fname, args, *i);
                 }
                 else
                 {
- // constants (nullary functions)
- std::string fname(get_symbol(*i++));
- define_nullary_function(fname, *i);
+ // (define f ...body...)
+ fname = get_symbol(*i++);
                 }
- return function(val(utree(utf8_symbol("<function>"))));
+
+ define_function(fname, args, *i);
+ return actor(val(utf8_symbol("<define " + fname + ">")));
             }
 
- if (function_compiler* mf = env.find(name))
+ if (name == "lambda")
             {
- function_list flist;
+ // (lambda (x) ...body...)
+ Iterator i = range.begin(); ++i;
+ utree const& arg_names = *i++;
+ Iterator ai = arg_names.begin();
+ std::vector<std::string> args;
+ while (ai != arg_names.end())
+ args.push_back(get_symbol(*ai++));
+ return make_lambda(args, *i);
+ }
+
+ if (compiled_function* mf = env.find(name))
+ {
+ actor_list flist;
                 Iterator i = range.begin(); ++i;
                 for (; i != range.end(); ++i)
- flist.push_back(compile(*i, env));
+ flist.push_back(compile(*i, env, fragments));
                 return (*mf)(flist);
             }
 
- return function(); // $$$ implement me $$$
+ BOOST_ASSERT(false);
+ return actor(); // $$$ implement me $$$
+ }
+
+ static std::string get_symbol(utree const& s)
+ {
+ utf8_symbol_range symbol = s.as<utf8_symbol_range>();
+ return std::string(symbol.begin(), symbol.end());
         }
     };
 
- actor compile(utree const& ast, environment& env)
+ inline actor compile(
+ utree const& ast, environment& env, actor_list& fragments)
     {
- return utree::visit(ast, compiler(env));
+ return utree::visit(ast, compiler(env, fragments));
     }
 
     void compile_all(
         utree const& ast,
         environment& env,
- function_list& results)
+ actor_list& results,
+ actor_list& fragments)
     {
         BOOST_FOREACH(utree const& program, ast)
         {
- scheme::function f = compile(program, env);
+ scheme::actor f = compile(program, env, fragments);
             results.push_back(f);
         }
     }
 
     void build_basic_environment(environment& env)
     {
- env.define("+", plus_composer());
+ env.define("if", if_);
+ env.define("<", less_than);
+ env.define("<=", less_than_equal);
+ env.define("+", plus);
+ env.define("-", minus);
+ env.define("*", times);
     }
 }
 

Modified: branches/release/libs/spirit/example/scheme/scheme_interpreter.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/scheme_interpreter.hpp (original)
+++ branches/release/libs/spirit/example/scheme/scheme_interpreter.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -5,11 +5,16 @@
     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 =============================================================================*/
 #if !defined(BOOST_SPIRIT_SCHEME_INTERPRETER)
-#define BOOST_SPIRIT_SCHEME_INTERPRETERnamespace scheme
+#define BOOST_SPIRIT_SCHEME_INTERPRETER
 
 #include <list>
 #include <boost/function.hpp>
 #include <boost/foreach.hpp>
+#include <boost/array.hpp>
+#include <boost/scoped_array.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+
+#define SCHEME_COMPOSITE_LIMIT 10
 
 namespace scheme
 {
@@ -17,135 +22,372 @@
 // The runtime interpreter
 ///////////////////////////////////////////////////////////////////////////////
 
- typedef boost::function<utree(utree const& args)> function;
- typedef std::list<function> function_list;
+ ///////////////////////////////////////////////////////////////////////////
+ // actor
+ ///////////////////////////////////////////////////////////////////////////
+ struct actor;
+
+ typedef std::list<actor> actor_list;
+ typedef boost::iterator_range<utree const*> args_type;
+ typedef boost::function<utree(args_type args)> actor_function;
+
+ struct actor
+ {
+ typedef utree result_type;
+
+ actor()
+ : f() {}
+
+ actor(actor_function const& f)
+ : f(f)
+ {
+ BOOST_ASSERT(!f.empty());
+ }
+
+ bool empty() const
+ {
+ return f.empty();
+ }
+
+ utree operator()() const
+ {
+ return f(args_type());
+ }
+
+ utree operator()(args_type x) const
+ {
+ return f(x);
+ }
+
+ template <typename A0>
+ utree operator()(A0 const& _0) const
+ {
+ boost::array<utree, 1> elements;
+ elements[0] = _0;
+ return f(get_range(elements));
+ }
+
+ template <typename A0, typename A1>
+ utree operator()(A0 const& _0, A1 const& _1) const
+ {
+ boost::array<utree, 2> elements;
+ elements[0] = _0;
+ elements[1] = _1;
+ return f(get_range(elements));
+ }
+
+ // More operators
+ #include "detail/scheme_function_call.hpp"
+
+ actor_function f;
+
+ template <std::size_t n>
+ static args_type
+ get_range(boost::array<utree, n> const& array)
+ {
+ return args_type(array.begin(), array.end());
+ }
+ };
 
     ///////////////////////////////////////////////////////////////////////////
     // values
     ///////////////////////////////////////////////////////////////////////////
- struct value
+ struct value_function
     {
         utree val;
- value(utree const& val) : val(val) {}
+ value_function(utree const& val) : val(val) {}
 
         typedef utree result_type;
- utree operator()(utree const& /*args*/) const
+ utree operator()(args_type /*args*/) const
         {
             return utree(boost::ref(val));
         }
     };
 
- struct value_composer
+ struct value
     {
- typedef function result_type;
- function operator()(utree const& val) const
+ typedef actor result_type;
+ actor operator()(utree const& val) const
         {
- return function(value(val));
+ return actor(value_function(val));
         }
     };
 
- value_composer const val = {};
+ value const val = {};
 
     ///////////////////////////////////////////////////////////////////////////
     // arguments
     ///////////////////////////////////////////////////////////////////////////
- struct argument
+ struct argument_function
     {
- int n;
- argument(int n) : n(n) {}
+ std::size_t n;
+ argument_function(std::size_t n) : n(n) {}
 
         typedef utree result_type;
- utree operator()(utree const& args) const
+ utree operator()(args_type args) const
+ {
+ return utree(boost::ref(*(args.begin()+n)));
+ }
+ };
+
+ struct argument
+ {
+ typedef actor result_type;
+ actor operator()(std::size_t n) const
+ {
+ return actor(argument_function(n));
+ }
+ };
+
+ argument const arg = {};
+ actor const _1 = arg(0);
+ actor const _2 = arg(1);
+ actor const _3 = arg(2);
+ actor const _4 = arg(3);
+ actor const _5 = arg(4);
+ actor const _6 = arg(5);
+ actor const _7 = arg(6);
+ actor const _8 = arg(7);
+ actor const _9 = arg(8);
+ actor const _10 = arg(10);
+
+ ///////////////////////////////////////////////////////////////////////////
+ // composite
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Derived>
+ struct composite
+ {
+ typedef actor result_type;
+ typedef composite<Derived> base_type;
+
+ actor operator()(actor_list const& elements) const
+ {
+ return derived()(elements);
+ }
+
+ template <typename A0>
+ actor operator()(A0 const& _0) const
+ {
+ actor_list elements;
+ elements.push_back(as_function(_0));
+ return derived()(elements);
+ }
+
+ template <typename A0, typename A1>
+ actor operator()(A0 const& _0, A1 const& _1) const
+ {
+ actor_list elements;
+ elements.push_back(as_function(_0));
+ elements.push_back(as_function(_1));
+ return derived()(elements);
+ }
+
+ // More operators
+ #include "detail/scheme_composite_call.hpp"
+
+ Derived const& derived() const
+ {
+ return *static_cast<Derived const*>(this);
+ }
+
+ template <typename T>
+ static actor as_function(T const& val)
+ {
+ return scheme::val(utree(val));
+ }
+
+ static actor const& as_function(actor const& f)
         {
- return utree(boost::ref(args[n]));
+ return f;
         }
     };
 
- struct argument_composer
+ ///////////////////////////////////////////////////////////////////////////
+ // unary_function
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Derived>
+ struct unary_function
     {
- typedef function result_type;
- function operator()(int n) const
+ actor a;
+ typedef unary_function<Derived> base_type;
+
+ unary_function(actor const& a)
+ : a(a)
         {
- return function(argument(n));
+ BOOST_ASSERT(!a.empty());
+ }
+
+ typedef utree result_type;
+ utree operator()(args_type args) const
+ {
+ return derived().eval(a(args));
+ }
+
+ Derived const& derived() const
+ {
+ return *static_cast<Derived const*>(this);
         }
     };
 
- argument_composer const arg = {};
+ template <typename Function>
+ struct unary_composite : composite<unary_composite<Function> >
+ {
+ using composite<unary_composite<Function> >::operator();
+ actor operator()(actor_list const& elements) const
+ {
+ return actor(Function(elements.front()));
+ }
+ };
 
     ///////////////////////////////////////////////////////////////////////////
- // plus
+ // binary_function
     ///////////////////////////////////////////////////////////////////////////
- struct plus_function
+ template <typename Derived>
+ struct binary_function
     {
- function_list elements;
- plus_function(function_list const& elements)
- : elements(elements) {}
+ actor a;
+ actor b;
+ typedef binary_function<Derived> base_type;
+
+ binary_function(actor const& a, actor const& b)
+ : a(a), b(b)
+ {
+ BOOST_ASSERT(!a.empty());
+ BOOST_ASSERT(!b.empty());
+ }
 
         typedef utree result_type;
- utree operator()(utree const& args) const
+ utree operator()(args_type args) const
         {
- utree result(0);
- BOOST_FOREACH(function const& element, elements)
+ return derived().eval(a(args), b(args));
+ }
+
+ Derived const& derived() const
+ {
+ return *static_cast<Derived const*>(this);
+ }
+ };
+
+ template <typename Function>
+ struct binary_composite : composite<binary_composite<Function> >
+ {
+ using composite<binary_composite<Function> >::operator();
+ actor operator()(actor_list const& elements) const
+ {
+ actor_list::const_iterator i = elements.begin();
+ actor a = *i++;
+ actor b = *i;
+ return actor(Function(a, b));
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // nary_function
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Derived>
+ struct nary_function : composite<Derived>
+ {
+ typedef nary_function<Derived> base_type;
+ actor_list elements;
+ nary_function(actor_list const& elements)
+ : elements(elements)
+ {
+ BOOST_FOREACH(actor const& element, elements)
             {
- result = result + element(args);
+ BOOST_ASSERT(!element.empty());
+ }
+ }
+
+ using composite<Derived>::operator();
+ utree operator()(args_type args) const
+ {
+ actor_list::const_iterator i = elements.begin();
+ utree result = (*i++)(args);
+ boost::iterator_range<actor_list::const_iterator>
+ rest(i++, elements.end());
+ BOOST_FOREACH(actor const& element, rest)
+ {
+ if (!derived().eval(result, element(args)))
+ break; // allow short-circuit evaluation
             }
             return result;
         }
+
+ Derived const& derived() const
+ {
+ return *static_cast<Derived const*>(this);
+ }
     };
 
- struct plus_composer
+ template <typename Function>
+ struct nary_composite : composite<nary_composite<Function> >
     {
- typedef function result_type;
- function operator()(function_list const& elements)
+ using composite<nary_composite<Function> >::operator();
+ actor operator()(actor_list const& elements) const
         {
- return function(plus_function(elements));
+ return actor(Function(elements));
         }
     };
 
- plus_composer const plus = {};
-
     ///////////////////////////////////////////////////////////////////////////
- // lambda
+ // function
     ///////////////////////////////////////////////////////////////////////////
     struct lambda_function
     {
         actor_list elements;
- actor f;
+ // we must hold f by reference because functions can be recursive
+ boost::reference_wrapper<actor const> f;
+
         lambda_function(actor const& f, actor_list const& elements)
           : elements(elements), f(f) {}
 
         typedef utree result_type;
- utree operator()(utree const& args) const
+ utree operator()(args_type args) const
         {
- utree fargs;
- BOOST_FOREACH(function const& element, elements)
+ if (!elements.empty())
+ {
+ boost::scoped_array<utree>
+ fargs(new utree[elements.size()]);
+ std::size_t i = 0;
+ BOOST_FOREACH(actor const& element, elements)
+ {
+ fargs[i++] = element(args);
+ }
+ utree const* fi = fargs.get();
+ return f.get()(args_type(fi, fi+elements.size()));
+ }
+ else
             {
- fargs.push_back(element(args));
+ return f.get()();
             }
- return f(fargs);
         }
     };
 
- struct lambda_composer
+ struct function : composite<function>
     {
- function f;
- int arity;
- lambda_composer(actor const& f, int arity)
- : f(f), arity(arity) {}
+ actor f;
 
- typedef function result_type;
- function operator()(function_list const& elements)
+ function() : f() {}
+ function(actor const& f) : f(f) {}
+
+ using base_type::operator();
+ actor operator()(actor_list const& elements) const
         {
- // $$$ use throw $$$
- BOOST_ASSERT(elements.size() == arity);
- return actor(lambda_function(f, elements));
+ return actor(call_function(f, elements));
         }
- };
 
- inline function_composer const lambda(actor const& f, int arity)
- {
- return lambda_composer(f, arity);
- }
+ function& operator=(function const& other)
+ {
+ f = other.f;
+ return *this;
+ }
+
+ function& operator=(actor const& f_)
+ {
+ f = f_;
+ return *this;
+ }
+ };
 }
 
 #endif

Modified: branches/release/libs/spirit/example/scheme/test/parse_qiexpr/generate_sexpr_to_ostream.cpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/parse_qiexpr/generate_sexpr_to_ostream.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/parse_qiexpr/generate_sexpr_to_ostream.cpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -3,14 +3,26 @@
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
-#include <fstream>
-
 #include "../../output/generate_sexpr.hpp"
 #include "../../output/generate_sexpr_impl.hpp"
 
+#include <fstream>
+
+///////////////////////////////////////////////////////////////////////////////
 // explicit template instantiation for the function parse_sexpr
 namespace scheme { namespace output
 {
     template bool generate_sexpr(BOOST_TYPEOF(std::cout)&, utree const& result);
 }}
 
+///////////////////////////////////////////////////////////////////////////////
+// this is needed if grammar debugging is on
+#if defined(BOOST_SPIRIT_DEBUG)
+namespace boost { namespace spirit { namespace traits
+{
+ void print_attribute(std::ostream& out, scheme::utree const& val)
+ {
+ scheme::output::generate_sexpr(out, val);
+ }
+}}}
+#endif

Modified: branches/release/libs/spirit/example/scheme/test/parse_qiexpr/input.txt
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/parse_qiexpr/input.txt (original)
+++ branches/release/libs/spirit/example/scheme/test/parse_qiexpr/input.txt 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -3,7 +3,38 @@
 // Distributed under the Boost Software License, Version 1.0. (See accompanying
 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  
-char_("abc")
+// parser primitives
 char_
+char_("abc")
 char_('a')
 char_('a', 'b')
+'a'
+"abc"
+
+// sequences
+char_ >> char_
+char_ >> char_('a') >> char_('a', 'b')
+(char_ >> char_('a')) >> char_('a', 'b')
+char_ >> (char_('a') >> char_('a', 'b'))
+char_ >> (char_('a')) >> char_('a', 'b')
+
+// alternatives and sequences
+char_ | char_
+char_ | char_('a') >> char_('a', 'b')
+(char_ | char_('a')) | char_('a', 'b')
+char_ >> (char_('a') | char_('a', 'b'))
+char_ >> char_('a') | char_('a', 'b')
+(char_ >> char_('a')) | char_('a', 'b')
+
+// unary operators
+*double_
++long_
+&int_ >> double_
+!int_ >> *double_
+char_ >> *(',' >> char_)
+
+// directives
+lexeme[*double_]
+
+
+

Modified: branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qi_test.cpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qi_test.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qi_test.cpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -11,7 +11,8 @@
 #include <fstream>
 #include <iterator>
 
-#include "../../input/parse_qiexpr.hpp"
+#include "../../utree.hpp"
+#include "../../qi/parse_qiexpr.hpp"
 #include "../../output/generate_sexpr.hpp"
 
 ///////////////////////////////////////////////////////////////////////////////

Modified: branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qiexpr.cpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qiexpr.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/parse_qiexpr/parse_qiexpr.cpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -5,8 +5,8 @@
 
 #include <fstream>
 
-#include "../../input/parse_qiexpr.hpp"
-#include "../../input/parse_qiexpr_impl.hpp"
+#include "../../qi/parse_qiexpr.hpp"
+#include "../../qi/parse_qiexpr_impl.hpp"
 
 // explicit template instantiation for the function parse_sexpr
 namespace scheme { namespace input

Modified: branches/release/libs/spirit/example/scheme/test/scheme.cpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/scheme.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/scheme.cpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -8,8 +8,8 @@
 
 #include "../input/sexpr.hpp"
 #include "../input/parse_sexpr_impl.hpp"
-#include "../scheme_interpreter.hpp"
 #include "../scheme_compiler.hpp"
+#include "../utree_io.hpp"
 #include <iostream>
 #include <fstream>
 
@@ -26,14 +26,23 @@
 {
     { // testing the c++ side
 
+ using scheme::if_;
         using scheme::plus;
+ using scheme::times;
+ using scheme::minus;
+ using scheme::lte;
         using scheme::_1;
         using scheme::_2;
+ using scheme::function;
 
- std::cout << "result: " << plus(11, 22, 33) () << std::endl;
- std::cout << "result: " << plus(11, 22, _1) (33) << std::endl;
- std::cout << "result: " << plus(11, _1, _2) (22, 33) << std::endl;
- std::cout << "result: " << plus(11, plus(_1, _2)) (22, 33) << std::endl;
+ std::cout << "result: " << plus(11, 22, 33)() << std::endl;
+ std::cout << "result: " << plus(11, 22, _1)(33) << std::endl;
+ std::cout << "result: " << plus(11, _1, _2)(22, 33) << std::endl;
+
+ function factorial;
+ factorial = if_(lte(_1, 0), 1, times(_1, factorial(minus(_1, 1))));
+
+ std::cout << "result: " << factorial(_1) (10) << std::endl;
     }
 
     char const* filename = NULL;
@@ -77,11 +86,12 @@
         std::cout << "success: " << std::endl;
         scheme::environment env;
         scheme::build_basic_environment(env);
- scheme::function_list flist;
- compile_all(program, env, flist);
- BOOST_FOREACH(scheme::function const& f, flist)
+ scheme::actor_list fragments;
+ scheme::actor_list flist;
+ compile_all(program, env, flist, fragments);
+ BOOST_FOREACH(scheme::actor const& f, flist)
         {
- std::cout << " result: " << f(scheme::utree()) << std::endl;
+ std::cout << "result: " << f() << std::endl;
         }
     }
     else

Modified: branches/release/libs/spirit/example/scheme/test/scheme_test.scm
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/scheme_test.scm (original)
+++ branches/release/libs/spirit/example/scheme/test/scheme_test.scm 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -1,3 +1,24 @@
+; These tests demostrate the functionality of the scheme
+; compiler/interpreter
+
 (define (dbl x) (+ x x))
+
 (define len 123)
-(dbl len)
\ No newline at end of file
+
+(dbl len) ; 246
+
+; The hello-world for interpreters ;-)
+(define (factorial n)
+ (if (<= n 0) 1
+ (* n (factorial (- n 1)))))
+
+(factorial 10) ; 3628800
+
+; Fibonacci using lambda
+(define fib
+ (lambda (n)
+ (if (< n 2)
+ n
+ (+ (fib (- n 1)) (fib (- n 2))))))
+
+(fib 10) ; 55
\ No newline at end of file

Modified: branches/release/libs/spirit/example/scheme/test/utree_test.cpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/test/utree_test.cpp (original)
+++ branches/release/libs/spirit/example/scheme/test/utree_test.cpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -9,6 +9,7 @@
 
 #include "../utree.hpp"
 #include "../utree_operators.hpp"
+#include "../utree_io.hpp"
 #include <iostream>
 
 inline std::ostream& println(std::ostream& out, scheme::utree const& val)
@@ -23,49 +24,49 @@
 {
     using scheme::utree;
 
- //~ {
- //~ // test the size
- //~ std::cout << "size of utree is: "
- //~ << sizeof(scheme::utree) << " bytes" << std::endl;
- //~ }
-
- //~ {
- //~ utree val;
- //~ println(std::cout, val);
- //~ }
-
- //~ {
- //~ utree val(true);
- //~ println(std::cout, val);
- //~ }
-
- //~ {
- //~ utree val(123);
- //~ println(std::cout, val);
- //~ }
-
- //~ {
- //~ utree val(123.456);
- //~ println(std::cout, val);
- //~ }
-
- //~ {
- //~ utree val("Hello, World");
- //~ println(std::cout, val);
- //~ utree val2;
- //~ val2 = val;
- //~ println(std::cout, val2);
- //~ utree val3("Hello, World. Chuckie is back!!!");
- //~ val = val3;
- //~ println(std::cout, val);
-
- //~ utree val4("Apple");
- //~ utree val5("Apple");
- //~ BOOST_ASSERT(val4 == val5);
-
- //~ utree val6("ApplePie");
- //~ BOOST_ASSERT(val4 < val6);
- //~ }
+ {
+ // test the size
+ std::cout << "size of utree is: "
+ << sizeof(scheme::utree) << " bytes" << std::endl;
+ }
+
+ {
+ utree val;
+ println(std::cout, val);
+ }
+
+ {
+ utree val(true);
+ println(std::cout, val);
+ }
+
+ {
+ utree val(123);
+ println(std::cout, val);
+ }
+
+ {
+ utree val(123.456);
+ println(std::cout, val);
+ }
+
+ {
+ utree val("Hello, World");
+ println(std::cout, val);
+ utree val2;
+ val2 = val;
+ println(std::cout, val2);
+ utree val3("Hello, World. Chuckie is back!!!");
+ val = val3;
+ println(std::cout, val);
+
+ utree val4("Apple");
+ utree val5("Apple");
+ BOOST_ASSERT(val4 == val5);
+
+ utree val6("ApplePie");
+ BOOST_ASSERT(val4 < val6);
+ }
 
     {
         utree val;

Modified: branches/release/libs/spirit/example/scheme/utree.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/utree.hpp (original)
+++ branches/release/libs/spirit/example/scheme/utree.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -19,6 +19,13 @@
 #include <boost/ref.hpp>
 #include "detail/utree_detail1.hpp"
 
+#if defined(BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable: 4804)
+# pragma warning(disable: 4805)
+# pragma warning(disable: 4244)
+#endif
+
 namespace scheme
 {
     ///////////////////////////////////////////////////////////////////////////
@@ -37,8 +44,7 @@
             symbol_type,
             binary_type,
             list_type,
- reference_type,
- function_type
+ reference_type
         };
     };
 
@@ -48,17 +54,6 @@
     struct nil {};
 
     ///////////////////////////////////////////////////////////////////////////
- // The environment (this is forward declared)
- ///////////////////////////////////////////////////////////////////////////
- class environment;
-
- ///////////////////////////////////////////////////////////////////////////
- // Function pointer
- ///////////////////////////////////////////////////////////////////////////
- class utree; // forward
- typedef utree (*function_ptr)(environment* env, utree& args);
-
- ///////////////////////////////////////////////////////////////////////////
     // A typed string with parametric Base storage. The storage can be any
     // range or (stl container) of chars.
     ///////////////////////////////////////////////////////////////////////////
@@ -166,18 +161,17 @@
         typedef boost::iterator_range<const_iterator> const_range;
 
         utree();
- explicit utree(bool b);
- explicit utree(unsigned int i);
- explicit utree(int i);
- explicit utree(double d);
- explicit utree(char const* str);
- explicit utree(char const* str, std::size_t len);
- explicit utree(std::string const& str);
- explicit utree(boost::reference_wrapper<utree> ref);
- explicit utree(function_ptr fptr);
+ utree(bool b);
+ utree(unsigned int i);
+ utree(int i);
+ utree(double d);
+ utree(char const* str);
+ utree(char const* str, std::size_t len);
+ utree(std::string const& str);
+ utree(boost::reference_wrapper<utree> ref);
 
         template <typename Base, utree_type::info type_>
- explicit utree(basic_string<Base, type_> const& bin);
+ utree(basic_string<Base, type_> const& bin);
 
         utree(utree const& other);
         ~utree();
@@ -190,7 +184,6 @@
         utree& operator=(char const* s);
         utree& operator=(std::string const& s);
         utree& operator=(boost::reference_wrapper<utree> ref);
- utree& operator=(function_ptr fptr);
 
         template <typename Base, utree_type::info type_>
         utree& operator=(basic_string<Base, type_> const& bin);
@@ -263,6 +256,9 @@
 
         int which() const;
 
+ utree& deref();
+ utree const& deref() const;
+
     private:
 
         typedef utree_type type;
@@ -290,10 +286,14 @@
             int i;
             double d;
             utree* p;
- function_ptr f;
         };
     };
 }
 
+#if defined(BOOST_MSVC)
+# pragma warning(pop)
+#endif
+
 #include "detail/utree_detail2.hpp"
+
 #endif

Modified: branches/release/libs/spirit/example/scheme/utree_operators.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/utree_operators.hpp (original)
+++ branches/release/libs/spirit/example/scheme/utree_operators.hpp 2010-07-04 15:45:44 EDT (Sun, 04 Jul 2010)
@@ -7,6 +7,12 @@
 #if !defined(BOOST_SPIRIT_UTREE_OPERATORS)
 #define BOOST_SPIRIT_UTREE_OPERATORS
 
+#if defined(BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable: 4804)
+# pragma warning(disable: 4805)
+#endif
+
 #include "utree.hpp"
 #include <boost/preprocessor/cat.hpp>
 #include <boost/type_traits/is_arithmetic.hpp>
@@ -22,8 +28,9 @@
     bool operator<=(utree const& a, utree const& b);
     bool operator>=(utree const& a, utree const& b);
 
- // Printing
+ // Input and output
     std::ostream& operator<<(std::ostream& out, utree const& x);
+ std::istream& operator>>(std::istream& in, utree& x);
 
     // Logical operators
     utree operator&&(utree const& a, utree const& b);
@@ -140,73 +147,73 @@
         }
     };
 
- struct utree_print
- {
- typedef void result_type;
-
- std::ostream& out;
- utree_print(std::ostream& out) : out(out) {}
-
- void operator()(scheme::nil) const
- {
- out << "nil";
- }
-
- template <typename T>
- void operator()(T val) const
- {
- out << val;
- }
-
- void operator()(bool b) const
- {
- out << (b ? "true" : "false");
- }
-
- void operator()(binary_range const& b) const
- {
- out << "b";
- out.width(2);
- out.fill('0');
-
- typedef binary_range::const_iterator iterator;
- for (iterator i = b.begin(); i != b.end(); ++i)
- out << std::hex << int((unsigned char)*i);
- out << std::dec;
- }
-
- void operator()(utf8_string_range const& str) const
- {
- typedef utf8_string_range::const_iterator iterator;
- iterator i = str.begin();
- out << '"';
- for (; i != str.end(); ++i)
- out << *i;
- out << '"';
- }
-
- void operator()(utf8_symbol_range const& str) const
- {
- typedef utf8_symbol_range::const_iterator iterator;
- iterator i = str.begin();
- for (; i != str.end(); ++i)
- out << *i;
- }
-
- template <typename Iterator>
- void operator()(boost::iterator_range<Iterator> const& range) const
- {
- typedef typename boost::iterator_range<Iterator>::const_iterator iterator;
- (*this)('(');
- for (iterator i = range.begin(); i != range.end(); ++i)
- {
- if (i != range.begin())
- (*this)(' ');
- scheme::utree::visit(*i, *this);
- }
- (*this)(')');
- }
- };
+// struct utree_print
+// {
+// typedef void result_type;
+//
+// std::ostream& out;
+// utree_print(std::ostream& out) : out(out) {}
+//
+// void operator()(scheme::nil) const
+// {
+// out << "nil";
+// }
+//
+// template <typename T>
+// void operator()(T val) const
+// {
+// out << val;
+// }
+//
+// void operator()(bool b) const
+// {
+// out << (b ? "true" : "false");
+// }
+//
+// void operator()(binary_range const& b) const
+// {
+// out << "b";
+// out.width(2);
+// out.fill('0');
+//
+// typedef binary_range::const_iterator iterator;
+// for (iterator i = b.begin(); i != b.end(); ++i)
+// out << std::hex << int((unsigned char)*i);
+// out << std::dec;
+// }
+//
+// void operator()(utf8_string_range const& str) const
+// {
+// typedef utf8_string_range::const_iterator iterator;
+// iterator i = str.begin();
+// out << '"';
+// for (; i != str.end(); ++i)
+// out << *i;
+// out << '"';
+// }
+//
+// void operator()(utf8_symbol_range const& str) const
+// {
+// typedef utf8_symbol_range::const_iterator iterator;
+// iterator i = str.begin();
+// for (; i != str.end(); ++i)
+// out << *i;
+// }
+//
+// template <typename Iterator>
+// void operator()(boost::iterator_range<Iterator> const& range) const
+// {
+// typedef typename boost::iterator_range<Iterator>::const_iterator iterator;
+// (*this)('(');
+// for (iterator i = range.begin(); i != range.end(); ++i)
+// {
+// if (i != range.begin())
+// (*this)(' ');
+// scheme::utree::visit(*i, *this);
+// }
+// (*this)(')');
+// }
+// };
 
     template <typename Base>
     struct logical_function
@@ -351,6 +358,8 @@
         template <typename A> \
         static utree eval(A& a) \
         { \
+ static int b; \
+ (void) b; \
             return utree(expr); \
         } \
     }; \
@@ -400,11 +409,11 @@
         return !(a < b);
     }
 
- inline std::ostream& operator<<(std::ostream& out, utree const& x)
- {
- utree::visit(x, utree_print(out));
- return out;
- }
+// inline std::ostream& operator<<(std::ostream& out, utree const& x)
+// {
+// utree::visit(x, utree_print(out));
+// return out;
+// }
 
     SCHEME_CREATE_LOGICAL_FUNCTION(and_, a&&b);
     SCHEME_CREATE_LOGICAL_FUNCTION(or_, a||b);
@@ -500,4 +509,8 @@
     }
 }
 
+#if defined(BOOST_MSVC)
+# pragma warning(pop)
+#endif
+
 #endif


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