Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-01-12 01:43:35


Author: eric_niebler
Date: 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
New Revision: 42691
URL: http://svn.boost.org/trac/boost/changeset/42691

Log:
new style transforms a-la proto v3
Added:
   trunk/boost/xpressive/proto/detail/as_lvalue.hpp (contents, props changed)
   trunk/boost/xpressive/proto/detail/dont_care.hpp (contents, props changed)
   trunk/boost/xpressive/proto/transform/bind.hpp (contents, props changed)
   trunk/boost/xpressive/proto/transform/call.hpp (contents, props changed)
   trunk/boost/xpressive/proto/transform/make.hpp (contents, props changed)
   trunk/boost/xpressive/proto/transform/when.hpp (contents, props changed)
Removed:
   trunk/boost/xpressive/proto/transform/apply.hpp
   trunk/boost/xpressive/proto/transform/branch.hpp
   trunk/boost/xpressive/proto/transform/compose.hpp
   trunk/boost/xpressive/proto/transform/construct.hpp
   trunk/boost/xpressive/proto/transform/function.hpp
   trunk/boost/xpressive/proto/transform/list.hpp
Text files modified:
   trunk/boost/xpressive/detail/core/linker.hpp | 8
   trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp | 109 +++++-----
   trunk/boost/xpressive/detail/core/matcher/assert_word_matcher.hpp | 6
   trunk/boost/xpressive/detail/core/matcher/attr_matcher.hpp | 6
   trunk/boost/xpressive/detail/core/matcher/charset_matcher.hpp | 4
   trunk/boost/xpressive/detail/core/matcher/literal_matcher.hpp | 13
   trunk/boost/xpressive/detail/core/matcher/mark_matcher.hpp | 4
   trunk/boost/xpressive/detail/core/matcher/optional_matcher.hpp | 8
   trunk/boost/xpressive/detail/core/matcher/range_matcher.hpp | 4
   trunk/boost/xpressive/detail/core/matcher/repeat_end_matcher.hpp | 4
   trunk/boost/xpressive/detail/core/matcher/set_matcher.hpp | 8
   trunk/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp | 4
   trunk/boost/xpressive/detail/core/matcher/string_matcher.hpp | 4
   trunk/boost/xpressive/detail/core/peeker.hpp | 34 +-
   trunk/boost/xpressive/detail/detail_fwd.hpp | 64 +++++-
   trunk/boost/xpressive/detail/dynamic/dynamic.hpp | 16
   trunk/boost/xpressive/detail/dynamic/parser.hpp | 24 +-
   trunk/boost/xpressive/detail/static/compile.hpp | 2
   trunk/boost/xpressive/detail/static/grammar.hpp | 214 ++++++++++++--------
   trunk/boost/xpressive/detail/static/transforms/as_action.hpp | 257 ++++++++++++------------
   trunk/boost/xpressive/detail/static/transforms/as_alternate.hpp | 198 +++++++++----------
   trunk/boost/xpressive/detail/static/transforms/as_independent.hpp | 80 ++++---
   trunk/boost/xpressive/detail/static/transforms/as_inverse.hpp | 59 ++--
   trunk/boost/xpressive/detail/static/transforms/as_marker.hpp | 63 +----
   trunk/boost/xpressive/detail/static/transforms/as_matcher.hpp | 30 +-
   trunk/boost/xpressive/detail/static/transforms/as_modifier.hpp | 51 ++--
   trunk/boost/xpressive/detail/static/transforms/as_quantifier.hpp | 271 ++++++++++++++------------
   trunk/boost/xpressive/detail/static/transforms/as_sequence.hpp | 33 +-
   trunk/boost/xpressive/detail/static/transforms/as_set.hpp | 246 +++++++++--------------
   trunk/boost/xpressive/detail/static/transmogrify.hpp | 10
   trunk/boost/xpressive/proto/expr.hpp | 2
   trunk/boost/xpressive/proto/fusion.hpp | 404 +++++++++++++++++----------------------
   trunk/boost/xpressive/proto/make_expr.hpp | 28 ++
   trunk/boost/xpressive/proto/matches.hpp | 199 +++++++++++++++----
   trunk/boost/xpressive/proto/proto_fwd.hpp | 408 +++++++++++++++++++++++++++++----------
   trunk/boost/xpressive/proto/ref.hpp | 2
   trunk/boost/xpressive/proto/traits.hpp | 67 +++++
   trunk/boost/xpressive/proto/transform.hpp | 10
   trunk/boost/xpressive/proto/transform/arg.hpp | 260 ++++++++++---------------
   trunk/boost/xpressive/proto/transform/fold.hpp | 294 +++++++++++++++++-----------
   trunk/boost/xpressive/proto/transform/fold_tree.hpp | 144 +++++++++-----
   trunk/boost/xpressive/proto/transform/pass_through.hpp | 72 +++---
   trunk/boost/xpressive/regex_actions.hpp | 33 +-
   trunk/boost/xpressive/regex_compiler.hpp | 4
   trunk/boost/xpressive/regex_primitives.hpp | 40 ++-
   trunk/boost/xpressive/xpressive_typeof.hpp | 24 +-
   trunk/libs/xpressive/proto/example/calc1.cpp | 4
   trunk/libs/xpressive/proto/example/calc2.cpp | 22 +-
   trunk/libs/xpressive/proto/example/calc3.cpp | 114 ++---------
   trunk/libs/xpressive/proto/example/hello.cpp | 2
   trunk/libs/xpressive/proto/example/lazy_vector.cpp | 10
   trunk/libs/xpressive/proto/example/mixed.cpp | 91 ++++----
   trunk/libs/xpressive/proto/example/rgb.cpp | 72 ++++--
   trunk/libs/xpressive/proto/example/tarray.cpp | 24 +-
   trunk/libs/xpressive/proto/example/vec3.cpp | 43 +--
   trunk/libs/xpressive/proto/example/vector.cpp | 8
   trunk/libs/xpressive/proto/test/Jamfile.v2 | 2
   trunk/libs/xpressive/proto/test/calculator.cpp | 14
   trunk/libs/xpressive/proto/test/examples.cpp | 287 ++++++++++++++++-----------
   trunk/libs/xpressive/proto/test/lambda.cpp | 92 +++-----
   trunk/libs/xpressive/proto/test/matches.cpp | 30 +
   trunk/libs/xpressive/proto/test/proto_fusion.cpp | 20 +
   trunk/libs/xpressive/proto/test/proto_fusion_s.cpp | 38 ++-
   trunk/libs/xpressive/proto/test/toy_spirit2.cpp | 365 ++++++++++++-----------------------
   64 files changed, 2669 insertions(+), 2394 deletions(-)

Modified: trunk/boost/xpressive/detail/core/linker.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/linker.hpp (original)
+++ trunk/boost/xpressive/detail/core/linker.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -159,7 +159,7 @@
         this->back_stack_.push(next);
     }
 
- template<bool Greedy>
+ template<typename Greedy>
     void accept(repeat_end_matcher<Greedy> const &matcher, void const *)
     {
         matcher.back_ = this->back_stack_.top();
@@ -179,14 +179,14 @@
         this->back_stack_.pop();
     }
 
- template<typename Xpr, bool Greedy>
+ template<typename Xpr, typename Greedy>
     void accept(optional_matcher<Xpr, Greedy> const &matcher, void const *next)
     {
         this->back_stack_.push(next);
         matcher.xpr_.link(*this);
     }
 
- template<typename Xpr, bool Greedy>
+ template<typename Xpr, typename Greedy>
     void accept(optional_mark_matcher<Xpr, Greedy> const &matcher, void const *next)
     {
         this->back_stack_.push(next);
@@ -211,7 +211,7 @@
         matcher.xpr_.link(*this);
     }
 
- template<typename Xpr, bool Greedy>
+ template<typename Xpr, typename Greedy>
     void accept(simple_repeat_matcher<Xpr, Greedy> const &matcher, void const *)
     {
         matcher.xpr_.link(*this);

Modified: trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/action_matcher.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -75,7 +75,7 @@
         typedef
             fusion::transform_view<
                 typename fusion::result_of::push_front<
- typename fusion::result_of::pop_front<proto::children<right_type> >::type const
+ typename fusion::result_of::pop_front<right_type>::type const
                   , reference_wrapper<left_type>
>::type const
               , proto::eval_fun<Context>
@@ -91,7 +91,7 @@
             return fusion::invoke<function_type>(
                 proto::arg(proto::arg_c<0>(proto::right(expr)))
               , evaluated_args(
- fusion::push_front(fusion::pop_front(proto::children_of(proto::right(expr))), boost::ref(proto::left(expr)))
+ fusion::push_front(fusion::pop_front(proto::right(expr)), boost::ref(proto::left(expr)))
                   , proto::eval_fun<Context>(ctx)
                 )
             );
@@ -263,20 +263,19 @@
     ///////////////////////////////////////////////////////////////////////////////
     // subreg_transform
     //
- template<typename Grammar>
- struct subreg_transform
- : Grammar
+ struct subreg_transform : proto::callable
     {
- subreg_transform();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
           : proto::terminal<sub_match<typename State::iterator> >
         {};
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &, State const &state, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &, State const &state, Visitor &visitor) const
         {
             sub_match<typename State::iterator> const &sub = state.sub_matches_[ visitor ];
             return proto::as_expr(sub);
@@ -286,20 +285,19 @@
     ///////////////////////////////////////////////////////////////////////////////
     // mark_transform
     //
- template<typename Grammar>
- struct mark_transform
- : Grammar
+ struct mark_transform : proto::callable
     {
- mark_transform();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
           : proto::terminal<sub_match<typename State::iterator> >
         {};
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &) const
         {
             sub_match<typename State::iterator> const &sub = state.sub_matches_[ proto::arg(expr).mark_number_ ];
             return proto::as_expr(sub);
@@ -331,22 +329,21 @@
     ///////////////////////////////////////////////////////////////////////////////
     // attr_transform
     //
- template<typename Grammar>
- struct attr_transform
- : Grammar
+ struct attr_transform : proto::callable
     {
- attr_transform();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
           : proto::result_of::as_expr<
                 opt<typename Expr::proto_arg0::matcher_type::value_type::second_type>
>
         {};
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &, State const &state, Visitor &)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &, State const &state, Visitor &) const
         {
             typedef typename Expr::proto_arg0::matcher_type::value_type::second_type attr_type;
             int slot = typename Expr::proto_arg0::nbr_type();
@@ -358,26 +355,26 @@
     ///////////////////////////////////////////////////////////////////////////////
     // attr_with_default_transform
     //
- template<typename Grammar>
+ template<typename Grammar, typename Callable = proto::callable>
     struct attr_with_default_transform
- : Grammar
     {
- attr_with_default_transform();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
           : proto::unary_expr<
                 attr_with_default_tag
- , typename Grammar::template apply<Expr, State, Visitor>::type
+ , typename Grammar::template result<void(Expr, State, Visitor)>::type
>
         {};
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
         {
- typename apply<Expr, State, Visitor>::type that = {
- Grammar::call(expr, state, visitor)
+ typename result<void(Expr, State, Visitor)>::type that = {
+ Grammar()(expr, state, visitor)
             };
             return that;
         }
@@ -386,22 +383,21 @@
     ///////////////////////////////////////////////////////////////////////////////
     // by_ref_transform
     //
- template<typename Grammar>
- struct by_ref_transform
- : Grammar
+ struct by_ref_transform : proto::callable
     {
- by_ref_transform();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
           : proto::terminal<typename proto::result_of::arg<Expr>::const_reference>
         {};
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &, Visitor &) const
         {
- return apply<Expr, State, Visitor>::type::make(proto::arg(expr));
+ return result<void(Expr, State, Visitor)>::type::make(proto::arg(expr));
         }
     };
 
@@ -410,17 +406,15 @@
     //
     struct BindActionArgs
       : proto::or_<
- subreg_transform<proto::terminal<any_matcher> >
- , mark_transform<proto::terminal<mark_placeholder> >
- , attr_transform<proto::terminal<read_attr<proto::_, proto::_> > >
- , by_ref_transform<proto::terminal<proto::_> >
- , attr_with_default_transform<
- proto::bitwise_or<
- attr_transform<proto::terminal<read_attr<proto::_, proto::_> > >
- , BindActionArgs
- >
+ proto::when<proto::terminal<any_matcher>, subreg_transform>
+ , proto::when<proto::terminal<mark_placeholder>, mark_transform>
+ , proto::when<proto::terminal<read_attr<proto::_, proto::_> >, attr_transform>
+ , proto::when<proto::terminal<proto::_>, by_ref_transform>
+ , proto::when<
+ proto::bitwise_or<proto::terminal<read_attr<proto::_, proto::_> >, BindActionArgs>
+ , attr_with_default_transform<proto::bitwise_or<attr_transform, BindActionArgs> >
>
- , proto::nary_expr<proto::_, proto::vararg<BindActionArgs> >
+ , proto::otherwise<proto::nary_expr<proto::_, proto::vararg<BindActionArgs> > >
>
     {};
 
@@ -444,8 +438,9 @@
         bool match(match_state<BidiIter> &state, Next const &next) const
         {
             // Bind the arguments
- typedef typename BindActionArgs::apply<Actor, match_state<BidiIter>, int>::type action_type;
- action<action_type> actor(BindActionArgs::call(this->actor_, state, this->sub_));
+ int sub = this->sub_; // BUGBUG this is a hack
+ typedef typename BindActionArgs::result<void(Actor, match_state<BidiIter>, int)>::type action_type;
+ action<action_type> actor(BindActionArgs()(this->actor_, state, sub));
 
             // Put the action in the action list
             actionable const **action_list_tail = state.action_list_tail_;

Modified: trunk/boost/xpressive/detail/core/matcher/assert_word_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/assert_word_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/assert_word_matcher.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -24,7 +24,7 @@
     ///////////////////////////////////////////////////////////////////////////////
     // word_boundary
     //
- template<bool IsBoundary>
+ template<typename IsBoundary>
     struct word_boundary
     {
         template<typename BidiIter>
@@ -32,10 +32,10 @@
         {
             if((state.flags_.match_not_bow_ && state.bos()) || (state.flags_.match_not_eow_ && state.eos()))
             {
- return !IsBoundary;
+ return !IsBoundary::value;
             }
 
- return IsBoundary == (prevword != thisword);
+ return IsBoundary::value == (prevword != thisword);
         }
     };
 

Modified: trunk/boost/xpressive/detail/core/matcher/attr_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/attr_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/attr_matcher.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -65,7 +65,7 @@
     ///////////////////////////////////////////////////////////////////////////////
     // attr_matcher
     // Note: the Matcher is a std::map
- template<typename Matcher, typename Traits, bool ICase>
+ template<typename Matcher, typename Traits, typename ICase>
     struct attr_matcher
       : quant_style<quant_none, 0, false>
     {
@@ -74,7 +74,7 @@
         attr_matcher(int slot, Matcher const &matcher, Traits const& traits)
           : slot_(slot-1)
         {
- char_translate<Traits, ICase> trans(traits);
+ char_translate<Traits, ICase::value> trans(traits);
             this->sym_.load(matcher, trans);
         }
 
@@ -82,7 +82,7 @@
         bool match(match_state<BidiIter> &state, Next const &next) const
         {
             BidiIter tmp = state.cur_;
- char_translate<Traits, ICase> trans(traits_cast<Traits>(state));
+ char_translate<Traits, ICase::value> trans(traits_cast<Traits>(state));
             result_type const &result = this->sym_(state.cur_, state.end_, trans);
             if(result)
             {

Modified: trunk/boost/xpressive/detail/core/matcher/charset_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/charset_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/charset_matcher.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -23,13 +23,13 @@
     ///////////////////////////////////////////////////////////////////////////////
     // charset_matcher
     //
- template<typename Traits, bool ICase, typename CharSet>
+ template<typename Traits, typename ICase, typename CharSet>
     struct charset_matcher
       : quant_style_fixed_width<1>
     {
         typedef typename Traits::char_type char_type;
         typedef Traits traits_type;
- typedef mpl::bool_<ICase> icase_type;
+ typedef ICase icase_type;
 
         charset_matcher(CharSet const &charset = CharSet())
           : charset_(charset)

Modified: trunk/boost/xpressive/detail/core/matcher/literal_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/literal_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/literal_matcher.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -24,18 +24,17 @@
     ///////////////////////////////////////////////////////////////////////////////
     // literal_matcher
     //
- template<typename Traits, bool ICase, bool Not>
+ template<typename Traits, typename ICase, typename Not>
     struct literal_matcher
       : quant_style_fixed_width<1>
     {
         typedef typename Traits::char_type char_type;
- typedef mpl::bool_<Not> not_type;
- typedef mpl::bool_<ICase> icase_type;
+ typedef Not not_type;
+ typedef ICase icase_type;
         char_type ch_;
 
- typedef literal_matcher<Traits, ICase, !Not> inverse_type;
- explicit literal_matcher(inverse_type that)
- : ch_(that.ch_)
+ explicit literal_matcher(char_type ch)
+ : ch_(ch)
         {}
 
         literal_matcher(char_type ch, Traits const &traits)
@@ -45,7 +44,7 @@
         template<typename BidiIter, typename Next>
         bool match(match_state<BidiIter> &state, Next const &next) const
         {
- if(state.eos() || Not ==
+ if(state.eos() || Not::value ==
                 (detail::translate(*state.cur_, traits_cast<Traits>(state), icase_type()) == this->ch_))
             {
                 return false;

Modified: trunk/boost/xpressive/detail/core/matcher/mark_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/mark_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/mark_matcher.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -28,11 +28,11 @@
     ///////////////////////////////////////////////////////////////////////////////
     // mark_matcher
     //
- template<typename Traits, bool ICase>
+ template<typename Traits, typename ICase>
     struct mark_matcher
       : quant_style_variable_width
     {
- typedef mpl::bool_<ICase> icase_type;
+ typedef ICase icase_type;
         int mark_number_;
 
         mark_matcher(int mark_number, Traits const &)

Modified: trunk/boost/xpressive/detail/core/matcher/optional_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/optional_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/optional_matcher.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -23,7 +23,7 @@
 
     ///////////////////////////////////////////////////////////////////////////////
     // optional_matcher
- template<typename Xpr, bool Greedy>
+ template<typename Xpr, typename Greedy>
     struct optional_matcher
       : quant_style<quant_variable_width, unknown_width::value, Xpr::pure>
     {
@@ -37,7 +37,7 @@
         template<typename BidiIter, typename Next>
         bool match(match_state<BidiIter> &state, Next const &next) const
         {
- return this->match_(state, next, mpl::bool_<Greedy>());
+ return this->match_(state, next, Greedy());
         }
 
     private:
@@ -79,7 +79,7 @@
 
     ///////////////////////////////////////////////////////////////////////////////
     // optional_mark_matcher
- template<typename Xpr, bool Greedy>
+ template<typename Xpr, typename Greedy>
     struct optional_mark_matcher
       : quant_style<quant_variable_width, unknown_width::value, Xpr::pure>
     {
@@ -95,7 +95,7 @@
         template<typename BidiIter, typename Next>
         bool match(match_state<BidiIter> &state, Next const &next) const
         {
- return this->match_(state, next, mpl::bool_<Greedy>());
+ return this->match_(state, next, Greedy());
         }
 
     private:

Modified: trunk/boost/xpressive/detail/core/matcher/range_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/range_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/range_matcher.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -26,12 +26,12 @@
     ///////////////////////////////////////////////////////////////////////////////
     // range_matcher
     //
- template<typename Traits, bool ICase>
+ template<typename Traits, typename ICase>
     struct range_matcher
       : quant_style_fixed_width<1>
     {
         typedef typename Traits::char_type char_type;
- typedef mpl::bool_<ICase> icase_type;
+ typedef ICase icase_type;
         char_type ch_min_;
         char_type ch_max_;
         bool not_;

Modified: trunk/boost/xpressive/detail/core/matcher/repeat_end_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/repeat_end_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/repeat_end_matcher.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -24,11 +24,11 @@
     ///////////////////////////////////////////////////////////////////////////////
     // repeat_end_matcher
     //
- template<bool Greedy>
+ template<typename Greedy>
     struct repeat_end_matcher
       : quant_style<quant_none, 0, false>
     {
- typedef mpl::bool_<Greedy> greedy_type;
+ typedef Greedy greedy_type;
         int mark_number_;
         unsigned int min_, max_;
         mutable void const *back_;

Modified: trunk/boost/xpressive/detail/core/matcher/set_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/set_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/set_matcher.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -30,12 +30,12 @@
 ///////////////////////////////////////////////////////////////////////////////
 // set_matcher
 //
-template<typename Traits, int Size>
+template<typename Traits, typename Size>
 struct set_matcher
   : quant_style_fixed_width<1>
 {
     typedef typename Traits::char_type char_type;
- char_type set_[ Size ];
+ char_type set_[ Size::value ];
     bool not_;
     bool icase_;
 
@@ -55,7 +55,7 @@
     {
         this->icase_ = true;
 
- for(int i = 0; i < Size; ++i)
+ for(int i = 0; i < Size::value; ++i)
         {
             this->set_[i] = traits.translate_nocase(this->set_[i]);
         }
@@ -63,7 +63,7 @@
 
     bool in_set(Traits const &traits, char_type ch) const
     {
- char_type const *begin = &this->set_[0], *end = begin + Size;
+ char_type const *begin = &this->set_[0], *end = begin + Size::value;
         ch = this->icase_ ? traits.translate_nocase(ch) : traits.translate(ch);
         return end != std::find(begin, end, ch);
     }

Modified: trunk/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -55,12 +55,12 @@
     ///////////////////////////////////////////////////////////////////////////////
     // simple_repeat_matcher
     //
- template<typename Xpr, bool Greedy>
+ template<typename Xpr, typename Greedy>
     struct simple_repeat_matcher
       : quant_style_variable_width
     {
         typedef Xpr xpr_type;
- typedef mpl::bool_<Greedy> greedy_type;
+ typedef Greedy greedy_type;
 
         Xpr xpr_;
         unsigned int min_, max_;

Modified: trunk/boost/xpressive/detail/core/matcher/string_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/matcher/string_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/core/matcher/string_matcher.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -26,13 +26,13 @@
     ///////////////////////////////////////////////////////////////////////////////
     // string_matcher
     //
- template<typename Traits, bool ICase>
+ template<typename Traits, typename ICase>
     struct string_matcher
       : quant_style_fixed_unknown_width
     {
         typedef typename Traits::char_type char_type;
         typedef typename Traits::string_type string_type;
- typedef mpl::bool_<ICase> icase_type;
+ typedef ICase icase_type;
         string_type str_;
         char_type const *end_;
 

Modified: trunk/boost/xpressive/detail/core/peeker.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/peeker.hpp (original)
+++ trunk/boost/xpressive/detail/core/peeker.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -142,20 +142,20 @@
         return mpl::true_();
     }
 
- template<typename Traits, bool ICase>
- mpl::false_ accept(literal_matcher<Traits, ICase, false> const &xpr)
+ template<typename Traits, typename ICase>
+ mpl::false_ accept(literal_matcher<Traits, ICase, mpl::false_> const &xpr)
     {
- this->bset_.set_char(xpr.ch_, ICase, this->get_traits_<Traits>());
+ this->bset_.set_char(xpr.ch_, ICase(), this->get_traits_<Traits>());
         return mpl::false_();
     }
 
- template<typename Traits, bool ICase>
+ template<typename Traits, typename ICase>
     mpl::false_ accept(string_matcher<Traits, ICase> const &xpr)
     {
- this->bset_.set_char(xpr.str_[0], ICase, this->get_traits_<Traits>());
+ this->bset_.set_char(xpr.str_[0], ICase(), this->get_traits_<Traits>());
         this->str_.begin_ = detail::data_begin(xpr.str_);
         this->str_.end_ = detail::data_end(xpr.str_);
- this->str_.icase_ = ICase;
+ this->str_.icase_ = ICase::value;
         return mpl::false_();
     }
 
@@ -167,35 +167,35 @@
         return mpl::false_();
     }
 
- template<typename Matcher, typename Traits, bool ICase>
+ template<typename Matcher, typename Traits, typename ICase>
     mpl::false_ accept(attr_matcher<Matcher, Traits, ICase> const &xpr)
     {
- xpr.sym_.peek(char_sink<Traits, ICase>(this->bset_, this->get_traits_<Traits>()));
+ xpr.sym_.peek(char_sink<Traits, ICase::value>(this->bset_, this->get_traits_<Traits>()));
         return mpl::false_();
     }
 
- template<typename Xpr, bool Greedy>
+ template<typename Xpr, typename Greedy>
     mpl::false_ accept(optional_matcher<Xpr, Greedy> const &)
     {
         this->fail(); // a union of xpr and next
         return mpl::false_();
     }
 
- template<typename Xpr, bool Greedy>
+ template<typename Xpr, typename Greedy>
     mpl::false_ accept(optional_mark_matcher<Xpr, Greedy> const &)
     {
         this->fail(); // a union of xpr and next
         return mpl::false_();
     }
 
- //template<typename Xpr, bool Greedy>
+ //template<typename Xpr, typename Greedy>
     //mpl::true_ accept(optional_matcher<Xpr, Greedy> const &xpr)
     //{
     // xpr.xpr_.peek(*this); // a union of xpr and next
     // return mpl::true_();
     //}
 
- //template<typename Xpr, bool Greedy>
+ //template<typename Xpr, typename Greedy>
     //mpl::true_ accept(optional_mark_matcher<Xpr, Greedy> const &xpr)
     //{
     // xpr.xpr_.peek(*this); // a union of xpr and next
@@ -209,23 +209,23 @@
         return mpl::false_();
     }
 
- template<bool ICase, typename Traits>
+ template<typename ICase, typename Traits>
     typename enable_if<is_narrow_char<typename Traits::char_type>, mpl::false_>::type
     accept(charset_matcher<Traits, ICase, basic_chset<Char> > const &xpr)
     {
         BOOST_ASSERT(0 != xpr.charset_.base().count());
- this->bset_.set_charset(xpr.charset_, ICase);
+ this->bset_.set_charset(xpr.charset_, ICase());
         return mpl::false_();
     }
 
- template<typename Traits, bool ICase>
+ template<typename Traits, typename ICase>
     mpl::false_ accept(range_matcher<Traits, ICase> const &xpr)
     {
- this->bset_.set_range(xpr.ch_min_, xpr.ch_max_, xpr.not_, ICase, this->get_traits_<Traits>());
+ this->bset_.set_range(xpr.ch_min_, xpr.ch_max_, xpr.not_, ICase(), this->get_traits_<Traits>());
         return mpl::false_();
     }
 
- template<typename Xpr, bool Greedy>
+ template<typename Xpr, typename Greedy>
     mpl::false_ accept(simple_repeat_matcher<Xpr, Greedy> const &xpr)
     {
         0 != xpr.min_ ? xpr.xpr_.peek(*this) : this->fail(); // could be a union of xpr and next

Modified: trunk/boost/xpressive/detail/detail_fwd.hpp
==============================================================================
--- trunk/boost/xpressive/detail/detail_fwd.hpp (original)
+++ trunk/boost/xpressive/detail/detail_fwd.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -95,7 +95,7 @@
     template<typename BidiIter>
     struct sequence;
 
- template<typename Traits, bool ICase>
+ template<typename Traits, typename ICase>
     struct mark_matcher;
 
     struct mark_begin_matcher;
@@ -111,27 +111,27 @@
     template<typename Traits>
     struct compound_charset;
 
- template<typename Traits, bool ICase, typename CharSet = compound_charset<Traits> >
+ template<typename Traits, typename ICase, typename CharSet = compound_charset<Traits> >
     struct charset_matcher;
 
- template<typename Traits, bool ICase>
+ template<typename Traits, typename ICase>
     struct range_matcher;
 
- template<typename Traits, int Size>
+ template<typename Traits, typename Size>
     struct set_matcher;
 
- template<typename Xpr, bool Greedy>
+ template<typename Xpr, typename Greedy>
     struct simple_repeat_matcher;
 
     struct repeat_begin_matcher;
 
- template<bool Greedy>
+ template<typename Greedy>
     struct repeat_end_matcher;
 
- template<typename Traits, bool ICase, bool Not>
+ template<typename Traits, typename ICase, typename Not>
     struct literal_matcher;
 
- template<typename Traits, bool ICase>
+ template<typename Traits, typename ICase>
     struct string_matcher;
 
     template<typename Actor>
@@ -140,13 +140,13 @@
     template<typename Predicate>
     struct predicate_matcher;
 
- template<typename Xpr, bool Greedy>
+ template<typename Xpr, typename Greedy>
     struct optional_matcher;
 
- template<typename Xpr, bool Greedy>
+ template<typename Xpr, typename Greedy>
     struct optional_mark_matcher;
 
- template<typename Matcher, typename Traits, bool ICase>
+ template<typename Matcher, typename Traits, typename ICase>
     struct attr_matcher;
 
     template<typename Nbr>
@@ -188,7 +188,7 @@
     template<typename Xpr>
     struct lookbehind_matcher;
 
- template<bool IsBoundary>
+ template<typename IsBoundary>
     struct word_boundary;
 
     template<typename BidiIter, typename Matcher>
@@ -386,6 +386,46 @@
 
 }}} // namespace boost::xpressive::detail
 
+namespace boost { namespace xpressive { namespace grammar_detail
+{
+ using proto::_;
+ using proto::or_;
+ using proto::if_;
+ using proto::call;
+ using proto::when;
+ using proto::otherwise;
+ using proto::switch_;
+ using proto::make;
+ using proto::_arg;
+ using proto::_left;
+ using proto::_right;
+ using proto::not_;
+ using proto::_state;
+ using proto::_visitor;
+ using proto::callable;
+ using proto::fold;
+ using proto::reverse_fold;
+ using proto::fold_tree;
+ using proto::reverse_fold_tree;
+ using proto::terminal;
+ using proto::shift_right;
+ using proto::bitwise_or;
+ using proto::logical_not;
+ using proto::dereference;
+ using proto::posit;
+ using proto::negate;
+ using proto::complement;
+ using proto::comma;
+ using proto::assign;
+ using proto::subscript;
+ using proto::nary_expr;
+ using proto::unary_expr;
+ using proto::binary_expr;
+ using proto::_deep_copy;
+ using proto::vararg;
+ namespace tag = proto::tag;
+}}}
+
 namespace boost { namespace xpressive { namespace op
 {
     struct push;

Modified: trunk/boost/xpressive/detail/dynamic/dynamic.hpp
==============================================================================
--- trunk/boost/xpressive/detail/dynamic/dynamic.hpp (original)
+++ trunk/boost/xpressive/detail/dynamic/dynamic.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -213,12 +213,12 @@
 {
     if(spec.greedy_)
     {
- simple_repeat_matcher<Xpr, true> quant(xpr, spec.min_, spec.max_, seq.width().value());
+ simple_repeat_matcher<Xpr, mpl::true_> quant(xpr, spec.min_, spec.max_, seq.width().value());
         seq = make_dynamic<BidiIter>(quant);
     }
     else
     {
- simple_repeat_matcher<Xpr, false> quant(xpr, spec.min_, spec.max_, seq.width().value());
+ simple_repeat_matcher<Xpr, mpl::false_> quant(xpr, spec.min_, spec.max_, seq.width().value());
         seq = make_dynamic<BidiIter>(quant);
     }
 }
@@ -243,12 +243,12 @@
     seq += make_dynamic<BidiIter>(alternate_end_matcher());
     if(spec.greedy_)
     {
- optional_matcher<xpr_type, true> opt(seq.xpr());
+ optional_matcher<xpr_type, mpl::true_> opt(seq.xpr());
         seq = make_dynamic<BidiIter>(opt);
     }
     else
     {
- optional_matcher<xpr_type, false> opt(seq.xpr());
+ optional_matcher<xpr_type, mpl::false_> opt(seq.xpr());
         seq = make_dynamic<BidiIter>(opt);
     }
 }
@@ -263,12 +263,12 @@
     seq += make_dynamic<BidiIter>(alternate_end_matcher());
     if(spec.greedy_)
     {
- optional_mark_matcher<xpr_type, true> opt(seq.xpr(), mark_nbr);
+ optional_mark_matcher<xpr_type, mpl::true_> opt(seq.xpr(), mark_nbr);
         seq = make_dynamic<BidiIter>(opt);
     }
     else
     {
- optional_mark_matcher<xpr_type, false> opt(seq.xpr(), mark_nbr);
+ optional_mark_matcher<xpr_type, mpl::false_> opt(seq.xpr(), mark_nbr);
         seq = make_dynamic<BidiIter>(opt);
     }
 }
@@ -313,13 +313,13 @@
         repeat_begin_matcher repeat_begin(mark_nbr);
         if(spec.greedy_)
         {
- repeat_end_matcher<true> repeat_end(mark_nbr, min, spec.max_);
+ repeat_end_matcher<mpl::true_> repeat_end(mark_nbr, min, spec.max_);
             seq = make_dynamic<BidiIter>(repeat_begin) + seq
                 + make_dynamic<BidiIter>(repeat_end);
         }
         else
         {
- repeat_end_matcher<false> repeat_end(mark_nbr, min, spec.max_);
+ repeat_end_matcher<mpl::false_> repeat_end(mark_nbr, min, spec.max_);
             seq = make_dynamic<BidiIter>(repeat_begin) + seq
                 + make_dynamic<BidiIter>(repeat_end);
         }

Modified: trunk/boost/xpressive/detail/dynamic/parser.hpp
==============================================================================
--- trunk/boost/xpressive/detail/dynamic/parser.hpp (original)
+++ trunk/boost/xpressive/detail/dynamic/parser.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -57,12 +57,12 @@
 {
     if(0 != (regex_constants::icase_ & flags))
     {
- literal_matcher<Traits, true, false> matcher(ch, traits);
+ literal_matcher<Traits, mpl::true_, mpl::false_> matcher(ch, traits);
         return make_dynamic<BidiIter>(matcher);
     }
     else
     {
- literal_matcher<Traits, false, false> matcher(ch, traits);
+ literal_matcher<Traits, mpl::false_, mpl::false_> matcher(ch, traits);
         return make_dynamic<BidiIter>(matcher);
     }
 }
@@ -79,8 +79,8 @@
 {
     using namespace regex_constants;
     typedef typename iterator_value<BidiIter>::type char_type;
- typedef set_matcher<Traits, 2> set_matcher;
- typedef literal_matcher<Traits, false, true> literal_matcher;
+ typedef detail::set_matcher<Traits, mpl::int_<2> > set_matcher;
+ typedef literal_matcher<Traits, mpl::false_, mpl::true_> literal_matcher;
 
     char_type const newline = traits.widen('\n');
     set_matcher s;
@@ -123,12 +123,12 @@
 
     if(0 != (regex_constants::icase_ & flags))
     {
- string_matcher<Traits, true> matcher(literal, traits);
+ string_matcher<Traits, mpl::true_> matcher(literal, traits);
         return make_dynamic<BidiIter>(matcher);
     }
     else
     {
- string_matcher<Traits, false> matcher(literal, traits);
+ string_matcher<Traits, mpl::false_> matcher(literal, traits);
         return make_dynamic<BidiIter>(matcher);
     }
 }
@@ -148,14 +148,14 @@
     {
         return make_dynamic<BidiIter>
         (
- mark_matcher<Traits, true>(mark_nbr, traits)
+ mark_matcher<Traits, mpl::true_>(mark_nbr, traits)
         );
     }
     else
     {
         return make_dynamic<BidiIter>
         (
- mark_matcher<Traits, false>(mark_nbr, traits)
+ mark_matcher<Traits, mpl::false_>(mark_nbr, traits)
         );
     }
 }
@@ -226,13 +226,13 @@
         charset_type charset(chset.base());
         if(icase)
         {
- charset_matcher<Traits, true, charset_type> matcher(charset);
+ charset_matcher<Traits, mpl::true_, charset_type> matcher(charset);
             merge_charset(matcher.charset_, chset, traits);
             return make_dynamic<BidiIter>(matcher);
         }
         else
         {
- charset_matcher<Traits, false, charset_type> matcher(charset);
+ charset_matcher<Traits, mpl::false_, charset_type> matcher(charset);
             merge_charset(matcher.charset_, chset, traits);
             return make_dynamic<BidiIter>(matcher);
         }
@@ -251,12 +251,12 @@
     {
         if(icase)
         {
- charset_matcher<Traits, true> matcher(chset);
+ charset_matcher<Traits, mpl::true_> matcher(chset);
             return make_dynamic<BidiIter>(matcher);
         }
         else
         {
- charset_matcher<Traits, false> matcher(chset);
+ charset_matcher<Traits, mpl::false_> matcher(chset);
             return make_dynamic<BidiIter>(matcher);
         }
     }

Modified: trunk/boost/xpressive/detail/static/compile.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/compile.hpp (original)
+++ trunk/boost/xpressive/detail/static/compile.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -41,7 +41,7 @@
         // "compile" the regex and wrap it in an xpression_adaptor.
         xpression_visitor<BidiIter, mpl::false_, Traits> visitor(traits, impl);
         intrusive_ptr<matchable_ex<BidiIter> const> adxpr = make_adaptor<matchable_ex<BidiIter> >(
- Grammar<char_type>::call(xpr, end_xpression(), visitor)
+ Grammar<char_type>()(xpr, end_xpression(), visitor)
         );
 
         // Link and optimize the regex

Modified: trunk/boost/xpressive/detail/static/grammar.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/grammar.hpp (original)
+++ trunk/boost/xpressive/detail/static/grammar.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -16,11 +16,8 @@
 #include <boost/mpl/if.hpp>
 #include <boost/mpl/bool.hpp>
 #include <boost/mpl/assert.hpp>
-#include <boost/xpressive/detail/static/is_pure.hpp>
 #include <boost/xpressive/proto/proto.hpp>
-#include <boost/xpressive/proto/transform/arg.hpp>
-#include <boost/xpressive/proto/transform/fold.hpp>
-#include <boost/xpressive/proto/transform/compose.hpp>
+#include <boost/xpressive/detail/static/is_pure.hpp>
 #include <boost/xpressive/detail/static/transforms/as_matcher.hpp>
 #include <boost/xpressive/detail/static/transforms/as_alternate.hpp>
 #include <boost/xpressive/detail/static/transforms/as_sequence.hpp>
@@ -61,7 +58,7 @@
     template<typename Char>
     struct ActionableGrammar;
 
- namespace detail
+ namespace grammar_detail
     {
         ///////////////////////////////////////////////////////////////////////////
         // CharLiteral
@@ -75,43 +72,43 @@
 
         ///////////////////////////////////////////////////////////////////////////
         // as_repeat
- template<typename Char, typename Gram, typename Tag, bool Greedy>
+ template<typename Char, typename Gram, typename Greedy>
         struct as_repeat
- : proto::if_<
- use_simple_repeat<proto::result_of::arg<mpl::_>, Char>
- , as_simple_quantifier<proto::unary_expr<Tag, Gram>, Greedy>
- , as_default_quantifier<proto::unary_expr<Tag, Gram>, Greedy>
+ : if_<
+ make<detail::use_simple_repeat<_arg, Char> >
+ , as_simple_quantifier<Gram, Greedy>
+ , as_default_quantifier<Greedy>
>
         {};
 
         ///////////////////////////////////////////////////////////////////////////
         // NonGreedyRepeatCases
- template<typename Char, typename Gram>
+ template<typename Gram>
         struct NonGreedyRepeatCases
         {
             template<typename Tag, typename Dummy = void>
             struct case_
- : proto::not_<proto::_>
+ : not_<_>
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::dereference, Dummy>
- : as_repeat<Char, Gram, proto::tag::dereference, false>
+ struct case_<tag::dereference, Dummy>
+ : dereference<Gram>
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::posit, Dummy>
- : as_repeat<Char, Gram, proto::tag::posit, false>
+ struct case_<tag::posit, Dummy>
+ : posit<Gram>
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::logical_not, Dummy>
- : as_repeat<Char, Gram, proto::tag::logical_not, false>
+ struct case_<tag::logical_not, Dummy>
+ : logical_not<Gram>
             {};
 
             template<uint_t Min, uint_t Max, typename Dummy>
- struct case_<generic_quant_tag<Min, Max>, Dummy>
- : as_repeat<Char, Gram, generic_quant_tag<Min, Max>, false>
+ struct case_<detail::generic_quant_tag<Min, Max>, Dummy>
+ : unary_expr<detail::generic_quant_tag<Min, Max>, Gram>
             {};
         };
 
@@ -122,42 +119,51 @@
         {
             template<typename Tag, typename Dummy = void>
             struct case_
- : proto::not_<proto::_>
+ : not_<_>
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::comma, Dummy>
- : as_list_set<ListSet<Char> >
+ struct case_<tag::comma, Dummy>
+ : when<ListSet<Char>, as_list_set_matcher<Char> >
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::assign, Dummy>
- : as_list_set<ListSet<Char> >
+ struct case_<tag::assign, Dummy>
+ : when<ListSet<Char>, as_list_set_matcher<Char> >
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::subscript, Dummy>
- : proto::transform::right<proto::subscript<set_initializer_type, as_set<Gram> > >
+ struct case_<tag::subscript, Dummy>
+ : when<subscript<detail::set_initializer_type, Gram>, call<as_set_matcher<Gram>(_right)> >
             {};
 
             template<typename Dummy>
- struct case_<lookahead_tag, Dummy>
- : proto::transform::arg<proto::unary_expr<lookahead_tag, as_lookahead<Gram> > >
+ struct case_<detail::lookahead_tag, Dummy>
+ : when<
+ unary_expr<detail::lookahead_tag, Gram>
+ , as_lookahead<Gram>
+ >
             {};
 
             template<typename Dummy>
- struct case_<lookbehind_tag, Dummy>
- : proto::transform::arg<proto::unary_expr<lookbehind_tag, as_lookbehind<Gram> > >
+ struct case_<detail::lookbehind_tag, Dummy>
+ : when<
+ unary_expr<detail::lookbehind_tag, Gram>
+ , as_lookbehind<Gram>
+ >
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::terminal, Dummy>
- : proto::or_<
- as_matcher<CharLiteral<Char> >
- , as_matcher<proto::terminal<posix_charset_placeholder> >
- , as_matcher<proto::terminal<range_placeholder<proto::_> > >
- , as_matcher<proto::terminal<logical_newline_placeholder> >
- , as_matcher<proto::terminal<assert_word_placeholder<word_boundary<true> > > >
+ struct case_<tag::terminal, Dummy>
+ : when<
+ or_<
+ CharLiteral<Char>
+ , terminal<detail::posix_charset_placeholder>
+ , terminal<detail::range_placeholder<_> >
+ , terminal<detail::logical_newline_placeholder>
+ , terminal<detail::assert_word_placeholder<detail::word_boundary<mpl::true_> > >
+ >
+ , as_matcher
>
             {};
         };
@@ -169,102 +175,140 @@
         {
             template<typename Tag, typename Dummy = void>
             struct case_
- : proto::not_<proto::_>
+ : not_<_>
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::shift_right, Dummy>
- : proto::transform::reverse_fold<proto::shift_right<Gram, Gram> >
+ struct case_<tag::terminal, Dummy>
+ : when<
+ _
+ , in_sequence<as_matcher>
+ >
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::terminal, Dummy>
- : in_sequence<as_matcher<proto::terminal<proto::_> > >
+ struct case_<tag::shift_right, Dummy>
+ : when<
+ shift_right<Gram, Gram>
+ , reverse_fold<_, _state, Gram>
+ >
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::bitwise_or, Dummy>
- : in_sequence<as_alternate<proto::bitwise_or<Gram, Gram> > >
+ struct case_<tag::bitwise_or, Dummy>
+ : when<
+ bitwise_or<Gram, Gram>
+ , in_sequence<
+ as_alternate_matcher<
+ reverse_fold_tree<_, make<fusion::nil>, in_alternate_list<Gram> >
+ >
+ >
+ >
             {};
 
- template<typename Dummy, bool Greedy>
+ template<typename Dummy, typename Greedy>
             struct case_<optional_tag<Greedy> , Dummy>
- : in_sequence<proto::transform::arg<proto::unary_expr<optional_tag<Greedy>, as_optional<Gram, Greedy> > > >
+ : when<
+ unary_expr<optional_tag<Greedy>, Gram>
+ , in_sequence<call<as_optional<Gram, Greedy>(_arg)> >
+ >
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::dereference, Dummy>
- : proto::transform::compose<as_repeat<Char, Gram, proto::tag::dereference, true>, Gram>
+ struct case_<tag::dereference, Dummy>
+ : when<
+ dereference<Gram>
+ , call<Gram(as_repeat<Char, Gram, mpl::true_>)>
+ >
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::posit, Dummy>
- : proto::transform::compose<as_repeat<Char, Gram, proto::tag::posit, true>, Gram>
+ struct case_<tag::posit, Dummy>
+ : when<
+ posit<Gram>
+ , call<Gram(as_repeat<Char, Gram, mpl::true_>)>
+ >
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::logical_not, Dummy>
- : proto::transform::compose<as_repeat<Char, Gram, proto::tag::logical_not, true>, Gram>
+ struct case_<tag::logical_not, Dummy>
+ : when<
+ logical_not<Gram>
+ , call<Gram(as_repeat<Char, Gram, mpl::true_>)>
+ >
             {};
 
             template<uint_t Min, uint_t Max, typename Dummy>
- struct case_<generic_quant_tag<Min, Max> , Dummy>
- : proto::transform::compose<as_repeat<Char, Gram, generic_quant_tag<Min, Max>, true>, Gram>
+ struct case_<detail::generic_quant_tag<Min, Max>, Dummy>
+ : when<
+ unary_expr<detail::generic_quant_tag<Min, Max>, Gram>
+ , call<Gram(as_repeat<Char, Gram, mpl::true_>)>
+ >
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::negate, Dummy>
- : proto::transform::compose<
- proto::transform::arg<proto::negate<proto::switch_<NonGreedyRepeatCases<Char, Gram> > > >
- , Gram
+ struct case_<tag::negate, Dummy>
+ : when<
+ negate<switch_<NonGreedyRepeatCases<Gram> > >
+ , call<Gram(call<as_repeat<Char, Gram, mpl::false_>(_arg)>)>
>
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::complement, Dummy>
- : in_sequence<as_inverse<
- proto::transform::arg<proto::complement<proto::switch_<InvertibleCases<Char, Gram> > > >
- > >
+ struct case_<tag::complement, Dummy>
+ : when<
+ complement<switch_<InvertibleCases<Char, Gram> > >
+ , in_sequence<call<as_inverse(call<switch_<InvertibleCases<Char, Gram> >(_arg)>)> >
+ >
             {};
 
             template<typename Dummy>
- struct case_<modifier_tag, Dummy>
- : as_modifier<proto::binary_expr<modifier_tag, proto::_, Gram> >
+ struct case_<detail::modifier_tag, Dummy>
+ : when<binary_expr<detail::modifier_tag, _, Gram>, as_modifier<Gram> >
             {};
 
             template<typename Dummy>
- struct case_<lookahead_tag, Dummy>
- : in_sequence<proto::transform::arg<proto::unary_expr<lookahead_tag, as_lookahead<Gram> > > >
+ struct case_<detail::lookahead_tag, Dummy>
+ : when<
+ unary_expr<detail::lookahead_tag, Gram>
+ , in_sequence<as_lookahead<Gram> >
+ >
             {};
 
             template<typename Dummy>
- struct case_<lookbehind_tag, Dummy>
- : in_sequence<proto::transform::arg<proto::unary_expr<lookbehind_tag, as_lookbehind<Gram> > > >
+ struct case_<detail::lookbehind_tag, Dummy>
+ : when<
+ unary_expr<detail::lookbehind_tag, Gram>
+ , in_sequence<as_lookbehind<Gram> >
+ >
             {};
 
             template<typename Dummy>
- struct case_<keeper_tag, Dummy>
- : in_sequence<proto::transform::arg<proto::unary_expr<keeper_tag, as_keeper<Gram> > > >
+ struct case_<detail::keeper_tag, Dummy>
+ : when<
+ unary_expr<detail::keeper_tag, Gram>
+ , in_sequence<as_keeper<Gram> >
+ >
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::comma, Dummy>
- : in_sequence<as_list_set<ListSet<Char> > >
+ struct case_<tag::comma, Dummy>
+ : when<ListSet<Char>, in_sequence<as_list_set_matcher<Char> > >
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::assign, Dummy>
- : proto::or_<
- proto::transform::compose<as_marker<proto::assign<basic_mark_tag, Gram> >, Gram>
- , in_sequence<as_list_set<ListSet<Char> > >
+ struct case_<tag::assign, Dummy>
+ : or_<
+ when<assign<detail::basic_mark_tag, Gram>, call<Gram(as_marker)> >
+ , when<ListSet<Char>, in_sequence<as_list_set_matcher<Char> > >
>
             {};
 
             template<typename Dummy>
- struct case_<proto::tag::subscript, Dummy>
- : proto::or_<
- in_sequence<proto::transform::right<proto::subscript<set_initializer_type, as_set<Gram> > > >
- , proto::transform::compose<as_action<proto::subscript<ActionableGrammar<Char>, proto::_> >, ActionableGrammar<Char> >
+ struct case_<tag::subscript, Dummy>
+ : or_<
+ when<subscript<detail::set_initializer_type, Gram>, in_sequence<call<as_set_matcher<Gram>(_right)> > >
+ , when<subscript<ActionableGrammar<Char>, _>, call<ActionableGrammar<Char>(as_action)> >
>
             {};
         };
@@ -282,9 +326,9 @@
             // Only in sub-expressions with actions attached do we allow attribute assignements
             template<typename Dummy>
             struct case_<proto::tag::assign, Dummy>
- : proto::or_<
+ : or_<
                     typename Cases<Char, Gram>::template case_<proto::tag::assign>
- , in_sequence<as_attr_matcher<proto::assign<proto::terminal<attribute_placeholder<proto::_> >, proto::_> > >
+ , when<proto::assign<terminal<detail::attribute_placeholder<_> >, _>, in_sequence<as_attr_matcher> >
>
             {};
         };
@@ -295,12 +339,12 @@
     // Grammar
     template<typename Char>
     struct Grammar
- : proto::switch_<detail::Cases<Char, Grammar<Char> > >
+ : proto::switch_<grammar_detail::Cases<Char, Grammar<Char> > >
     {};
 
     template<typename Char>
     struct ActionableGrammar
- : proto::switch_<detail::ActionableCases<Char, ActionableGrammar<Char> > >
+ : proto::switch_<grammar_detail::ActionableCases<Char, ActionableGrammar<Char> > >
     {};
 
     ///////////////////////////////////////////////////////////////////////////

Modified: trunk/boost/xpressive/detail/static/transforms/as_action.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transforms/as_action.hpp (original)
+++ trunk/boost/xpressive/detail/static/transforms/as_action.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -24,53 +24,11 @@
 #include <boost/xpressive/detail/static/static.hpp>
 #include <boost/xpressive/detail/static/transforms/as_quantifier.hpp>
 #include <boost/xpressive/proto/proto.hpp>
-#include <boost/xpressive/proto/transform/arg.hpp>
-#include <boost/xpressive/proto/transform/fold.hpp>
+#include <boost/xpressive/proto/transform.hpp>
 
 namespace boost { namespace xpressive { namespace detail
 {
     ///////////////////////////////////////////////////////////////////////////////
- // FindAttr
- // Look for patterns like (a1= terminal<RHS>) and return the type of the RHS.
- template<typename Nbr>
- struct FindAttr
- : proto::or_<
- proto::transform::state< proto::terminal<proto::_> >
- // Ignore nested actions, because attributes are scoped:
- , proto::transform::state< proto::subscript<proto::_, proto::_> >
- , proto::transform::arg<
- proto::transform::right<
- proto::assign<
- proto::terminal<xpressive::detail::attribute_placeholder<Nbr> >
- , proto::_
- >
- >
- >
- , proto::transform::fold<proto::nary_expr<proto::_, proto::vararg<FindAttr<Nbr> > > >
- >
- {};
-
- ///////////////////////////////////////////////////////////////////////////////
- // by_value
- // Store all terminals within an action by value to avoid dangling references.
- template<typename Terminal>
- struct by_value
- : Terminal
- {
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : proto::result_of::as_expr<typename proto::result_of::arg<Expr>::type>
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &)
- {
- return proto::as_expr(proto::arg(expr));
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////////
     // read_attr
     // Placeholder that knows the slot number of an attribute as well as the type
     // of the object stored in it.
@@ -81,112 +39,155 @@
         typedef Matcher matcher_type;
     };
 
+}}}
+
+namespace boost { namespace xpressive { namespace grammar_detail
+{
+ ///////////////////////////////////////////////////////////////////////////////
+ // FindAttr
+ // Look for patterns like (a1= terminal<RHS>) and return the type of the RHS.
+ template<typename Nbr>
+ struct FindAttr
+ : or_<
+ // Ignore nested actions, because attributes are scoped
+ when< subscript<_, _>, _state >
+ , when< terminal<_>, _state >
+ , when< proto::assign<terminal<detail::attribute_placeholder<Nbr> >, _>, call<_arg(_right)> >
+ , otherwise< fold<_, _state, FindAttr<Nbr> > >
+ >
+ {};
+
     ///////////////////////////////////////////////////////////////////////////////
     // as_read_attr
     // For patterns like (a1 = RHS)[ref(i) = a1], transform to
     // (a1 = RHS)[ref(i) = read_attr<1, RHS>] so that when reading the attribute
     // we know what type is stored in the attribute slot.
- template<typename Grammar>
- struct as_read_attr
- : Grammar
+ struct as_read_attr : callable
     {
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
           : proto::result_of::as_expr<
- read_attr<
+ detail::read_attr<
                     typename Expr::proto_arg0::nbr_type
                   , typename FindAttr<typename Expr::proto_arg0::nbr_type>
- ::template apply<State, mpl::void_, int>::type
+ ::template result<void(State, mpl::void_, int)>::type
>
>
         {};
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &, State const &, Visitor &)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &, State const &, Visitor &) const
         {
- typename apply<Expr, State, Visitor>::type that = {{}};
+ typename result<void(Expr, State, Visitor)>::type that = {{}};
             return that;
         }
     };
 
     ///////////////////////////////////////////////////////////////////////////////
+ // by_value
+ // Store all terminals within an action by value to avoid dangling references.
+ struct by_value : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : proto::result_of::as_expr<typename proto::result_of::arg<Expr>::type>
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &, Visitor &) const
+ {
+ return proto::as_expr(proto::arg(expr));
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////////////
     // DeepCopy
     // Turn all refs into values, and also bind all attribute placeholders with
     // the types from which they are being assigned.
     struct DeepCopy
- : proto::or_<
- as_read_attr<proto::terminal<xpressive::detail::attribute_placeholder<proto::_> > >
- , by_value<proto::terminal<proto::_> >
- , proto::nary_expr<proto::_, proto::vararg<DeepCopy> >
+ : or_<
+ when< terminal<detail::attribute_placeholder<_> >, as_read_attr>
+ , when< terminal<_>, by_value >
+ , otherwise< nary_expr<_, vararg<DeepCopy> > >
>
     {};
 
     ///////////////////////////////////////////////////////////////////////////////
- // max_attr
- // Take the maximum of the current attr slot number and the state.
- template<typename Grammar>
- struct max_attr
- : Grammar
- {
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : mpl::max<State, typename Grammar::template apply<Expr, State, Visitor>::type>
- {};
- };
-
- ///////////////////////////////////////////////////////////////////////////////
     // attr_nbr
     // For an attribute placeholder, return the attribute's slot number.
- template<typename Grammar>
- struct attr_nbr
- : Grammar
+ struct attr_nbr : callable
     {
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
           : Expr::proto_arg0::nbr_type
         {};
     };
 
+ struct max_attr;
+
     ///////////////////////////////////////////////////////////////////////////////
     // MaxAttr
     // In an action (rx)[act], find the largest attribute slot being used.
     struct MaxAttr
- : proto::or_<
- attr_nbr< proto::terminal< xpressive::detail::attribute_placeholder<proto::_> > >
- , proto::transform::state< proto::terminal<proto::_> >
+ : or_<
+ when< terminal<detail::attribute_placeholder<_> >, attr_nbr>
+ , when< terminal<_>, make<mpl::int_<0> > >
             // Ignore nested actions, because attributes are scoped:
- , proto::transform::state< proto::subscript<proto::_, proto::_> >
- , proto::transform::fold<proto::nary_expr<proto::_, max_attr<proto::vararg<MaxAttr> > > >
+ , when< subscript<_, _>, make<mpl::int_<0> > >
+ , otherwise< fold<_, make<mpl::int_<0> >, max_attr> >
>
     {};
 
     ///////////////////////////////////////////////////////////////////////////////
+ // max_attr
+ // Take the maximum of the current attr slot number and the state.
+ struct max_attr : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : mpl::max<State, typename MaxAttr::result<void(Expr, State, Visitor)>::type>
+ {};
+ };
+
+ ///////////////////////////////////////////////////////////////////////////////
     // as_attr_matcher
     // turn a1=matcher into attr_matcher<Matcher>(1)
- template<typename Grammar>
- struct as_attr_matcher
- : Grammar
+ struct as_attr_matcher : callable
     {
- as_attr_matcher();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
         {
             typedef
- attr_matcher<
+ detail::attr_matcher<
                     typename proto::result_of::arg<typename Expr::proto_arg1>::type
                   , typename Visitor::traits_type
- , Visitor::icase_type::value
+ , typename Visitor::icase_type
>
             type;
         };
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &, Visitor &visitor) const
         {
- return typename apply<Expr, State, Visitor>::type(
+ return typename result<void(Expr, State, Visitor)>::type(
                 Expr::proto_arg0::proto_base_expr::proto_arg0::nbr_type::value
               , proto::arg(proto::right(expr))
               , visitor.traits()
@@ -197,32 +198,31 @@
     ///////////////////////////////////////////////////////////////////////////////
     // add_attrs
     // Wrap an expression in attr_begin_matcher/attr_end_matcher pair
- template<typename Grammar>
- struct add_attrs
- : Grammar
+ struct add_attrs : callable
     {
- add_attrs();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename, typename>
- struct apply
- : proto::shift_right<
- typename proto::terminal<
- attr_begin_matcher<typename MaxAttr::apply<Expr, mpl::int_<0>, int>::type>
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : shift_right<
+ typename terminal<
+ detail::attr_begin_matcher<typename MaxAttr::result<void(Expr, mpl::int_<0>, int)>::type>
>::type
- , typename proto::shift_right<
+ , typename shift_right<
                     Expr
- , proto::terminal<attr_end_matcher>::type
+ , terminal<detail::attr_end_matcher>::type
>::type
>
         {};
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &, Visitor &) const
         {
- attr_begin_matcher<typename MaxAttr::apply<Expr, mpl::int_<0>, int>::type> begin;
- attr_end_matcher end;
- typename apply<Expr, State, Visitor>::type that = {{begin}, {expr, {end}}};
+ detail::attr_begin_matcher<typename MaxAttr::result<void(Expr, mpl::int_<0>, int)>::type> begin;
+ detail::attr_end_matcher end;
+ typename result<void(Expr, State, Visitor)>::type that = {{begin}, {expr, {end}}};
             return that;
         }
     };
@@ -230,19 +230,13 @@
     ///////////////////////////////////////////////////////////////////////////////
     // InsertAttrs
     struct InsertAttrs
- : proto::or_<
- add_attrs<proto::if_<mpl::apply_wrap3<MaxAttr, mpl::_, mpl::int_<0>, int> > >
- , proto::_
- >
+ : if_<MaxAttr, add_attrs, _>
     {};
 
     ///////////////////////////////////////////////////////////////////////////////
     // CheckAssertion
     struct CheckAssertion
- : proto::function<
- proto::terminal<check_tag>
- , proto::_
- >
+ : proto::function<terminal<detail::check_tag>, _>
     {};
 
     ///////////////////////////////////////////////////////////////////////////////
@@ -251,28 +245,27 @@
     // If A and B use attributes, wrap the above expression in
     // a attr_begin_matcher<Count> / attr_end_matcher pair, where Count is
     // the number of attribute slots used by the pattern/action.
- template<typename Grammar>
- struct as_action
- : Grammar
+ struct as_action : callable
     {
- as_action();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
         {
             typedef typename proto::result_of::left<Expr>::type expr_type;
             typedef typename proto::result_of::right<Expr>::type action_type;
- typedef typename DeepCopy::apply<action_type, expr_type, int>::type action_copy_type;
+ typedef typename DeepCopy::result<void(action_type, expr_type, int)>::type action_copy_type;
 
             typedef
- typename InsertMark::apply<expr_type, State, Visitor>::type
+ typename InsertMark::result<void(expr_type, State, Visitor)>::type
             marked_expr_type;
 
             typedef
                 typename mpl::if_<
                     proto::matches<action_type, CheckAssertion>
- , predicate_matcher<action_copy_type>
- , action_matcher<action_copy_type>
+ , detail::predicate_matcher<action_copy_type>
+ , detail::action_matcher<action_copy_type>
>::type
             matcher_type;
 
@@ -284,20 +277,20 @@
             no_attr_type;
 
             typedef
- typename InsertAttrs::apply<no_attr_type, State, Visitor>::type
+ typename InsertAttrs::result<void(no_attr_type, State, Visitor)>::type
             type;
         };
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
         {
- typedef apply<Expr, State, Visitor> apply_type;
+ typedef result<void(Expr, State, Visitor)> apply_type;
             typedef typename apply_type::matcher_type matcher_type;
 
             int dummy = 0;
             typename apply_type::marked_expr_type marked_expr =
- InsertMark::call(proto::left(expr), state, visitor);
+ InsertMark()(proto::left(expr), state, visitor);
 
             typename apply_type::no_attr_type that =
             {
@@ -305,13 +298,13 @@
               , {
                     matcher_type
                     (
- DeepCopy::call(proto::right(expr), proto::left(expr), dummy)
+ DeepCopy()(proto::right(expr), proto::left(expr), dummy)
                       , proto::arg(proto::left(marked_expr)).mark_number_
                     )
                 }
             };
 
- return InsertAttrs::call(that, state, visitor);
+ return InsertAttrs()(that, state, visitor);
         }
     };
 

Modified: trunk/boost/xpressive/detail/static/transforms/as_alternate.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transforms/as_alternate.hpp (original)
+++ trunk/boost/xpressive/detail/static/transforms/as_alternate.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -16,124 +16,114 @@
 #include <boost/config.hpp>
 #include <boost/mpl/assert.hpp>
 #include <boost/type_traits/is_same.hpp>
-#include <boost/xpressive/proto/traits.hpp>
-#include <boost/xpressive/proto/matches.hpp>
-#include <boost/xpressive/proto/transform/fold.hpp>
-#include <boost/xpressive/proto/transform/branch.hpp>
-#include <boost/xpressive/proto/transform/fold_tree.hpp>
+#include <boost/xpressive/proto/proto.hpp>
 #include <boost/xpressive/detail/detail_fwd.hpp>
 #include <boost/xpressive/detail/static/static.hpp>
 #include <boost/xpressive/detail/core/matcher/alternate_matcher.hpp>
 #include <boost/xpressive/detail/utility/cons.hpp>
 
-namespace boost { namespace xpressive { namespace detail
-{
-
- ///////////////////////////////////////////////////////////////////////////////
- // alternates_list
- // a fusion-compatible sequence of alternate expressions, that also keeps
- // track of the list's width and purity.
- template<typename Head, typename Tail>
- struct alternates_list
- : fusion::cons<Head, Tail>
- {
- BOOST_STATIC_CONSTANT(std::size_t, width = Head::width == Tail::width ? Head::width : unknown_width::value);
- BOOST_STATIC_CONSTANT(bool, pure = Head::pure && Tail::pure);
-
- alternates_list(Head const &head, Tail const &tail)
- : fusion::cons<Head, Tail>(head, tail)
- {
- }
- };
-
- template<typename Head>
- struct alternates_list<Head, fusion::nil>
- : fusion::cons<Head, fusion::nil>
- {
- BOOST_STATIC_CONSTANT(std::size_t, width = Head::width);
- BOOST_STATIC_CONSTANT(bool, pure = Head::pure);
-
- alternates_list(Head const &head, fusion::nil const &tail)
- : fusion::cons<Head, fusion::nil>(head, tail)
- {
- }
- };
+#define UNCV(x) typename remove_const<x>::type
+#define UNREF(x) typename remove_reference<x>::type
+#define UNCVREF(x) UNCV(UNREF(x))
 
- ///////////////////////////////////////////////////////////////////////////////
- // in_alternate
- template<typename Grammar>
- struct in_alternate
- : Grammar
+namespace boost { namespace xpressive
+{
+ namespace detail
     {
- in_alternate();
+ ///////////////////////////////////////////////////////////////////////////////
+ // alternates_list
+ // a fusion-compatible sequence of alternate expressions, that also keeps
+ // track of the list's width and purity.
+ template<typename Head, typename Tail>
+ struct alternates_list
+ : fusion::cons<Head, Tail>
+ {
+ BOOST_STATIC_CONSTANT(std::size_t, width = Head::width == Tail::width ? Head::width : detail::unknown_width::value);
+ BOOST_STATIC_CONSTANT(bool, pure = Head::pure && Tail::pure);
+
+ alternates_list(Head const &head, Tail const &tail)
+ : fusion::cons<Head, Tail>(head, tail)
+ {
+ }
+ };
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
- {
- typedef alternates_list<
- typename Grammar::template apply<Expr, alternate_end_xpression, Visitor>::type
- , State
- > type;
+ template<typename Head>
+ struct alternates_list<Head, fusion::nil>
+ : fusion::cons<Head, fusion::nil>
+ {
+ BOOST_STATIC_CONSTANT(std::size_t, width = Head::width);
+ BOOST_STATIC_CONSTANT(bool, pure = Head::pure);
+
+ alternates_list(Head const &head, fusion::nil const &tail)
+ : fusion::cons<Head, fusion::nil>(head, tail)
+ {
+ }
         };
+ }
 
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return typename apply<Expr, State, Visitor>::type(
- Grammar::call(expr, alternate_end_xpression(), visitor)
- , state
- );
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////////
- // as_alternate_matcher
- template<typename Grammar>
- struct as_alternate_matcher
- : Grammar
+ namespace grammar_detail
     {
- as_alternate_matcher();
+ ///////////////////////////////////////////////////////////////////////////////
+ // in_alternate_list
+ template<typename Grammar>
+ struct in_alternate_list : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ {
+ typedef detail::alternates_list<
+ typename Grammar::template result<void(Expr, detail::alternate_end_xpression, Visitor)>::type
+ , State
+ > type;
+ };
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ return typename result<void(Expr, State, Visitor)>::type(
+ Grammar()(expr, detail::alternate_end_xpression(), visitor)
+ , state
+ );
+ }
+ };
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
- {
- typedef alternate_matcher<
- typename Grammar::template apply<Expr, State, Visitor>::type
- , typename Visitor::traits_type
- > type;
+ ///////////////////////////////////////////////////////////////////////////////
+ // as_alternate_matcher
+ template<typename Grammar>
+ struct as_alternate_matcher : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ {
+ typedef detail::alternate_matcher<
+ typename Grammar::template result<void(Expr, State, Visitor)>::type
+ , typename Visitor::traits_type
+ > type;
+ };
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ return typename result<void(Expr, State, Visitor)>::type(
+ Grammar()(expr, state, visitor)
+ );
+ }
         };
 
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return typename apply<Expr, State, Visitor>::type(
- Grammar::call(expr, state, visitor)
- );
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////////
- // as_alternate
- template<typename Grammar>
- struct as_alternate
- : as_alternate_matcher<
- proto::transform::reverse_fold_tree<
- typename Grammar::proto_tag
- , in_alternate<typename Grammar::proto_arg0>
- , fusion::nil
- >
- >
- {
- BOOST_MPL_ASSERT((
- is_same<
- typename Grammar::proto_arg0
- , typename Grammar::proto_arg1
- >
- ));
- };
+ }
+
+}}
 
-}}}
+#undef UNCV
+#undef UNREF
+#undef UNCVREF
 
 #endif

Modified: trunk/boost/xpressive/detail/static/transforms/as_independent.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transforms/as_independent.hpp (original)
+++ trunk/boost/xpressive/detail/static/transforms/as_independent.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -17,7 +17,7 @@
 #include <boost/xpressive/detail/detail_fwd.hpp>
 #include <boost/xpressive/detail/static/static.hpp>
 #include <boost/xpressive/proto/proto.hpp>
-#include <boost/xpressive/proto/transform/arg.hpp>
+#include <boost/xpressive/proto/transform.hpp>
 
 namespace boost { namespace xpressive { namespace detail
 {
@@ -29,77 +29,87 @@
 
     struct lookbehind_tag
     {};
+}}}
+
+namespace boost { namespace xpressive { namespace grammar_detail
+{
 
     template<typename Grammar>
- struct as_lookahead
- : Grammar
+ struct as_lookahead : callable
     {
- as_lookahead();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
         {
- typedef lookahead_matcher<
- typename Grammar::template apply<Expr, true_xpression, Visitor>::type
+ typedef typename proto::result_of::arg<Expr>::type arg_type;
+ typedef detail::lookahead_matcher<
+ typename Grammar::template result<void(arg_type, detail::true_xpression, Visitor)>::type
> type;
         };
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &, Visitor &visitor) const
         {
- return typename apply<Expr, State, Visitor>::type(
- Grammar::call(expr, true_xpression(), visitor)
+ return typename result<void(Expr, State, Visitor)>::type(
+ Grammar()(proto::arg(expr), detail::true_xpression(), visitor)
               , false
             );
         }
     };
 
     template<typename Grammar>
- struct as_lookbehind
- : Grammar
+ struct as_lookbehind : callable
     {
- as_lookbehind();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
         {
- typedef lookbehind_matcher<
- typename Grammar::template apply<Expr, true_xpression, Visitor>::type
+ typedef typename proto::result_of::arg<Expr>::type arg_type;
+ typedef detail::lookbehind_matcher<
+ typename Grammar::template result<void(arg_type, detail::true_xpression, Visitor)>::type
> type;
         };
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &, Visitor &visitor) const
         {
- typename Grammar::template apply<Expr, true_xpression, Visitor>::type const &
- expr2 = Grammar::call(expr, true_xpression(), visitor);
+ typedef typename proto::result_of::arg<Expr>::type arg_type;
+ typedef
+ typename Grammar::template result<void(arg_type, detail::true_xpression, Visitor)>::type
+ xpr_type;
+ xpr_type const &expr2 = Grammar()(proto::arg(expr), detail::true_xpression(), visitor);
             std::size_t width = expr2.get_width().value();
- return typename apply<Expr, State, Visitor>::type(expr2, width, false);
+ return detail::lookbehind_matcher<xpr_type>(expr2, width, false);
         }
     };
 
     template<typename Grammar>
- struct as_keeper
- : Grammar
+ struct as_keeper : callable
     {
- as_keeper();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
         {
- typedef keeper_matcher<
- typename Grammar::template apply<Expr, true_xpression, Visitor>::type
+ typedef typename proto::result_of::arg<Expr>::type arg_type;
+ typedef detail::keeper_matcher<
+ typename Grammar::template result<void(arg_type, detail::true_xpression, Visitor)>::type
> type;
         };
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &, Visitor &visitor) const
         {
- return typename apply<Expr, State, Visitor>::type(
- Grammar::call(expr, true_xpression(), visitor)
+ return typename result<void(Expr, State, Visitor)>::type(
+ Grammar()(proto::arg(expr), detail::true_xpression(), visitor)
             );
         }
     };

Modified: trunk/boost/xpressive/detail/static/transforms/as_inverse.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transforms/as_inverse.hpp (original)
+++ trunk/boost/xpressive/detail/static/transforms/as_inverse.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -14,11 +14,16 @@
 #endif
 
 #include <boost/mpl/sizeof.hpp>
+#include <boost/mpl/not.hpp>
 #include <boost/xpressive/detail/detail_fwd.hpp>
 #include <boost/xpressive/detail/static/static.hpp>
 #include <boost/xpressive/proto/proto.hpp>
 
-namespace boost { namespace xpressive { namespace detail
+#define UNCV(x) typename remove_const<x>::type
+#define UNREF(x) typename remove_reference<x>::type
+#define UNCVREF(x) UNCV(UNREF(x))
+
+namespace boost { namespace xpressive { namespace grammar_detail
 {
 
     template<typename T>
@@ -32,62 +37,58 @@
         }
     };
 
- template<typename Traits, bool ICase, bool Not>
- struct inverter<literal_matcher<Traits, ICase, Not> >
+ template<typename Traits, typename ICase, typename Not>
+ struct inverter<detail::literal_matcher<Traits, ICase, Not> >
     {
- typedef literal_matcher<Traits, ICase, !Not> type;
- static type call(literal_matcher<Traits, ICase, Not> t)
+ typedef detail::literal_matcher<Traits, ICase, typename mpl::not_<Not>::type> type;
+ static type call(detail::literal_matcher<Traits, ICase, Not> t)
         {
- return type(t);
+ return type(t.ch_);
         }
     };
 
     template<typename Traits>
- struct inverter<logical_newline_matcher<Traits> >
+ struct inverter<detail::logical_newline_matcher<Traits> >
     {
         // ~_ln matches any one character that is not in the "newline" character class
- typedef posix_charset_matcher<Traits> type;
- static type call(logical_newline_matcher<Traits> t)
+ typedef detail::posix_charset_matcher<Traits> type;
+ static type call(detail::logical_newline_matcher<Traits> t)
         {
             return type(t.newline(), true);
         }
     };
 
     template<typename Traits>
- struct inverter<assert_word_matcher<word_boundary<true>, Traits> >
+ struct inverter<detail::assert_word_matcher<detail::word_boundary<mpl::true_>, Traits> >
     {
- typedef assert_word_matcher<word_boundary<false>, Traits> type;
- static type call(assert_word_matcher<word_boundary<true>, Traits> t)
+ typedef detail::assert_word_matcher<detail::word_boundary<mpl::false_>, Traits> type;
+ static type call(detail::assert_word_matcher<detail::word_boundary<mpl::true_>, Traits> t)
         {
             return type(t.word());
         }
     };
 
- template<typename T>
- typename inverter<T>::type invert(T const &t)
+ struct as_inverse : callable
     {
- return inverter<T>::call(t);
- }
+ template<typename Sig>
+ struct result;
 
- template<typename Grammar>
- struct as_inverse
- : Grammar
- {
- as_inverse();
-
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : inverter<typename Grammar::template apply<Expr, State, Visitor>::type>
+ template<typename This, typename Matcher>
+ struct result<This(Matcher)>
+ : inverter<UNCVREF(Matcher)>
         {};
 
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ template<typename Matcher>
+ typename inverter<Matcher>::type operator ()(Matcher const &matcher) const
         {
- return detail::invert(Grammar::call(expr, state, visitor));
+ return inverter<Matcher>::call(matcher);
         }
     };
 
 }}}
 
+#undef UNCV
+#undef UNREF
+#undef UNCVREF
+
 #endif

Modified: trunk/boost/xpressive/detail/static/transforms/as_marker.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transforms/as_marker.hpp (original)
+++ trunk/boost/xpressive/detail/static/transforms/as_marker.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -17,67 +17,38 @@
 #include <boost/xpressive/detail/static/static.hpp>
 #include <boost/xpressive/proto/proto.hpp>
 
-//#include <boost/xpressive/proto/transform/construct.hpp>
-
-namespace boost { namespace xpressive { namespace detail
+namespace boost { namespace xpressive { namespace grammar_detail
 {
 
- //template<typename Grammar>
- //struct as_marker
- // : proto::transform::construct<
- // proto::transform::identity<Grammar>
- // , proto::shift_right<
- // proto::terminal<mark_begin_matcher>::type
- // , proto::shift_right<
- // proto::transform::right<proto::_>
- // , proto::terminal<mark_end_matcher>::type
- // >
- // >(
- // proto::terminal<mark_begin_matcher>::type(
- // mark_begin_matcher(proto::transform::arg<proto::transform::left<proto::_> > )
- // )
- // , proto::shift_right<
- // proto::transform::right<proto::_>
- // , proto::terminal<mark_end_matcher>::type
- // >(
- // proto::transform::right<proto::_>
- // , proto::terminal<mark_end_matcher>::type(
- // mark_end_matcher(proto::transform::arg<proto::transform::left<proto::_> > )
- // )
- // )
- // )
- // >
- //{};
-
     ///////////////////////////////////////////////////////////////////////////////
     // as_marker
     // Insert mark tags before and after the expression
- template<typename Grammar>
- struct as_marker
- : Grammar
+ struct as_marker : callable
     {
- as_marker();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename, typename>
- struct apply
- : proto::shift_right<
- proto::terminal<mark_begin_matcher>::type
- , typename proto::shift_right<
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : shift_right<
+ terminal<detail::mark_begin_matcher>::type
+ , typename shift_right<
                     typename proto::result_of::right<Expr>::type
- , proto::terminal<mark_end_matcher>::type
+ , terminal<detail::mark_end_matcher>::type
>::type
>
         {};
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &, Visitor &) const
         {
- int mark_nbr = get_mark_number(proto::left(expr));
- mark_begin_matcher begin(mark_nbr);
- mark_end_matcher end(mark_nbr);
+ int mark_nbr = detail::get_mark_number(proto::left(expr));
+ detail::mark_begin_matcher begin(mark_nbr);
+ detail::mark_end_matcher end(mark_nbr);
 
- typename apply<Expr, State, Visitor>::type that = {{begin}, {proto::right(expr), {end}}};
+ typename result<void(Expr, State, Visitor)>::type that
+ = {{begin}, {proto::right(expr), {end}}};
             return that;
         }
     };

Modified: trunk/boost/xpressive/detail/static/transforms/as_matcher.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transforms/as_matcher.hpp (original)
+++ trunk/boost/xpressive/detail/static/transforms/as_matcher.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -14,29 +14,29 @@
 #endif
 
 #include <boost/mpl/assert.hpp>
-#include <boost/type_traits/is_same.hpp>
 #include <boost/xpressive/detail/detail_fwd.hpp>
 #include <boost/xpressive/detail/static/static.hpp>
 
-namespace boost { namespace xpressive { namespace detail
+namespace boost { namespace xpressive { namespace grammar_detail
 {
-
- template<typename Grammar>
- struct as_matcher
- : Grammar
+ struct as_matcher : callable
     {
- as_matcher();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : Visitor::template apply<
- typename proto::result_of::arg<Expr>::type
- >
- {};
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ {
+ typedef
+ typename Visitor::template apply<
+ typename proto::result_of::arg<Expr>::type
+ >::type
+ type;
+ };
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &, Visitor &visitor) const
         {
             return visitor.call(proto::arg(expr));
         }

Modified: trunk/boost/xpressive/detail/static/transforms/as_modifier.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transforms/as_modifier.hpp (original)
+++ trunk/boost/xpressive/detail/static/transforms/as_modifier.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -17,57 +17,54 @@
 #include <boost/xpressive/detail/detail_fwd.hpp>
 #include <boost/xpressive/detail/static/static.hpp>
 #include <boost/xpressive/proto/proto.hpp>
-#include <boost/xpressive/proto/transform/arg.hpp>
+
+#define UNCV(x) typename remove_const<x>::type
+#define UNREF(x) typename remove_reference<x>::type
+#define UNCVREF(x) UNCV(UNREF(x))
 
 namespace boost { namespace xpressive { namespace detail
 {
-
     ///////////////////////////////////////////////////////////////////////////////
     // regex operator tags
     struct modifier_tag
- {
- };
+ {};
 
- ///////////////////////////////////////////////////////////////////////////////
- // scoped_swap
- // for swapping state back after proto::compile returns
- template<typename Old, typename New>
- struct scoped_swap
- {
- ~scoped_swap() { this->old_->swap(*this->new_); }
- Old *old_;
- New *new_;
- };
+}}}
+
+namespace boost { namespace xpressive { namespace grammar_detail
+{
 
     ///////////////////////////////////////////////////////////////////////////////
     // as_modifier
     template<typename Grammar>
- struct as_modifier
- : Grammar
+ struct as_modifier : callable
     {
- as_modifier();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
         {
             typedef typename proto::result_of::arg<typename proto::result_of::left<Expr>::type>::type modifier_type;
             typedef typename modifier_type::BOOST_NESTED_TEMPLATE apply<Visitor>::type visitor_type;
- typedef typename proto::transform::right<Grammar>::template apply<Expr, State, visitor_type>::type type;
+ typedef typename Grammar::template result<void(typename proto::result_of::right<Expr>::type, State, visitor_type)>::type type;
         };
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
         {
- typedef typename apply<Expr, State, Visitor>::visitor_type new_visitor_type;
+ typedef result<void(Expr, State, Visitor)> result_;
+ typedef typename result_::visitor_type new_visitor_type;
             new_visitor_type new_visitor(proto::arg(proto::left(expr)).call(visitor));
- new_visitor.swap(visitor);
- scoped_swap<Visitor, new_visitor_type> const undo = {&visitor, &new_visitor};
- detail::ignore_unused(undo);
- return proto::transform::right<Grammar>::call(expr, state, new_visitor);
+ return Grammar()(proto::right(expr), state, new_visitor);
         }
     };
 
 }}}
 
+#undef UNCV
+#undef UNREF
+#undef UNCVREF
+
 #endif

Modified: trunk/boost/xpressive/detail/static/transforms/as_quantifier.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transforms/as_quantifier.hpp (original)
+++ trunk/boost/xpressive/detail/static/transforms/as_quantifier.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -17,12 +17,17 @@
 #include <boost/type_traits/is_same.hpp>
 #include <boost/xpressive/detail/detail_fwd.hpp>
 #include <boost/xpressive/detail/static/static.hpp>
-#include <boost/xpressive/proto/transform/arg.hpp>
-#include <boost/xpressive/proto/transform/compose.hpp>
+#include <boost/xpressive/proto/proto.hpp>
+
+#define CV(x) typename add_const<x>::type
+#define REF(x) typename add_reference<x>::type
+#define CVREF(x) REF(CV(x))
+#define UNCV(x) typename remove_const<x>::type
+#define UNREF(x) typename remove_reference<x>::type
+#define UNCVREF(x) UNCV(UNREF(x))
 
 namespace boost { namespace xpressive { namespace detail
 {
-
     ///////////////////////////////////////////////////////////////////////////////
     // generic_quant_tag
     template<uint_t Min, uint_t Max>
@@ -31,6 +36,11 @@
         typedef mpl::integral_c<uint_t, Min> min_type;
         typedef mpl::integral_c<uint_t, Max> max_type;
     };
+}}}
+
+namespace boost { namespace xpressive { namespace grammar_detail
+{
+ using detail::uint_t;
 
     ///////////////////////////////////////////////////////////////////////////////
     // min_type / max_type
@@ -60,67 +70,65 @@
 
     ///////////////////////////////////////////////////////////////////////////////
     // as_simple_quantifier
- template<typename Grammar, bool Greedy>
- struct as_simple_quantifier
- : Grammar
+ template<typename Grammar, typename Greedy>
+ struct as_simple_quantifier : callable
     {
- typedef proto::transform::arg<Grammar> grammar_type;
- as_simple_quantifier();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
         {
- typedef typename grammar_type::template apply<Expr, true_xpression, Visitor>::type xpr_type;
- typedef simple_repeat_matcher<xpr_type, Greedy> matcher_type;
+ typedef typename proto::result_of::arg<Expr>::type arg_type;
+ typedef typename Grammar::template result<void(arg_type, detail::true_xpression, Visitor)>::type xpr_type;
+ typedef detail::simple_repeat_matcher<xpr_type, Greedy> matcher_type;
             typedef typename proto::terminal<matcher_type>::type type;
         };
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
         {
- typename apply<Expr, State, Visitor>::xpr_type const &xpr =
- grammar_type::call(expr, true_xpression(), visitor);
- return apply<Expr, State, Visitor>::type::make(
- typename apply<Expr, State, Visitor>::matcher_type(
- xpr
- , min_type<typename Expr::proto_tag>::value
- , max_type<typename Expr::proto_tag>::value
- , xpr.get_width().value()
- )
- );
+ typedef typename proto::result_of::arg<Expr>::type arg_type;
+ typedef typename Grammar::template result<void(arg_type, detail::true_xpression, Visitor)>::type xpr_type;
+ typedef detail::simple_repeat_matcher<xpr_type, Greedy> matcher_type;
+ typedef typename Expr::proto_tag tag;
+
+ xpr_type const &xpr = Grammar()(proto::arg(expr), detail::true_xpression(), visitor);
+ matcher_type matcher(xpr, min_type<tag>(), max_type<tag>(), xpr.get_width().value());
+ return proto::terminal<matcher_type>::type::make(matcher);
         }
     };
 
     ///////////////////////////////////////////////////////////////////////////////
     // add_hidden_mark
- template<typename Grammar>
- struct add_hidden_mark
- : Grammar
+ struct add_hidden_mark : callable
     {
- add_hidden_mark();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename, typename>
- struct apply
- : proto::shift_right<
- proto::terminal<mark_begin_matcher>::type
- , typename proto::shift_right<
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : shift_right<
+ terminal<detail::mark_begin_matcher>::type
+ , typename shift_right<
                     Expr
- , proto::terminal<mark_end_matcher>::type
+ , terminal<detail::mark_end_matcher>::type
>::type
>
         {};
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
         {
             // we're inserting a hidden mark ... so grab the next hidden mark number.
             int mark_nbr = visitor.get_hidden_mark();
- mark_begin_matcher begin(mark_nbr);
- mark_end_matcher end(mark_nbr);
+ detail::mark_begin_matcher begin(mark_nbr);
+ detail::mark_end_matcher end(mark_nbr);
 
- typename apply<Expr, State, Visitor>::type that = {{begin}, {expr, {end}}};
+ typename result<void(Expr, State, Visitor)>::type that
+ = {{begin}, {expr, {end}}};
             return that;
         }
     };
@@ -128,109 +136,113 @@
     ///////////////////////////////////////////////////////////////////////////////
     // InsertMark
     struct InsertMark
- : proto::or_<
- proto::assign<basic_mark_tag, proto::_>
- , add_hidden_mark<proto::_>
+ : or_<
+ when<proto::assign<detail::basic_mark_tag, _>, _>
+ , otherwise<add_hidden_mark>
>
     {};
 
     ///////////////////////////////////////////////////////////////////////////////
     // as_default_quantifier_impl
- template<bool Greedy, uint_t Min, uint_t Max>
- struct as_default_quantifier_impl
+ template<typename Greedy, uint_t Min, uint_t Max>
+ struct as_default_quantifier_impl : callable
     {
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : proto::shift_right<
- proto::terminal<repeat_begin_matcher>::type
- , typename proto::shift_right<
- typename InsertMark::apply<typename proto::result_of::arg<Expr>::type, State, Visitor>::type
- , typename proto::terminal<repeat_end_matcher<Greedy> >::type
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : shift_right<
+ terminal<detail::repeat_begin_matcher>::type
+ , typename shift_right<
+ typename InsertMark::template result<void(typename proto::result_of::arg<Expr>::type, State, Visitor)>::type
+ , typename terminal<detail::repeat_end_matcher<Greedy> >::type
>::type
>
         {};
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
         {
             // Ensure this sub-expression is book-ended with mark matchers
             typedef typename proto::result_of::arg<Expr>::type arg_type;
- typename InsertMark::apply<arg_type, State, Visitor>::type const &
- marked_sub = InsertMark::call(proto::arg(expr), state, visitor);
+ typename InsertMark::template result<void(arg_type, State, Visitor)>::type const &
+ marked_sub = InsertMark()(proto::arg(expr), state, visitor);
 
             // Get the mark_number from the begin_mark_matcher
             int mark_number = proto::arg(proto::left(marked_sub)).mark_number_;
             BOOST_ASSERT(0 != mark_number);
 
- unsigned min_ = min_type<typename Expr::proto_tag>::value;
- unsigned max_ = max_type<typename Expr::proto_tag>::value;
+ unsigned min_ = min_type<typename Expr::proto_tag>();
+ unsigned max_ = max_type<typename Expr::proto_tag>();
 
- repeat_begin_matcher begin(mark_number);
- repeat_end_matcher<Greedy> end(mark_number, min_, max_);
+ detail::repeat_begin_matcher begin(mark_number);
+ detail::repeat_end_matcher<Greedy> end(mark_number, min_, max_);
 
- typename apply<Expr, State, Visitor>::type that = {{begin}, {marked_sub, {end}}};
+ typename result<void(Expr, State, Visitor)>::type that
+ = {{begin}, {marked_sub, {end}}};
             return that;
         }
     };
 
     ///////////////////////////////////////////////////////////////////////////////
     // optional_tag
- template<bool Greedy>
+ template<typename Greedy>
     struct optional_tag
     {};
 
     ///////////////////////////////////////////////////////////////////////////////
     // as_default_optional
- template<typename Grammar, bool Greedy>
- struct as_default_optional
- : Grammar
+ template<typename Grammar, typename Greedy>
+ struct as_default_optional : callable
     {
- as_default_optional();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
         {
- typedef optional_matcher<
- typename Grammar::template apply<Expr, alternate_end_xpression, Visitor>::type
+ typedef detail::optional_matcher<
+ typename Grammar::template result<void(Expr, detail::alternate_end_xpression, Visitor)>::type
               , Greedy
> type;
         };
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
         {
- return typename apply<Expr, State, Visitor>::type(
- Grammar::call(expr, alternate_end_xpression(), visitor)
+ return typename result<void(Expr, State, Visitor)>::type(
+ Grammar()(expr, detail::alternate_end_xpression(), visitor)
             );
         }
     };
 
     ///////////////////////////////////////////////////////////////////////////////
     // as_mark_optional
- template<typename Grammar, bool Greedy>
- struct as_mark_optional
- : Grammar
+ template<typename Grammar, typename Greedy>
+ struct as_mark_optional : callable
     {
- as_mark_optional();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
         {
- typedef optional_mark_matcher<
- typename Grammar::template apply<Expr, alternate_end_xpression, Visitor>::type
+ typedef detail::optional_mark_matcher<
+ typename Grammar::template result<void(Expr, detail::alternate_end_xpression, Visitor)>::type
               , Greedy
> type;
         };
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
         {
             int mark_number = proto::arg(proto::left(expr)).mark_number_;
- return typename apply<Expr, State, Visitor>::type(
- Grammar::call(expr, alternate_end_xpression(), visitor)
+ return typename result<void(Expr, State, Visitor)>::type(
+ Grammar()(expr, detail::alternate_end_xpression(), visitor)
               , mark_number
             );
         }
@@ -239,93 +251,96 @@
     ///////////////////////////////////////////////////////////////////////////////
     // IsMarkerOrRepeater
     struct IsMarkerOrRepeater
- : proto::or_<
- proto::shift_right<proto::terminal<repeat_begin_matcher>, proto::_>
- , proto::assign<proto::terminal<mark_placeholder>, proto::_>
+ : or_<
+ shift_right<terminal<detail::repeat_begin_matcher>, _>
+ , assign<terminal<detail::mark_placeholder>, _>
>
     {};
 
     ///////////////////////////////////////////////////////////////////////////////
     // as_optional
- template<typename Grammar, bool Greedy>
+ template<typename Grammar, typename Greedy>
     struct as_optional
- : proto::if_<
- proto::matches<mpl::_, IsMarkerOrRepeater>
- , as_mark_optional<Grammar, Greedy>
- , as_default_optional<Grammar, Greedy>
+ : or_<
+ when<IsMarkerOrRepeater, as_mark_optional<Grammar, Greedy> >
+ , otherwise<as_default_optional<Grammar, Greedy> >
>
- {
- as_optional();
- };
+ {};
 
     ///////////////////////////////////////////////////////////////////////////////
     // make_optional_
- template<bool Greedy>
- struct make_optional_
+ template<typename Greedy>
+ struct make_optional_ : callable
     {
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : proto::unary_expr<optional_tag<Greedy>, Expr>
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : unary_expr<optional_tag<Greedy>, Expr>
         {};
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &)
+ typename unary_expr<optional_tag<Greedy>, Expr>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
         {
- typename apply<Expr, State, Visitor>::type that = {expr};
+ typename unary_expr<optional_tag<Greedy>, Expr>::type that = {expr};
             return that;
         }
     };
 
     ///////////////////////////////////////////////////////////////////////////////
     // as_default_quantifier_impl
- template<bool Greedy, uint_t Max>
+ template<typename Greedy, uint_t Max>
     struct as_default_quantifier_impl<Greedy, 0, Max>
- : proto::transform::compose<
- as_default_quantifier_impl<Greedy, 1, Max>
- , make_optional_<Greedy>
- >
+ : call<make_optional_<Greedy>(as_default_quantifier_impl<Greedy, 1, Max>)>
     {};
 
     ///////////////////////////////////////////////////////////////////////////////
     // as_default_quantifier_impl
- template<bool Greedy>
+ template<typename Greedy>
     struct as_default_quantifier_impl<Greedy, 0, 1>
- : proto::transform::compose<
- proto::transform::arg<proto::_>
- , make_optional_<Greedy>
- >
+ : call<make_optional_<Greedy>(_arg)>
     {};
 
     ///////////////////////////////////////////////////////////////////////////////
     // as_default_quantifier
- template<typename Grammar, bool Greedy>
- struct as_default_quantifier
- : Grammar
+ template<typename Greedy>
+ struct as_default_quantifier : callable
     {
- as_default_quantifier();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : as_default_quantifier_impl<
- Greedy
- , min_type<typename Expr::proto_tag>::value
- , max_type<typename Expr::proto_tag>::value
- >::template apply<Expr, State, Visitor>
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : boost::result_of<
+ as_default_quantifier_impl<
+ Greedy
+ , min_type<typename Expr::proto_tag>::value
+ , max_type<typename Expr::proto_tag>::value
+ >(Expr, State, Visitor)
+ >
         {};
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
         {
             return as_default_quantifier_impl<
                 Greedy
               , min_type<typename Expr::proto_tag>::value
               , max_type<typename Expr::proto_tag>::value
- >::call(expr, state, visitor);
+ >()(expr, state, visitor);
         }
     };
 
 }}}
 
+#undef CV
+#undef REF
+#undef CVREF
+#undef UNCV
+#undef UNREF
+#undef UNCVREF
+
 #endif

Modified: trunk/boost/xpressive/detail/static/transforms/as_sequence.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transforms/as_sequence.hpp (original)
+++ trunk/boost/xpressive/detail/static/transforms/as_sequence.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -18,30 +18,33 @@
 #include <boost/xpressive/detail/detail_fwd.hpp>
 #include <boost/xpressive/detail/static/static.hpp>
 
-namespace boost { namespace xpressive { namespace detail
-{
+#define UNCV(x) typename remove_const<x>::type
+#define UNREF(x) typename remove_reference<x>::type
+#define UNCVREF(x) UNCV(UNREF(x))
 
+namespace boost { namespace xpressive { namespace grammar_detail
+{
     template<typename Grammar>
- struct in_sequence
- : Grammar
+ struct in_sequence : callable
     {
- in_sequence();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
         {
- typedef static_xpression<
- typename Grammar::template apply<Expr, State, Visitor>::type
+ typedef detail::static_xpression<
+ typename Grammar::template result<void(Expr, State, Visitor)>::type
               , State
> type;
         };
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
         {
- return typename apply<Expr, State, Visitor>::type(
- Grammar::call(expr, state, visitor)
+ return typename result<void(Expr, State, Visitor)>::type(
+ Grammar()(expr, state, visitor)
               , state
             );
         }
@@ -49,4 +52,8 @@
 
 }}}
 
+#undef UNCV
+#undef UNREF
+#undef UNCVREF
+
 #endif

Modified: trunk/boost/xpressive/detail/static/transforms/as_set.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transforms/as_set.hpp (original)
+++ trunk/boost/xpressive/detail/static/transforms/as_set.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -15,214 +15,155 @@
 
 #include <boost/mpl/assert.hpp>
 #include <boost/xpressive/proto/proto.hpp>
-#include <boost/xpressive/proto/transform/arg.hpp>
-#include <boost/xpressive/proto/transform/apply.hpp>
 #include <boost/xpressive/detail/detail_fwd.hpp>
 #include <boost/xpressive/detail/static/static.hpp>
 #include <boost/xpressive/detail/utility/chset/chset.hpp>
 #include <boost/xpressive/detail/utility/traits_utils.hpp>
 
-namespace boost { namespace xpressive { namespace detail
-{
-
- template<typename I>
- typename I::next next_(I)
- {
- return typename I::next();
- }
-
- template<typename Grammar>
- struct next
- : Grammar
- {
- next();
-
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : Grammar::template apply<Expr, State, Visitor>::type::next
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return detail::next_(Grammar::call(expr, state, visitor));
- }
- };
-
- template<typename Grammar>
- struct push_back
- : Grammar
- {
- push_back();
+#define UNCV(x) typename remove_const<x>::type
+#define UNREF(x) typename remove_reference<x>::type
+#define UNCVREF(x) UNCV(UNREF(x))
 
- template<typename Expr, typename State, typename Visitor>
- static typename Grammar::template apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- visitor.accept(proto::arg(expr));
- return Grammar::call(expr, state, visitor);
- }
- };
+namespace boost { namespace xpressive { namespace grammar_detail
+{
 
     ///////////////////////////////////////////////////////////////////////////
     // CharLiteral
     template<typename Char>
     struct CharLiteral
- : proto::or_<
- proto::terminal<char>
- , proto::terminal<Char>
+ : or_<
+ terminal<char>
+ , terminal<Char>
>
     {};
 
     template<>
     struct CharLiteral<char>
- : proto::terminal<char>
+ : terminal<char>
     {};
 
     ///////////////////////////////////////////////////////////////////////////
     // ListSet
     // matches expressions like (set= 'a','b','c')
     // calculates the size of the set
- // populates an array of characters
     template<typename Char>
     struct ListSet
- : proto::transform::left<
- proto::or_<
- proto::comma<
- next<ListSet<Char> >
- , push_back<CharLiteral<Char> >
- >
- , proto::assign<
- proto::transform::always<set_initializer_type, mpl::int_<1> >
- , push_back<CharLiteral<Char> >
- >
+ : or_<
+ when<
+ comma<ListSet<Char>, CharLiteral<Char> >
+ , make<mpl::next<call<ListSet<Char>(_left)> > > // TODO make a custom transform for this...
+ >
+ , when<
+ assign<detail::set_initializer_type, CharLiteral<Char> >
+ , make<mpl::int_<1> >
>
>
     {};
 
- ///////////////////////////////////////////////////////////////////////////
- // set_fill_visitor
- template<typename Traits>
- struct set_fill_visitor
- {
- typedef typename Traits::char_type char_type;
-
- set_fill_visitor(char_type *buffer, Traits const &traits)
- : buffer_(buffer)
- , traits_(traits)
- {}
-
- template<typename Char>
- void accept(Char ch)
- {
- *this->buffer_++ = this->traits_.translate(
- char_cast<typename Traits::char_type>(ch, this->traits_)
- );
- }
+ template<typename Char, typename Traits>
+ void fill_list_set(Char *&, detail::set_initializer_type, Traits const &)
+ {}
 
- char_type *buffer_;
- Traits const &traits_;
- };
+ template<typename Char, typename Expr, typename Traits>
+ void fill_list_set(Char *&buffer, Expr const &expr, Traits const &traits)
+ {
+ fill_list_set(buffer, proto::left(expr), traits);
+ *buffer++ = traits.translate(detail::char_cast<Char>(proto::arg(proto::right(expr)), traits));
+ }
 
     ///////////////////////////////////////////////////////////////////////////////
- // as_list_set
- template<typename Grammar>
- struct as_list_set
- : Grammar
+ // as_list_set_matcher
+ template<typename Char>
+ struct as_list_set_matcher
     {
- as_list_set();
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
         {
- typedef typename Visitor::traits_type traits_type;
- typedef set_matcher<
- traits_type
- , Grammar::template apply<Expr, State, set_fill_visitor<traits_type> >::type::value
+ typedef detail::set_matcher<
+ typename Visitor::traits_type
+ , typename ListSet<Char>::template result<void(Expr, State, Visitor)>::type
> type;
         };
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &, Visitor &visitor) const
         {
- typename apply<Expr, State, Visitor>::type set;
- set_fill_visitor<typename Visitor::traits_type> filler(set.set_, visitor.traits());
- Grammar::call(expr, state, filler);
+ detail::set_matcher<
+ typename Visitor::traits_type
+ , typename ListSet<Char>::template result<void(Expr, State, Visitor)>::type
+ > set;
+ typename Visitor::char_type *buffer = set.set_;
+ fill_list_set(buffer, expr, visitor.traits());
             return set;
         }
     };
 
     ///////////////////////////////////////////////////////////////////////////////
- // charset_context
+ // merge_charset
     //
     template<typename Grammar, typename CharSet, typename Visitor>
- struct charset_context
+ struct merge_charset
     {
- template<typename Expr, typename Tag>
- struct eval_
- {
- typedef void result_type;
- void operator()(Expr const &expr, charset_context const &ctx) const
- {
- ctx.set(Grammar::call(expr, end_xpression(), ctx.visitor_));
- }
- };
-
- template<typename Expr>
- struct eval_<Expr, proto::tag::bitwise_or>
- {
- typedef void result_type;
- void operator()(Expr const &expr, charset_context const &ctx) const
- {
- proto::eval(proto::left(expr), ctx);
- proto::eval(proto::right(expr), ctx);
- }
- };
-
- // Gah, this is to work around a MSVC bug.
- template<typename Expr>
- struct eval
- : eval_<Expr, typename Expr::proto_tag>
- {};
-
         typedef typename Visitor::traits_type traits_type;
         typedef typename CharSet::char_type char_type;
         typedef typename CharSet::icase_type icase_type;
 
- explicit charset_context(CharSet &charset, Visitor &visitor)
+ merge_charset(CharSet &charset, Visitor &visitor)
           : charset_(charset)
           , visitor_(visitor)
         {}
 
- template<bool Not>
- void set(literal_matcher<traits_type, icase_type::value, Not> const &ch) const
+ template<typename Expr>
+ void operator ()(Expr const &expr) const
+ {
+ this->call_(expr, typename Expr::proto_tag());
+ }
+
+ private:
+ template<typename Expr, typename Tag>
+ void call_(Expr const &expr, Tag) const
+ {
+ this->set_(Grammar()(expr, detail::end_xpression(), this->visitor_));
+ }
+
+ template<typename Expr>
+ void call_(Expr const &expr, tag::bitwise_or) const
+ {
+ (*this)(proto::left(expr));
+ (*this)(proto::right(expr));
+ }
+
+ template<typename Not>
+ void set_(detail::literal_matcher<traits_type, icase_type, Not> const &ch) const
         {
             // BUGBUG fixme!
- BOOST_MPL_ASSERT_NOT((mpl::bool_<Not>));
+ BOOST_MPL_ASSERT_NOT((Not));
             set_char(this->charset_.charset_, ch.ch_, this->visitor_.traits(), icase_type());
         }
 
- void set(range_matcher<traits_type, icase_type::value> const &rg) const
+ void set_(detail::range_matcher<traits_type, icase_type> const &rg) const
         {
             // BUGBUG fixme!
             BOOST_ASSERT(!rg.not_);
             set_range(this->charset_.charset_, rg.ch_min_, rg.ch_max_, this->visitor_.traits(), icase_type());
         }
 
- template<int Size>
- void set(set_matcher<traits_type, Size> const &set_) const
+ template<typename Size>
+ void set_(detail::set_matcher<traits_type, Size> const &set_) const
         {
             // BUGBUG fixme!
             BOOST_ASSERT(!set_.not_);
- for(int i=0; i<Size; ++i)
+ for(int i = 0; i < Size::value; ++i)
             {
- set_char(this->charset_.charset_, set_.set_[i], this->visitor_.traits(), icase_type::value);
+ set_char(this->charset_.charset_, set_.set_[i], this->visitor_.traits(), icase_type());
             }
         }
 
- void set(posix_charset_matcher<traits_type> const &posix) const
+ void set_(detail::posix_charset_matcher<traits_type> const &posix) const
         {
             set_class(this->charset_.charset_, posix.mask_, posix.not_, this->visitor_.traits());
         }
@@ -234,44 +175,47 @@
     ///////////////////////////////////////////////////////////////////////////////
     //
     template<typename Grammar>
- struct as_set
- : Grammar
+ struct as_set_matcher
     {
- as_set();
+ template<typename Sig>
+ struct result;
 
- template<typename, typename, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
         {
             typedef typename Visitor::char_type char_type;
 
             // if sizeof(char_type)==1, merge everything into a basic_chset
             // BUGBUG this is not optimal.
             typedef typename mpl::if_<
- is_narrow_char<char_type>
- , basic_chset<char_type>
- , compound_charset<typename Visitor::traits_type>
+ detail::is_narrow_char<char_type>
+ , detail::basic_chset<char_type>
+ , detail::compound_charset<typename Visitor::traits_type>
>::type charset_type;
 
- typedef charset_matcher<
+ typedef detail::charset_matcher<
                 typename Visitor::traits_type
- , Visitor::icase_type::value
+ , typename Visitor::icase_type
               , charset_type
> type;
         };
 
         template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &, Visitor &visitor) const
         {
- typedef typename apply<Expr, State, Visitor>::type set_type;
+ typedef typename result<void(Expr, State, Visitor)>::type set_type;
             set_type matcher;
- charset_context<Grammar, set_type, Visitor> ctx(matcher, visitor);
- // Walks the tree and fills in the charset
- proto::eval(expr, ctx);
+ merge_charset<Grammar, set_type, Visitor> merge(matcher, visitor);
+ merge(expr); // Walks the tree and fills in the charset
             return matcher;
         }
     };
 
 }}}
 
+#undef UNCV
+#undef UNREF
+#undef UNCVREF
+
 #endif

Modified: trunk/boost/xpressive/detail/static/transmogrify.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transmogrify.hpp (original)
+++ trunk/boost/xpressive/detail/static/transmogrify.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -44,8 +44,8 @@
         typedef typename mpl::if_
         <
             is_char_literal<Matcher, char_type>
- , literal_matcher<Traits, ICase::value, false>
- , string_matcher<Traits, ICase::value>
+ , literal_matcher<Traits, ICase, mpl::false_>
+ , string_matcher<Traits, ICase>
>::type type;
 
         template<typename Matcher2, typename Visitor>
@@ -128,7 +128,7 @@
         // By design, we don't widen character ranges.
         typedef typename iterator_value<BidiIter>::type char_type;
         BOOST_MPL_ASSERT((is_same<Char, char_type>));
- typedef range_matcher<Traits, ICase::value> type;
+ typedef range_matcher<Traits, ICase> type;
 
         template<typename Matcher2, typename Visitor>
         static type call(Matcher2 const &m, Visitor &visitor)
@@ -140,7 +140,7 @@
     template<typename BidiIter, typename ICase, typename Traits>
     struct transmogrify<BidiIter, ICase, Traits, mark_placeholder >
     {
- typedef mark_matcher<Traits, ICase::value> type;
+ typedef mark_matcher<Traits, ICase> type;
 
         template<typename Matcher2, typename Visitor>
         static type call(Matcher2 const &m, Visitor &visitor)
@@ -162,7 +162,7 @@
         }
     };
 
- template<typename BidiIter, typename Traits, int Size>
+ template<typename BidiIter, typename Traits, typename Size>
     struct transmogrify<BidiIter, mpl::true_, Traits, set_matcher<Traits, Size> >
     {
         typedef set_matcher<Traits, Size> type;

Added: trunk/boost/xpressive/proto/detail/as_lvalue.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/xpressive/proto/detail/as_lvalue.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -0,0 +1,36 @@
+///////////////////////////////////////////////////////////////////////////////
+/// \file as_lvalue.hpp
+/// Contains definition of the call<> transform.
+//
+// Copyright 2007 Eric Niebler. 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)
+
+#ifndef BOOST_PROTO_TRANSFORM_AS_LVALUE_HPP_EAN_12_27_2007
+#define BOOST_PROTO_TRANSFORM_AS_LVALUE_HPP_EAN_12_27_2007
+
+namespace boost { namespace proto
+{
+ namespace detail
+ {
+ template<typename T>
+ T &as_lvalue(T &t)
+ {
+ return t;
+ }
+
+ template<typename T>
+ T const &as_lvalue(T const &t)
+ {
+ return t;
+ }
+
+ template<typename T>
+ T &uncv(T const &t)
+ {
+ return const_cast<T &>(t);
+ }
+ }
+}}
+
+#endif

Added: trunk/boost/xpressive/proto/detail/dont_care.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/xpressive/proto/detail/dont_care.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -0,0 +1,23 @@
+///////////////////////////////////////////////////////////////////////////////
+/// \file dont_care.hpp
+/// Definintion of dont_care, a dummy parameter
+//
+// Copyright 2007 Eric Niebler. 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)
+
+#ifndef BOOST_PROTO_DETAIL_DONT_CARE_HPP_EAN_11_07_2007
+#define BOOST_PROTO_DETAIL_DONT_CARE_HPP_EAN_11_07_2007
+
+namespace boost { namespace proto
+{
+ namespace detail
+ {
+ struct dont_care
+ {
+ dont_care(...);
+ };
+ }
+}}
+
+#endif

Modified: trunk/boost/xpressive/proto/expr.hpp
==============================================================================
--- trunk/boost/xpressive/proto/expr.hpp (original)
+++ trunk/boost/xpressive/proto/expr.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -172,7 +172,7 @@
             typedef void proto_is_expr_;
             typedef expr proto_derived_expr;
 
- BOOST_PROTO_IDENTITY_TRANSFORM();
+ //BOOST_PROTO_IDENTITY_TRANSFORM();
             BOOST_PP_REPEAT(ARG_COUNT, BOOST_PROTO_ARG, ~)
             BOOST_PP_REPEAT_FROM_TO(ARG_COUNT, BOOST_PROTO_MAX_ARITY, BOOST_PROTO_VOID, ~)
 

Modified: trunk/boost/xpressive/proto/fusion.hpp
==============================================================================
--- trunk/boost/xpressive/proto/fusion.hpp (original)
+++ trunk/boost/xpressive/proto/fusion.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -1,83 +1,156 @@
 ///////////////////////////////////////////////////////////////////////////////
 /// \file fusion.hpp
-/// Make any Proto parse tree a valid Fusion sequence
+/// Make any Proto expression a valid Fusion sequence
 //
 // Copyright 2007 Eric Niebler. 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)
 
-#ifndef BOOST_PROTO_FUSION_HPP_EAN_04_29_2006
-#define BOOST_PROTO_FUSION_HPP_EAN_04_29_2006
+#ifndef BOOST_PROTO_FUSION_HPP_EAN_11_04_2006
+#define BOOST_PROTO_FUSION_HPP_EAN_11_04_2006
 
 #include <boost/xpressive/proto/detail/prefix.hpp>
-#include <boost/xpressive/proto/proto.hpp>
-#include <boost/mpl/if.hpp>
-#include <boost/mpl/at.hpp>
-#include <boost/mpl/size.hpp>
-#include <boost/mpl/deref.hpp>
-#include <boost/mpl/advance.hpp>
-#include <boost/mpl/distance.hpp>
-#include <boost/mpl/begin_end.hpp>
-#include <boost/mpl/next_prior.hpp>
-#include <boost/type_traits/remove_const.hpp>
 #include <boost/type_traits/remove_reference.hpp>
+#include <boost/mpl/long.hpp>
 #include <boost/fusion/include/is_view.hpp>
 #include <boost/fusion/include/tag_of_fwd.hpp>
 #include <boost/fusion/include/category_of.hpp>
 #include <boost/fusion/include/iterator_base.hpp>
-#include <boost/fusion/include/mpl.hpp>
 #include <boost/fusion/include/intrinsic.hpp>
+#include <boost/fusion/include/pop_front.hpp>
+#include <boost/fusion/include/reverse.hpp>
 #include <boost/fusion/include/single_view.hpp>
 #include <boost/fusion/include/transform_view.hpp>
 #include <boost/fusion/support/ext_/is_segmented.hpp>
 #include <boost/fusion/sequence/intrinsic/ext_/segments.hpp>
 #include <boost/fusion/sequence/intrinsic/ext_/size_s.hpp>
 #include <boost/fusion/view/ext_/segmented_iterator.hpp>
+#include <boost/xpressive/proto/proto_fwd.hpp>
+#include <boost/xpressive/proto/traits.hpp>
 #include <boost/xpressive/proto/detail/suffix.hpp>
 
-#define UNREF(x) typename remove_reference<x>::type
-#define UNCVREF(x) typename remove_cv<typename remove_reference<x>::type>::type
+/// INTERNAL ONLY
+///
+#define UNREF(x) typename boost::remove_reference<x>::type
 
 namespace boost { namespace proto
 {
+
     namespace detail
     {
- template<typename Expr, int Pos>
- struct ref_iterator
- : fusion::iterator_base<ref_iterator<Expr, Pos> >
+
+ template<typename Expr, long Pos>
+ struct expr_iterator
+ : fusion::iterator_base<expr_iterator<Expr, Pos> >
         {
             typedef Expr expr_type;
- typedef mpl::long_<Pos> index;
- typedef fusion::forward_traversal_tag category;
- typedef tag::proto_ref_iterator fusion_tag;
+ static long const index = Pos;
+ typedef fusion::random_access_traversal_tag category;
+ typedef tag::proto_expr_iterator fusion_tag;
 
- ref_iterator(Expr const &expr)
- : expr_(expr)
+ expr_iterator(Expr const &e)
+ : expr(e)
             {}
 
- Expr expr_;
+ Expr const &expr;
         };
+
     }
 
     template<typename Expr>
- struct children
- : proto::ref_<Expr>
+ struct flat_view
     {
- children(Expr &expr)
- : proto::ref_<Expr>(proto::ref_<Expr>::make(expr))
+ typedef Expr expr_type;
+ typedef typename Expr::proto_tag proto_tag;
+ typedef fusion::forward_traversal_tag category;
+ typedef tag::proto_flat_view fusion_tag;
+
+ explicit flat_view(Expr &expr)
+ : expr_(expr)
         {}
+
+ Expr &expr_;
     };
 
- template<typename Expr>
- children<Expr> children_of(Expr &expr)
+ namespace functional
     {
- return children<Expr>(expr);
+ struct flatten
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr>
+ struct result<This(Expr)>
+ {
+ typedef flat_view<UNREF(Expr) const> type;
+ };
+
+ template<typename Expr>
+ flat_view<Expr const> operator ()(Expr const &expr) const
+ {
+ return flat_view<Expr const>(expr);
+ }
+ };
+
+ struct pop_front
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr>
+ struct result<This(Expr)>
+ : fusion::result_of::pop_front<UNREF(Expr) const>
+ {};
+
+ template<typename Expr>
+ typename fusion::result_of::pop_front<Expr const>::type
+ operator ()(Expr const &expr) const
+ {
+ return fusion::pop_front(expr);
+ }
+ };
+
+ struct reverse
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr>
+ struct result<This(Expr)>
+ : fusion::result_of::reverse<UNREF(Expr) const>
+ {};
+
+ template<typename Expr>
+ typename fusion::result_of::reverse<Expr const>::type
+ operator ()(Expr const &expr) const
+ {
+ return fusion::reverse(expr);
+ }
+ };
+
     }
 
+ template<>
+ struct is_callable<functional::flatten>
+ : mpl::true_
+ {};
+
+ template<>
+ struct is_callable<functional::pop_front>
+ : mpl::true_
+ {};
+
+ template<>
+ struct is_callable<functional::reverse>
+ : mpl::true_
+ {};
+
+ functional::flatten const flatten = {};
+
     template<typename Context>
     struct eval_fun
     {
- eval_fun(Context &ctx)
+ explicit eval_fun(Context &ctx)
           : ctx_(ctx)
         {}
 
@@ -91,7 +164,7 @@
 
         template<typename Expr>
         typename proto::result_of::eval<Expr, Context>::type
- operator()(Expr &expr) const
+ operator ()(Expr &expr) const
         {
             return proto::eval(expr, this->ctx_);
         }
@@ -103,13 +176,15 @@
 
 namespace boost { namespace fusion
 {
+
     namespace extension
     {
+
         template<typename Tag>
         struct is_view_impl;
 
         template<>
- struct is_view_impl<proto::tag::proto_ref>
+ struct is_view_impl<proto::tag::proto_flat_view>
         {
             template<typename Iterator>
             struct apply
@@ -130,11 +205,14 @@
         struct value_of_impl;
 
         template<>
- struct value_of_impl<proto::tag::proto_ref_iterator>
+ struct value_of_impl<proto::tag::proto_expr_iterator>
         {
             template<typename Iterator>
             struct apply
- : proto::result_of::arg<typename Iterator::expr_type, typename Iterator::index>
+ : proto::result_of::arg_c<
+ typename Iterator::expr_type
+ , Iterator::index
+ >
             {};
         };
 
@@ -142,19 +220,21 @@
         struct deref_impl;
 
         template<>
- struct deref_impl<proto::tag::proto_ref_iterator>
+ struct deref_impl<proto::tag::proto_expr_iterator>
         {
             template<typename Iterator>
             struct apply
             {
- typedef typename proto::result_of::arg<
- typename Iterator::expr_type
- , typename Iterator::index
- >::type const &type;
+ typedef
+ typename proto::result_of::arg_c<
+ typename Iterator::expr_type const
+ , Iterator::index
+ >::type const &
+ type;
 
                 static type call(Iterator const &iter)
                 {
- return proto::arg<typename Iterator::index>(iter.expr_);
+ return proto::arg_c<Iterator::index>(iter.expr);
                 }
             };
         };
@@ -163,19 +243,21 @@
         struct advance_impl;
 
         template<>
- struct advance_impl<proto::tag::proto_ref_iterator>
+ struct advance_impl<proto::tag::proto_expr_iterator>
         {
             template<typename Iterator, typename N>
             struct apply
             {
- typedef typename proto::detail::ref_iterator<
- typename Iterator::expr_type
- , Iterator::index::value + N::value
- > type;
+ typedef
+ typename proto::detail::expr_iterator<
+ typename Iterator::expr_type
+ , Iterator::index + N::value
+ >
+ type;
 
                 static type call(Iterator const &iter)
                 {
- return type(iter.expr_);
+ return type(iter.expr);
                 }
             };
         };
@@ -184,11 +266,11 @@
         struct distance_impl;
 
         template<>
- struct distance_impl<proto::tag::proto_ref_iterator>
+ struct distance_impl<proto::tag::proto_expr_iterator>
         {
             template<typename IteratorFrom, typename IteratorTo>
             struct apply
- : mpl::long_<IteratorTo::index::value - IteratorFrom::index::value>
+ : mpl::long_<IteratorTo::index - IteratorFrom::index>
             {};
         };
 
@@ -196,11 +278,11 @@
         struct next_impl;
 
         template<>
- struct next_impl<proto::tag::proto_ref_iterator>
+ struct next_impl<proto::tag::proto_expr_iterator>
         {
             template<typename Iterator>
             struct apply
- : advance_impl<proto::tag::proto_ref_iterator>::template apply<Iterator, mpl::long_<1> >
+ : advance_impl<proto::tag::proto_expr_iterator>::template apply<Iterator, mpl::long_<1> >
             {};
         };
 
@@ -208,11 +290,11 @@
         struct prior_impl;
 
         template<>
- struct prior_impl<proto::tag::proto_ref_iterator>
+ struct prior_impl<proto::tag::proto_expr_iterator>
         {
             template<typename Iterator>
             struct apply
- : advance_impl<proto::tag::proto_ref_iterator>::template apply<Iterator, mpl::long_<-1> >
+ : advance_impl<proto::tag::proto_expr_iterator>::template apply<Iterator, mpl::long_<-1> >
             {};
         };
 
@@ -220,7 +302,7 @@
         struct category_of_impl;
 
         template<>
- struct category_of_impl<proto::tag::proto_ref>
+ struct category_of_impl<proto::tag::proto_expr>
         {
             template<typename Sequence>
             struct apply
@@ -233,11 +315,11 @@
         struct size_impl;
 
         template<>
- struct size_impl<proto::tag::proto_ref>
+ struct size_impl<proto::tag::proto_expr>
         {
             template<typename Sequence>
             struct apply
- : Sequence::proto_arity
+ : mpl::long_<0 == Sequence::proto_arity::value ? 1 : Sequence::proto_arity::value>
             {};
         };
 
@@ -245,14 +327,14 @@
         struct begin_impl;
 
         template<>
- struct begin_impl<proto::tag::proto_ref>
+ struct begin_impl<proto::tag::proto_expr>
         {
             template<typename Sequence>
             struct apply
             {
- typedef proto::detail::ref_iterator<Sequence const, 0> type;
+ typedef proto::detail::expr_iterator<Sequence, 0> type;
 
- static type call(Sequence& seq)
+ static type call(Sequence const &seq)
                 {
                     return type(seq);
                 }
@@ -263,14 +345,19 @@
         struct end_impl;
 
         template<>
- struct end_impl<proto::tag::proto_ref>
+ struct end_impl<proto::tag::proto_expr>
         {
             template<typename Sequence>
             struct apply
             {
- typedef proto::detail::ref_iterator<Sequence const, Sequence::proto_arity::value> type;
+ typedef
+ proto::detail::expr_iterator<
+ Sequence
+ , 0 == Sequence::proto_arity::value ? 1 : Sequence::proto_arity::value
+ >
+ type;
 
- static type call(Sequence& seq)
+ static type call(Sequence const &seq)
                 {
                     return type(seq);
                 }
@@ -281,29 +368,28 @@
         struct value_at_impl;
 
         template<>
- struct value_at_impl<proto::tag::proto_ref>
+ struct value_at_impl<proto::tag::proto_expr>
         {
- template<typename Sequence, typename N>
+ template<typename Sequence, typename Index>
             struct apply
- {
- typedef typename proto::result_of::arg<Sequence, N>::type type;
- };
+ : proto::result_of::arg_c<Sequence, Index::value>
+ {};
         };
 
         template<typename Tag>
         struct at_impl;
 
         template<>
- struct at_impl<proto::tag::proto_ref>
+ struct at_impl<proto::tag::proto_expr>
         {
- template<typename Sequence, typename N>
+ template<typename Sequence, typename Index>
             struct apply
             {
- typedef typename proto::result_of::arg<Sequence, N>::type const &type;
+ typedef typename proto::result_of::arg_c<Sequence, Index::value>::type const &type;
 
                 static type call(Sequence &seq)
                 {
- return proto::arg_c<N::value>(seq);
+ return proto::arg_c<Index::value>(seq);
                 }
             };
         };
@@ -312,7 +398,7 @@
         struct is_segmented_impl;
 
         template<>
- struct is_segmented_impl<proto::tag::proto_expr>
+ struct is_segmented_impl<proto::tag::proto_flat_view>
         {
             template<typename Iterator>
             struct apply
@@ -330,16 +416,16 @@
             struct result<This(Expr)>
               : mpl::if_<
                     is_same<Tag, UNREF(Expr)::proto_tag>
- , UNCVREF(Expr) const &
- , fusion::single_view<UNCVREF(Expr) const &>
+ , proto::flat_view<UNREF(Expr) const>
+ , fusion::single_view<UNREF(Expr) const &>
>
             {};
 
             template<typename Expr>
- typename result<as_element(Expr)>::type
- operator()(Expr &expr) const
+ typename result<as_element(Expr const &)>::type
+ operator ()(Expr const &expr) const
             {
- return typename result<as_element(Expr)>::type(expr);
+ return typename result<as_element(Expr const &)>::type(expr);
             }
         };
 
@@ -347,7 +433,7 @@
         struct segments_impl;
 
         template<>
- struct segments_impl<proto::tag::proto_expr>
+ struct segments_impl<proto::tag::proto_flat_view>
         {
             template<typename Sequence>
             struct apply
@@ -355,20 +441,19 @@
                 typedef typename Sequence::proto_tag proto_tag;
 
                 typedef fusion::transform_view<
- proto::ref_<Sequence>
+ typename Sequence::expr_type
                   , as_element<proto_tag>
> type;
 
                 static type call(Sequence &sequence)
                 {
- proto::ref_<Sequence> r = {sequence};
- return type(r, as_element<proto_tag>());
+ return type(sequence.expr_, as_element<proto_tag>());
                 }
             };
         };
 
         template<>
- struct category_of_impl<proto::tag::proto_expr>
+ struct category_of_impl<proto::tag::proto_flat_view>
         {
             template<typename Sequence>
             struct apply
@@ -378,7 +463,7 @@
         };
 
         template<>
- struct begin_impl<proto::tag::proto_expr>
+ struct begin_impl<proto::tag::proto_flat_view>
         {
             template<typename Sequence>
             struct apply
@@ -387,7 +472,7 @@
         };
 
         template<>
- struct end_impl<proto::tag::proto_expr>
+ struct end_impl<proto::tag::proto_flat_view>
         {
             template<typename Sequence>
             struct apply
@@ -396,159 +481,18 @@
         };
 
         template<>
- struct size_impl<proto::tag::proto_expr>
+ struct size_impl<proto::tag::proto_flat_view>
         {
             template<typename Sequence>
             struct apply
               : fusion::segmented_size<Sequence>
             {};
         };
+
     }
-}}
 
-//namespace boost { namespace mpl
-//{
- //template<>
- //struct begin_impl<proto::tag::proto_expr>
- //{
- // template<typename Sequence>
- // struct apply
- // : begin_impl<typename sequence_tag<typename Sequence::proto_args>::type>
- // ::template apply<typename Sequence::proto_args>
- // {};
- //};
-
- //template<>
- //struct end_impl<proto::tag::proto_expr>
- //{
- // template<typename Sequence>
- // struct apply
- // : end_impl<typename sequence_tag<typename Sequence::proto_args>::type>
- // ::template apply<typename Sequence::proto_args>
- // {};
- //};
-
- //template<>
- //struct size_impl<proto::tag::proto_expr>
- //{
- // template<typename Sequence>
- // struct apply
- // {
- // typedef typename Sequence::proto_arity type;
- // };
- //};
-
- //template<>
- //struct at_impl<proto::tag::proto_expr>
- //{
- // template<typename Sequence, typename N>
- // struct apply
- // : at_impl<typename sequence_tag<typename Sequence::proto_args>::type>
- // ::template apply<typename Sequence::proto_args, N>
- // {};
- //};
-
-
- //template<>
- //struct begin_impl<proto::tag::proto_ref>
- //{
- // template<typename Sequence>
- // struct apply
- // : begin_impl<typename sequence_tag<typename Sequence::proto_args>::type>
- // ::template apply<typename Sequence::proto_args>
- // {};
- //};
-
- //template<>
- //struct end_impl<proto::tag::proto_ref>
- //{
- // template<typename Sequence>
- // struct apply
- // : end_impl<typename sequence_tag<typename Sequence::proto_args>::type>
- // ::template apply<typename Sequence::proto_args>
- // {};
- //};
-
- //template<>
- //struct size_impl<proto::tag::proto_ref>
- //{
- // template<typename Sequence>
- // struct apply
- // {
- // typedef typename Sequence::proto_arity type;
- // };
- //};
-
- //template<>
- //struct at_impl<proto::tag::proto_ref>
- //{
- // template<typename Sequence, typename N>
- // struct apply
- // : at_impl<typename sequence_tag<typename Sequence::proto_args>::type>
- // ::template apply<typename Sequence::proto_args, N>
- // {};
- //};
-
-
-//}} // namespace boost::mpl
-
-//namespace boost { namespace mpl
-//{
-// template<typename Tag, typename Args, long Arity>
-// struct sequence_tag<proto::expr<Tag, Args, Arity> >
-// {
-// typedef proto::tag::proto_expr type;
-// };
-//
-// template<typename Expr>
-// struct sequence_tag<proto::ref_<Expr> >
-// {
-// typedef proto::tag::proto_expr type;
-// };
-//
-// template<>
-// struct begin_impl<proto::tag::proto_expr>
-// {
-// template<typename Sequence>
-// struct apply
-// : begin_impl<typename sequence_tag<typename Sequence::proto_args>::type>
-// ::template apply<typename Sequence::proto_args>
-// {};
-// };
-//
-// template<>
-// struct end_impl<proto::tag::proto_expr>
-// {
-// template<typename Sequence>
-// struct apply
-// : end_impl<typename sequence_tag<typename Sequence::proto_args>::type>
-// ::template apply<typename Sequence::proto_args>
-// {};
-// };
-//
-// template<>
-// struct size_impl<proto::tag::proto_expr>
-// {
-// template<typename Sequence>
-// struct apply
-// {
-// typedef typename Sequence::proto_arity type;
-// };
-// };
-//
-// template<>
-// struct at_impl<proto::tag::proto_expr>
-// {
-// template<typename Sequence, typename N>
-// struct apply
-// : at_impl<typename sequence_tag<typename Sequence::proto_args>::type>
-// ::template apply<typename Sequence::proto_args, N>
-// {};
-// };
-//
-//}} // namespace boost::mpl
+}}
 
 #undef UNREF
-#undef UNCVREF
 
 #endif

Modified: trunk/boost/xpressive/proto/make_expr.hpp
==============================================================================
--- trunk/boost/xpressive/proto/make_expr.hpp (original)
+++ trunk/boost/xpressive/proto/make_expr.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -513,6 +513,8 @@
             template<typename Tag, typename Domain>
             struct make_expr
             {
+ BOOST_PROTO_CALLABLE()
+
                 template<typename Sig>
                 struct result
                 {};
@@ -534,6 +536,8 @@
             template<typename Domain>
             struct make_expr<tag::terminal, Domain>
             {
+ BOOST_PROTO_CALLABLE()
+
                 template<typename Sig>
                 struct result
                 {};
@@ -561,6 +565,8 @@
             template<typename Tag, typename Domain>
             struct unpack_expr
             {
+ BOOST_PROTO_CALLABLE()
+
                 template<typename Sig>
                 struct result
                 {};
@@ -585,6 +591,8 @@
             template<typename Tag, typename Domain>
             struct unfused_expr_fun
             {
+ BOOST_PROTO_CALLABLE()
+
                 template<typename Sequence>
                 struct result
                   : result_of::unpack_expr<Tag, Domain, Sequence>
@@ -601,7 +609,9 @@
             template<typename Tag, typename Domain>
             struct unfused_expr
               : fusion::unfused_generic<unfused_expr_fun<Tag, Domain> >
- {};
+ {
+ BOOST_PROTO_CALLABLE()
+ };
         }
 
         /// unpack_expr
@@ -651,6 +661,22 @@
         /**/
 
     #include BOOST_PP_ITERATE()
+
+ template<typename Tag, typename Domain>
+ struct is_callable<functional::make_expr<Tag, Domain> >
+ : mpl::true_
+ {};
+
+ template<typename Tag, typename Domain>
+ struct is_callable<functional::unpack_expr<Tag, Domain> >
+ : mpl::true_
+ {};
+
+ template<typename Tag, typename Domain>
+ struct is_callable<functional::unfused_expr<Tag, Domain> >
+ : mpl::true_
+ {};
+
     }}
 
     #undef BOOST_PROTO_AT

Modified: trunk/boost/xpressive/proto/matches.hpp
==============================================================================
--- trunk/boost/xpressive/proto/matches.hpp (original)
+++ trunk/boost/xpressive/proto/matches.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -35,6 +35,7 @@
     #include <boost/type_traits/is_pointer.hpp>
     #include <boost/xpressive/proto/proto_fwd.hpp>
     #include <boost/xpressive/proto/traits.hpp>
+ #include <boost/xpressive/proto/transform/when.hpp>
     #include <boost/xpressive/proto/detail/suffix.hpp> // must be last include
 
     // Some compilers (like GCC) need extra help figuring out a template's arity.
@@ -59,7 +60,7 @@
 
         namespace detail
         {
- struct _;
+ struct ignore;
 
             template<typename Expr, typename Grammar>
             struct matches_impl;
@@ -83,6 +84,26 @@
             template<typename And>
             struct last;
 
+ template<typename T, typename U>
+ struct array_matches
+ : mpl::false_
+ {};
+
+ template<typename T, std::size_t M>
+ struct array_matches<T[M], T *>
+ : mpl::true_
+ {};
+
+ template<typename T, std::size_t M>
+ struct array_matches<T[M], T const *>
+ : mpl::true_
+ {};
+
+ template<typename T, std::size_t M>
+ struct array_matches<T[M], T[proto::N]>
+ : mpl::true_
+ {};
+
             template<typename T, typename U
                 BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(long Arity = mpl::aux::template_arity<U>::value)
>
@@ -100,6 +121,16 @@
               : mpl::true_
             {};
 
+ template<typename T, std::size_t M, typename U>
+ struct lambda_matches<T[M], U BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(-1)>
+ : array_matches<T[M], U>
+ {};
+
+ template<typename T, std::size_t M>
+ struct lambda_matches<T[M], T[M] BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(-1)>
+ : mpl::true_
+ {};
+
             template<template<typename> class T, typename Expr0, typename Grammar0>
             struct lambda_matches<T<Expr0>, T<Grammar0> BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(1) >
               : lambda_matches<Expr0, Grammar0>
@@ -117,13 +148,13 @@
 
             template<typename Args1, typename Args2, typename Back>
             struct vararg_matches<Args1, Args2, Back, true, true, typename Back::proto_is_vararg_>
- : matches_impl<expr<_, Args1, Args1::size>, expr<_, Args2, Args1::size> >
+ : matches_impl<expr<ignore, Args1, Args1::size>, expr<ignore, Args2, Args1::size> >
             {};
 
             template<typename Args1, typename Args2, typename Back>
             struct vararg_matches<Args1, Args2, Back, true, false, typename Back::proto_is_vararg_>
               : and2<
- matches_impl<expr<_, Args1, Args2::size>, expr<_, Args2, Args2::size> >::value
+ matches_impl<expr<ignore, Args1, Args2::size>, expr<ignore, Args2, Args2::size> >::value
                   , vararg_matches_impl<Args1, typename Back::proto_base_expr, Args2::size + 1, Args1::size>
>
             {};
@@ -328,9 +359,18 @@
         #undef BOOST_PROTO_DEFINE_LAMBDA_MATCHES
 
             // handle proto::if_
- template<typename Expr, typename Condition>
- struct matches_impl<Expr, if_<Condition> >
- : mpl::apply1<Condition, Expr>::type
+ template<typename Expr, typename If, typename Then, typename Else>
+ struct matches_impl<Expr, proto::if_<If, Then, Else> >
+ : mpl::eval_if<
+ typename when<_, If>::template result<void(Expr, mpl::void_, mpl::void_)>::type
+ , matches_impl<Expr, typename Then::proto_base_expr>
+ , matches_impl<Expr, typename Else::proto_base_expr>
+ >::type
+ {};
+
+ template<typename Expr, typename If>
+ struct matches_impl<Expr, proto::if_<If> >
+ : when<_, If>::template result<void(Expr, mpl::void_, mpl::void_)>::type
             {};
 
             // handle proto::not_
@@ -362,12 +402,10 @@
             struct _
               : has_identity_transform
             {
+ BOOST_PROTO_CALLABLE()
                 typedef _ proto_base_expr;
                 typedef void proto_is_wildcard_;
             };
-
- template<typename T>
- transform::detail::yes_type is_wildcard_expression_fun(T const *);
         }
 
         namespace control
@@ -377,90 +415,135 @@
             struct not_
               : has_identity_transform
             {
+ BOOST_PROTO_CALLABLE()
                 typedef not_ proto_base_expr;
             };
 
- // if_
- template<typename Condition, typename Then, typename Else>
- struct if_
- : or_<
- and_<if_<Condition>, Then>
- , and_<not_<if_<Condition> >, Else>
- >
- {};
+ //// if_
+ //template<typename Condition, typename Then, typename Else>
+ //struct if_
+ // : or_<
+ // and_<if_<Condition>, Then>
+ // , and_<not_<if_<Condition> >, Else>
+ // >
+ //{};
+
+ //template<typename Condition, typename Then>
+ //struct if_<Condition, Then, void>
+ // : and_<if_<Condition>, Then>
+ //{};
+
+ //template<typename Condition>
+ //struct if_<Condition, void, void>
+ // : has_identity_transform
+ //{
+ // typedef if_ proto_base_expr;
+ //};
 
- template<typename Condition, typename Then>
- struct if_<Condition, Then, void>
- : and_<if_<Condition>, Then>
- {};
 
- template<typename Condition>
- struct if_<Condition, void, void>
- : has_identity_transform
+ // if_
+ template<typename If, typename Then, typename Else>
+ struct if_ : callable
             {
                 typedef if_ proto_base_expr;
+
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : mpl::eval_if<
+ typename when<_, If>::template result<void(Expr, State, Visitor)>::type
+ , typename when<_, Then>::template result<void(Expr, State, Visitor)>
+ , typename when<_, Else>::template result<void(Expr, State, Visitor)>
+ >
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ typedef
+ typename mpl::if_<
+ typename when<_, If>::template result<void(Expr, State, Visitor)>::type
+ , when<_, Then>
+ , when<_, Else>
+ >::type
+ branch;
+
+ return branch()(expr, state, visitor);
+ }
             };
 
             // or_
             template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, typename G)>
- struct or_
+ struct or_ : callable
             {
                 typedef or_ proto_base_expr;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
                 {
                     typedef typename detail::matches_impl<Expr, or_>::which which;
- typedef typename which::template apply<Expr, State, Visitor>::type type;
+ typedef typename which::template result<void(Expr, State, Visitor)>::type type;
                 };
 
                 template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
                 {
                     typedef typename detail::matches_impl<Expr, or_>::which which;
- return which::call(expr, state, visitor);
+ return which()(expr, state, visitor);
                 }
             };
 
             // and_
             template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, typename G)>
- struct and_
+ struct and_ : callable
             {
                 typedef and_ proto_base_expr;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
                 {
                     typedef typename detail::last<and_>::type which;
- typedef typename which::template apply<Expr, State, Visitor>::type type;
+ typedef typename which::template result<void(Expr, State, Visitor)>::type type;
                 };
 
                 template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
                 {
                     typedef typename detail::last<and_>::type which;
- return which::call(expr, state, visitor);
+ return which()(expr, state, visitor);
                 }
             };
 
             // switch_
             template<typename Cases>
- struct switch_
+ struct switch_ : callable
             {
                 typedef switch_ proto_base_expr;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : Cases::template case_<typename Expr::proto_tag>::template apply<Expr, State, Visitor>
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : Cases::template case_<typename Expr::proto_tag>::template result<void(Expr, State, Visitor)>
                 {};
 
                 template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
                 {
- return Cases::template case_<typename Expr::proto_tag>::call(expr, state, visitor);
+ return typename Cases::template case_<typename Expr::proto_tag>()(expr, state, visitor);
                 }
             };
 
@@ -479,6 +562,32 @@
                 typedef void proto_is_vararg_;
             };
         }
+
+ template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, typename G)>
+ struct is_callable<or_<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, G)> >
+ : mpl::true_
+ {};
+
+ template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, typename G)>
+ struct is_callable<and_<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_LOGICAL_ARITY, G)> >
+ : mpl::true_
+ {};
+
+ template<typename Grammar>
+ struct is_callable<not_<Grammar> >
+ : mpl::true_
+ {};
+
+ template<typename If, typename Then, typename Else>
+ struct is_callable<if_<If, Then, Else> >
+ : mpl::true_
+ {};
+
+ template<typename Grammar>
+ struct is_callable<vararg<Grammar> >
+ : mpl::true_
+ {};
+
     }}
 
     #if defined(_MSC_VER) && (_MSC_VER >= 1020)

Modified: trunk/boost/xpressive/proto/proto_fwd.hpp
==============================================================================
--- trunk/boost/xpressive/proto/proto_fwd.hpp (original)
+++ trunk/boost/xpressive/proto/proto_fwd.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -52,10 +52,7 @@
         typedef char yes_type;
         typedef char (&no_type)[2];
 
- struct dont_care
- {
- dont_care(...);
- };
+ struct dont_care;
 
         template<typename T>
         struct remove_cv_ref
@@ -117,8 +114,8 @@
 
         // Fusion tags
         struct proto_expr;
- struct proto_ref;
- struct proto_ref_iterator;
+ struct proto_expr_iterator;
+ struct proto_flat_view;
     }
 
     namespace wildcardns_
@@ -205,15 +202,15 @@
>
         struct and_;
 
- template<typename Condition, typename Then = void, typename Else = void>
+ template<typename Grammar>
+ struct not_;
+
+ template<typename Condition, typename Then = _, typename Else = not_<_> >
         struct if_;
 
         template<typename Cases>
         struct switch_;
 
- template<typename Grammar>
- struct not_;
-
         template<typename T>
         struct exact;
 
@@ -440,124 +437,327 @@
 
         template<typename Tag, typename Domain = deduce_domain>
         struct unfused_expr;
+
+ typedef make_expr<tag::terminal> make_terminal;
+ typedef make_expr<tag::posit> make_posit;
+ typedef make_expr<tag::negate> make_negate;
+ typedef make_expr<tag::dereference> make_dereference;
+ typedef make_expr<tag::complement> make_complement;
+ typedef make_expr<tag::address_of> make_address_of;
+ typedef make_expr<tag::logical_not> make_logical_not;
+ typedef make_expr<tag::pre_inc> make_pre_inc;
+ typedef make_expr<tag::pre_dec> make_pre_dec;
+ typedef make_expr<tag::post_inc> make_post_inc;
+ typedef make_expr<tag::post_dec> make_post_dec;
+ typedef make_expr<tag::shift_left> make_shift_left;
+ typedef make_expr<tag::shift_right> make_shift_right;
+ typedef make_expr<tag::multiplies> make_multiplies;
+ typedef make_expr<tag::divides> make_divides;
+ typedef make_expr<tag::modulus> make_modulus;
+ typedef make_expr<tag::plus> make_plus;
+ typedef make_expr<tag::minus> make_minus;
+ typedef make_expr<tag::less> make_less;
+ typedef make_expr<tag::greater> make_greater;
+ typedef make_expr<tag::less_equal> make_less_equal;
+ typedef make_expr<tag::greater_equal> make_greater_equal;
+ typedef make_expr<tag::equal_to> make_equal_to;
+ typedef make_expr<tag::not_equal_to> make_not_equal_to;
+ typedef make_expr<tag::logical_or> make_logical_or;
+ typedef make_expr<tag::logical_and> make_logical_and;
+ typedef make_expr<tag::bitwise_and> make_bitwise_and;
+ typedef make_expr<tag::bitwise_or> make_bitwise_or;
+ typedef make_expr<tag::bitwise_xor> make_bitwise_xor;
+ typedef make_expr<tag::comma> make_comma;
+ typedef make_expr<tag::mem_ptr> make_mem_ptr;
+ typedef make_expr<tag::assign> make_assign;
+ typedef make_expr<tag::shift_left_assign> make_shift_left_assign;
+ typedef make_expr<tag::shift_right_assign> make_shift_right_assign;
+ typedef make_expr<tag::multiplies_assign> make_multiplies_assign;
+ typedef make_expr<tag::divides_assign> make_divides_assign;
+ typedef make_expr<tag::modulus_assign> make_modulus_assign;
+ typedef make_expr<tag::plus_assign> make_plus_assign;
+ typedef make_expr<tag::minus_assign> make_minus_assign;
+ typedef make_expr<tag::bitwise_and_assign> make_bitwise_and_assign;
+ typedef make_expr<tag::bitwise_or_assign> make_bitwise_or_assign;
+ typedef make_expr<tag::bitwise_xor_assign> make_bitwise_xor_assign;
+ typedef make_expr<tag::subscript> make_subscript;
+ typedef make_expr<tag::if_else_> make_if_else;
+ typedef make_expr<tag::function> make_function;
+
+ //typedef make_expr_ref<tag::terminal> make_terminal_ref;
+ //typedef make_expr_ref<tag::posit> make_posit_ref;
+ //typedef make_expr_ref<tag::negate> make_negate_ref;
+ //typedef make_expr_ref<tag::dereference> make_dereference_ref;
+ //typedef make_expr_ref<tag::complement> make_complement_ref;
+ //typedef make_expr_ref<tag::address_of> make_address_of_ref;
+ //typedef make_expr_ref<tag::logical_not> make_logical_not_ref;
+ //typedef make_expr_ref<tag::pre_inc> make_pre_inc_ref;
+ //typedef make_expr_ref<tag::pre_dec> make_pre_dec_ref;
+ //typedef make_expr_ref<tag::post_inc> make_post_inc_ref;
+ //typedef make_expr_ref<tag::post_dec> make_post_dec_ref;
+ //typedef make_expr_ref<tag::shift_left> make_shift_left_ref;
+ //typedef make_expr_ref<tag::shift_right> make_shift_right_ref;
+ //typedef make_expr_ref<tag::multiplies> make_multiplies_ref;
+ //typedef make_expr_ref<tag::divides> make_divides_ref;
+ //typedef make_expr_ref<tag::modulus> make_modulus_ref;
+ //typedef make_expr_ref<tag::plus> make_plus_ref;
+ //typedef make_expr_ref<tag::minus> make_minus_ref;
+ //typedef make_expr_ref<tag::less> make_less_ref;
+ //typedef make_expr_ref<tag::greater> make_greater_ref;
+ //typedef make_expr_ref<tag::less_equal> make_less_equal_ref;
+ //typedef make_expr_ref<tag::greater_equal> make_greater_equal_ref;
+ //typedef make_expr_ref<tag::equal_to> make_equal_to_ref;
+ //typedef make_expr_ref<tag::not_equal_to> make_not_equal_to_ref;
+ //typedef make_expr_ref<tag::logical_or> make_logical_or_ref;
+ //typedef make_expr_ref<tag::logical_and> make_logical_and_ref;
+ //typedef make_expr_ref<tag::bitwise_and> make_bitwise_and_ref;
+ //typedef make_expr_ref<tag::bitwise_or> make_bitwise_or_ref;
+ //typedef make_expr_ref<tag::bitwise_xor> make_bitwise_xor_ref;
+ //typedef make_expr_ref<tag::comma> make_comma_ref;
+ //typedef make_expr_ref<tag::mem_ptr> make_mem_ptr_ref;
+ //typedef make_expr_ref<tag::assign> make_assign_ref;
+ //typedef make_expr_ref<tag::shift_left_assign> make_shift_left_assign_ref;
+ //typedef make_expr_ref<tag::shift_right_assign> make_shift_right_assign_ref;
+ //typedef make_expr_ref<tag::multiplies_assign> make_multiplies_assign_ref;
+ //typedef make_expr_ref<tag::divides_assign> make_divides_assign_ref;
+ //typedef make_expr_ref<tag::modulus_assign> make_modulus_assign_ref;
+ //typedef make_expr_ref<tag::plus_assign> make_plus_assign_ref;
+ //typedef make_expr_ref<tag::minus_assign> make_minus_assign_ref;
+ //typedef make_expr_ref<tag::bitwise_and_assign> make_bitwise_and_assign_ref;
+ //typedef make_expr_ref<tag::bitwise_or_assign> make_bitwise_or_assign_ref;
+ //typedef make_expr_ref<tag::bitwise_xor_assign> make_bitwise_xor_assign_ref;
+ //typedef make_expr_ref<tag::subscript> make_subscript_ref;
+ //typedef make_expr_ref<tag::if_else_> make_if_else_ref;
+ //typedef make_expr_ref<tag::function> make_function_ref;
+
+ struct flatten;
+ struct pop_front;
+ struct reverse;
+ }
+
+ typedef functional::make_terminal _make_terminal;
+ typedef functional::make_posit _make_posit;
+ typedef functional::make_negate _make_negate;
+ typedef functional::make_dereference _make_dereference;
+ typedef functional::make_complement _make_complement;
+ typedef functional::make_address_of _make_address_of;
+ typedef functional::make_logical_not _make_logical_not;
+ typedef functional::make_pre_inc _make_pre_inc;
+ typedef functional::make_pre_dec _make_pre_dec;
+ typedef functional::make_post_inc _make_post_inc;
+ typedef functional::make_post_dec _make_post_dec;
+ typedef functional::make_shift_left _make_shift_left;
+ typedef functional::make_shift_right _make_shift_right;
+ typedef functional::make_multiplies _make_multiplies;
+ typedef functional::make_divides _make_divides;
+ typedef functional::make_modulus _make_modulus;
+ typedef functional::make_plus _make_plus;
+ typedef functional::make_minus _make_minus;
+ typedef functional::make_less _make_less;
+ typedef functional::make_greater _make_greater;
+ typedef functional::make_less_equal _make_less_equal;
+ typedef functional::make_greater_equal _make_greater_equal;
+ typedef functional::make_equal_to _make_equal_to;
+ typedef functional::make_not_equal_to _make_not_equal_to;
+ typedef functional::make_logical_or _make_logical_or;
+ typedef functional::make_logical_and _make_logical_and;
+ typedef functional::make_bitwise_and _make_bitwise_and;
+ typedef functional::make_bitwise_or _make_bitwise_or;
+ typedef functional::make_bitwise_xor _make_bitwise_xor;
+ typedef functional::make_comma _make_comma;
+ typedef functional::make_mem_ptr _make_mem_ptr;
+ typedef functional::make_assign _make_assign;
+ typedef functional::make_shift_left_assign _make_shift_left_assign;
+ typedef functional::make_shift_right_assign _make_shift_right_assign;
+ typedef functional::make_multiplies_assign _make_multiplies_assign;
+ typedef functional::make_divides_assign _make_divides_assign;
+ typedef functional::make_modulus_assign _make_modulus_assign;
+ typedef functional::make_plus_assign _make_plus_assign;
+ typedef functional::make_minus_assign _make_minus_assign;
+ typedef functional::make_bitwise_and_assign _make_bitwise_and_assign;
+ typedef functional::make_bitwise_or_assign _make_bitwise_or_assign;
+ typedef functional::make_bitwise_xor_assign _make_bitwise_xor_assign;
+ typedef functional::make_subscript _make_subscript;
+ typedef functional::make_if_else _make_if_else;
+ typedef functional::make_function _make_function;
+
+ //typedef functional::make_terminal_ref _make_terminal_ref;
+ //typedef functional::make_posit_ref _make_posit_ref;
+ //typedef functional::make_negate_ref _make_negate_ref;
+ //typedef functional::make_dereference_ref _make_dereference_ref;
+ //typedef functional::make_complement_ref _make_complement_ref;
+ //typedef functional::make_address_of_ref _make_address_of_ref;
+ //typedef functional::make_logical_not_ref _make_logical_not_ref;
+ //typedef functional::make_pre_inc_ref _make_pre_inc_ref;
+ //typedef functional::make_pre_dec_ref _make_pre_dec_ref;
+ //typedef functional::make_post_inc_ref _make_post_inc_ref;
+ //typedef functional::make_post_dec_ref _make_post_dec_ref;
+ //typedef functional::make_shift_left_ref _make_shift_left_ref;
+ //typedef functional::make_shift_right_ref _make_shift_right_ref;
+ //typedef functional::make_multiplies_ref _make_multiplies_ref;
+ //typedef functional::make_divides_ref _make_divides_ref;
+ //typedef functional::make_modulus_ref _make_modulus_ref;
+ //typedef functional::make_plus_ref _make_plus_ref;
+ //typedef functional::make_minus_ref _make_minus_ref;
+ //typedef functional::make_less_ref _make_less_ref;
+ //typedef functional::make_greater_ref _make_greater_ref;
+ //typedef functional::make_less_equal_ref _make_less_equal_ref;
+ //typedef functional::make_greater_equal_ref _make_greater_equal_ref;
+ //typedef functional::make_equal_to_ref _make_equal_to_ref;
+ //typedef functional::make_not_equal_to_ref _make_not_equal_to_ref;
+ //typedef functional::make_logical_or_ref _make_logical_or_ref;
+ //typedef functional::make_logical_and_ref _make_logical_and_ref;
+ //typedef functional::make_bitwise_and_ref _make_bitwise_and_ref;
+ //typedef functional::make_bitwise_or_ref _make_bitwise_or_ref;
+ //typedef functional::make_bitwise_xor_ref _make_bitwise_xor_ref;
+ //typedef functional::make_comma_ref _make_comma_ref;
+ //typedef functional::make_mem_ptr_ref _make_mem_ptr_ref;
+ //typedef functional::make_assign_ref _make_assign_ref;
+ //typedef functional::make_shift_left_assign_ref _make_shift_left_assign_ref;
+ //typedef functional::make_shift_right_assign_ref _make_shift_right_assign_ref;
+ //typedef functional::make_multiplies_assign_ref _make_multiplies_assign_ref;
+ //typedef functional::make_divides_assign_ref _make_divides_assign_ref;
+ //typedef functional::make_modulus_assign_ref _make_modulus_assign_ref;
+ //typedef functional::make_plus_assign_ref _make_plus_assign_ref;
+ //typedef functional::make_minus_assign_ref _make_minus_assign_ref;
+ //typedef functional::make_bitwise_and_assign_ref _make_bitwise_and_assign_ref;
+ //typedef functional::make_bitwise_or_assign_ref _make_bitwise_or_assign_ref;
+ //typedef functional::make_bitwise_xor_assign_ref _make_bitwise_xor_assign_ref;
+ //typedef functional::make_subscript_ref _make_subscript_ref;
+ //typedef functional::make_if_else_ref _make_if_else_ref;
+ //typedef functional::make_function_ref _make_function_ref;
+
+ typedef functional::flatten _flatten;
+ typedef functional::pop_front _pop_front;
+ typedef functional::reverse _reverse;
+ typedef functional::deep_copy _deep_copy;
+
+#define BOOST_PROTO_IDENTITY_TRANSFORM() \
+ template<typename Expr_, typename State_, typename Visitor_> \
+ Expr_ const &operator ()(Expr_ const &expr_, State_ const &, Visitor_ &) const \
+ { \
+ return expr_; \
+ } \
+ \
+ template<typename Sig> \
+ struct result; \
+ \
+ template<typename This, typename Expr_, typename State_, typename Visitor_> \
+ struct result<This(Expr_,State_,Visitor_)> \
+ { \
+ typedef Expr_ type; \
     }
 
-#define BOOST_PROTO_IDENTITY_TRANSFORM()\
- template<typename Expr_, typename State_, typename Visitor_>\
- static Expr_ const &call(Expr_ const &expr_, State_ const &, Visitor_ &)\
- {\
- return expr_;\
- }\
- template<typename Expr_, typename, typename>\
- struct apply\
- {\
- typedef Expr_ type;\
- }
-
- namespace transform
+ namespace has_transformns_
     {
- namespace detail
- {
- using proto::detail::yes_type;
- using proto::detail::no_type;
-
- struct default_factory;
-
- no_type is_wildcard_expression_fun(...);
-
- template<typename T>
- struct is_wildcard_expression;
- }
+ template<typename Grammar>
+ struct has_pass_through_transform;
 
- template<typename Grammar, typename N = mpl::long_<0> >
- struct arg;
+ struct has_identity_transform
+ {
+ BOOST_PROTO_IDENTITY_TRANSFORM();
+ };
+ }
 
- template<typename Grammar, long N>
- struct arg_c;
+ using has_transformns_::has_identity_transform;
+ using has_transformns_::has_pass_through_transform;
 
- template<typename Grammar>
- struct left;
+ //template<typename T>
+ //struct is_transform;
 
- template<typename Grammar>
- struct right;
+ template<typename T>
+ struct is_callable;
 
- template<typename Grammar>
- struct state;
+ template<typename T>
+ struct is_aggregate;
 
- template<typename Grammar>
- struct visitor;
+ namespace transform
+ {
+ #define BOOST_PROTO_CALLABLE() typedef void proto_is_callable_;
 
- template<typename Grammar>
- struct identity;
+ struct callable
+ {
+ BOOST_PROTO_CALLABLE()
+ };
 
- template<typename Grammar, typename Always, typename Factory = detail::default_factory>
- struct always;
+ template<typename Grammar, typename Fun = Grammar>
+ struct when;
 
- template<typename Grammar, typename Lambda, typename Factory = detail::default_factory>
- struct apply1;
+ template<typename Fun>
+ struct otherwise;
 
- template<typename Grammar, typename Lambda, typename Factory = detail::default_factory>
- struct apply2;
+ template<typename Fun>
+ struct call;
 
- template<typename Grammar, typename Lambda, typename Factory = detail::default_factory>
- struct apply3;
+ template<typename Fun>
+ struct make;
 
- template<typename Grammar, typename State>
- struct branch;
+ template<typename Fun>
+ struct bind;
 
- template<typename Grammar, typename State = void>
+ template<typename Sequence, typename State, typename Fun>
         struct fold;
 
- template<typename Grammar, typename State = void>
+ template<typename Sequence, typename State, typename Fun>
         struct reverse_fold;
 
- template<typename Tag, typename Grammar, typename State = void>
+ // BUGBUG can we replace fold_tree with fold<flatten(_), state, fun> ?
+ template<typename Sequence, typename State, typename Fun>
         struct fold_tree;
 
- template<typename Tag, typename Grammar, typename State = void>
+ template<typename Sequence, typename State, typename Fun>
         struct reverse_fold_tree;
 
- template<typename Grammar, typename Function1>
- struct function1;
-
- template<typename Grammar, typename Function2>
- struct function2;
-
- template<typename Grammar, typename Function3>
- struct function3;
-
- template<typename Grammar>
- struct list;
-
- template<typename Grammar>
- struct tail;
-
- template<typename Grammar>
- struct pass_through;
-
- template<typename Grammar, typename ConstructorFun>
- struct construct;
-
- template<typename Grammar, typename ConstructorFun>
- struct pod_construct;
- }
-
- namespace has_transformns_
- {
- template<typename Grammar>
- struct has_pass_through_transform;
-
- struct has_identity_transform
- {
- BOOST_PROTO_IDENTITY_TRANSFORM();
- };
- }
-
- using has_transformns_::has_identity_transform;
- using has_transformns_::has_pass_through_transform;
-
- template<typename T>
- struct is_transform;
+ struct _expr;
+ struct _state;
+ struct _visitor;
+
+ template<int I>
+ struct _arg_c;
+
+ struct _arg0;
+ struct _arg1;
+ struct _arg2;
+ struct _arg3;
+ struct _arg4;
+ struct _arg5;
+ struct _arg6;
+ struct _arg7;
+ struct _arg8;
+ struct _arg9;
+
+ typedef _arg0 _arg;
+ typedef _arg0 _left;
+ typedef _arg1 _right;
+ }
+
+ using transform::when;
+ using transform::otherwise;
+ using transform::_arg0;
+ using transform::_arg1;
+ using transform::_arg2;
+ using transform::_arg3;
+ using transform::_arg4;
+ using transform::_arg5;
+ using transform::_arg6;
+ using transform::_arg7;
+ using transform::_arg8;
+ using transform::_arg9;
+ using transform::_arg;
+ using transform::_left;
+ using transform::_right;
+ using transform::_expr;
+ using transform::_state;
+ using transform::_visitor;
+ using transform::_arg_c;
+ using transform::call;
+ using transform::make;
+ using transform::bind;
+ using transform::fold;
+ using transform::reverse_fold;
+ using transform::fold_tree;
+ using transform::reverse_fold_tree;
+ using transform::callable;
 
     template<typename T>
     struct is_extension;

Modified: trunk/boost/xpressive/proto/ref.hpp
==============================================================================
--- trunk/boost/xpressive/proto/ref.hpp (original)
+++ trunk/boost/xpressive/proto/ref.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -43,7 +43,7 @@
             typedef typename Expr::proto_args proto_args;
             typedef typename Expr::proto_arity proto_arity;
             typedef typename Expr::proto_domain proto_domain;
- typedef tag::proto_ref fusion_tag;
+ //typedef tag::proto_expr fusion_tag;
             typedef void proto_is_ref_;
             typedef void proto_is_expr_;
             typedef Expr proto_derived_expr;

Modified: trunk/boost/xpressive/proto/traits.hpp
==============================================================================
--- trunk/boost/xpressive/proto/traits.hpp (original)
+++ trunk/boost/xpressive/proto/traits.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -29,8 +29,12 @@
     #include <boost/mpl/or.hpp>
     #include <boost/mpl/bool.hpp>
     #include <boost/mpl/eval_if.hpp>
+ #include <boost/mpl/aux_/template_arity.hpp>
+ #include <boost/mpl/aux_/lambda_arity_param.hpp>
     #include <boost/static_assert.hpp>
     #include <boost/utility/result_of.hpp>
+ #include <boost/type_traits/is_pod.hpp>
+ #include <boost/type_traits/is_same.hpp>
     #include <boost/type_traits/is_array.hpp>
     #include <boost/type_traits/is_function.hpp>
     #include <boost/type_traits/remove_cv.hpp>
@@ -56,13 +60,56 @@
 
     namespace boost { namespace proto
     {
+ namespace detail
+ {
+ template<typename T, typename EnableIf = void>
+ struct is_callable2_
+ : mpl::false_
+ {};
+
+ template<typename T>
+ struct is_callable2_<T, typename T::proto_is_callable_>
+ : mpl::true_
+ {};
+
+ template<typename T BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(long Arity = mpl::aux::template_arity<T>::value)>
+ struct is_callable_
+ : is_callable2_<T>
+ {};
+ }
+
         template<typename T>
- struct is_transform
- : mpl::false_
+ struct is_callable
+ : proto::detail::is_callable_<T>
         {};
 
         template<>
- struct is_transform<proto::_>
+ struct is_callable<proto::_>
+ : mpl::true_
+ {};
+
+ template<>
+ struct is_callable<proto::callable>
+ : mpl::false_
+ {};
+
+ #if BOOST_WORKAROUND(__GNUC__, == 3)
+ // work around GCC bug
+ template<typename Tag, typename Args, long N>
+ struct is_callable<proto::expr<Tag, Args, N> >
+ : mpl::false_
+ {};
+ #endif
+
+ /// is_aggregate
+ ///
+ template<typename T>
+ struct is_aggregate
+ : is_pod<T>
+ {};
+
+ template<typename Tag, typename Args, long N>
+ struct is_aggregate<expr<Tag, Args, N> >
           : mpl::true_
         {};
 
@@ -202,7 +249,6 @@
             template<typename T>
             struct terminal : has_identity_transform
             {
- terminal();
                 typedef expr<proto::tag::terminal, args0<T> > type;
                 typedef type proto_base_expr;
                 typedef proto::tag::terminal proto_tag;
@@ -213,7 +259,6 @@
             template<typename T, typename U, typename V>
             struct if_else_ : has_pass_through_transform<if_else_<T, U, V> >
             {
- if_else_();
                 typedef expr<proto::tag::if_else_, args3<T, U, V> > type;
                 typedef type proto_base_expr;
                 typedef proto::tag::if_else_ proto_tag;
@@ -226,7 +271,6 @@
             template<typename Tag, typename T>
             struct unary_expr : has_pass_through_transform<unary_expr<Tag, T> >
             {
- unary_expr();
                 typedef expr<Tag, args1<T> > type;
                 typedef type proto_base_expr;
                 typedef Tag proto_tag;
@@ -237,7 +281,6 @@
             template<typename Tag, typename T, typename U>
             struct binary_expr : has_pass_through_transform<binary_expr<Tag, T, U> >
             {
- binary_expr();
                 typedef expr<Tag, args2<T, U> > type;
                 typedef type proto_base_expr;
                 typedef Tag proto_tag;
@@ -249,7 +292,6 @@
             template<typename T> \
             struct Name : has_pass_through_transform<Name<T> > \
             { \
- Name(); \
                 typedef expr<proto::tag::Name, args1<T> > type; \
                 typedef type proto_base_expr; \
                 typedef proto::tag::Name proto_tag; \
@@ -261,7 +303,6 @@
             template<typename T, typename U> \
             struct Name : has_pass_through_transform<Name<T, U> > \
             { \
- Name(); \
                 typedef expr<proto::tag::Name, args2<T, U> > type; \
                 typedef type proto_base_expr; \
                 typedef proto::tag::Name proto_tag; \
@@ -704,6 +745,14 @@
                     return that;
                 }
             };
+
+ template<
+ template<BOOST_PP_ENUM_PARAMS(N, typename BOOST_PP_INTERCEPT)> class T
+ , BOOST_PP_ENUM_PARAMS(N, typename A)
+ >
+ struct is_callable_<T<BOOST_PP_ENUM_PARAMS(N, A)> BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(N)>
+ : is_same<BOOST_PP_CAT(A, BOOST_PP_DEC(N)), callable>
+ {};
         }
 
         template<BOOST_PP_ENUM_PARAMS(N, typename A)>

Modified: trunk/boost/xpressive/proto/transform.hpp
==============================================================================
--- trunk/boost/xpressive/proto/transform.hpp (original)
+++ trunk/boost/xpressive/proto/transform.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -10,16 +10,14 @@
 #define BOOST_PROTO_TRANSFORM_HPP_EAN_06_23_2007
 
 #include <boost/xpressive/proto/detail/prefix.hpp> // must be first include
-#include <boost/xpressive/proto/transform/apply.hpp>
 #include <boost/xpressive/proto/transform/arg.hpp>
-#include <boost/xpressive/proto/transform/branch.hpp>
-#include <boost/xpressive/proto/transform/compose.hpp>
-#include <boost/xpressive/proto/transform/construct.hpp>
+#include <boost/xpressive/proto/transform/bind.hpp>
+#include <boost/xpressive/proto/transform/call.hpp>
 #include <boost/xpressive/proto/transform/fold.hpp>
 #include <boost/xpressive/proto/transform/fold_tree.hpp>
-#include <boost/xpressive/proto/transform/function.hpp>
-#include <boost/xpressive/proto/transform/list.hpp>
+#include <boost/xpressive/proto/transform/make.hpp>
 #include <boost/xpressive/proto/transform/pass_through.hpp>
+#include <boost/xpressive/proto/transform/when.hpp>
 #include <boost/xpressive/proto/detail/suffix.hpp> // must be last include
 
 #endif

Deleted: trunk/boost/xpressive/proto/transform/apply.hpp
==============================================================================
--- trunk/boost/xpressive/proto/transform/apply.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
+++ (empty file)
@@ -1,167 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-/// \file apply.hpp
-/// Proto transforms for applying MPL placeholder expressions.
-//
-// Copyright 2007 Eric Niebler. 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)
-
-#ifndef BOOST_PROTO_TRANSFORM_APPLY_HPP_EAN_06_23_2007
-#define BOOST_PROTO_TRANSFORM_APPLY_HPP_EAN_06_23_2007
-
-#include <boost/xpressive/proto/detail/prefix.hpp>
-#include <boost/mpl/apply.hpp>
-#include <boost/xpressive/proto/proto_fwd.hpp> // is_transform
-#include <boost/xpressive/proto/detail/suffix.hpp>
-
-namespace boost { namespace proto { namespace transform
-{
- namespace detail
- {
- struct any
- {
- template<typename T>
- any(T const &)
- {}
- };
-
- struct default_factory
- {
- default_factory()
- {}
-
- default_factory const &operator()() const
- {
- return *this;
- }
-
- default_factory const &operator()(any) const
- {
- return *this;
- }
-
- default_factory const &operator()(any, any) const
- {
- return *this;
- }
-
- default_factory const &operator()(any, any, any) const
- {
- return *this;
- }
-
- template<typename T>
- operator T() const
- {
- return T();
- }
- };
- }
-
- // Always return the specified type/object
- template<typename Grammar, typename Always, typename Factory>
- struct always
- : Grammar
- {
- always() {}
-
- template<typename, typename, typename>
- struct apply
- {
- typedef Always type;
- };
-
- template<typename Expr, typename State, typename Visitor>
- static Always
- call(Expr const &, State const &, Visitor &)
- {
- return Factory()();
- }
- };
-
- // Apply an MPL lambda, passing just Expr
- template<typename Grammar, typename Lambda, typename Factory>
- struct apply1
- : Grammar
- {
- apply1() {}
-
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : mpl::apply1<Lambda, typename Grammar::template apply<Expr, State, Visitor>::type>
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return Factory()(Grammar::call(expr, state, visitor));
- }
- };
-
- // Apply an MPL lambda, passing Expr and State
- template<typename Grammar, typename Lambda, typename Factory>
- struct apply2
- : Grammar
- {
- apply2() {}
-
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : mpl::apply2<Lambda, typename Grammar::template apply<Expr, State, Visitor>::type, State>
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return Factory()(Grammar::call(expr, state, visitor), state);
- }
- };
-
- // Apply an MPL lambda, passing Expr, State and Visitor
- template<typename Grammar, typename Lambda, typename Factory>
- struct apply3
- : Grammar
- {
- apply3() {}
-
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : mpl::apply3<Lambda, typename Grammar::template apply<Expr, State, Visitor>::type, State, Visitor>
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return Factory()(Grammar::call(expr, state, visitor), state, visitor);
- }
- };
-
-}}}
-
-namespace boost { namespace proto
-{
- template<typename Grammar, typename Always, typename Factory>
- struct is_transform<transform::always<Grammar, Always, Factory> >
- : mpl::true_
- {};
-
- template<typename Grammar, typename Lambda, typename Factory>
- struct is_transform<transform::apply1<Grammar, Lambda, Factory> >
- : mpl::true_
- {};
-
- template<typename Grammar, typename Lambda, typename Factory>
- struct is_transform<transform::apply2<Grammar, Lambda, Factory> >
- : mpl::true_
- {};
-
- template<typename Grammar, typename Lambda, typename Factory>
- struct is_transform<transform::apply3<Grammar, Lambda, Factory> >
- : mpl::true_
- {};
-}}
-
-#endif

Modified: trunk/boost/xpressive/proto/transform/arg.hpp
==============================================================================
--- trunk/boost/xpressive/proto/transform/arg.hpp (original)
+++ trunk/boost/xpressive/proto/transform/arg.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -1,192 +1,144 @@
 ///////////////////////////////////////////////////////////////////////////////
 /// \file arg.hpp
-/// Proto transforms for extracting arguments from expressions.
+/// Contains definition of the argN transforms.
 //
 // Copyright 2007 Eric Niebler. 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)
 
-#ifndef BOOST_PROTO_TRANSFORM_ARG_HPP_EAN_12_16_2006
-#define BOOST_PROTO_TRANSFORM_ARG_HPP_EAN_12_16_2006
+#ifndef BOOST_PROTO_TRANSFORM_ARG_HPP_EAN_11_01_2007
+#define BOOST_PROTO_TRANSFORM_ARG_HPP_EAN_11_01_2007
 
 #include <boost/xpressive/proto/detail/prefix.hpp>
 #include <boost/xpressive/proto/proto_fwd.hpp>
 #include <boost/xpressive/proto/traits.hpp>
 #include <boost/xpressive/proto/detail/suffix.hpp>
 
-namespace boost { namespace proto { namespace transform
+namespace boost { namespace proto
 {
- // A transform that simply extracts the arg from an expression
- template<typename Grammar, typename N>
- struct arg
- : Grammar
- {
- arg() {}
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : proto::result_of::arg<typename Grammar::template apply<Expr, State, Visitor>::type, N>
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type //reference
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- // NOTE Grammar::call could return a temporary!
- // Don't return a dangling reference
- return proto::arg<N>(Grammar::call(expr, state, visitor));
- }
- };
-
- // A transform that simply extracts the arg from an expression
- template<typename Grammar, long N>
- struct arg_c
- : Grammar
+ namespace transform
     {
- arg_c() {}
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : proto::result_of::arg_c<typename Grammar::template apply<Expr, State, Visitor>::type, N>
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type //const &
- call(Expr const &expr, State const &state, Visitor &visitor)
+ struct _expr : callable
         {
- return proto::arg_c<N>(Grammar::call(expr, state, visitor));
- }
- };
-
- // A transform that simply extracts the left arg from an expression
- template<typename Grammar>
- struct left
- : Grammar
- {
- left() {}
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : proto::result_of::left<typename Grammar::template apply<Expr, State, Visitor>::type>
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type //const &
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return proto::left(Grammar::call(expr, state, visitor));
- }
- };
-
- // A transform that simply extracts the right arg from an expression
- template<typename Grammar>
- struct right
- : Grammar
- {
- right() {}
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ {
+ typedef Expr type;
+ };
+
+ //template<typename This, typename Expr, typename State, typename Visitor>
+ //struct result<This(Expr &, State, Visitor)>
+ //{
+ // typedef Expr const &type;
+ //};
+
+ template<typename Expr, typename State, typename Visitor>
+ Expr const &
+ operator ()(Expr const &expr, State const &, Visitor &) const
+ {
+ return expr;
+ }
+ };
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : proto::result_of::right<typename Grammar::template apply<Expr, State, Visitor>::type>
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type //const &
- call(Expr const &expr, State const &state, Visitor &visitor)
+ struct _state : callable
         {
- return proto::right(Grammar::call(expr, state, visitor));
- }
- };
-
- // Just return the passed in Expr
- template<typename Grammar>
- struct identity
- : Grammar
- {
- identity() {}
- BOOST_PROTO_IDENTITY_TRANSFORM();
- };
-
- // Just return the state
- template<typename Grammar>
- struct state
- : Grammar
- {
- state() {}
+ template<typename Sig>
+ struct result;
 
- template<typename, typename State, typename>
- struct apply
- {
- typedef State type;
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ {
+ typedef State type;
+ };
+
+ //template<typename This, typename Expr, typename State, typename Visitor>
+ //struct result<This(Expr, State &, Visitor)>
+ //{
+ // typedef State const &type;
+ //};
+
+ template<typename Expr, typename State, typename Visitor>
+ State const &
+ operator ()(Expr const &, State const &state, Visitor &) const
+ {
+ return state;
+ }
         };
 
- template<typename Expr, typename State, typename Visitor>
- static State const &
- call(Expr const &, State const &state_, Visitor &)
+ struct _visitor : callable
         {
- return state_;
- }
- };
-
- // Just return the visitor
- template<typename Grammar>
- struct visitor
- : Grammar
- {
- visitor() {}
+ template<typename Sig>
+ struct result;
 
- template<typename, typename, typename Visitor>
- struct apply
- {
- typedef Visitor type;
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ {
+ typedef Visitor type;
+ };
+
+ template<typename Expr, typename State, typename Visitor>
+ Visitor &
+ operator ()(Expr const &, State const &, Visitor &visitor) const
+ {
+ return visitor;
+ }
         };
 
- template<typename Expr, typename State, typename Visitor>
- static Visitor &
- call(Expr const &, State const &, Visitor &visitor_)
+ template<int I>
+ struct _arg_c : callable
         {
- return visitor_;
- }
- };
+ template<typename Sig>
+ struct result;
 
-}}}
-
-namespace boost { namespace proto
-{
- template<typename Grammar, typename N>
- struct is_transform<transform::arg<Grammar, N> >
- : mpl::true_
- {};
-
- template<typename Grammar, long N>
- struct is_transform<transform::arg_c<Grammar, N> >
- : mpl::true_
- {};
-
- template<typename Grammar>
- struct is_transform<transform::left<Grammar> >
- : mpl::true_
- {};
-
- template<typename Grammar>
- struct is_transform<transform::right<Grammar> >
- : mpl::true_
- {};
+ //template<typename This, typename Expr, typename State, typename Visitor>
+ //struct result<This(Expr, State, Visitor)>
+ // : proto::result_of::value_at_c<Expr, I>
+ //{};
+
+ //template<typename This, typename Expr, typename State, typename Visitor>
+ //struct result<This(Expr &, State, Visitor)>
+ // : proto::result_of::arg_c<Expr const &, I>
+ //{};
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : proto::result_of::arg_c<Expr, I>
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename proto::result_of::arg_c<Expr, I>::type
+ operator ()(Expr const &expr, State const &, Visitor &) const
+ {
+ return proto::arg_c<I>(expr);
+ }
+ };
 
- template<typename Grammar>
- struct is_transform<transform::identity<Grammar> >
- : mpl::true_
- {};
+ struct _arg0 : _arg_c<0> {};
+ struct _arg1 : _arg_c<1> {};
+ struct _arg2 : _arg_c<2> {};
+ struct _arg3 : _arg_c<3> {};
+ struct _arg4 : _arg_c<4> {};
+ struct _arg5 : _arg_c<5> {};
+ struct _arg6 : _arg_c<6> {};
+ struct _arg7 : _arg_c<7> {};
+ struct _arg8 : _arg_c<8> {};
+ struct _arg9 : _arg_c<9> {};
+
+ typedef _arg0 _arg;
+ typedef _arg0 _left;
+ typedef _arg1 _right;
+ }
 
- template<typename Grammar>
- struct is_transform<transform::state<Grammar> >
+ template<int I>
+ struct is_callable<transform::_arg_c<I> >
       : mpl::true_
     {};
 
- template<typename Grammar>
- struct is_transform<transform::visitor<Grammar> >
- : mpl::true_
- {};
 }}
 
 #endif

Added: trunk/boost/xpressive/proto/transform/bind.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/xpressive/proto/transform/bind.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -0,0 +1,90 @@
+#ifndef BOOST_PP_IS_ITERATING
+ ///////////////////////////////////////////////////////////////////////////////
+ /// \file bind.hpp
+ /// Contains definition of the bind<> transform.
+ //
+ // Copyright 2007 Eric Niebler. 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)
+
+ #ifndef BOOST_PROTO_TRANSFORM_BIND_HPP_EAN_12_02_2007
+ #define BOOST_PROTO_TRANSFORM_BIND_HPP_EAN_12_02_2007
+
+ #include <boost/xpressive/proto/detail/prefix.hpp>
+ #include <boost/xpressive/proto/proto_fwd.hpp>
+ #include <boost/xpressive/proto/transform/make.hpp>
+ #include <boost/xpressive/proto/transform/call.hpp>
+ #include <boost/xpressive/proto/detail/suffix.hpp>
+
+ namespace boost { namespace proto
+ {
+
+ namespace transform
+ {
+ template<typename Fun>
+ struct bind : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : call<
+ typename make<Fun>::template result<void(Expr, State, Visitor)>::type
+ >::template result<void(Expr, State, Visitor)>
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ return call<
+ typename make<Fun>::template result<void(Expr, State, Visitor)>::type
+ >()(expr, state, visitor);
+ }
+ };
+
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/transform/bind.hpp>))
+ #include BOOST_PP_ITERATE()
+
+ }
+
+ template<typename Fun>
+ struct is_callable<transform::bind<Fun> >
+ : mpl::true_
+ {};
+
+ }}
+
+ #endif
+
+#else
+
+ #define N BOOST_PP_ITERATION()
+
+ template<typename Return BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+ struct bind<Return(BOOST_PP_ENUM_PARAMS(N, A))> : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : call<
+ typename make<Return>::template result<void(Expr, State, Visitor)>::type(BOOST_PP_ENUM_PARAMS(N, A))
+ >::template result<void(Expr, State, Visitor)>
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ return call<
+ typename make<Return>::template result<void(Expr, State, Visitor)>::type(BOOST_PP_ENUM_PARAMS(N, A))
+ >()(expr, state, visitor);
+ }
+ };
+
+ #undef N
+
+#endif

Deleted: trunk/boost/xpressive/proto/transform/branch.hpp
==============================================================================
--- trunk/boost/xpressive/proto/transform/branch.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
+++ (empty file)
@@ -1,52 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-/// \file branch.hpp
-/// A special-purpose proto transform for transforming one branch of the expression
-/// tree separately from the rest. Given an expression and a new state, it
-/// transforms the expression using the new state.
-//
-// Copyright 2007 Eric Niebler. 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)
-
-#ifndef BOOST_PROTO_TRANSFORM_BRANCH_HPP_EAN_12_16_2006
-#define BOOST_PROTO_TRANSFORM_BRANCH_HPP_EAN_12_16_2006
-
-#include <boost/xpressive/proto/detail/prefix.hpp>
-#include <boost/mpl/bool.hpp>
-#include <boost/xpressive/proto/proto_fwd.hpp>
-#include <boost/xpressive/proto/detail/suffix.hpp>
-
-namespace boost { namespace proto { namespace transform
-{
-
- // A branch compiler, for compiling a sub-tree with a specified state
- template<typename Grammar, typename BranchState>
- struct branch
- : Grammar
- {
- branch() {}
-
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : Grammar::template apply<Expr, BranchState, Visitor>
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &, Visitor &visitor)
- {
- return Grammar::call(expr, BranchState(), visitor);
- }
- };
-
-}}}
-
-namespace boost { namespace proto
-{
- template<typename Grammar, typename BranchState>
- struct is_transform<transform::branch<Grammar, BranchState> >
- : mpl::true_
- {};
-}}
-
-#endif

Added: trunk/boost/xpressive/proto/transform/call.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/xpressive/proto/transform/call.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -0,0 +1,339 @@
+#ifndef BOOST_PP_IS_ITERATING
+ ///////////////////////////////////////////////////////////////////////////////
+ /// \file call.hpp
+ /// Contains definition of the call<> transform.
+ //
+ // Copyright 2007 Eric Niebler. 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)
+
+ #ifndef BOOST_PROTO_TRANSFORM_CALL_HPP_EAN_11_02_2007
+ #define BOOST_PROTO_TRANSFORM_CALL_HPP_EAN_11_02_2007
+
+ #include <boost/xpressive/proto/detail/prefix.hpp>
+ #include <boost/utility/result_of.hpp>
+ #include <boost/xpressive/proto/proto_fwd.hpp>
+ #include <boost/xpressive/proto/traits.hpp>
+ #include <boost/xpressive/proto/detail/dont_care.hpp>
+ #include <boost/xpressive/proto/detail/as_lvalue.hpp>
+ #include <boost/xpressive/proto/detail/suffix.hpp>
+
+ namespace boost { namespace proto
+ {
+
+ namespace transform
+ {
+ namespace detail
+ {
+ using proto::detail::uncv;
+ using proto::detail::as_lvalue;
+ using proto::detail::dont_care;
+ typedef char (&yes_type)[2];
+ typedef char no_type;
+
+ struct private_type_
+ {
+ private_type_ const &operator ,(int) const;
+ };
+
+ template<typename T>
+ yes_type check_fun_arity(T const &);
+
+ no_type check_fun_arity(private_type_ const &);
+
+ template<typename Fun>
+ struct callable0_wrap : Fun
+ {
+ callable0_wrap();
+ typedef private_type_ const &(*pfun0)();
+ operator pfun0() const;
+ };
+
+ template<typename Fun>
+ struct callable1_wrap : Fun
+ {
+ callable1_wrap();
+ typedef private_type_ const &(*pfun1)(dont_care);
+ operator pfun1() const;
+ };
+
+ template<typename Fun>
+ struct callable2_wrap : Fun
+ {
+ callable2_wrap();
+ typedef private_type_ const &(*pfun2)(dont_care, dont_care);
+ operator pfun2() const;
+ };
+
+ template<typename Fun>
+ struct arity0
+ {
+ static callable0_wrap<Fun> &fun;
+
+ static int const value =
+ sizeof(yes_type) == sizeof(check_fun_arity((fun(), 0)))
+ ? 0
+ : 3;
+ };
+
+ template<typename Fun, typename A0>
+ struct arity1
+ {
+ static callable1_wrap<Fun> &fun;
+ static A0 &a0;
+
+ static int const value =
+ sizeof(yes_type) == sizeof(check_fun_arity((fun(a0), 0)))
+ ? 1
+ : 3;
+ };
+
+ template<typename Fun, typename A0, typename A1>
+ struct arity2
+ {
+ static callable2_wrap<Fun> &fun;
+ static A0 &a0;
+ static A1 &a1;
+
+ static int const value =
+ sizeof(yes_type) == sizeof(check_fun_arity((fun(a0, a1), 0)))
+ ? 2
+ : 3;
+ };
+
+ template<typename Fun, typename Expr, typename State, typename Visitor>
+ struct call3
+ {
+ typedef typename boost::result_of<Fun(Expr, State, Visitor)>::type type;
+
+ template<typename Expr2, typename State2, typename Visitor2>
+ static type call(Expr2 &expr, State2 &state, Visitor2 &visitor)
+ {
+ Fun f;
+ return f(expr, state, visitor);
+ }
+ };
+
+ template<typename Fun, typename Expr, typename State, typename Visitor
+ , int Arity = arity0<Fun>::value>
+ struct call0
+ : call3<Fun, Expr, State, Visitor>
+ {};
+
+ template<typename Fun, typename Expr, typename State, typename Visitor>
+ struct call0<Fun, Expr, State, Visitor, 0>
+ {
+ typedef typename boost::result_of<Fun()>::type type;
+
+ template<typename Expr2, typename State2, typename Visitor2>
+ static type call(Expr2 &, State2 &, Visitor2 &)
+ {
+ Fun f;
+ return f();
+ }
+ };
+
+ template<typename Fun, typename Expr, typename State, typename Visitor
+ , int Arity = arity1<Fun, Expr>::value>
+ struct call1
+ : call3<Fun, Expr, State, Visitor>
+ {};
+
+ template<typename Fun, typename Expr, typename State, typename Visitor>
+ struct call1<Fun, Expr, State, Visitor, 1>
+ {
+ typedef typename boost::result_of<Fun(Expr)>::type type;
+
+ template<typename Expr2, typename State2, typename Visitor2>
+ static type call(Expr2 &expr, State2 &, Visitor2 &)
+ {
+ Fun f;
+ return f(expr);
+ }
+ };
+
+ template<typename Fun, typename Expr, typename State, typename Visitor
+ , int Arity = arity2<Fun, Expr, State>::value>
+ struct call2
+ : call3<Fun, Expr, State, Visitor>
+ {};
+
+ template<typename Fun, typename Expr, typename State, typename Visitor>
+ struct call2<Fun, Expr, State, Visitor, 2>
+ {
+ typedef typename boost::result_of<Fun(Expr, State)>::type type;
+
+ template<typename Expr2, typename State2, typename Visitor2>
+ static type call(Expr2 &expr, State2 &state, Visitor2 &)
+ {
+ Fun f;
+ return f(expr, state);
+ }
+ };
+ }
+
+ template<typename Fun>
+ struct call : Fun
+ {
+ BOOST_PROTO_CALLABLE()
+ };
+
+ template<typename Fun>
+ struct call<Fun()> : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : detail::call0<
+ Fun
+ , Expr
+ , State
+ , Visitor
+ >
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ return result<void(Expr, State, Visitor)>::call(expr, state, visitor);
+ }
+ };
+
+ template<typename Fun, typename Arg0>
+ struct call<Fun(Arg0)> : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : detail::call1<
+ Fun
+ , typename when<_, Arg0>::template result<void(Expr, State, Visitor)>::type
+ , State
+ , Visitor
+ >
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ return result<void(Expr, State, Visitor)>::call(
+ detail::as_lvalue(when<_, Arg0>()(expr, state, visitor))
+ , state
+ , visitor
+ );
+ }
+ };
+
+ template<typename Fun, typename Arg0, typename Arg1>
+ struct call<Fun(Arg0, Arg1)> : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : detail::call2<
+ Fun
+ , typename when<_, Arg0>::template result<void(Expr, State, Visitor)>::type
+ , typename when<_, Arg1>::template result<void(Expr, State, Visitor)>::type
+ , Visitor
+ >
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ return result<void(Expr, State, Visitor)>::call(
+ detail::as_lvalue(when<_, Arg0>()(expr, state, visitor))
+ , detail::as_lvalue(when<_, Arg1>()(expr, state, visitor))
+ , visitor
+ );
+ }
+ };
+
+ template<typename Fun, typename Arg0, typename Arg1, typename Arg2>
+ struct call<Fun(Arg0, Arg1, Arg2)> : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ // TODO can I avoid boost::result_of here
+ : boost::result_of<
+ Fun(
+ typename when<_, Arg0>::template result<void(Expr, State, Visitor)>::type
+ , typename when<_, Arg1>::template result<void(Expr, State, Visitor)>::type
+ , typename when<_, Arg2>::template result<void(Expr, State, Visitor)>::type
+ )
+ >
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ Fun f;
+ return f(
+ detail::as_lvalue(when<_, Arg0>()(expr, state, visitor))
+ , detail::as_lvalue(when<_, Arg1>()(expr, state, visitor))
+ , detail::uncv(when<_, Arg2>()(expr, state, visitor)) // HACK
+ );
+ }
+ };
+
+ #if BOOST_PROTO_MAX_ARITY > 3
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (4, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/transform/call.hpp>))
+ #include BOOST_PP_ITERATE()
+ #endif
+ }
+
+ template<typename Fun>
+ struct is_callable<transform::call<Fun> >
+ : mpl::true_
+ {};
+
+ }}
+
+ #endif
+
+#else
+
+ #define N BOOST_PP_ITERATION()
+
+ template<typename Fun BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+ struct call<Fun(BOOST_PP_ENUM_PARAMS(N, A))> : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : boost::result_of<
+ #define TMP(Z, M, DATA) typename when<_, BOOST_PP_CAT(A, M)>::template result<void(Expr, State, Visitor)>::type
+ Fun(BOOST_PP_ENUM(N, TMP, ~))
+ #undef TMP
+ >
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ Fun f;
+ #define TMP(Z, M, DATA) when<_, BOOST_PP_CAT(A, M)>()(expr, state, visitor)
+ return f(BOOST_PP_ENUM(N, TMP, ~));
+ #undef TMP
+ }
+ };
+
+ #undef N
+
+#endif

Deleted: trunk/boost/xpressive/proto/transform/compose.hpp
==============================================================================
--- trunk/boost/xpressive/proto/transform/compose.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
+++ (empty file)
@@ -1,58 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-/// \file compose.hpp
-/// A special-purpose proto transform for composing two transfomations. Given
-/// two Grammars, expressions that match the first grammar are transformed
-/// according to that grammar, and the result is forwarded to the second
-/// for further transformation.
-//
-// Copyright 2007 Eric Niebler. 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)
-
-#ifndef BOOST_PROTO_TRANSFORM_COMPOSE_HPP_EAN_04_01_2007
-#define BOOST_PROTO_TRANSFORM_COMPOSE_HPP_EAN_04_01_2007
-
-#include <boost/xpressive/proto/detail/prefix.hpp>
-#include <boost/mpl/bool.hpp> // mpl::true_
-#include <boost/xpressive/proto/proto_fwd.hpp>
-#include <boost/xpressive/proto/detail/suffix.hpp>
-
-namespace boost { namespace proto { namespace transform
-{
-
- // Composes two transforms
- template<typename Grammar1, typename Grammar2>
- struct compose
- : Grammar1
- {
- compose() {}
-
- template<typename Expr, typename State, typename Visitor>
- struct apply
- {
- typedef typename Grammar2::template apply<
- typename Grammar1::template apply<Expr, State, Visitor>::type
- , State
- , Visitor
- >::type type;
- };
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return Grammar2::call(Grammar1::call(expr, state, visitor), state, visitor);
- }
- };
-
-}}}
-
-namespace boost { namespace proto
-{
- template<typename Grammar1, typename Grammar2>
- struct is_transform<transform::compose<Grammar1, Grammar2> >
- : mpl::true_
- {};
-}}
-
-#endif

Deleted: trunk/boost/xpressive/proto/transform/construct.hpp
==============================================================================
--- trunk/boost/xpressive/proto/transform/construct.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
+++ (empty file)
@@ -1,270 +0,0 @@
-#ifndef BOOST_PP_IS_ITERATING
- ///////////////////////////////////////////////////////////////////////////////
- /// \file construct.hpp
- /// For constructing an arbitrary type from a bunch of transforms.
- //
- // Copyright 2007 Eric Niebler. 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)
-
- #ifndef BOOST_PROTO_TRANSFORM_CONSTRUCT_HPP_EAN_12_26_2006
- #define BOOST_PROTO_TRANSFORM_CONSTRUCT_HPP_EAN_12_26_2006
-
- #include <boost/xpressive/proto/detail/prefix.hpp>
- #include <boost/preprocessor/iterate.hpp>
- #include <boost/preprocessor/facilities/intercept.hpp>
- #include <boost/preprocessor/repetition/enum.hpp>
- #include <boost/preprocessor/repetition/enum_params.hpp>
- #include <boost/preprocessor/repetition/enum_trailing.hpp>
- #include <boost/preprocessor/repetition/enum_binary_params.hpp>
- #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
- #include <boost/mpl/bool.hpp>
- #include <boost/mpl/aux_/has_type.hpp>
- #include <boost/mpl/aux_/lambda_arity_param.hpp>
- #include <boost/type_traits/is_pod.hpp>
- #include <boost/type_traits/is_function.hpp>
- #include <boost/type_traits/remove_pointer.hpp>
- #include <boost/xpressive/proto/proto_fwd.hpp>
- #include <boost/xpressive/proto/detail/suffix.hpp>
-
- namespace boost { namespace proto { namespace transform
- {
- namespace detail
- {
- template<typename T>
- struct is_aggregate
- : is_pod<T>
- {};
-
- template<typename Tag, typename Args, long N>
- struct is_aggregate<expr<Tag, Args, N> >
- : mpl::true_
- {};
-
- template<typename T, bool HasType = mpl::aux::has_type<T>::value>
- struct nested_type
- {
- typedef typename T::type type;
- };
-
- template<typename T>
- struct nested_type<T, false>
- {
- typedef T type;
- };
-
- template<typename T BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(BOOST_PROTO_MAX_ARITY, typename A, = no_type BOOST_PP_INTERCEPT)>
- struct nested_type_if
- : nested_type<T>
- {
- typedef yes_type proto_transform_applied;
- };
-
- template<typename T>
- struct nested_type_if<T BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, no_type BOOST_PP_INTERCEPT)>
- {
- typedef T type;
- typedef no_type proto_transform_applied;
- };
-
- template<typename Arg, bool IsFunction = is_function<typename remove_pointer<Arg>::type>::value>
- struct as_transform
- {
- typedef Arg type;
- };
-
- template<typename Arg>
- struct as_transform<Arg, true>
- {
- typedef construct<_, typename remove_pointer<Arg>::type> type;
- };
-
- template<typename Arg, bool IsFunction = is_function<typename remove_pointer<Arg>::type>::value>
- struct as_pod_transform
- {
- typedef Arg type;
- };
-
- template<typename Arg>
- struct as_pod_transform<Arg, true>
- {
- typedef pod_construct<_, typename remove_pointer<Arg>::type> type;
- };
-
- template<typename R, typename Expr, typename State, typename Visitor
- BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(long Arity = mpl::aux::template_arity<R>::value)
- >
- struct apply_aux_
- {
- typedef R type;
- typedef no_type proto_transform_applied;
- };
-
- template<typename R, typename Expr, typename State, typename Visitor, bool IsTransform = is_transform<R>::value>
- struct apply_
- : apply_aux_<R, Expr, State, Visitor>
- {};
-
- template<typename R, typename Expr, typename State, typename Visitor>
- struct apply_<R, Expr, State, Visitor, true>
- : nested_type<typename R::template apply<Expr, State, Visitor>::type>
- {
- typedef yes_type proto_transform_applied;
- };
-
- // work around GCC bug
- template<typename Tag, typename Args, long N, typename Expr, typename State, typename Visitor>
- struct apply_<expr<Tag, Args, N>, Expr, State, Visitor, false>
- {
- typedef expr<Tag, Args, N> type;
- typedef no_type proto_transform_applied;
- };
-
- template<typename T>
- void ignore_unused(T const &)
- {}
- }
-
- template<typename Grammar, typename ConstructorFun>
- struct construct
- : Grammar
- {
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : ConstructorFun::template apply<typename Grammar::template apply<Expr, State, Visitor>::type, State, Visitor>
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return ConstructorFun::call(Grammar::call(expr, state, visitor), state, visitor);
- }
- };
-
- #define BOOST_PROTO_APPLY_(Z, N, DATA) \
- typename apply_<BOOST_PP_CAT(DATA, N), Expr, State, Visitor>::type \
- /**/
-
- #define BOOST_PROTO_IS_APPLIED_(Z, N, DATA) \
- typename apply_<BOOST_PP_CAT(DATA, N), Expr, State, Visitor>::proto_transform_applied \
- /**/
-
- #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/transform/construct.hpp>))
- #include BOOST_PP_ITERATE()
-
- #undef BOOST_PROTO_APPLY_
- #undef BOOST_PROTO_IS_APPLIED_
-
- }}}
-
- namespace boost { namespace proto
- {
- template<typename Grammar, typename ConstructorFun>
- struct is_transform<transform::construct<Grammar, ConstructorFun> >
- : mpl::true_
- {};
-
- template<typename Grammar, typename ConstructorFun>
- struct is_transform<transform::pod_construct<Grammar, ConstructorFun> >
- : mpl::true_
- {};
- }}
-
- #endif
-
-#else
-
- #define N BOOST_PP_ITERATION()
-
- #if N > 0
- namespace detail
- {
- template<
- template<BOOST_PP_ENUM_PARAMS(N, typename BOOST_PP_INTERCEPT)> class T
- BOOST_PP_ENUM_TRAILING_PARAMS(N, typename G),
- typename Expr, typename State, typename Visitor
- >
- struct apply_aux_<T<BOOST_PP_ENUM_PARAMS(N, G)>, Expr, State, Visitor BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(N)>
- : nested_type_if<
- T<BOOST_PP_ENUM(N, BOOST_PROTO_APPLY_, G)>
- BOOST_PP_ENUM_TRAILING(N, BOOST_PROTO_IS_APPLIED_, G)
- >
- {};
- }
- #endif
-
- template<typename Grammar, typename Result BOOST_PP_ENUM_TRAILING_PARAMS(N, typename Arg)>
- struct construct<Grammar, Result(BOOST_PP_ENUM_PARAMS(N, Arg))>
- : Grammar
- {
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : detail::apply_<Result, typename Grammar::template apply<Expr, State, Visitor>::type, State, Visitor>
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- typedef typename apply<Expr, State, Visitor>::type result_type;
- return construct::call_(expr, state, visitor, detail::is_aggregate<result_type>());
- }
-
- private:
- /// INTERNAL ONLY
- ///
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call_(Expr const &expr, State const &state, Visitor &visitor, mpl::true_)
- {
- typename Grammar::template apply<Expr, State, Visitor>::type const &expr2
- = Grammar::call(expr, state, visitor);
- detail::ignore_unused(expr2);
- typename apply<Expr, State, Visitor>::type that = {
- BOOST_PP_ENUM_BINARY_PARAMS(N, detail::as_transform<Arg, >::type::call(expr2, state, visitor) BOOST_PP_INTERCEPT)
- };
- return that;
- }
-
- /// INTERNAL ONLY
- ///
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call_(Expr const &expr, State const &state, Visitor &visitor, mpl::false_)
- {
- typename Grammar::template apply<Expr, State, Visitor>::type const &expr2
- = Grammar::call(expr, state, visitor);
- detail::ignore_unused(expr2);
- return typename apply<Expr, State, Visitor>::type(
- BOOST_PP_ENUM_BINARY_PARAMS(N, detail::as_transform<Arg, >::type::call(expr2, state, visitor) BOOST_PP_INTERCEPT)
- );
- }
- };
-
- template<typename Grammar, typename Result BOOST_PP_ENUM_TRAILING_PARAMS(N, typename Arg)>
- struct pod_construct<Grammar, Result(BOOST_PP_ENUM_PARAMS(N, Arg))>
- : Grammar
- {
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : detail::apply_<Result, typename Grammar::template apply<Expr, State, Visitor>::type, State, Visitor>
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- typename Grammar::template apply<Expr, State, Visitor>::type const &expr2
- = Grammar::call(expr, state, visitor);
- detail::ignore_unused(expr2);
- typename apply<Expr, State, Visitor>::type that = {
- BOOST_PP_ENUM_BINARY_PARAMS(N, detail::as_pod_transform<Arg, >::type::call(expr2, state, visitor) BOOST_PP_INTERCEPT)
- };
- return that;
- }
- };
-
- #undef N
-
-#endif

Modified: trunk/boost/xpressive/proto/transform/fold.hpp
==============================================================================
--- trunk/boost/xpressive/proto/transform/fold.hpp (original)
+++ trunk/boost/xpressive/proto/transform/fold.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -1,145 +1,212 @@
 #ifndef BOOST_PP_IS_ITERATING
     ///////////////////////////////////////////////////////////////////////////////
     /// \file fold.hpp
- /// A special-purpose proto transform for merging sequences of binary operations.
- /// It transforms the right operand and passes the result as state while transforming
- /// the left. Or, it might do the left first, if you choose.
+ /// Contains definition of the fold<> and reverse_fold<> transforms.
     //
     // Copyright 2007 Eric Niebler. 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)
 
- #ifndef BOOST_PROTO_TRANSFORM_FOLD_HPP_EAN_12_16_2006
- #define BOOST_PROTO_TRANSFORM_FOLD_HPP_EAN_12_16_2006
+ #ifndef BOOST_PROTO_TRANSFORM_FOLD_HPP_EAN_11_04_2007
+ #define BOOST_PROTO_TRANSFORM_FOLD_HPP_EAN_11_04_2007
 
     #include <boost/xpressive/proto/detail/prefix.hpp>
- #include <boost/preprocessor/cat.hpp>
- #include <boost/preprocessor/arithmetic/inc.hpp>
- #include <boost/preprocessor/arithmetic/sub.hpp>
- #include <boost/preprocessor/iteration/iterate.hpp>
- #include <boost/preprocessor/repetition/repeat.hpp>
+ #include <boost/fusion/include/fold.hpp>
+ #include <boost/fusion/include/reverse.hpp>
     #include <boost/xpressive/proto/proto_fwd.hpp>
+ #include <boost/xpressive/proto/fusion.hpp>
     #include <boost/xpressive/proto/traits.hpp>
- #include <boost/xpressive/proto/transform/branch.hpp>
     #include <boost/xpressive/proto/detail/suffix.hpp>
 
- namespace boost { namespace proto { namespace transform
+ namespace boost { namespace proto
     {
 
- namespace detail
+ namespace transform
         {
- template<typename Grammar, typename Expr, typename State, typename Visitor, long Arity = Expr::proto_arity::value>
- struct fold_impl
- {};
 
- template<typename Grammar, typename Expr, typename State, typename Visitor, long Arity = Expr::proto_arity::value>
- struct reverse_fold_impl
- {};
+ namespace detail
+ {
 
- #define BOOST_PROTO_ARG_N_TYPE(n)\
- BOOST_PP_CAT(proto_arg, n)\
- /**/
-
- #define BOOST_PROTO_FOLD_STATE_TYPE(z, n, data)\
- typedef typename Grammar::BOOST_PROTO_ARG_N_TYPE(n)::template\
- apply<typename Expr::BOOST_PROTO_ARG_N_TYPE(n)::proto_base_expr, BOOST_PP_CAT(state, n), Visitor>::type\
- BOOST_PP_CAT(state, BOOST_PP_INC(n));\
- /**/
-
- #define BOOST_PROTO_FOLD_STATE(z, n, data)\
- BOOST_PP_CAT(state, BOOST_PP_INC(n)) const &BOOST_PP_CAT(s, BOOST_PP_INC(n)) =\
- Grammar::BOOST_PROTO_ARG_N_TYPE(n)::call(expr.BOOST_PP_CAT(arg, n).proto_base(), BOOST_PP_CAT(s, n), visitor);\
- /**/
-
- #define BOOST_PROTO_REVERSE_FOLD_STATE_TYPE(z, n, data)\
- typedef typename Grammar::BOOST_PROTO_ARG_N_TYPE(BOOST_PP_SUB(data, BOOST_PP_INC(n)))::template\
- apply<typename Expr::BOOST_PROTO_ARG_N_TYPE(BOOST_PP_SUB(data, BOOST_PP_INC(n)))::proto_base_expr, BOOST_PP_CAT(state, BOOST_PP_SUB(data, n)), Visitor>::type\
- BOOST_PP_CAT(state, BOOST_PP_SUB(data, BOOST_PP_INC(n)));\
- /**/
-
- #define BOOST_PROTO_REVERSE_FOLD_STATE(z, n, data)\
- BOOST_PP_CAT(state, BOOST_PP_SUB(data, BOOST_PP_INC(n))) const &BOOST_PP_CAT(s, BOOST_PP_SUB(data, BOOST_PP_INC(n))) =\
- Grammar::BOOST_PROTO_ARG_N_TYPE(BOOST_PP_SUB(data, BOOST_PP_INC(n)))::call(expr.BOOST_PP_CAT(arg, BOOST_PP_SUB(data, BOOST_PP_INC(n))).proto_base(), BOOST_PP_CAT(s, BOOST_PP_SUB(data, n)), visitor);\
- /**/
-
- #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/transform/fold.hpp>))
- #include BOOST_PP_ITERATE()
-
- #undef BOOST_PROTO_REVERSE_FOLD_STATE
- #undef BOOST_PROTO_REVERSE_FOLD_STATE_TYPE
- #undef BOOST_PROTO_FOLD_STATE
- #undef BOOST_PROTO_FOLD_STATE_TYPE
- #undef BOOST_PROTO_ARG_N_TYPE
- }
+ template<typename Transform, typename Visitor>
+ struct as_callable
+ {
+ as_callable(Visitor &v)
+ : v_(v)
+ {}
+
+ typedef when<_, Transform> Tfx;
+
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State>
+ struct result<This(Expr, State)>
+ : Tfx::template result<void(typename proto::detail::remove_cv_ref<Expr>::type
+ , typename proto::detail::remove_cv_ref<State>::type
+ , Visitor)>
+ {};
+
+ template<typename Expr, typename State>
+ typename Tfx::template result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state) const
+ {
+ return Tfx()(expr, state, this->v_);
+ }
+
+ private:
+ Visitor &v_;
+ };
+
+
+ template<typename Fun, typename Expr, typename State, typename Visitor, long Arity = Expr::proto_arity::value>
+ struct fold_impl
+ {};
+
+ template<typename Fun, typename Expr, typename State, typename Visitor, long Arity = Expr::proto_arity::value>
+ struct reverse_fold_impl
+ {};
+
+ #define BOOST_PROTO_ARG_N_TYPE(n)\
+ BOOST_PP_CAT(proto_arg, n)\
+ /**/
+
+ #define BOOST_PROTO_FOLD_STATE_TYPE(z, n, data)\
+ typedef typename when<_, Fun>::template\
+ result<void(typename Expr::BOOST_PROTO_ARG_N_TYPE(n)::proto_base_expr, BOOST_PP_CAT(state, n), Visitor)>::type\
+ BOOST_PP_CAT(state, BOOST_PP_INC(n));\
+ /**/
+
+ #define BOOST_PROTO_FOLD_STATE(z, n, data)\
+ BOOST_PP_CAT(state, BOOST_PP_INC(n)) const &BOOST_PP_CAT(s, BOOST_PP_INC(n)) =\
+ when<_, Fun>()(expr.BOOST_PP_CAT(arg, n).proto_base(), BOOST_PP_CAT(s, n), visitor);\
+ /**/
+
+ #define BOOST_PROTO_REVERSE_FOLD_STATE_TYPE(z, n, data)\
+ typedef typename when<_, Fun>::template\
+ result<void(typename Expr::BOOST_PROTO_ARG_N_TYPE(BOOST_PP_SUB(data, BOOST_PP_INC(n)))::proto_base_expr, BOOST_PP_CAT(state, BOOST_PP_SUB(data, n)), Visitor)>::type\
+ BOOST_PP_CAT(state, BOOST_PP_SUB(data, BOOST_PP_INC(n)));\
+ /**/
+
+ #define BOOST_PROTO_REVERSE_FOLD_STATE(z, n, data)\
+ BOOST_PP_CAT(state, BOOST_PP_SUB(data, BOOST_PP_INC(n))) const &BOOST_PP_CAT(s, BOOST_PP_SUB(data, BOOST_PP_INC(n))) =\
+ when<_, Fun>()(expr.BOOST_PP_CAT(arg, BOOST_PP_SUB(data, BOOST_PP_INC(n))).proto_base(), BOOST_PP_CAT(s, BOOST_PP_SUB(data, n)), visitor);\
+ /**/
+
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/transform/fold.hpp>))
+ #include BOOST_PP_ITERATE()
+
+ #undef BOOST_PROTO_REVERSE_FOLD_STATE
+ #undef BOOST_PROTO_REVERSE_FOLD_STATE_TYPE
+ #undef BOOST_PROTO_FOLD_STATE
+ #undef BOOST_PROTO_FOLD_STATE_TYPE
+ #undef BOOST_PROTO_ARG_N_TYPE
 
- // A fold transform that transforms the left sub-tree and
- // uses the result as state while transforming the right.
- template<typename Grammar>
- struct fold<Grammar, void>
- : Grammar
- {
- fold() {}
+ } // namespace detail
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : detail::fold_impl<Grammar, typename Expr::proto_base_expr, State, Visitor>
- {};
+ template<typename Sequence, typename State0, typename Fun>
+ struct fold : callable
+ {
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return apply<Expr, State, Visitor>::call(expr.proto_base(), state, visitor);
- }
- };
-
- // A reverse_fold compiler that compiles the right sub-tree and
- // uses the result as state while compiling the left.
- template<typename Grammar>
- struct reverse_fold<Grammar, void>
- : Grammar
- {
- reverse_fold() {}
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : fusion::result_of::fold<
+ typename when<_, Sequence>::template result<void(Expr, State, Visitor)>::type
+ , typename when<_, State0>::template result<void(Expr, State, Visitor)>::type
+ , detail::as_callable<Fun, Visitor>
+ >
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ detail::as_callable<Fun, Visitor> fun(visitor);
+ return fusion::fold(
+ when<_, Sequence>()(expr, state, visitor)
+ , when<_, State0>()(expr, state, visitor)
+ , fun
+ );
+ }
+ };
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : detail::reverse_fold_impl<Grammar, typename Expr::proto_base_expr, State, Visitor>
+ template<typename Sequence, typename State, typename Fun>
+ struct reverse_fold
+ : fold<_reverse(Sequence), State, Fun>
             {};
 
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return apply<Expr, State, Visitor>::call(expr.proto_base(), state, visitor);
- }
- };
-
- // Causes Doxygen to crash. Sigh.
- #ifndef BOOST_PROTO_DOXYGEN_INVOKED
- template<typename Grammar, typename State>
- struct fold
- : branch<fold<Grammar, void>, State>
- {};
+ // A fold transform that transforms the left sub-tree and
+ // uses the result as state while transforming the right.
+ template<typename State0, typename Fun>
+ struct fold<_, State0, Fun> : callable
+ {
+ template<typename Sig>
+ struct result;
 
- template<typename Grammar, typename State>
- struct reverse_fold
- : branch<reverse_fold<Grammar, void>, State>
- {};
- #endif
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : detail::fold_impl<
+ Fun
+ , typename Expr::proto_base_expr
+ , typename when<_, State0>::template result<void(Expr, State, Visitor)>::type
+ , Visitor
+ >
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ return result<void(Expr, State, Visitor)>::call(
+ expr.proto_base()
+ , when<_, State0>()(expr, state, visitor)
+ , visitor
+ );
+ }
+ };
 
- }}}
+ // A reverse_fold compiler that compiles the right sub-tree and
+ // uses the result as state while compiling the left.
+ template<typename State0, typename Fun>
+ struct reverse_fold<_, State0, Fun> : callable
+ {
+ template<typename Sig>
+ struct result;
 
- namespace boost { namespace proto
- {
- template<typename Grammar, typename State>
- struct is_transform<transform::fold<Grammar, State> >
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : detail::reverse_fold_impl<
+ Fun
+ , typename Expr::proto_base_expr
+ , typename when<_, State0>::template result<void(Expr, State, Visitor)>::type
+ , Visitor
+ >
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ return result<void(Expr, State, Visitor)>::call(
+ expr.proto_base()
+ , when<_, State0>()(expr, state, visitor)
+ , visitor
+ );
+ }
+ };
+ }
+
+ template<typename Sequence, typename State, typename Fun>
+ struct is_callable<transform::fold<Sequence, State, Fun> >
           : mpl::true_
         {};
 
- template<typename Grammar, typename State>
- struct is_transform<transform::reverse_fold<Grammar, State> >
+ template<typename Sequence, typename State, typename Fun>
+ struct is_callable<transform::reverse_fold<Sequence, State, Fun> >
           : mpl::true_
         {};
+
     }}
 
     #endif
@@ -148,8 +215,8 @@
 
     #define N BOOST_PP_ITERATION()
 
- template<typename Grammar, typename Expr, typename state0, typename Visitor>
- struct fold_impl<Grammar, Expr, state0, Visitor, N>
+ template<typename Fun, typename Expr, typename state0, typename Visitor>
+ struct fold_impl<Fun, Expr, state0, Visitor, N>
             {
                 BOOST_PP_REPEAT(N, BOOST_PROTO_FOLD_STATE_TYPE, N)
                 typedef BOOST_PP_CAT(state, N) type;
@@ -161,8 +228,8 @@
                 }
             };
 
- template<typename Grammar, typename Expr, typename BOOST_PP_CAT(state, N), typename Visitor>
- struct reverse_fold_impl<Grammar, Expr, BOOST_PP_CAT(state, N), Visitor, N>
+ template<typename Fun, typename Expr, typename BOOST_PP_CAT(state, N), typename Visitor>
+ struct reverse_fold_impl<Fun, Expr, BOOST_PP_CAT(state, N), Visitor, N>
             {
                 BOOST_PP_REPEAT(N, BOOST_PROTO_REVERSE_FOLD_STATE_TYPE, N)
                 typedef state0 type;
@@ -173,6 +240,7 @@
                     return s0;
                 }
             };
+
     #undef N
 
 #endif

Modified: trunk/boost/xpressive/proto/transform/fold_tree.hpp
==============================================================================
--- trunk/boost/xpressive/proto/transform/fold_tree.hpp (original)
+++ trunk/boost/xpressive/proto/transform/fold_tree.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -1,76 +1,116 @@
 ///////////////////////////////////////////////////////////////////////////////
-/// \file fold_tree.hpp
-/// A higher-level transform that uses the fold, and branch transforms
-/// to recursively fold a tree.
+/// \file fold.hpp
+/// Contains definition of the fold_tree<> and reverse_fold_tree<> transforms.
 //
 // Copyright 2007 Eric Niebler. 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)
 
-#ifndef BOOST_PROTO_TRANSFORM_FOLD_TREE_HPP_EAN_06_18_2007
-#define BOOST_PROTO_TRANSFORM_FOLD_TREE_HPP_EAN_06_18_2007
+#ifndef BOOST_PROTO_TRANSFORM_FOLD_TREE_HPP_EAN_11_05_2007
+#define BOOST_PROTO_TRANSFORM_FOLD_TREE_HPP_EAN_11_05_2007
 
 #include <boost/xpressive/proto/detail/prefix.hpp>
+#include <boost/xpressive/proto/proto_fwd.hpp>
+#include <boost/xpressive/proto/traits.hpp>
 #include <boost/xpressive/proto/transform/fold.hpp>
 #include <boost/xpressive/proto/detail/suffix.hpp>
 
-namespace boost { namespace proto { namespace transform
+namespace boost { namespace proto
 {
 
- namespace detail
+ namespace transform
     {
- template<typename Tag, typename Grammar>
- struct fold_tree_
- : or_<
- transform::fold<
- nary_expr<Tag, vararg<fold_tree_<Tag, Grammar> > >
- >
- , Grammar
- >
- {};
-
- template<typename Tag, typename Grammar>
- struct reverse_fold_tree_
- : or_<
- transform::reverse_fold<
- nary_expr<Tag, vararg<reverse_fold_tree_<Tag, Grammar> > >
- >
- , Grammar
- >
- {};
- }
 
- /// fold_tree
- ///
- template<typename Tag, typename Grammar, typename State>
- struct fold_tree
- : transform::fold<
- nary_expr<Tag, vararg<detail::fold_tree_<Tag, Grammar> > >
- , State
- >
- {};
+ namespace detail
+ {
 
- /// reverse_fold_tree
- ///
- template<typename Tag, typename Grammar, typename State>
- struct reverse_fold_tree
- : transform::reverse_fold<
- nary_expr<Tag, vararg<detail::reverse_fold_tree_<Tag, Grammar> > >
- , State
- >
- {};
+ template<typename Grammar, typename Fun>
+ struct fold_tree_
+ : or_<
+ when<Grammar, fold<_, _state, fold_tree_<Grammar, Fun> > >
+ , when<_, Fun>
+ >
+ {};
 
-}}}
+ template<typename Grammar, typename Fun>
+ struct reverse_fold_tree_
+ : or_<
+ when<Grammar, reverse_fold<_, _state, reverse_fold_tree_<Grammar, Fun> > >
+ , when<_, Fun>
+ >
+ {};
+ }
 
-namespace boost { namespace proto
-{
- template<typename Tag, typename Grammar, typename State>
- struct is_transform<transform::fold_tree<Tag, Grammar, State> >
+ template<typename Sequence, typename State0, typename Fun>
+ struct fold_tree
+ : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ {
+ typedef fold<
+ Sequence
+ , State0
+ , detail::fold_tree_<
+ nary_expr<typename Expr::proto_tag, vararg<_> >
+ , Fun
+ >
+ > impl;
+
+ typedef typename impl::template result<void(Expr, State, Visitor)>::type type;
+ };
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<fold_tree(Expr const &, State const &, Visitor &)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ typedef typename result<void(Expr, State, Visitor)>::impl impl;
+ return impl()(expr, state, visitor);
+ }
+ };
+
+ template<typename Sequence, typename State0, typename Fun>
+ struct reverse_fold_tree
+ : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ {
+ typedef reverse_fold<
+ Sequence
+ , State0
+ , detail::reverse_fold_tree_<
+ nary_expr<typename Expr::proto_tag, vararg<_> >
+ , Fun
+ >
+ > impl;
+
+ typedef typename impl::template result<void(Expr, State, Visitor)>::type type;
+ };
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ typedef typename result<void(Expr, State, Visitor)>::impl impl;
+ return impl()(expr, state, visitor);
+ }
+ };
+ }
+
+ template<typename Sequence, typename State0, typename Fun>
+ struct is_callable<transform::fold_tree<Sequence, State0, Fun> >
       : mpl::true_
     {};
 
- template<typename Tag, typename Grammar, typename State>
- struct is_transform<transform::reverse_fold_tree<Tag, Grammar, State> >
+ template<typename Sequence, typename State0, typename Fun>
+ struct is_callable<transform::reverse_fold_tree<Sequence, State0, Fun> >
       : mpl::true_
     {};
 }}

Deleted: trunk/boost/xpressive/proto/transform/function.hpp
==============================================================================
--- trunk/boost/xpressive/proto/transform/function.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
+++ (empty file)
@@ -1,115 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-/// \file function.hpp
-/// Proto transforms for applying a function object.
-//
-// Copyright 2007 Eric Niebler. 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)
-
-#ifndef BOOST_PROTO_TRANSFORM_FUNCTION_HPP_EAN_06_23_2007
-#define BOOST_PROTO_TRANSFORM_FUNCTION_HPP_EAN_06_23_2007
-
-#include <boost/xpressive/proto/detail/prefix.hpp>
-#include <boost/utility/result_of.hpp>
-#include <boost/xpressive/proto/proto_fwd.hpp>
-#include <boost/xpressive/proto/detail/suffix.hpp>
-
-namespace boost { namespace proto { namespace transform
-{
-
- // Apply a function object, passing just Expr
- template<typename Grammar, typename Function1>
- struct function1
- : Grammar
- {
- function1() {}
-
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : boost::result_of<
- Function1(
- typename Grammar::template apply<Expr, State, Visitor>::type
- )
- >
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return Function1()(Grammar::call(expr, state, visitor));
- }
- };
-
- // Apply a function object, passing Expr and State
- template<typename Grammar, typename Function2>
- struct function2
- : Grammar
- {
- function2() {}
-
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : boost::result_of<
- Function2(
- typename Grammar::template apply<Expr, State, Visitor>::type
- , State const &
- )
- >
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return Function2()(Grammar::call(expr, state, visitor), state);
- }
- };
-
- // Apply a function object, passing Expr, State and Visitor
- template<typename Grammar, typename Function3>
- struct function3
- : Grammar
- {
- function3() {}
-
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : boost::result_of<
- Function3(
- typename Grammar::template apply<Expr, State, Visitor>::type
- , State const &
- , Visitor &
- )
- >
- {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return Function3()(Grammar::call(expr, state, visitor), state, visitor);
- }
- };
-
-}}}
-
-namespace boost { namespace proto
-{
- template<typename Grammar, typename Function1>
- struct is_transform<transform::function1<Grammar, Function1> >
- : mpl::true_
- {};
-
- template<typename Grammar, typename Function2>
- struct is_transform<transform::function2<Grammar, Function2> >
- : mpl::true_
- {};
-
- template<typename Grammar, typename Function3>
- struct is_transform<transform::function3<Grammar, Function3> >
- : mpl::true_
- {};
-}}
-
-#endif

Deleted: trunk/boost/xpressive/proto/transform/list.hpp
==============================================================================
--- trunk/boost/xpressive/proto/transform/list.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
+++ (empty file)
@@ -1,87 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-/// \file list.hpp
-/// A special-purpose proto transform for putting things into a
-/// fusion::cons<> list.
-//
-// Copyright 2007 Eric Niebler. 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)
-
-#ifndef BOOST_PROTO_TRANSFORM_LIST_HPP_EAN_12_16_2006
-#define BOOST_PROTO_TRANSFORM_LIST_HPP_EAN_12_16_2006
-
-#include <boost/xpressive/proto/detail/prefix.hpp>
-#include <boost/version.hpp>
-#if BOOST_VERSION < 103500
-# include <boost/spirit/fusion/sequence/cons.hpp>
-#else
-# include <boost/fusion/include/cons.hpp>
-#endif
-#include <boost/xpressive/proto/proto_fwd.hpp>
-#include <boost/xpressive/proto/detail/suffix.hpp>
-
-namespace boost { namespace proto { namespace transform
-{
-
- // A list transform, that puts elements into a fusion cons-list
- template<typename Grammar>
- struct list
- : Grammar
- {
- list() {}
-
- template<typename Expr, typename State, typename Visitor>
- struct apply
- {
- typedef fusion::cons<
- typename Grammar::template apply<Expr, State, Visitor>::type
- , State
- > type;
- };
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return typename apply<Expr, State, Visitor>::type
- (Grammar::call(expr, state, visitor), state);
- }
- };
-
- // A tail transform, that returns the tail of a fusion cons-list
- template<typename Grammar>
- struct tail
- : Grammar
- {
- tail() {}
-
- template<typename Expr, typename State, typename Visitor>
- struct apply
- {
- typedef typename Grammar::template apply<Expr, State, Visitor>::type::cdr_type type;
- };
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return Grammar::call(expr, state, visitor).cdr;
- }
- };
-
-}}}
-
-namespace boost { namespace proto
-{
- template<typename Grammar>
- struct is_transform<transform::list<Grammar> >
- : mpl::true_
- {};
-
- template<typename Grammar>
- struct is_transform<transform::tail<Grammar> >
- : mpl::true_
- {};
-}}
-
-#endif

Added: trunk/boost/xpressive/proto/transform/make.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/xpressive/proto/transform/make.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -0,0 +1,308 @@
+#ifndef BOOST_PP_IS_ITERATING
+ ///////////////////////////////////////////////////////////////////////////////
+ /// \file make.hpp
+ /// Contains definition of the make<> transform.
+ //
+ // Copyright 2007 Eric Niebler. 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)
+
+ #ifndef BOOST_PROTO_TRANSFORM_MAKE_HPP_EAN_12_02_2007
+ #define BOOST_PROTO_TRANSFORM_MAKE_HPP_EAN_12_02_2007
+
+ #include <boost/xpressive/proto/detail/prefix.hpp>
+ #include <boost/mpl/aux_/has_type.hpp>
+ #include <boost/mpl/aux_/template_arity.hpp>
+ #include <boost/mpl/aux_/lambda_arity_param.hpp>
+ #include <boost/utility/result_of.hpp>
+ #include <boost/xpressive/proto/proto_fwd.hpp>
+ #include <boost/xpressive/proto/traits.hpp>
+ #include <boost/xpressive/proto/args.hpp>
+ #include <boost/xpressive/proto/detail/as_lvalue.hpp>
+ #include <boost/xpressive/proto/detail/suffix.hpp>
+
+ namespace boost { namespace proto
+ {
+
+ namespace transform
+ {
+ namespace detail
+ {
+ using proto::detail::as_lvalue;
+
+ template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_ARITY, typename A, void)>
+ struct typelist
+ {
+ typedef void type;
+ };
+
+ template<typename T, bool HasType = mpl::aux::has_type<T>::value>
+ struct nested_type
+ {
+ typedef typename T::type type;
+ };
+
+ template<typename T>
+ struct nested_type<T, false>
+ {
+ typedef T type;
+ };
+
+ template<typename T, typename Args, typename EnableIf = void>
+ struct nested_type_if
+ : nested_type<T>
+ {};
+
+ template<typename R, typename Expr, typename State, typename Visitor
+ , bool IsTransform = is_callable<R>::value
+ >
+ struct make_if_;
+
+ template<typename R, typename Expr, typename State, typename Visitor
+ BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(long Arity = mpl::aux::template_arity<R>::value)
+ >
+ struct make_
+ {
+ typedef R type;
+ typedef void not_applied_;
+ };
+
+ template<typename R, typename Expr, typename State, typename Visitor>
+ struct make_if_<R, Expr, State, Visitor, false>
+ : make_<R, Expr, State, Visitor>
+ {};
+
+ #if BOOST_WORKAROUND(__GNUC__, == 3)
+ // work around GCC bug
+ template<typename Tag, typename Args, long N, typename Expr, typename State, typename Visitor>
+ struct make_if_<expr<Tag, Args, N>, Expr, State, Visitor, false>
+ {
+ typedef expr<Tag, Args, N> type;
+ typedef void not_applied_;
+ };
+ #endif
+
+ template<typename R, typename Expr, typename State, typename Visitor>
+ struct make_if_<R, Expr, State, Visitor, true>
+ : boost::result_of<R(Expr, State, Visitor)>
+ {};
+
+ template<typename Type, bool IsAggregate = is_aggregate<Type>::value>
+ struct construct_
+ {
+ typedef Type result_type;
+
+ Type operator ()() const
+ {
+ return Type();
+ }
+
+ #define TMP(Z, N, DATA) \
+ template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)> \
+ Type operator ()(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, &a)) const \
+ { \
+ return Type(BOOST_PP_ENUM_PARAMS_Z(Z, N, a)); \
+ }
+ BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), TMP, ~)
+ #undef TMP
+ };
+
+ template<typename Type>
+ struct construct_<Type, true>
+ {
+ typedef Type result_type;
+
+ Type operator ()() const
+ {
+ return Type();
+ }
+
+ #define TMP(Z, N, DATA) \
+ template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)> \
+ Type operator ()(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, &a)) const \
+ { \
+ Type that = {BOOST_PP_ENUM_PARAMS_Z(Z, N, a)}; \
+ return that; \
+ }
+ BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), TMP, ~)
+ #undef TMP
+ };
+
+ template<typename T, typename A, long N>
+ struct construct_<expr<T, A, N>, true>
+ {
+ typedef expr<T, A, N> result_type;
+
+ #define TMP(Z, N, DATA) \
+ template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)> \
+ result_type operator ()(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, &a)) const \
+ { \
+ return result_type::make(BOOST_PP_ENUM_PARAMS_Z(Z, N, a)); \
+ }
+ BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), TMP, ~)
+ #undef TMP
+ };
+
+ #define TMP(Z, N, DATA) \
+ template<typename Type BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, typename A)> \
+ Type construct(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, &a)) \
+ { \
+ return construct_<Type>()(BOOST_PP_ENUM_PARAMS_Z(Z, N, a)); \
+ }
+ BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, TMP, ~)
+ #undef TMP
+ }
+
+ template<typename Fun>
+ struct make : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : detail::make_<Fun, Expr, State, Visitor>
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ typedef typename result<void(Expr, State, Visitor)>::type result_type;
+ return result_type();
+ }
+ };
+
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/transform/make.hpp>))
+ #include BOOST_PP_ITERATE()
+ }
+
+ template<typename Fun>
+ struct is_callable<transform::make<Fun> >
+ : mpl::true_
+ {};
+
+ }}
+
+ #endif
+
+#else
+
+ #define N BOOST_PP_ITERATION()
+
+ namespace detail
+ {
+ #if N > 0
+ template<typename T BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+ struct nested_type_if<
+ T
+ , typelist<BOOST_PP_ENUM_PARAMS(N, A)>
+ , typename typelist<
+ BOOST_PP_ENUM_BINARY_PARAMS(N, typename A, ::not_applied_ BOOST_PP_INTERCEPT)
+ >::type
+ >
+ {
+ typedef T type;
+ typedef void not_applied_;
+ };
+
+ template<
+ template<BOOST_PP_ENUM_PARAMS(N, typename BOOST_PP_INTERCEPT)> class R
+ BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)
+ , typename Expr, typename State, typename Visitor
+ >
+ struct make_<R<BOOST_PP_ENUM_PARAMS(N, A)>, Expr, State, Visitor
+ BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(N)
+ >
+ : nested_type_if<
+ #define TMP0(Z, M, DATA) make_if_<BOOST_PP_CAT(A, M), Expr, State, Visitor>
+ #define TMP1(Z, M, DATA) typename TMP0(Z, M, DATA) ::type
+ R<BOOST_PP_ENUM(N, TMP1, ~)>
+ , typelist<BOOST_PP_ENUM(N, TMP0, ~) >
+ #undef TMP0
+ #undef TMP1
+ >
+ {};
+ #endif
+
+ template<
+ typename R
+ BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)
+ , typename Expr, typename State, typename Visitor
+ >
+ struct make_if_<R(BOOST_PP_ENUM_PARAMS(N, A)), Expr, State, Visitor, false>
+ : when<_, R(BOOST_PP_ENUM_PARAMS(N, A))>::template result<void(Expr, State, Visitor)>
+ {};
+
+ template<
+ typename R
+ BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)
+ , typename Expr, typename State, typename Visitor
+ >
+ struct make_if_<R(*)(BOOST_PP_ENUM_PARAMS(N, A)), Expr, State, Visitor, false>
+ : when<_, R(BOOST_PP_ENUM_PARAMS(N, A))>::template result<void(Expr, State, Visitor)>
+ {};
+
+ template<typename T, typename A>
+ struct construct_<expr<T, A, N>, true>
+ {
+ typedef expr<T, A, N> result_type;
+
+ template<BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), typename A)>
+ result_type operator ()(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_MAX(N, 1), A, &a)) const
+ {
+ return result_type::make(BOOST_PP_ENUM_PARAMS(BOOST_PP_MAX(N, 1), a));
+ }
+ };
+ }
+
+ template<typename Return BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+ struct make<Return(BOOST_PP_ENUM_PARAMS(N, A))> : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : detail::make_<Return, Expr, State, Visitor>
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ typedef typename result<void(Expr, State, Visitor)>::type result_type;
+ return detail::construct<result_type>(
+ #define TMP(Z, M, DATA) detail::as_lvalue(when<_, BOOST_PP_CAT(A, M)>()(expr, state, visitor))
+ BOOST_PP_ENUM(N, TMP, DATA)
+ #undef TMP
+ );
+ }
+ };
+
+ #if BOOST_WORKAROUND(__GNUC__, == 3)
+ // work around GCC bug
+ template<typename Tag, typename Args, long Arity BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+ struct make<expr<Tag, Args, Arity>(BOOST_PP_ENUM_PARAMS(N, A))> : callable
+ {
+ template<typename Sig>
+ struct result
+ {
+ typedef expr<Tag, Args, Arity> type;
+ };
+
+ template<typename Expr, typename State, typename Visitor>
+ expr<Tag, Args, Arity> operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ return proto::expr<Tag, Args, Arity>::make(
+ #define TMP(Z, M, DATA) detail::as_lvalue(when<_, BOOST_PP_CAT(A, M)>()(expr, state, visitor))
+ BOOST_PP_ENUM(N, TMP, DATA)
+ #undef TMP
+ );
+ }
+ };
+ #endif
+
+ #undef N
+
+#endif

Modified: trunk/boost/xpressive/proto/transform/pass_through.hpp
==============================================================================
--- trunk/boost/xpressive/proto/transform/pass_through.hpp (original)
+++ trunk/boost/xpressive/proto/transform/pass_through.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -28,11 +28,11 @@
 
             #define BOOST_PROTO_DEFINE_TRANSFORM_TYPE(z, n, data)\
                 typename Grammar::BOOST_PP_CAT(proto_arg, n)\
- ::template apply<typename Expr::BOOST_PP_CAT(proto_arg, n)::proto_base_expr, State, Visitor>\
+ ::template result<void(typename Expr::BOOST_PP_CAT(proto_arg, n)::proto_base_expr, State, Visitor)>\
                 ::type
 
             #define BOOST_PROTO_DEFINE_TRANSFORM(z, n, data)\
- Grammar::BOOST_PP_CAT(proto_arg, n)::call(\
+ typename Grammar::BOOST_PP_CAT(proto_arg, n)()(\
                     expr.BOOST_PP_CAT(arg, n).proto_base(), state, visitor\
                 )
 
@@ -54,46 +54,48 @@
             };
         } // namespace detail
 
- template<typename Grammar>
- struct pass_through
- : Grammar
- {
- pass_through() {}
-
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : detail::pass_through_impl<
- Grammar
- , typename Expr::proto_base_expr
- , State
- , Visitor
- , Expr::proto_arity::value
- >
- {};
+ //template<typename Grammar>
+ //struct pass_through
+ // : Grammar
+ //{
+ // pass_through() {}
+
+ // template<typename Expr, typename State, typename Visitor>
+ // struct apply
+ // : detail::pass_through_impl<
+ // Grammar
+ // , typename Expr::proto_base_expr
+ // , State
+ // , Visitor
+ // , Expr::proto_arity::value
+ // >
+ // {};
+
+ // template<typename Expr, typename State, typename Visitor>
+ // static typename apply<Expr, State, Visitor>::type
+ // call(Expr const &expr, State const &state, Visitor &visitor)
+ // {
+ // return apply<Expr, State, Visitor>::call(expr.proto_base(), state, visitor);
+ // }
+ //};
 
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return apply<Expr, State, Visitor>::call(expr.proto_base(), state, visitor);
- }
- };
     } // namespace transform
 
- template<typename Grammar>
- struct is_transform<transform::pass_through<Grammar> >
- : mpl::true_
- {};
+ //template<typename Grammar>
+ //struct is_transform<transform::pass_through<Grammar> >
+ // : mpl::true_
+ //{};
 
     namespace has_transformns_
     {
         template<typename Grammar>
         struct has_pass_through_transform
         {
- has_pass_through_transform() {}
+ template<typename Sig>
+ struct result;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
               : transform::detail::pass_through_impl<
                     Grammar
                   , typename Expr::proto_base_expr
@@ -104,10 +106,10 @@
             {};
 
             template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
             {
- return apply<Expr, State, Visitor>::call(expr.proto_base(), state, visitor);
+ return result<void(Expr, State, Visitor)>::call(expr.proto_base(), state, visitor);
             }
         };
 

Added: trunk/boost/xpressive/proto/transform/when.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/xpressive/proto/transform/when.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -0,0 +1,86 @@
+#ifndef BOOST_PP_IS_ITERATING
+ ///////////////////////////////////////////////////////////////////////////////
+ /// \file when.hpp
+ /// Definition of when transform.
+ //
+ // Copyright 2007 Eric Niebler. 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)
+
+ #ifndef BOOST_PROTO_TRANSFORM_WHEN_HPP_EAN_10_29_2007
+ #define BOOST_PROTO_TRANSFORM_WHEN_HPP_EAN_10_29_2007
+
+ #include <boost/xpressive/proto/detail/prefix.hpp>
+ #include <boost/mpl/if.hpp>
+ #include <boost/xpressive/proto/proto_fwd.hpp>
+ #include <boost/xpressive/proto/traits.hpp>
+ #include <boost/xpressive/proto/transform/call.hpp>
+ #include <boost/xpressive/proto/transform/make.hpp>
+ #include <boost/xpressive/proto/detail/suffix.hpp>
+
+ namespace boost { namespace proto { namespace transform
+ {
+ // Simple transform, takes a raw transform and
+ // applies it directly.
+ template<typename Grammar, typename Fun>
+ struct when
+ : Fun
+ {
+ typedef typename Grammar::proto_base_expr proto_base_expr;
+ };
+
+ template<typename Grammar, typename Fun>
+ struct when<Grammar, Fun *>
+ : when<Grammar, Fun>
+ {};
+
+ template<typename Fun>
+ struct otherwise
+ : when<_, Fun>
+ {};
+
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/transform/when.hpp>))
+ #include BOOST_PP_ITERATE()
+
+ }}} // namespace boost::proto::transform
+
+ #endif
+
+#else
+
+ #define N BOOST_PP_ITERATION()
+
+ template<typename Grammar, typename Return BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+ struct when<Grammar, Return(BOOST_PP_ENUM_PARAMS(N, A))>
+ : callable
+ {
+ typedef Return when_function_type_(BOOST_PP_ENUM_PARAMS(N, A));
+ typedef typename Grammar::proto_base_expr proto_base_expr;
+
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : mpl::if_<
+ is_callable<Return>
+ , call<when_function_type_> // "Return" is a function to call
+ , make<when_function_type_> // "Return" is an object to construct
+ >::type::template result<void(Expr, State, Visitor)>
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<void(Expr, State, Visitor)>::type
+ operator ()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ return typename mpl::if_<
+ is_callable<Return>
+ , call<when_function_type_>
+ , make<when_function_type_>
+ >::type()(expr, state, visitor);
+ }
+ };
+
+ #undef N
+
+#endif

Modified: trunk/boost/xpressive/regex_actions.hpp
==============================================================================
--- trunk/boost/xpressive/regex_actions.hpp (original)
+++ trunk/boost/xpressive/regex_actions.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -40,7 +40,7 @@
 
 // Doxygen can't handle proto :-(
 #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED
-# include <boost/xpressive/proto/transform/fold.hpp>
+# include <boost/xpressive/proto/transform.hpp>
 # include <boost/xpressive/detail/core/matcher/action_matcher.hpp>
 #endif
 
@@ -86,21 +86,15 @@
         struct check_tag
         {};
 
- template<typename Grammar>
- struct BindArg
- : Grammar
+ struct BindArg : proto::callable
         {
- template<typename Expr, typename State, typename Visitor>
- struct apply
- {
- typedef State type;
- };
+ typedef int result_type;
 
- template<typename Expr, typename State, typename Visitor>
- static State call(Expr const &expr, State const &state, Visitor &visitor)
+ template<typename Visitor, typename Expr>
+ int operator ()(Visitor &visitor, Expr const &expr) const
             {
                 visitor.let(expr);
- return state;
+ return 0;
             }
         };
 
@@ -108,10 +102,15 @@
         {};
 
         struct BindArgs
- : boost::proto::transform::fold<
- boost::proto::function<
- boost::proto::transform::state<boost::proto::terminal<let_tag> >
- , boost::proto::vararg< BindArg< boost::proto::assign<boost::proto::_, boost::proto::_> > >
+ : proto::when<
+ // let(_a = b, _c = d)
+ proto::function<
+ proto::terminal<let_tag>
+ , proto::vararg<proto::assign<proto::_, proto::_> >
+ >
+ , proto::function<
+ proto::_state // no-op
+ , proto::vararg<proto::call<BindArg(proto::_visitor, proto::_)> >
>
>
         {};
@@ -130,7 +129,7 @@
         template<typename Args, typename BidiIter>
         void bind_args(let_<Args> const &args, match_results<BidiIter> &what)
         {
- BindArgs::call(args, 0, what);
+ BindArgs()(args, 0, what);
         }
     }
 

Modified: trunk/boost/xpressive/regex_compiler.hpp
==============================================================================
--- trunk/boost/xpressive/regex_compiler.hpp (original)
+++ trunk/boost/xpressive/regex_compiler.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -502,10 +502,10 @@
             return detail::make_assert_end_line<BidiIter>(this->traits_.flags(), this->rxtraits());
 
         case token_assert_word_boundary:
- return detail::make_assert_word<BidiIter>(detail::word_boundary<true>(), this->rxtraits());
+ return detail::make_assert_word<BidiIter>(detail::word_boundary<mpl::true_>(), this->rxtraits());
 
         case token_assert_not_word_boundary:
- return detail::make_assert_word<BidiIter>(detail::word_boundary<false>(), this->rxtraits());
+ return detail::make_assert_word<BidiIter>(detail::word_boundary<mpl::false_>(), this->rxtraits());
 
         case token_assert_word_begin:
             return detail::make_assert_word<BidiIter>(detail::word_begin(), this->rxtraits());

Modified: trunk/boost/xpressive/regex_primitives.hpp
==============================================================================
--- trunk/boost/xpressive/regex_primitives.hpp (original)
+++ trunk/boost/xpressive/regex_primitives.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -22,7 +22,7 @@
 // Doxygen can't handle proto :-(
 #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED
 # include <boost/xpressive/proto/proto.hpp>
-# include <boost/xpressive/proto/transform/arg.hpp>
+# include <boost/xpressive/proto/transform.hpp>
 # include <boost/xpressive/detail/core/icase.hpp>
 # include <boost/xpressive/detail/static/compile.hpp>
 # include <boost/xpressive/detail/static/modifier.hpp>
@@ -31,7 +31,7 @@
 namespace boost { namespace xpressive { namespace detail
 {
 
- typedef assert_word_placeholder<word_boundary<true> > assert_word_boundary;
+ typedef assert_word_placeholder<word_boundary<mpl::true_> > assert_word_boundary;
     typedef assert_word_placeholder<word_begin> assert_word_begin;
     typedef assert_word_placeholder<word_end> assert_word_end;
 
@@ -52,33 +52,35 @@
         using proto::extends<basic_mark_tag, mark_tag>::operator =;
     };
 
- template<typename Grammar>
- struct push_back_sub
- : proto::transform::identity<Grammar>
+ struct push_back : proto::callable
     {
- template<typename Sub>
- static int to_sub(Sub const &sub, proto::tag::terminal)
- {
- return proto::arg(sub).mark_number_;
- }
+ typedef int result_type;
 
- template<typename Sub>
- static int to_sub(Sub const &, proto::tag::negate)
+ template<typename Subs>
+ int operator ()(Subs &subs, int i) const
         {
- return -1;
+ subs.push_back(i);
+ return i;
         }
+ };
+
+ struct mark_number2 : proto::callable
+ {
+ typedef int result_type;
 
- template<typename Expr, typename State, typename Visitor>
- static Expr const &call(Expr const &expr, State const &, Visitor &subs)
+ template<typename Expr>
+ int operator ()(Expr const &expr) const
         {
- subs.push_back(push_back_sub::to_sub(expr, typename Expr::proto_tag()));
- return expr;
+ return expr.mark_number_;
         }
     };
 
     // s1 or -s1
     struct SubMatch
- : push_back_sub<proto::or_<basic_mark_tag, proto::negate<basic_mark_tag > > >
+ : proto::or_<
+ proto::when<basic_mark_tag, push_back(proto::_visitor, mark_number2(proto::_arg)) >
+ , proto::when<proto::negate<basic_mark_tag>, push_back(proto::_visitor, mpl::int_<-1>()) >
+ >
     {};
 
     struct SubMatchList
@@ -93,7 +95,7 @@
     to_vector(Subs const &subs)
     {
         std::vector<int> subs_;
- SubMatchList::call(subs, 0, subs_);
+ SubMatchList()(subs, 0, subs_);
         return subs_;
     }
 

Modified: trunk/boost/xpressive/xpressive_typeof.hpp
==============================================================================
--- trunk/boost/xpressive/xpressive_typeof.hpp (original)
+++ trunk/boost/xpressive/xpressive_typeof.hpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -38,7 +38,7 @@
 BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::word_end)
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::generic_quant_tag, (unsigned int)(unsigned int))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::basic_regex, (typename))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::word_boundary, (bool))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::word_boundary, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::value, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::reference, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::local, (typename))
@@ -80,28 +80,28 @@
 BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::attr_end_matcher)
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::assert_bol_matcher, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::assert_eol_matcher, (typename))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::literal_matcher, (typename)(bool)(bool))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::string_matcher, (typename)(bool))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::charset_matcher, (typename)(bool)(typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::literal_matcher, (typename)(typename)(typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::string_matcher, (typename)(typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::charset_matcher, (typename)(typename)(typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::logical_newline_matcher, (typename))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::mark_matcher, (typename)(bool))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::repeat_end_matcher, (bool))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::mark_matcher, (typename)(typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::repeat_end_matcher, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::alternate_matcher, (typename)(typename))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::optional_matcher, (typename)(bool))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::optional_mark_matcher, (typename)(bool))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::simple_repeat_matcher, (typename)(bool))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::optional_matcher, (typename)(typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::optional_mark_matcher, (typename)(typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::simple_repeat_matcher, (typename)(typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::regex_byref_matcher, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::regex_matcher, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::posix_charset_matcher, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::assert_word_matcher, (typename)(typename))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::range_matcher, (typename)(bool))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::range_matcher, (typename)(typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::keeper_matcher, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::lookahead_matcher, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::lookbehind_matcher, (typename))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::set_matcher, (typename)(int))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::set_matcher, (typename)(typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::predicate_matcher, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::action_matcher, (typename))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::attr_matcher, (typename)(typename)(bool))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::attr_matcher, (typename)(typename)(typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::attr_begin_matcher, (typename))
 
 ///////////////////////////////////////////////////////////////////////////////

Modified: trunk/libs/xpressive/proto/example/calc1.cpp
==============================================================================
--- trunk/libs/xpressive/proto/example/calc1.cpp (original)
+++ trunk/libs/xpressive/proto/example/calc1.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -36,7 +36,7 @@
 
     // Handle the evaluation of the placeholder terminals
     template<typename I>
- double operator()(proto::tag::terminal, arg<I>) const
+ double operator ()(proto::tag::terminal, arg<I>) const
     {
         return d[ I() - 1 ];
     }
@@ -60,7 +60,7 @@
     // Displays "6"
     std::cout << evaluate( _1 * _2, 3.0, 2.0 ) << std::endl;
 
- // Displays "1.5"
+ // Displays "0.5"
     std::cout << evaluate( (_1 - _2) / _2, 3.0, 2.0 ) << std::endl;
 
     return 0;

Modified: trunk/libs/xpressive/proto/example/calc2.cpp
==============================================================================
--- trunk/libs/xpressive/proto/example/calc2.cpp (original)
+++ trunk/libs/xpressive/proto/example/calc2.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -5,7 +5,7 @@
 //
 // This example enhances the simple arithmetic expression evaluator
 // in calc1.cpp by using proto::extends to make arithemetic
-// expressions immediately evaluatable with operator(), a-la a
+// expressions immediately evaluatable with operator (), a-la a
 // function object
 
 #include <iostream>
@@ -17,7 +17,7 @@
 // Will be used to define the placeholders _1 and _2
 template<typename I> struct arg {};
 
-// For expressions in the calculator domain, operator()
+// For expressions in the calculator domain, operator ()
 // will be special; it will evaluate the expression.
 struct calculator_domain;
 
@@ -40,14 +40,14 @@
 
     // Handle the evaluation of the placeholder terminals
     template<typename I>
- double operator()(proto::tag::terminal, arg<I>) const
+ double operator ()(proto::tag::terminal, arg<I>) const
     {
         return d[ I() - 1 ];
     }
 };
 
 // Wrap all calculator expressions in this type, which defines
-// operator() to evaluate the expression.
+// operator () to evaluate the expression.
 template<typename Expr>
 struct calculator_expression
   : proto::extends<Expr, calculator_expression<Expr>, calculator_domain>
@@ -55,27 +55,27 @@
     typedef
         proto::extends<Expr, calculator_expression<Expr>, calculator_domain>
     base_type;
-
+
     explicit calculator_expression(Expr const &expr = Expr())
       : base_type(expr)
     {}
 
- using base_type::operator=;
+ using base_type::operator =;
 
- // Override operator() to evaluate the expression
- double operator()() const
+ // Override operator () to evaluate the expression
+ double operator ()() const
     {
         calculator_context const ctx;
         return proto::eval(*this, ctx);
     }
 
- double operator()(double d1) const
+ double operator ()(double d1) const
     {
         calculator_context const ctx(d1);
         return proto::eval(*this, ctx);
     }
 
- double operator()(double d1, double d2) const
+ double operator ()(double d1, double d2) const
     {
         calculator_context const ctx(d1, d2);
         return proto::eval(*this, ctx);
@@ -100,7 +100,7 @@
     // Displays "6"
     std::cout << ( _1 * _2 )( 3.0, 2.0 ) << std::endl;
 
- // Displays "1.5"
+ // Displays "0.5"
     std::cout << ( (_1 - _2) / _2 )( 3.0, 2.0 ) << std::endl;
 
     return 0;

Modified: trunk/libs/xpressive/proto/example/calc3.cpp
==============================================================================
--- trunk/libs/xpressive/proto/example/calc3.cpp (original)
+++ trunk/libs/xpressive/proto/example/calc3.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -5,7 +5,7 @@
 //
 // This example enhances the arithmetic expression evaluator
 // in calc2.cpp by using a proto transform to calculate the
-// number of arguments an expression requires and using a
+// number of arguments an expression requires and using a
 // compile-time assert to guarantee that the right number of
 // arguments are actually specified.
 
@@ -15,61 +15,14 @@
 #include <boost/mpl/min_max.hpp>
 #include <boost/xpressive/proto/proto.hpp>
 #include <boost/xpressive/proto/context.hpp>
-#include <boost/xpressive/proto/transform/arg.hpp>
-#include <boost/xpressive/proto/transform/fold.hpp>
-#include <boost/xpressive/proto/transform/apply.hpp>
+#include <boost/xpressive/proto/transform.hpp>
 using namespace boost;
 
 // Will be used to define the placeholders _1 and _2
-template<typename I> struct arg { typedef I arity; };
-
-// A meta-function for getting a placeholder terminal's arity.
-template<typename Arg>
-struct arg_arity
-{
- typedef typename Arg::arity type;
-};
-
-// A custom transform that fetches the arity of a placeholder terminal
-template<typename Grammar>
-struct placeholder_arity
- : Grammar
-{
- template<typename Expr, typename, typename>
- struct apply
- : arg_arity<typename proto::result_of::arg<Expr>::type>
- {};
-
- //// If this transform had a runtime counterpart, it would look like this:
- //template<typename Expr, typename State, typename Visitor>
- //static typename apply<Expr, State, Visitor>::type
- //call(Expr const &expr, State const &state, Visitor &visitor)
- //{
- // ... do stuff ...
- //}
-};
-
-// A custom transforms for calculating the max arity of a calculator expression
-template<typename Grammar>
-struct max_arity
- : Grammar
-{
- template<typename Expr, typename State, typename Visitor>
- struct apply
- {
- // Calculate the arity of the current expression.
- typedef typename Grammar::template apply<Expr, State, Visitor>::type arity;
- // The old maximum is passed along in the State parameter by
- // proto::transform::fold<> (see below). The new maximum is the
- // larger of the old maximum and the arity we just calculated.
- typedef typename mpl::max<arity, State>::type type;
- };
-
- // As with placeholder_arity<> above, placeholder_arity<> has no need
- // for a call() member function.
-};
+template<typename I> struct arg : I {};
 
 using proto::_;
+using namespace proto::transform;
 
 // This grammar basically says that a calculator expression is one of:
 // - A placeholder terminal
@@ -79,41 +32,18 @@
 // expression arity for each of the three cases.
 struct CalculatorGrammar
   : proto::or_<
- // placeholders have a non-zero arity ...
- placeholder_arity< proto::terminal< arg<_> > >
 
- //// This accomplishes the same thing without the need to
- //// define a separate placeholder_arity<> transform, but
- //// is a little more cryptic.
- //proto::transform::apply1<
- // proto::terminal< arg<_> >
- // , arg_arity< proto::result_of::arg<mpl::_> >
- //>
+ // placeholders have a non-zero arity ...
+ when< proto::terminal< arg<_> >, _arg >
 
         // Any other terminals have arity 0 ...
- , proto::transform::always< proto::terminal<_>, mpl::int_<0> >
+ , when< proto::terminal<_>, mpl::int_<0>() >
+
         // For any non-terminals, find the arity of the children and
         // take the maximum. This is recursive.
- , proto::transform::fold<
- // This matches any non-terminal for which the children
- // are themselves calculator expressions.
- proto::nary_expr<_, proto::vararg< max_arity< CalculatorGrammar > > >
-
- //// This accomplishes the same thing without the need to
- //// define a separate max_arity<> transform, but is a little
- //// more cryptic.
- //proto::nary_expr<
- // _
- // , proto::vararg<
- // // Here, mpl::_1 will be replaced with the result of applying
- // // the CalculatorGrammar transform (i.e., the arity of the
- // // child node), and mpl::_2 will be replaced with the State of
- // // the transformation so far (i.e., the maximum arity found so
- // // far).
- // proto::transform::apply2<CalculatorGrammar, mpl::max<mpl::_1, mpl::_2> >
- // >
- //>
- >
+ , when< proto::nary_expr<_, proto::vararg<_> >
+ , fold<_, mpl::int_<0>(), mpl::max<CalculatorGrammar, _state>() > >
+
>
 {};
 
@@ -122,10 +52,10 @@
 // is not used, is mpl::void_.
 template<typename Expr>
 struct calculator_arity
- : CalculatorGrammar::apply<Expr, mpl::int_<0>, mpl::void_>
+ : boost::result_of<CalculatorGrammar(Expr, mpl::int_<0>, mpl::void_)>
 {};
 
-// For expressions in the calculator domain, operator()
+// For expressions in the calculator domain, operator ()
 // will be special; it will evaluate the expression.
 struct calculator_domain;
 
@@ -148,14 +78,14 @@
 
     // Handle the evaluation of the placeholder terminals
     template<typename I>
- double operator()(proto::tag::terminal, arg<I>) const
+ double operator ()(proto::tag::terminal, arg<I>) const
     {
         return d[ I() - 1 ];
     }
 };
 
 // Wrap all calculator expressions in this type, which defines
-// operator() to evaluate the expression.
+// operator () to evaluate the expression.
 template<typename Expr>
 struct calculator_expression
   : proto::extends<Expr, calculator_expression<Expr>, calculator_domain>
@@ -163,15 +93,15 @@
     typedef
         proto::extends<Expr, calculator_expression<Expr>, calculator_domain>
     base_type;
-
+
     explicit calculator_expression(Expr const &expr = Expr())
       : base_type(expr)
     {}
 
- using base_type::operator=;
+ using base_type::operator =;
 
- // Override operator() to evaluate the expression
- double operator()() const
+ // Override operator () to evaluate the expression
+ double operator ()() const
     {
         // Assert that the expression has arity 0
         BOOST_MPL_ASSERT_RELATION(0, ==, calculator_arity<Expr>::type::value);
@@ -179,7 +109,7 @@
         return proto::eval(*this, ctx);
     }
 
- double operator()(double d1) const
+ double operator ()(double d1) const
     {
         // Assert that the expression has arity 1
         BOOST_MPL_ASSERT_RELATION(1, ==, calculator_arity<Expr>::type::value);
@@ -187,7 +117,7 @@
         return proto::eval(*this, ctx);
     }
 
- double operator()(double d1, double d2) const
+ double operator ()(double d1, double d2) const
     {
         // Assert that the expression has arity 2
         BOOST_MPL_ASSERT_RELATION(2, ==, calculator_arity<Expr>::type::value);
@@ -214,7 +144,7 @@
     // Displays "6"
     std::cout << ( _1 * _2 )( 3.0, 2.0 ) << std::endl;
 
- // Displays "1.5"
+ // Displays "0.5"
     std::cout << ( (_1 - _2) / _2 )( 3.0, 2.0 ) << std::endl;
 
     // This won't compile because the arity of the

Modified: trunk/libs/xpressive/proto/example/hello.cpp
==============================================================================
--- trunk/libs/xpressive/proto/example/hello.cpp (original)
+++ trunk/libs/xpressive/proto/example/hello.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -10,7 +10,7 @@
 #include <boost/typeof/std/ostream.hpp>
 using namespace boost;
 
-proto::terminal< std::ostream & >::type cout_ = { std::cout };
+proto::terminal< std::ostream & >::type cout_ = {std::cout};
 
 template< typename Expr >
 void evaluate( Expr const & expr )

Modified: trunk/libs/xpressive/proto/example/lazy_vector.cpp
==============================================================================
--- trunk/libs/xpressive/proto/example/lazy_vector.cpp (original)
+++ trunk/libs/xpressive/proto/example/lazy_vector.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -22,13 +22,13 @@
 using proto::_;
 
 // This grammar describes which lazy vector expressions
-// are allowed; namely, vector terminals and addition
+// are allowed; namely, vector terminals and addition
 // and subtraction of lazy vector expressions.
 struct LazyVectorGrammar
   : proto::or_<
         proto::terminal< std::vector<_> >
- , proto::plus< LazyVectorGrammar, LazyVectorGrammar>
- , proto::minus< LazyVectorGrammar, LazyVectorGrammar>
+ , proto::plus< LazyVectorGrammar, LazyVectorGrammar >
+ , proto::minus< LazyVectorGrammar, LazyVectorGrammar >
>
 {};
 
@@ -57,7 +57,7 @@
     {
         typedef typename proto::result_of::arg<Expr>::type::value_type result_type;
 
- result_type operator()( Expr const & expr, lazy_subscript_context & ctx ) const
+ result_type operator ()( Expr const & expr, lazy_subscript_context & ctx ) const
         {
             return proto::arg( expr )[ ctx.subscript_ ];
         }
@@ -67,7 +67,7 @@
 };
 
 // Here is the domain-specific expression wrapper, which overrides
-// operator[] to evaluate the expression using the lazy_subscript_context.
+// operator [] to evaluate the expression using the lazy_subscript_context.
 template<typename Expr>
 struct lazy_vector_expr
   : proto::extends<Expr, lazy_vector_expr<Expr>, lazy_vector_domain>

Modified: trunk/libs/xpressive/proto/example/mixed.cpp
==============================================================================
--- trunk/libs/xpressive/proto/example/mixed.cpp (original)
+++ trunk/libs/xpressive/proto/example/mixed.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -18,11 +18,13 @@
 #include <boost/xpressive/proto/proto.hpp>
 #include <boost/xpressive/proto/debug.hpp>
 #include <boost/xpressive/proto/context.hpp>
+#include <boost/xpressive/proto/transform.hpp>
 #include <boost/typeof/std/list.hpp>
 #include <boost/typeof/std/vector.hpp>
 #include <boost/typeof/std/complex.hpp>
 
 using namespace boost;
+using namespace proto::transform;
 using proto::_;
 
 template<typename Expr>
@@ -38,30 +40,24 @@
     Iter it;
 };
 
-template<typename Cont>
-iterator_wrapper<typename Cont::const_iterator> cbegin(Cont const &cont)
+struct begin : proto::callable
 {
- return iterator_wrapper<typename Cont::const_iterator>(cont.begin());
-}
-
-template<typename Grammar>
-struct begin
- : Grammar
-{
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : proto::terminal<
- iterator_wrapper<
- typename proto::result_of::arg<Expr>::type::const_iterator
- >
+ template<class Sig>
+ struct result;
+
+ template<class This, class Cont>
+ struct result<This(Cont)>
+ : proto::result_of::as_expr<
+ iterator_wrapper<typename remove_reference<Cont>::type::const_iterator>
>
     {};
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
+
+ template<typename Cont>
+ typename result<begin(Cont const &)>::type
+ operator ()(Cont const &cont) const
     {
- return proto::as_expr(cbegin(proto::arg(expr)));
+ iterator_wrapper<typename Cont::const_iterator> it(cont.begin());
+ return proto::as_expr(it);
     }
 };
 
@@ -69,10 +65,10 @@
 // begin iterators
 struct Begin
   : proto::or_<
- begin< proto::terminal< std::vector<_, _> > >
- , begin< proto::terminal< std::list<_, _> > >
- , proto::terminal<_>
- , proto::nary_expr<_, proto::vararg<Begin> >
+ when< proto::terminal< std::vector<_, _> >, begin(_arg) >
+ , when< proto::terminal< std::list<_, _> >, begin(_arg) >
+ , when< proto::terminal<_> >
+ , when< proto::nary_expr<_, proto::vararg<Begin> > >
>
 {};
 
@@ -93,7 +89,7 @@
     {
         typedef typename std::iterator_traits<Iter>::reference result_type;
 
- result_type operator()(Expr &expr, DereferenceCtx const &) const
+ result_type operator ()(Expr &expr, DereferenceCtx const &) const
         {
             return *proto::arg(expr).it;
         }
@@ -117,7 +113,7 @@
     {
         typedef void result_type;
 
- result_type operator()(Expr &expr, IncrementCtx const &) const
+ result_type operator ()(Expr &expr, IncrementCtx const &) const
         {
             ++proto::arg(expr).it;
         }
@@ -148,11 +144,14 @@
 };
 
 // A vector grammar is a terminal or some op that is not an
-// assignment op. (Assignment will be handles specially.)
+// assignment op. (Assignment will be handled specially.)
 struct MixedGrammar
   : proto::or_<
         proto::terminal<_>
- , proto::and_<proto::nary_expr<_, proto::vararg<MixedGrammar> >, proto::not_<AssignOps> >
+ , proto::and_<
+ proto::nary_expr<_, proto::vararg<MixedGrammar> >
+ , proto::not_<AssignOps>
+ >
>
 {};
 
@@ -172,7 +171,7 @@
     {}
 private:
     // hide this:
- using proto::extends<Expr, MixedExpr<Expr>, MixedDomain>::operator[];
+ using proto::extends<Expr, MixedExpr<Expr>, MixedDomain>::operator [];
 };
 
 // Define a trait type for detecting vector and list terminals, to
@@ -201,7 +200,7 @@
     struct assign_op
     {
         template<typename T, typename U>
- void operator()(T &t, U const &u) const
+ void operator ()(T &t, U const &u) const
         {
             t = u;
         }
@@ -210,7 +209,7 @@
     struct plus_assign_op
     {
         template<typename T, typename U>
- void operator()(T &t, U const &u) const
+ void operator ()(T &t, U const &u) const
         {
             t += u;
         }
@@ -219,7 +218,7 @@
     struct minus_assign_op
     {
         template<typename T, typename U>
- void operator()(T &t, U const &u) const
+ void operator ()(T &t, U const &u) const
         {
             t -= u;
         }
@@ -227,26 +226,36 @@
 
     struct sin_
     {
- template<typename Sig> struct result {};
+ template<typename Sig>
+ struct result;
+
         template<typename This, typename Arg>
         struct result<This(Arg)>
           : remove_const<typename remove_reference<Arg>::type>
         {};
 
         template<typename Arg>
- Arg operator()(Arg const &arg) const
+ Arg operator ()(Arg const &arg) const
         {
             return std::sin(arg);
         }
     };
 
- BOOST_PROTO_DEFINE_FUNCTION_TEMPLATE(
- 1
- , sin
+ template<typename A>
+ typename proto::result_of::make_expr<
+ proto::tag::function
       , MixedDomain
- , (boost::proto::tag::function)
- , ((sin_))
- )
+ , sin_ const
+ , A const
+ >::type sin(A const &a)
+ {
+ return proto::result_of::make_expr<
+ proto::tag::function
+ , MixedDomain
+ , sin_ const
+ , A const
+ >::call(sin_(), a);
+ }
 
     template<typename FwdIter, typename Expr, typename Op>
     void evaluate(FwdIter begin, FwdIter end, Expr const &expr, Op op)
@@ -254,7 +263,7 @@
         int i = 0;
         IncrementCtx const inc = {};
         DereferenceCtx const deref = {};
- typename Begin::apply<Expr, int, int>::type expr2 = Begin::call(expr, i, i);
+ typename boost::result_of<Begin(Expr, int, int)>::type expr2 = Begin()(expr, i, i);
         for(; begin != end; ++begin)
         {
             op(*begin, proto::eval(expr2, deref));

Modified: trunk/libs/xpressive/proto/example/rgb.cpp
==============================================================================
--- trunk/libs/xpressive/proto/example/rgb.cpp (original)
+++ trunk/libs/xpressive/proto/example/rgb.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -11,9 +11,7 @@
 
 #include <iostream>
 #include <boost/xpressive/proto/proto.hpp>
-#include <boost/xpressive/proto/transform/arg.hpp>
-#include <boost/xpressive/proto/transform/apply.hpp>
-#include <boost/xpressive/proto/transform/compose.hpp>
+#include <boost/xpressive/proto/transform.hpp>
 using namespace boost::proto;
 
 struct RedTag
@@ -40,35 +38,49 @@
     }
 };
 
-typedef terminal<RedTag>::type Red;
-typedef terminal<BlueTag>::type Blue;
-typedef terminal<GreenTag>::type Green;
+typedef terminal<RedTag>::type RedT;
+typedef terminal<BlueTag>::type BlueT;
+typedef terminal<GreenTag>::type GreenT;
+
+struct Red;
+struct Blue;
+struct Green;
 
 ///////////////////////////////////////////////////////////////////////////////
 // A transform that produces new colors according to some arbitrary rules:
 // red & green give blue, red & blue give green, blue and green give red.
+struct Red
+ : or_<
+ plus<Green, Blue>
+ , plus<Blue, Green>
+ , plus<Red, Red>
+ , terminal<RedTag>
+ >
+{};
+
+struct Green
+ : or_<
+ plus<Red, Blue>
+ , plus<Blue, Red>
+ , plus<Green, Green>
+ , terminal<GreenTag>
+ >
+{};
+
+struct Blue
+ : or_<
+ plus<Red, Green>
+ , plus<Green, Red>
+ , plus<Blue, Blue>
+ , terminal<BlueTag>
+ >
+{};
+
 struct RGB
   : or_<
- // leave terminals as they are
- terminal<_>
- , transform::compose<
- // Match binary nodes, convert left and right to terminals
- plus<RGB, RGB>
- // Forward resulting binary expression to the following transform
- , or_<
- // Green + Blue -> Red
- transform::always<plus<Green, Blue>, Red>
- , transform::always<plus<Blue, Green>, Red>
- // Red + Green -> Blue
- , transform::always<plus<Red, Green>, Blue>
- , transform::always<plus<Green, Red>, Blue>
- // Red + Blue -> Green
- , transform::always<plus<Red, Blue>, Green>
- , transform::always<plus<Blue, Red>, Green>
- // else (both same color), select the left operand
- , transform::left<_>
- >
- >
+ when< Red, RedTag() >
+ , when< Blue, BlueTag() >
+ , when< Green, GreenTag() >
>
 {};
 
@@ -76,14 +88,14 @@
 void printColor(Expr const & expr)
 {
     int i = 0; // dummy state and visitor parameter, not used
- std::cout << arg(RGB::call(expr, i, i)) << std::endl;
+ std::cout << RGB()(expr, i, i) << std::endl;
 }
 
 int main()
 {
- printColor(Red() + Green());
- printColor(Red() + Green() + Blue());
- printColor(Red() + (Green() + Blue()));
+ printColor(RedT() + GreenT());
+ printColor(RedT() + GreenT() + BlueT());
+ printColor(RedT() + (GreenT() + BlueT()));
 
     return 0;
 }

Modified: trunk/libs/xpressive/proto/example/tarray.cpp
==============================================================================
--- trunk/libs/xpressive/proto/example/tarray.cpp (original)
+++ trunk/libs/xpressive/proto/example/tarray.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -52,7 +52,7 @@
 
     // Index array terminals with our subscript. Everything
     // else will be handled by the default evaluation context.
- int operator()(proto::tag::terminal, int const (&data)[3]) const
+ int operator ()(proto::tag::terminal, int const (&data)[3]) const
     {
         return data[this->i_];
     }
@@ -68,43 +68,43 @@
 
     TArrayPrintCtx() {}
 
- std::ostream &operator()(proto::tag::terminal, int i) const
+ std::ostream &operator ()(proto::tag::terminal, int i) const
     {
         return std::cout << i;
     }
 
- std::ostream &operator()(proto::tag::terminal, int const (&arr)[3]) const
+ std::ostream &operator ()(proto::tag::terminal, int const (&arr)[3]) const
     {
         return std::cout << '{' << arr[0] << ", " << arr[1] << ", " << arr[2] << '}';
     }
 
     template<typename L, typename R>
- std::ostream &operator()(proto::tag::plus, L const &l, R const &r) const
+ std::ostream &operator ()(proto::tag::plus, L const &l, R const &r) const
     {
         return std::cout << '(' << l << " + " << r << ')';
     }
 
     template<typename L, typename R>
- std::ostream &operator()(proto::tag::minus, L const &l, R const &r) const
+ std::ostream &operator ()(proto::tag::minus, L const &l, R const &r) const
     {
         return std::cout << '(' << l << " - " << r << ')';
     }
 
     template<typename L, typename R>
- std::ostream &operator()(proto::tag::multiplies, L const &l, R const &r) const
+ std::ostream &operator ()(proto::tag::multiplies, L const &l, R const &r) const
     {
         return std::cout << l << " * " << r;
     }
 
     template<typename L, typename R>
- std::ostream &operator()(proto::tag::divides, L const &l, R const &r) const
+ std::ostream &operator ()(proto::tag::divides, L const &l, R const &r) const
     {
         return std::cout << l << " / " << r;
     }
 };
 
 // Here is the domain-specific expression wrapper, which overrides
-// operator[] to evaluate the expression using the TArraySubscriptCtx.
+// operator [] to evaluate the expression using the TArraySubscriptCtx.
 template<typename Expr>
 struct TArrayExpr
   : proto::extends<Expr, TArrayExpr<Expr>, TArrayDomain>
@@ -143,9 +143,9 @@
         (*this)[2] = k;
     }
 
- // Here we override operator[] to give read/write access to
+ // Here we override operator [] to give read/write access to
     // the elements of the array. (We could use the TArrayExpr
- // operator[] if we made the subscript context smarter about
+ // operator [] if we made the subscript context smarter about
     // returning non-const reference when appropriate.)
     int &operator [](std::ptrdiff_t i)
     {
@@ -157,13 +157,13 @@
         return proto::arg(*this)[i];
     }
 
- // Here we define a operator= for TArray terminals that
+ // Here we define a operator = for TArray terminals that
     // takes a TArray expression.
     template< typename Expr >
     TArray &operator =(Expr const & expr)
     {
         // proto::as_expr<TArrayDomain>(expr) is the same as
- // expr unless expr is an integer, in which case it
+ // expr unless expr is an integer, in which case it
         // is made into a TArrayExpr terminal first.
         return this->assign(proto::as_expr<TArrayDomain>(expr));
     }

Modified: trunk/libs/xpressive/proto/example/vec3.cpp
==============================================================================
--- trunk/libs/xpressive/proto/example/vec3.cpp (original)
+++ trunk/libs/xpressive/proto/example/vec3.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -16,11 +16,9 @@
 #include <boost/xpressive/proto/proto.hpp>
 #include <boost/xpressive/proto/context.hpp>
 #include <boost/xpressive/proto/proto_typeof.hpp>
-#include <boost/xpressive/proto/transform/arg.hpp>
-#include <boost/xpressive/proto/transform/fold.hpp>
-#include <boost/xpressive/proto/transform/apply.hpp>
-#include <boost/xpressive/proto/transform/function.hpp>
+#include <boost/xpressive/proto/transform.hpp>
 using namespace boost::proto;
+using namespace transform;
 namespace mpl = boost::mpl;
 
 // Here is an evaluation context that indexes into a Vec3
@@ -36,7 +34,7 @@
 
     // Index array terminals with our subscript. Everything
     // else will be handled by the default evaluation context.
- int operator()(tag::terminal, int const (&arr)[3]) const
+ int operator ()(tag::terminal, int const (&arr)[3]) const
     {
         return arr[this->i_];
     }
@@ -45,41 +43,40 @@
 };
 
 // Here is an evaluation context that counts the number
-// of Vec3 terminals in an expression.
+// of Vec3 terminals in an expression.
 struct CountLeavesCtx
   : callable_context< CountLeavesCtx, null_context >
 {
     CountLeavesCtx()
       : count(0)
       {}
-
+
       typedef void result_type;
-
- void operator()(tag::terminal, int const(&)[3])
+
+ void operator ()(tag::terminal, int const(&)[3])
       {
           ++this->count;
       }
-
+
       int count;
 };
 
+struct iplus : std::plus<int>, callable {};
+
 // Here is a transform that does the same thing as the above context.
 // It demonstrates the use of the std::plus<> function object
-// with the function2 transform. With minor modifications, this
+// with the fold transform. With minor modifications, this
 // transform could be used to calculate the leaf count at compile
-// time, rather at runtime.
+// time, rather than at runtime.
 struct CountLeaves
   : or_<
         // match a Vec3 terminal, return 1
- transform::always<terminal<int[3]>, mpl::int_<1> >
+ when<terminal<int[3]>, mpl::int_<1>() >
         // match a terminal, return int() (which is 0)
- , transform::always<terminal<_>, int>
+ , when<terminal<_>, int() >
         // fold everything else, using std::plus<> to add
         // the leaf count of each child to the accumulated state.
- , transform::fold<
- nary_expr<_, vararg<transform::function2<CountLeaves, std::plus<int> > > >
- , int // initial state of the fold is int() (which is 0)
- >
+ , otherwise< fold<_, int(), iplus(CountLeaves, _state) > >
>
 {};
 
@@ -94,17 +91,17 @@
         (*this)[2] = k;
     }
 
- int &operator[](int i)
+ int &operator [](int i)
     {
         return arg(*this)[i];
     }
 
- int const &operator[](int i) const
+ int const &operator [](int i) const
     {
         return arg(*this)[i];
     }
 
- // Here we define a operator= for Vec3 terminals that
+ // Here we define a operator = for Vec3 terminals that
     // takes a Vec3 expression.
     template< typename Expr >
     Vec3 &operator =(Expr const & expr)
@@ -134,10 +131,10 @@
     // CountLeavesCtx evaluation context.
     CountLeavesCtx ctx;
     eval(expr, ctx);
-
+
     // This is another way to count the leaves using a transform.
     int i = 0;
- assert( CountLeaves::call(expr, i, i) == ctx.count );
+ assert( CountLeaves()(expr, i, i) == ctx.count );
 
     return ctx.count;
 }

Modified: trunk/libs/xpressive/proto/example/vector.cpp
==============================================================================
--- trunk/libs/xpressive/proto/example/vector.cpp (original)
+++ trunk/libs/xpressive/proto/example/vector.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -42,7 +42,7 @@
     {
         typedef T result_type;
 
- T operator()(Expr &expr, VectorSubscriptCtx const &ctx) const
+ T operator ()(Expr &expr, VectorSubscriptCtx const &ctx) const
         {
             return proto::arg(expr)[ctx.i_];
         }
@@ -73,11 +73,11 @@
     {
         typedef void result_type;
 
- result_type operator()(Expr &expr, VectorSizeCtx const &ctx) const
+ result_type operator ()(Expr &expr, VectorSizeCtx const &ctx) const
         {
             if(ctx.size_ != proto::arg(expr).size())
             {
- throw std::invalid_argument("LHS and RHS are not compatible");
+ throw std::runtime_error("LHS and RHS are not compatible");
             }
         }
     };
@@ -124,7 +124,7 @@
 {};
 
 // Here is VectorExpr, which extends a proto expr type by
-// giving it an operator[] which uses the VectorSubscriptCtx
+// giving it an operator [] which uses the VectorSubscriptCtx
 // to evaluate an expression with a given index.
 template<typename Expr>
 struct VectorExpr

Modified: trunk/libs/xpressive/proto/test/Jamfile.v2
==============================================================================
--- trunk/libs/xpressive/proto/test/Jamfile.v2 (original)
+++ trunk/libs/xpressive/proto/test/Jamfile.v2 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -21,7 +21,7 @@
     :
         [ run proto_fusion.cpp : : : <toolset>gcc:<cxxflags>-ftemplate-depth-1024 ]
         [ run proto_fusion_s.cpp ]
- [ run toy_spirit.cpp ]
+# [ run toy_spirit.cpp ]
         [ run toy_spirit2.cpp ]
         [ run calculator.cpp ]
         [ run lambda.cpp ]

Modified: trunk/libs/xpressive/proto/test/calculator.cpp
==============================================================================
--- trunk/libs/xpressive/proto/test/calculator.cpp (original)
+++ trunk/libs/xpressive/proto/test/calculator.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -22,36 +22,36 @@
       : i_(i)
     {}
 
- int operator()(proto::tag::terminal, placeholder) const
+ int operator ()(proto::tag::terminal, placeholder) const
     {
         return this->i_;
     }
 
- int operator()(proto::tag::terminal, int j) const
+ int operator ()(proto::tag::terminal, int j) const
     {
         return j;
     }
 
     template<typename Left, typename Right>
- int operator()(proto::tag::plus, Left const &left, Right const &right) const
+ int operator ()(proto::tag::plus, Left const &left, Right const &right) const
     {
         return proto::eval(left, *this) + proto::eval(right, *this);
     }
 
     template<typename Left, typename Right>
- int operator()(proto::tag::minus, Left const &left, Right const &right) const
+ int operator ()(proto::tag::minus, Left const &left, Right const &right) const
     {
         return proto::eval(left, *this) - proto::eval(right, *this);
     }
 
     template<typename Left, typename Right>
- int operator()(proto::tag::multiplies, Left const &left, Right const &right) const
+ int operator ()(proto::tag::multiplies, Left const &left, Right const &right) const
     {
         return proto::eval(left, *this) * proto::eval(right, *this);
     }
 
     template<typename Left, typename Right>
- int operator()(proto::tag::divides, Left const &left, Right const &right) const
+ int operator ()(proto::tag::divides, Left const &left, Right const &right) const
     {
         return proto::eval(left, *this) / proto::eval(right, *this);
     }
@@ -70,7 +70,7 @@
     {}
 
     template<typename T>
- result_type operator()(T const &t) const
+ result_type operator ()(T const &t) const
     {
         Fun fun(t);
         return proto::eval(this->expr_, fun);

Modified: trunk/libs/xpressive/proto/test/examples.cpp
==============================================================================
--- trunk/libs/xpressive/proto/test/examples.cpp (original)
+++ trunk/libs/xpressive/proto/test/examples.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// matches.hpp
+// examples2.hpp
 //
 // Copyright 2006 Eric Niebler. Distributed under the Boost
 // Software License, Version 1.0. (See accompanying file
@@ -9,17 +9,14 @@
 #include <boost/config.hpp>
 #include <boost/mpl/min_max.hpp>
 #include <boost/xpressive/proto/proto.hpp>
-#include <boost/xpressive/proto/transform/arg.hpp>
-#include <boost/xpressive/proto/transform/fold.hpp>
-#include <boost/xpressive/proto/transform/branch.hpp>
-#include <boost/xpressive/proto/transform/list.hpp>
-#include <boost/xpressive/proto/transform/apply.hpp>
-#include <boost/xpressive/proto/transform/construct.hpp>
-#include <boost/xpressive/proto/transform/fold_tree.hpp>
+#include <boost/xpressive/proto/transform.hpp>
 #include <boost/utility/result_of.hpp>
+#include <boost/fusion/include/cons.hpp>
+#include <boost/fusion/include/pop_front.hpp>
 #include <boost/test/unit_test.hpp>
 
 using namespace boost::proto;
+using namespace transform;
 namespace mpl = boost::mpl;
 namespace fusion = boost::fusion;
 
@@ -49,40 +46,87 @@
 //]
 }
 
-//[ binary_max
+//[ binary_arity
+/*<< The `CalculatorArity` is a transform for calculating
+the arity of a calculator expression. It will be define in
+terms of `binary_arity`, which is defined in terms of
+`CalculatorArity`; hence, the definition is recursive.>>*/
+struct CalculatorArity;
+
+// A custom transform that returns the arity of a unary
+// calculator expression by finding the arity of the
+// child expression.
+struct unary_arity
+ /*<< Custom transforms should inherit from
+ callable. In some cases, (e.g., when the transform
+ is a template), it is also necessary to specialize
+ the proto::is_callable<> trait. >>*/
+ : callable
+{
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ /*<< Transforms have a nested `result<>` for calculating their return type. >>*/
+ struct result<This(Expr, State, Visitor)>
+ {
+ /*<< Get the child. >>*/
+ typedef typename result_of::arg<Expr>::type child_expr;
+
+ /*<< Apply `CalculatorArity` to find the arity of the child. >>*/
+ typedef typename boost::result_of<CalculatorArity(child_expr, State, Visitor)>::type type;
+ };
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<unary_arity(Expr, State, Visitor)>::type
+ /*<< Transforms have a nested `operator ()` member function. >>*/
+ operator ()(Expr const &, State const &, Visitor &) const
+ {
+ /*<< The `unary_arity` transform doesn't have an interesting
+ runtime counterpart, so just return a default-constructed object
+ of the correct type. >>*/
+ return typename result<unary_arity(Expr, State, Visitor)>::type();
+ }
+};
+
 // A custom transform that returns the arity of a binary
 // calculator expression by finding the maximum of the
-// arities of the two children expressions.
-/*<< All transforms take a Grammar as a template parameter. >>*/
-template<typename Grammar>
-struct binary_max
- /*<< All transforms must inherit from the `Grammar`, so that the transform
- IS-A `Grammar`, and matches the same expressions that `Grammar` does. >>*/
- : Grammar
+// arities of the mpl::int_<2> children expressions.
+struct binary_arity
+ /*<< All custom transforms should inherit from
+ callable. In some cases, (e.g., when the transform
+ is a template), it is also necessary to specialize
+ the proto::is_callable<> trait. >>*/
+ : callable
 {
- template<typename Expr, typename State, typename Visitor>
- /*<< Transforms have a nested `apply<>` for calculating their return type. >>*/
- struct apply
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ /*<< Transforms have a nested `result<>` for calculating their return type. >>*/
+ struct result<This(Expr, State, Visitor)>
     {
- /*<< Apply `Grammar`'s transform. This is what makes it possible to chain transforms. >>*/
- typedef typename mpl::apply_wrap3<Grammar, Expr, State, Visitor>::type expr_type;
- /*<< After applying `Grammar`'s transform, the children expressions have been
- replaced with their arities. >>*/
- typedef typename result_of::left<expr_type>::type left_arity;
- typedef typename result_of::right<expr_type>::type right_arity;
+ /*<< Get the left and right children. >>*/
+ typedef typename result_of::left<Expr>::type left_expr;
+ typedef typename result_of::right<Expr>::type right_expr;
+
+ /*<< Apply `CalculatorArity` to find the arity of the left and right children. >>*/
+ typedef typename boost::result_of<CalculatorArity(left_expr, State, Visitor)>::type left_arity;
+ typedef typename boost::result_of<CalculatorArity(right_expr, State, Visitor)>::type right_arity;
+
         /*<< The return type is the maximum of the children's arities. >>*/
         typedef typename mpl::max<left_arity, right_arity>::type type;
     };
 
     template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
+ typename result<binary_arity(Expr, State, Visitor)>::type
     /*<< Transforms have a nested `call()` member function. >>*/
- call(Expr const &, State const &, Visitor &)
+ operator ()(Expr const &, State const &, Visitor &) const
     {
- /*<< Usually, the `call()` member function invokes the `Grammar`'s `call()` function,
- as `Grammar::call(expr,state,visitor)`, but this transform doesn't have an interesting
- runtime counterpart, so just return a default-constructed object of the correct type. >>*/
- return typename apply<Expr, State, Visitor>::type();
+ /*<< The `binary_arity` transform doesn't have an interesting
+ runtime counterpart, so just return a default-constructed object
+ of the correct type. >>*/
+ return typename result<binary_arity(Expr, State, Visitor)>::type();
     }
 };
 //]
@@ -91,76 +135,87 @@
 terminal< placeholder2 >::type const _2 = {{}};
 
 //[ CalculatorArityGrammar
-struct CalculatorGrammar
+struct CalculatorArity
+ : or_<
+ when< terminal< placeholder1 >, mpl::int_<1>() >
+ , when< terminal< placeholder2 >, mpl::int_<2>() >
+ , when< terminal<_>, mpl::int_<0>() >
+ , when< unary_expr<_, _>, unary_arity >
+ , when< binary_expr<_, _, _>, binary_arity >
+ >
+{};
+//]
+
+//[ CalculatorArityGrammar2
+struct CalcArity2
   : or_<
- transform::always< terminal< placeholder1 >, mpl::int_<1> >
- , transform::always< terminal< placeholder2 >, mpl::int_<2> >
- , transform::always< terminal< _ >, mpl::int_<0> >
- , transform::arg< unary_expr< _, CalculatorGrammar > >
- , binary_max< binary_expr< _, CalculatorGrammar, CalculatorGrammar > >
+ when< terminal< placeholder1 >, mpl::int_<1>() >
+ , when< terminal< placeholder2 >, mpl::int_<2>() >
+ , when< terminal<_>, mpl::int_<0>() >
+ , when< unary_expr<_, CalcArity2>, CalcArity2(_arg) >
+ , when< binary_expr<_, CalcArity2, CalcArity2>, mpl::max<CalcArity2(_left), CalcArity2(_right)>() >
>
 {};
 //]
 
+// BUGBUG find workaround for this
+#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
+#define _pop_front(x) call<_pop_front(x)>
+#define _arg(x) call<_arg(x)>
+#endif
+
 //[ AsArgList
 // This transform matches function invocations such as foo(1,'a',"b")
 // and transforms them into Fusion cons lists of their arguments. In this
 // case, the result would be cons(1, cons('a', cons("b", nil()))).
 struct ArgsAsList
- /*<< Use a `branch<>` transform to use `fusion::nil` as the initial
- state of this transformation. >>*/
- : transform::branch<
- /*<< Use a `reverse_fold<>` transform to iterate over the children
- of this node in reverse order, building a fusion list from back to
- front. >>*/
- transform::reverse_fold<
- /*<< The `Grammar` we're matching is a function invocation. >>*/
- function<
- /*<< The first child expression of a `function<>` node is the
- function being invoked. We don't want that in our list, so use
- the `state<>` transform to effectively skip it. (Recall that
- we're building a list in the state parameter, and that the
- `state<>` transform just returns the state unmodified. So this
- says to match a `terminal<>` but to not add it to the list.) >>*/
- transform::state<terminal<_> >
- /*<< We use `vararg<>` here because the function expression we're
- matching can have an arbitrary number of arguments. >>*/
- , vararg<
- /*<< The `list<>` transform puts the rest of the function
- arguments in a fusion cons list. >>*/
- transform::list<
- /*<< The arguments to the function are terminals.
- Extract the argument from each terminal before putting
- them into the list. >>*/
- transform::arg<terminal<_> >
- >
- >
- >
- >
- /*<< Here is the initial state used by this transform. >>*/
- , fusion::nil
- >
+ : when<
+ function<terminal<_>, vararg<terminal<_> > >
+ /*<< Use a `reverse_fold<>` transform to iterate over the children
+ of this node in reverse order, building a fusion list from back to
+ front. >>*/
+ , reverse_fold<
+ /*<< The first child expression of a `function<>` node is the
+ function being invoked. We don't want that in our list, so use
+ the `pop_front()` to remove it. >>*/
+ _pop_front(_)
+ /*<< `nil` is the initial state used by the `reverse_fold<>`
+ transform. >>*/
+ , fusion::nil()
+ /*<< Put the rest of the function arguments in a fusion cons
+ list. >>*/
+ , fusion::cons<_arg, _state>(_arg, _state)
+ >
+ >
 {};
 //]
 
 //[ FoldTreeToList
-// This grammar describes what counts as the terminals in expressions
-// of the form (_1=1,'a',"b"), which will be flattened using
-// reverse_fold_tree<> below.
-struct Terminals
- : or_<
- transform::arg<transform::right<assign<_, terminal<_> > > >
- , transform::arg<terminal<_> >
- >
-{};
-
 // This transform matches expressions of the form (_1=1,'a',"b")
 // (note the use of the comma operator) and transforms it into a
 // Fusion cons list of their arguments. In this case, the result
 // would be cons(1, cons('a', cons("b", nil()))).
 struct FoldTreeToList
- /*<< Fold all terminals that are separated by commas into a Fusion cons list. >>*/
- : transform::reverse_fold_tree<tag::comma, transform::list<Terminals>, fusion::nil>
+ : or_<
+ // This grammar describes what counts as the terminals in expressions
+ // of the form (_1=1,'a',"b"), which will be flattened using
+ // reverse_fold_tree<> below.
+ when<assign<_, terminal<_> >
+ , _arg(_right)
+ >
+ , when<terminal<_>
+ , _arg
+ >
+ , when<
+ comma<FoldTreeToList, FoldTreeToList>
+ /*<< Fold all terminals that are separated by commas into a Fusion cons list. >>*/
+ , reverse_fold_tree<
+ _
+ , fusion::nil()
+ , fusion::cons<FoldTreeToList, _state>(FoldTreeToList, _state)
+ >
+ >
+ >
 {};
 //]
 
@@ -169,12 +224,14 @@
 // them to doubles.
 struct Promote
   : or_<
- /*<< Match a `terminal<float>`, then construct a `terminal<double>::type` with the `float`. >>*/
- transform::construct<terminal<float>, terminal<double>::type(transform::arg<_>) >
- , terminal<_>
- /*<< `nary_expr<>` has a pass-through transform which will transform each child
- sub-expression using the `Promote` transform. >>*/
- , nary_expr<_, vararg<Promote> >
+ /*<< Match a `terminal<float>`, then construct a
+ `terminal<double>::type` with the `float`. >>*/
+ when<terminal<float>, terminal<double>::type(_arg) >
+ , when<terminal<_> >
+ /*<< `nary_expr<>` has a pass-through transform which
+ will transform each child sub-expression using the
+ `Promote` transform. >>*/
+ , when<nary_expr<_, vararg<Promote> > >
>
 {};
 //]
@@ -187,40 +244,29 @@
 // `make_pair_(1, 3.14)` and actually builds a `std::pair<>`
 // from the arguments.
 struct MakePair
- : transform::construct<
+ : when<
         /*<< Match expressions like `make_pair_(1, 3.14)` >>*/
         function<terminal<make_pair_tag>, terminal<_>, terminal<_> >
       /*<< Return `std::pair<F,S>(f,s)` where `f` and `s` are the
       first and second arguments to the lazy `make_pair_()` function >>*/
- , std::pair<
- transform::arg<transform::arg_c<_, 1> >
- , transform::arg<transform::arg_c<_, 2> >
- >(
- transform::arg<transform::arg_c<_, 1> >
- , transform::arg<transform::arg_c<_, 2> >
- )
+ , std::pair<_arg(_arg1), _arg(_arg2)>(_arg(_arg1), _arg(_arg2))
>
 {};
 //]
 
 //[ NegateInt
 struct NegateInt
- : transform::construct<
- terminal<int>
- , negate<_>(_)
- >
+ : when<terminal<int>, negate<_>(_)>
 {};
 //]
 
 #ifndef BOOST_MSVC
 //[ SquareAndPromoteInt
 struct SquareAndPromoteInt
- : transform::construct<
+ : when<
         terminal<int>
- , multiplies<terminal<long>::type, terminal<long>::type>::type(
- terminal<long>::type(transform::arg<_>)
- , terminal<long>::type(transform::arg<_>)
- )
+ , multiplies<terminal<long>::type, terminal<long>::type>::type
+ (terminal<long>::type(_arg), terminal<long>::type(_arg))
>
 {};
 //]
@@ -231,23 +277,27 @@
     //[ CalculatorArityTest
     int i = 0; // not used, dummy state and visitor parameter
 
- std::cout << CalculatorGrammar::call( lit(100) * 200, i, i) << '\n';
- std::cout << CalculatorGrammar::call( (_1 - _1) / _1 * 100, i, i) << '\n';
- std::cout << CalculatorGrammar::call( (_2 - _1) / _2 * 100, i, i) << '\n';
+ std::cout << CalculatorArity()( lit(100) * 200, i, i) << '\n';
+ std::cout << CalculatorArity()( (_1 - _1) / _1 * 100, i, i) << '\n';
+ std::cout << CalculatorArity()( (_2 - _1) / _2 * 100, i, i) << '\n';
     //]
 
- BOOST_CHECK_EQUAL(0, CalculatorGrammar::call( lit(100) * 200, i, i));
- BOOST_CHECK_EQUAL(1, CalculatorGrammar::call( (_1 - _1) / _1 * 100, i, i));
- BOOST_CHECK_EQUAL(2, CalculatorGrammar::call( (_2 - _1) / _2 * 100, i, i));
+ BOOST_CHECK_EQUAL(0, CalculatorArity()( lit(100) * 200, i, i));
+ BOOST_CHECK_EQUAL(1, CalculatorArity()( (_1 - _1) / _1 * 100, i, i));
+ BOOST_CHECK_EQUAL(2, CalculatorArity()( (_2 - _1) / _2 * 100, i, i));
+
+ BOOST_CHECK_EQUAL(0, CalcArity2()( lit(100) * 200, i, i));
+ BOOST_CHECK_EQUAL(1, CalcArity2()( (_1 - _1) / _1 * 100, i, i));
+ BOOST_CHECK_EQUAL(2, CalcArity2()( (_2 - _1) / _2 * 100, i, i));
 
     using boost::fusion::cons;
     using boost::fusion::nil;
- cons<int, cons<char, cons<char const (&)[2]> > > args(ArgsAsList::call( _1(1, 'a', "b"), i, i ));
+ cons<int, cons<char, cons<std::string> > > args(ArgsAsList()( _1(1, 'a', std::string("b")), i, i ));
     BOOST_CHECK_EQUAL(args.car, 1);
     BOOST_CHECK_EQUAL(args.cdr.car, 'a');
     BOOST_CHECK_EQUAL(args.cdr.cdr.car, std::string("b"));
 
- cons<int, cons<char, cons<char const (&)[2]> > > lst(FoldTreeToList::call( (_1 = 1, 'a', "b"), i, i ));
+ cons<int, cons<char, cons<std::string> > > lst(FoldTreeToList()( (_1 = 1, 'a', std::string("b")), i, i ));
     BOOST_CHECK_EQUAL(lst.car, 1);
     BOOST_CHECK_EQUAL(lst.cdr.car, 'a');
     BOOST_CHECK_EQUAL(lst.cdr.cdr.car, std::string("b"));
@@ -255,13 +305,13 @@
     plus<
         terminal<double>::type
       , terminal<double>::type
- >::type p = Promote::call( lit(1.f) + 2.f, i, i );
+ >::type p = Promote()( lit(1.f) + 2.f, i, i );
 
     //[ LazyMakePairTest
     int j = 0; // not used, dummy state and visitor parameter
 
- std::pair<int, double> p2 = MakePair::call( make_pair_(1, 3.14), j, j );
-
+ std::pair<int, double> p2 = MakePair()( make_pair_(1, 3.14), j, j );
+
     std::cout << p2.first << std::endl;
     std::cout << p2.second << std::endl;
     //]
@@ -269,13 +319,12 @@
     BOOST_CHECK_EQUAL(p2.first, 1);
     BOOST_CHECK_EQUAL(p2.second, 3.14);
 
- NegateInt::call(lit(1), i, i);
+ NegateInt()(lit(1), i, i);
 #ifndef BOOST_MSVC
- SquareAndPromoteInt::call(lit(1), i, i);
+ SquareAndPromoteInt()(lit(1), i, i);
 #endif
 }
 
-
 using namespace boost::unit_test;
 ///////////////////////////////////////////////////////////////////////////////
 // init_unit_test_suite

Modified: trunk/libs/xpressive/proto/test/lambda.cpp
==============================================================================
--- trunk/libs/xpressive/proto/test/lambda.cpp (original)
+++ trunk/libs/xpressive/proto/test/lambda.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -10,13 +10,14 @@
 #include <boost/mpl/int.hpp>
 #include <boost/mpl/min_max.hpp>
 #include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/identity.hpp>
 #include <boost/mpl/next_prior.hpp>
 #if BOOST_VERSION < 103500
 # include <boost/spirit/fusion/sequence/at.hpp>
 # include <boost/spirit/fusion/sequence/tuple.hpp>
 namespace boost { namespace fusion { namespace result_of { using namespace meta; }}}
 #else
-# include <boost/fusion/include/tuple.hpp>
+# include <boost/fusion/tuple.hpp>
 #endif
 #include <boost/typeof/typeof.hpp>
 #include <boost/typeof/std/sstream.hpp>
@@ -26,9 +27,7 @@
 #include <boost/type_traits/add_reference.hpp>
 #include <boost/xpressive/proto/proto.hpp>
 #include <boost/xpressive/proto/context.hpp>
-#include <boost/xpressive/proto/transform/arg.hpp>
-#include <boost/xpressive/proto/transform/fold.hpp>
-#include <boost/xpressive/proto/transform/apply.hpp>
+#include <boost/xpressive/proto/transform.hpp>
 #include <boost/test/unit_test.hpp>
 #include <boost/test/floating_point_comparison.hpp>
 
@@ -48,76 +47,61 @@
     typedef I arity;
 };
 
-// Some custom transforms for calculating the max arity of a lambda expression
-template<typename Grammar>
-struct max_arity
- : Grammar
-{
- template<typename Expr, typename State, typename Visitor>
- struct apply
- {
- typedef typename Grammar::template apply<Expr, State, Visitor>::type arity;
- typedef typename mpl::max<arity, State>::type type;
- };
-};
-
-template<typename Grammar>
+template<typename T>
 struct placeholder_arity
- : Grammar
 {
- template<typename Expr, typename, typename>
- struct apply
- : mpl::next<typename proto::result_of::arg<Expr>::type::arity>
- {};
+ typedef typename T::arity type;
 };
 
-using proto::_;
+namespace grammar
+{
+ using namespace proto;
+ using namespace transform;
 
-// The lambda grammar, with the transforms for calculating the max arity
-struct LambdaGrammar
- : proto::or_<
- placeholder_arity< proto::terminal< placeholder<_> > >
- , proto::transform::always< proto::terminal<_>, mpl::int_<0> >
- , proto::transform::fold<
- proto::nary_expr<_, proto::vararg< max_arity< LambdaGrammar > > >
+ // The lambda grammar, with the transforms for calculating the max arity
+ struct Lambda
+ : or_<
+ when< terminal< placeholder<_> >, mpl::next<placeholder_arity<_arg> >() >
+ , when< terminal<_>, mpl::int_<0>() >
+ , when< nary_expr<_, vararg<_> >, fold<_, mpl::int_<0>(), mpl::max<Lambda,_state>()> >
>
- >
-{};
+ {};
+}
 
 // simple wrapper for calculating a lambda expression's arity.
 template<typename Expr>
 struct lambda_arity
- : LambdaGrammar::apply<Expr, mpl::int_<0>, mpl::void_>
+ : boost::result_of<grammar::Lambda(Expr, mpl::void_, mpl::void_)>
 {};
 
 // The lambda context is the same as the default context
 // with the addition of special handling for lambda placeholders
 template<typename Tuple>
 struct lambda_context
+ : proto::callable_context<lambda_context<Tuple> const>
 {
     lambda_context(Tuple const &args)
       : args_(args)
     {}
 
- template<typename Expr, typename EnableIf = void>
- struct eval
- : proto::default_eval<Expr, lambda_context<Tuple> >
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename I>
+ struct result<This(proto::tag::terminal, placeholder<I> const &)>
+ : fusion::result_of::at<Tuple, I>
     {};
 
- template<typename Expr>
- struct eval<Expr, typename enable_if<proto::matches<Expr, proto::terminal<placeholder<_> > > >::type>
+ template<typename I>
+ typename fusion::result_of::at<Tuple, I>::type
+ operator ()(proto::tag::terminal, placeholder<I> const &) const
     {
- typedef typename proto::result_of::arg<Expr>::type::arity index;
- typedef typename fusion::result_of::at<Tuple, index>::type result_type;
- result_type operator()(Expr const &expr, lambda_context<Tuple> &ctx)
- {
-#if BOOST_VERSION < 103500
- return fusion::at<index::value>(ctx.args_);
-#else
- return fusion::at<index>(ctx.args_);
-#endif
- }
- };
+ #if BOOST_VERSION < 103500
+ return fusion::at<I::value>(this->args_);
+ #else
+ return fusion::at<I>(this->args_);
+ #endif
+ }
 
     Tuple args_;
 };
@@ -139,8 +123,8 @@
       , proto::result_of::eval<T const, lambda_context<fusion::tuple<> > >
>::type nullary_type;
 
- // Define our operator() that evaluates the lambda expression.
- nullary_type operator()() const
+ // Define our operator () that evaluates the lambda expression.
+ nullary_type operator ()() const
     {
         fusion::tuple<> args;
         lambda_context<fusion::tuple<> > ctx(args);
@@ -149,7 +133,7 @@
 
     template<typename A0>
     typename proto::result_of::eval<T const, lambda_context<fusion::tuple<A0 const &> > >::type
- operator()(A0 const &a0) const
+ operator ()(A0 const &a0) const
     {
         fusion::tuple<A0 const &> args(a0);
         lambda_context<fusion::tuple<A0 const &> > ctx(args);
@@ -158,7 +142,7 @@
 
     template<typename A0, typename A1>
     typename proto::result_of::eval<T const, lambda_context<fusion::tuple<A0 const &, A1 const &> > >::type
- operator()(A0 const &a0, A1 const &a1) const
+ operator ()(A0 const &a0, A1 const &a1) const
     {
         fusion::tuple<A0 const &, A1 const &> args(a0, a1);
         lambda_context<fusion::tuple<A0 const &, A1 const &> > ctx(args);

Modified: trunk/libs/xpressive/proto/test/matches.cpp
==============================================================================
--- trunk/libs/xpressive/proto/test/matches.cpp (original)
+++ trunk/libs/xpressive/proto/test/matches.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -11,6 +11,7 @@
 #include <boost/mpl/placeholders.hpp>
 #include <boost/type_traits/is_same.hpp>
 #include <boost/xpressive/proto/proto.hpp>
+#include <boost/xpressive/proto/transform.hpp>
 #include <boost/test/unit_test.hpp>
 
 using namespace boost;
@@ -48,8 +49,8 @@
>
 {};
 
-terminal< std::istream & >::type const cin_ = { std::cin };
-terminal< std::ostream & >::type const cout_ = { std::cout };
+terminal< std::istream & >::type const cin_ = {std::cin};
+terminal< std::ostream & >::type const cout_ = {std::cout};
 
 struct Anything
   : or_<
@@ -130,20 +131,20 @@
     assert_matches< terminal<convertible_to<int> > >( as_arg((int_convertible())) );
     assert_matches< terminal<convertible_to<int> > >( as_expr((int_convertible())) );
 
- assert_matches< if_<is_same<proto::result_of::arg<mpl::_>, int> > >( lit(1) );
- assert_not_matches< if_<is_same<proto::result_of::arg<mpl::_>, int> > >( lit('a') );
+ assert_matches< if_<is_same<_arg, int>() > >( lit(1) );
+ assert_not_matches< if_<is_same<_arg, int>() > >( lit('a') );
 
     assert_matches<
         and_<
             terminal<_>
- , if_<is_same<proto::result_of::arg<mpl::_>, int> >
+ , if_<is_same<_arg, int>() >
>
>( lit(1) );
 
     assert_not_matches<
         and_<
             terminal<_>
- , if_<is_same<proto::result_of::arg<mpl::_>, int> >
+ , if_<is_same<_arg, int>() >
>
>( lit('a') );
 
@@ -155,10 +156,18 @@
     assert_matches< terminal<char const (&)[6]> >( as_arg("hello") );
     assert_matches< terminal<char const (&)[6]> >( as_expr("hello") );
 
+ assert_matches< terminal<char [6]> >( lit("hello") );
+ assert_matches< terminal<char [6]> >( as_arg("hello") );
+ assert_matches< terminal<char [6]> >( as_expr("hello") );
+
     assert_matches< terminal<char const (&)[N]> >( lit("hello") );
     assert_matches< terminal<char const (&)[N]> >( as_arg("hello") );
     assert_matches< terminal<char const (&)[N]> >( as_expr("hello") );
 
+ assert_matches< terminal<char [N]> >( lit("hello") );
+ assert_matches< terminal<char [N]> >( as_arg("hello") );
+ assert_matches< terminal<char [N]> >( as_expr("hello") );
+
     assert_matches< terminal<std::string> >( lit(std::string("hello")) );
     assert_matches< terminal<std::string> >( as_arg(std::string("hello")) );
     assert_matches< terminal<std::string> >( as_expr(std::string("hello")) );
@@ -201,15 +210,15 @@
 
     assert_matches<
         or_<
- if_<is_same<proto::result_of::arg<mpl::_>, char> >
- , if_<is_same<proto::result_of::arg<mpl::_>, int> >
+ if_<is_same<_arg, char>() >
+ , if_<is_same<_arg, int>() >
>
>( lit(1) );
 
     assert_not_matches<
         or_<
- if_<is_same<proto::result_of::arg<mpl::_>, char> >
- , if_<is_same<proto::result_of::arg<mpl::_>, int> >
+ if_<is_same<_arg, char>() >
+ , if_<is_same<_arg, int>() >
>
>( lit(1u) );
 
@@ -244,3 +253,4 @@
 
     return test;
 }
+

Modified: trunk/libs/xpressive/proto/test/proto_fusion.cpp
==============================================================================
--- trunk/libs/xpressive/proto/test/proto_fusion.cpp (original)
+++ trunk/libs/xpressive/proto/test/proto_fusion.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -65,7 +65,7 @@
     {}
 
     template<typename Op>
- void operator()(Op const &op) const
+ void operator ()(Op const &op) const
     {
         this->sout_ << '(' << boost::addressof(op) << ')';
     }
@@ -75,41 +75,43 @@
 
 void test1()
 {
+ using boost::proto::flatten;
+
     std::stringstream sout;
 
     // Test for 1-way branching "tree"
     sout.str("");
- boost::fusion::for_each(!!!!(a_ >> b_), to_string(sout));
+ boost::fusion::for_each(flatten(!!!!(a_ >> b_)), to_string(sout));
     BOOST_CHECK_EQUAL("(a>>b)", sout.str());
 
     // Tests for 2-way branching trees
     sout.str("");
- boost::fusion::for_each(a_ >> b_ >> c_, to_string(sout));
+ boost::fusion::for_each(flatten(a_ >> b_ >> c_), to_string(sout));
     BOOST_CHECK_EQUAL("(a)(b)(c)", sout.str());
 
     sout.str("");
- boost::fusion::for_each(a_ | b_ | c_, to_string(sout));
+ boost::fusion::for_each(flatten(a_ | b_ | c_), to_string(sout));
     BOOST_CHECK_EQUAL("(a)(b)(c)", sout.str());
 
     sout.str("");
- boost::fusion::for_each(a_ >> b_ | c_ >> d_, to_string(sout));
+ boost::fusion::for_each(flatten(a_ >> b_ | c_ >> d_), to_string(sout));
     BOOST_CHECK_EQUAL("(a>>b)(c>>d)", sout.str());
 
     sout.str("");
- boost::fusion::for_each(a_ | b_ >> c_ | d_, to_string(sout));
+ boost::fusion::for_each(flatten(a_ | b_ >> c_ | d_), to_string(sout));
     BOOST_CHECK_EQUAL("(a)(b>>c)(d)", sout.str());
 
     sout.str("");
- boost::fusion::for_each(a_ >> b_ | c_ >> d_ | e_ >> f_ >> g_, to_string(sout));
+ boost::fusion::for_each(flatten(a_ >> b_ | c_ >> d_ | e_ >> f_ >> g_), to_string(sout));
     BOOST_CHECK_EQUAL("(a>>b)(c>>d)(e>>f>>g)", sout.str());
 
     sout.str("");
- boost::fusion::for_each(a_ >> b_ | c_ >> d_ | e_ >> (f_ | g_) >> h_, to_string(sout));
+ boost::fusion::for_each(flatten(a_ >> b_ | c_ >> d_ | e_ >> (f_ | g_) >> h_), to_string(sout));
     BOOST_CHECK_EQUAL("(a>>b)(c>>d)(e>>f|g>>h)", sout.str());
 
     // Test for n-way branching tree
     sout.str("");
- boost::fusion::for_each(a_(b_(c_ >> d_, e_ | f_), g_ >> h_)(i_), to_string(sout));
+ boost::fusion::for_each(flatten(a_(b_(c_ >> d_, e_ | f_), g_ >> h_)(i_)), to_string(sout));
     BOOST_CHECK_EQUAL("(a)(b)(c>>d)(e|f)(g>>h)(i)", sout.str());
 }
 

Modified: trunk/libs/xpressive/proto/test/proto_fusion_s.cpp
==============================================================================
--- trunk/libs/xpressive/proto/test/proto_fusion_s.cpp (original)
+++ trunk/libs/xpressive/proto/test/proto_fusion_s.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -55,7 +55,7 @@
     {}
 
     template<typename Op>
- void operator()(Op const &op) const
+ void operator ()(Op const &op) const
     {
         this->sout_ << '(' << boost::addressof(op.proto_base()) << ')';
     }
@@ -65,6 +65,8 @@
 
 void test1()
 {
+ using boost::proto::flatten;
+
     boost::proto::terminal<char>::type a_ = {'a'};
     boost::proto::terminal<char>::type b_ = {'b'};
     boost::proto::terminal<char>::type c_ = {'c'};
@@ -79,37 +81,37 @@
 
     // Test for 1-way branching "tree"
     sout.str("");
- boost::fusion::for_each_s(!!!!(a_ >> b_), to_string(sout));
+ boost::fusion::for_each_s(flatten(!!!!(a_ >> b_)), to_string(sout));
     BOOST_CHECK_EQUAL("(a>>b)", sout.str());
 
     // Tests for 2-way branching trees
     sout.str("");
- boost::fusion::for_each_s(a_ >> b_ >> c_, to_string(sout));
+ boost::fusion::for_each_s(flatten(a_ >> b_ >> c_), to_string(sout));
     BOOST_CHECK_EQUAL("(a)(b)(c)", sout.str());
 
     sout.str("");
- boost::fusion::for_each_s(a_ | b_ | c_, to_string(sout));
+ boost::fusion::for_each_s(flatten(a_ | b_ | c_), to_string(sout));
     BOOST_CHECK_EQUAL("(a)(b)(c)", sout.str());
 
     sout.str("");
- boost::fusion::for_each_s(a_ >> b_ | c_ >> d_, to_string(sout));
+ boost::fusion::for_each_s(flatten(a_ >> b_ | c_ >> d_), to_string(sout));
     BOOST_CHECK_EQUAL("(a>>b)(c>>d)", sout.str());
 
     sout.str("");
- boost::fusion::for_each_s(a_ | b_ >> c_ | d_, to_string(sout));
+ boost::fusion::for_each_s(flatten(a_ | b_ >> c_ | d_), to_string(sout));
     BOOST_CHECK_EQUAL("(a)(b>>c)(d)", sout.str());
 
     sout.str("");
- boost::fusion::for_each_s(a_ >> b_ | c_ >> d_ | e_ >> f_ >> g_, to_string(sout));
+ boost::fusion::for_each_s(flatten(a_ >> b_ | c_ >> d_ | e_ >> f_ >> g_), to_string(sout));
     BOOST_CHECK_EQUAL("(a>>b)(c>>d)(e>>f>>g)", sout.str());
 
     sout.str("");
- boost::fusion::for_each_s(a_ >> b_ | c_ >> d_ | e_ >> (f_ | g_) >> h_, to_string(sout));
+ boost::fusion::for_each_s(flatten(a_ >> b_ | c_ >> d_ | e_ >> (f_ | g_) >> h_), to_string(sout));
     BOOST_CHECK_EQUAL("(a>>b)(c>>d)(e>>f|g>>h)", sout.str());
 
     // Test for n-way branching tree
     sout.str("");
- boost::fusion::for_each_s(a_(b_(c_ >> d_, e_ | f_), g_ >> h_)(i_), to_string(sout));
+ boost::fusion::for_each_s(flatten(a_(b_(c_ >> d_, e_ | f_), g_ >> h_)(i_)), to_string(sout));
     BOOST_CHECK_EQUAL("(a)(b)(c>>d)(e|f)(g>>h)(i)", sout.str());
 }
 
@@ -134,6 +136,8 @@
 
 void test2()
 {
+ using boost::proto::flatten;
+
     My<boost::proto::terminal<char>::type> a_ = {{'a'}};
     My<boost::proto::terminal<char>::type> b_ = {{'b'}};
     My<boost::proto::terminal<char>::type> c_ = {{'c'}};
@@ -148,37 +152,37 @@
 
     // Test for 1-way branching "tree"
     sout.str("");
- boost::fusion::for_each_s(!!!!(a_ >> b_), to_string(sout));
+ boost::fusion::for_each_s(flatten(!!!!(a_ >> b_)), to_string(sout));
     BOOST_CHECK_EQUAL("(a>>b)", sout.str());
 
     // Tests for 2-way branching trees
     sout.str("");
- boost::fusion::for_each_s(a_ >> b_ >> c_, to_string(sout));
+ boost::fusion::for_each_s(flatten(a_ >> b_ >> c_), to_string(sout));
     BOOST_CHECK_EQUAL("(a)(b)(c)", sout.str());
 
     sout.str("");
- boost::fusion::for_each_s(a_ | b_ | c_, to_string(sout));
+ boost::fusion::for_each_s(flatten(a_ | b_ | c_), to_string(sout));
     BOOST_CHECK_EQUAL("(a)(b)(c)", sout.str());
 
     sout.str("");
- boost::fusion::for_each_s(a_ >> b_ | c_ >> d_, to_string(sout));
+ boost::fusion::for_each_s(flatten(a_ >> b_ | c_ >> d_), to_string(sout));
     BOOST_CHECK_EQUAL("(a>>b)(c>>d)", sout.str());
 
     sout.str("");
- boost::fusion::for_each_s(a_ | b_ >> c_ | d_, to_string(sout));
+ boost::fusion::for_each_s(flatten(a_ | b_ >> c_ | d_), to_string(sout));
     BOOST_CHECK_EQUAL("(a)(b>>c)(d)", sout.str());
 
     sout.str("");
- boost::fusion::for_each_s(a_ >> b_ | c_ >> d_ | e_ >> f_ >> g_, to_string(sout));
+ boost::fusion::for_each_s(flatten(a_ >> b_ | c_ >> d_ | e_ >> f_ >> g_), to_string(sout));
     BOOST_CHECK_EQUAL("(a>>b)(c>>d)(e>>f>>g)", sout.str());
 
     sout.str("");
- boost::fusion::for_each_s(a_ >> b_ | c_ >> d_ | e_ >> (f_ | g_) >> h_, to_string(sout));
+ boost::fusion::for_each_s(flatten(a_ >> b_ | c_ >> d_ | e_ >> (f_ | g_) >> h_), to_string(sout));
     BOOST_CHECK_EQUAL("(a>>b)(c>>d)(e>>f|g>>h)", sout.str());
 
     // Test for n-way branching tree
     sout.str("");
- boost::fusion::for_each_s(a_(b_(c_ >> d_, e_ | f_), g_ >> h_)(i_), to_string(sout));
+ boost::fusion::for_each_s(flatten(a_(b_(c_ >> d_, e_ | f_), g_ >> h_)(i_)), to_string(sout));
     BOOST_CHECK_EQUAL("(a)(b)(c>>d)(e|f)(g>>h)(i)", sout.str());
 }
 

Modified: trunk/libs/xpressive/proto/test/toy_spirit2.cpp
==============================================================================
--- trunk/libs/xpressive/proto/test/toy_spirit2.cpp (original)
+++ trunk/libs/xpressive/proto/test/toy_spirit2.cpp 2008-01-12 01:43:28 EST (Sat, 12 Jan 2008)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// toy_spirit2.cpp
+// toy_spirit3.cpp
 //
 // Copyright 2006 Eric Niebler. Distributed under the Boost
 // Software License, Version 1.0. (See accompanying file
@@ -7,25 +7,25 @@
 
 #include <cctype>
 #include <string>
+#include <cstring>
 #include <iomanip>
 #include <iostream>
+#include <boost/version.hpp>
 #include <boost/assert.hpp>
 #include <boost/mpl/assert.hpp>
 #include <boost/utility/result_of.hpp>
 #include <boost/type_traits/is_same.hpp>
 #include <boost/xpressive/proto/proto.hpp>
-#include <boost/xpressive/proto/transform/arg.hpp>
-#include <boost/xpressive/proto/transform/construct.hpp>
-#include <boost/xpressive/proto/transform/fold_tree.hpp>
-#include <boost/xpressive/proto/transform/list.hpp>
+#include <boost/xpressive/proto/transform.hpp>
 #if BOOST_VERSION < 103500
 # include <boost/spirit/fusion/algorithm/for_each.hpp>
 # include <boost/spirit/fusion/algorithm/fold.hpp>
 # include <boost/spirit/fusion/algorithm/any.hpp>
 #else
-#include <boost/fusion/include/for_each.hpp>
-#include <boost/fusion/include/fold.hpp>
-#include <boost/fusion/include/any.hpp>
+# include <boost/fusion/include/for_each.hpp>
+# include <boost/fusion/include/fold.hpp>
+# include <boost/fusion/include/cons.hpp>
+# include <boost/fusion/include/any.hpp>
 #endif
 #include <boost/test/unit_test.hpp>
 
@@ -70,7 +70,7 @@
             FwdIter tmp = begin;
             std::string::const_iterator istr = str.begin(), estr = str.end();
             for(; istr != estr; ++tmp, istr += 2)
- if(tmp == end || *tmp != *istr && *tmp != *(istr+1))
+ if(tmp == end || (*tmp != *istr && *tmp != *(istr+1)))
                     return false;
             begin = tmp;
             return true;
@@ -101,44 +101,22 @@
         }
     } // namespace utility
 
- // Composite parser that contains a Fusion cons-list of other parsers
- // OR
- // A compiler that compiles an expression and wraps the result in
- // a composite<> wrapper
- template<typename Tag, typename List>
- struct composite
+ template<typename List>
+ struct alternate
     {
- composite(List const &list)
+ explicit alternate(List const &list)
           : elems(list)
         {}
-
         List elems;
     };
 
- template<typename Tag, typename Grammar>
- struct as_composite
- : Grammar
- {
- as_composite();
-
- // The apply<> struct and the call() member are to satisfy the
- // proto compiler/transform protocol
- template<typename Expr, typename State, typename Visitor>
- struct apply
- {
- typedef composite<
- Tag
- , typename Grammar::template apply<Expr, State, Visitor>::type
- > type;
- };
-
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return typename apply<Expr, State, Visitor>::type
- (Grammar::call(expr, state, visitor));
- }
+ template<typename List>
+ struct sequence
+ {
+ explicit sequence(List const &list)
+ : elems(list)
+ {}
+ List elems;
     };
 
     struct char_range
@@ -171,205 +149,111 @@
     struct ichar_range
       : std::pair<char, char>
     {
- ichar_range(char_range const &rng)
- : std::pair<char, char>(rng)
+ ichar_range(char from, char to)
+ : std::pair<char, char>(from, to)
         {}
     };
 
     // The no-case directive
     struct no_case_tag {};
 
- // The no-case transform, applies the tree-transform with
- // mpl::true_ as the visitor.
- template<typename Grammar>
- struct no_case_transform
- : Grammar
+ struct True : mpl::true_ {};
+
+ ///////////////////////////////////////////////////////////////////////////////
+ /// Begin Spirit grammar here
+ ///////////////////////////////////////////////////////////////////////////////
+ namespace grammar
     {
- no_case_transform();
+ using namespace proto;
+ using namespace fusion;
+ using namespace transform;
 
- template<typename Expr, typename State, typename>
- struct apply
- : Grammar::template apply<Expr, State, mpl::true_>
- {};
+ struct SpiritExpr;
 
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &)
- {
- mpl::true_ case_sensitive;
- return Grammar::call(expr, state, case_sensitive);
- }
- };
+ struct AnyChar
+ : terminal<char_tag>
+ {};
 
- // remove_case specializations for stripping case-sensitivity from parsers
- template<typename T, bool CaseSensitive>
- struct remove_case
- {
- typedef T type;
- template<typename U> static U const &call(U const &t)
- {
- return t;
- }
- };
+ struct CharLiteral
+ : terminal<char>
+ {};
 
- template<>
- struct remove_case<char, true>
- {
- typedef ichar type;
- static ichar call(char ch)
- {
- return ichar(ch);
- }
- };
+ struct NTBSLiteral
+ : terminal<char const *>
+ {};
 
- template<>
- struct remove_case<char const *, true>
- {
- typedef istr type;
- static istr call(char const *sz)
- {
- return istr(sz);
- }
- };
+ struct CharParser
+ : function<AnyChar, CharLiteral>
+ {};
 
- template<typename T, std::size_t N>
- struct remove_case<T(&)[N], true>
- : remove_case<char const *, true>
- {};
+ struct CharRangeParser
+ : function<AnyChar, CharLiteral, CharLiteral>
+ {};
 
- template<>
- struct remove_case<char_range, true>
- {
- typedef ichar_range type;
- static ichar_range call(char_range const &rng)
- {
- return ichar_range(rng);
- }
- };
+ struct NoCase
+ : terminal<no_case_tag>
+ {};
 
- // A case-sensitive transform that removes case conditionally, depending on
- // a compile-time flag carried by the visitor.
- template<typename Grammar>
- struct case_sensitive
- : Grammar
- {
- case_sensitive();
+ // The visitor determines the case-sensitivity of the terminals
+ typedef _visitor _icase;
 
- template<typename Expr, typename State, typename Visitor>
- struct apply
- : remove_case<
- typename Grammar::template apply<Expr, State, Visitor>::type
- , Visitor::value
+ // Ugh, would be nice to find a work-around for this:
+ #if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
+ #define _arg(x) call<_arg(x)>
+ #define True() make<True()>
+ #endif
+
+ // Extract the arg from terminals
+ struct SpiritTerminal
+ : or_<
+ when< AnyChar, _arg >
+ , when< CharLiteral, if_<_icase, ichar(_arg), _arg> >
+ , when< CharParser, if_<_icase, ichar(_arg(_arg1)), _arg(_arg1)> > // char_('a')
+ , when< NTBSLiteral, if_<_icase, istr(_arg), char const*(_arg)> >
+ , when< CharRangeParser, if_<_icase
+ , ichar_range(_arg(_arg1), _arg(_arg2))
+ , char_range(_arg(_arg1), _arg(_arg2))> > // char_('a','z')
>
         {};
 
- template<typename Expr, typename State, typename Visitor>
- static typename apply<Expr, State, Visitor>::type
- call(Expr const &expr, State const &state, Visitor &visitor)
- {
- return apply<Expr, State, Visitor>::call(Grammar::call(expr, state, visitor));
- }
- };
-
- ///////////////////////////////////////////////////////////////////////////////
- /// Begin ToySpiritGrammar here
- ///////////////////////////////////////////////////////////////////////////////
+ struct FoldToList
+ : reverse_fold_tree<_, nil(), cons<SpiritExpr, _state>(SpiritExpr, _state)>
+ {};
 
- struct ToySpiritGrammar;
+ // sequence rule folds all >>'s together into a list
+ // and wraps the result in a sequence<> wrapper
+ struct SpiritSequence
+ : when< shift_right<SpiritExpr, SpiritExpr>, sequence<FoldToList>(FoldToList) >
+ {};
 
- struct AnyChar
- : proto::terminal<char_tag>
- {};
-
- struct CharLiteral
- : proto::terminal<char>
- {};
-
- struct NTBSLiteral
- : proto::terminal<char const *>
- {};
-
- struct CharParser
- : proto::function<AnyChar, CharLiteral>
- {};
-
- struct CharRangeParser
- : proto::function<AnyChar, CharLiteral, CharLiteral>
- {};
-
- struct NoCase
- : proto::terminal<no_case_tag>
- {};
-
- // Extract the arg from terminals
- struct ToySpiritTerminal
- : proto::or_<
- proto::transform::arg< AnyChar >
- , case_sensitive< proto::transform::arg< CharLiteral > >
- , case_sensitive< proto::transform::arg< NTBSLiteral > >
- , case_sensitive<
- proto::transform::arg< proto::transform::arg_c< CharParser, 1 > > // char_('a')
- >
- , case_sensitive<
- proto::transform::construct< // char_('a','z')
- CharRangeParser
- , char_range(
- proto::transform::arg< proto::transform::arg_c< proto::_, 1 > >
- , proto::transform::arg< proto::transform::arg_c< proto::_, 2 > >
- )
- >
- >
- >
- {};
+ // alternate rule folds all |'s together into a list
+ // and wraps the result in a alternate<> wrapper
+ struct SpiritAlternate
+ : when< bitwise_or<SpiritExpr, SpiritExpr>, alternate<FoldToList>(FoldToList) >
+ {};
 
- // sequence rule folds all >>'s together into a list
- // and wraps the result in a composite<> wrapper
- struct ToySpiritSequence
- : as_composite<
- proto::tag::shift_right
- , proto::transform::reverse_fold_tree<
- proto::tag::shift_right
- , proto::transform::list<ToySpiritGrammar>
- , fusion::nil
- >
- >
- {};
+ // Directives such as no_case are handled here
+ struct SpiritDirective
+ : when< subscript<NoCase, SpiritExpr>, SpiritExpr(_right, _state, True()) >
+ {};
 
- // alternate rule folds all |'s together into a list
- // and wraps the result in a composite<> wrapper
- struct ToySpiritAlternate
- : as_composite<
- proto::tag::bitwise_or
- , proto::transform::reverse_fold_tree<
- proto::tag::bitwise_or
- , proto::transform::list<ToySpiritGrammar>
- , fusion::nil
+ // A SpiritExpr is an alternate, a sequence, a directive or a terminal
+ struct SpiritExpr
+ : or_<
+ SpiritSequence
+ , SpiritAlternate
+ , SpiritDirective
+ , SpiritTerminal
>
- >
- {};
+ {};
 
- // Directives such as no_case are handled here
- struct ToySpiritDirective
- : no_case_transform<
- proto::transform::arg_c<
- proto::subscript< NoCase, ToySpiritGrammar >
- , 1
- >
- >
- {};
+ } // namespace grammar
 
- // A ToySpiritGrammar is an alternate, a sequence, a directive or a terminal
- struct ToySpiritGrammar
- : proto::or_<
- ToySpiritSequence
- , ToySpiritAlternate
- , ToySpiritDirective
- , ToySpiritTerminal
- >
- {};
+ using grammar::SpiritExpr;
+ using grammar::NoCase;
 
     ///////////////////////////////////////////////////////////////////////////////
- /// End ToySpiritGrammar
+ /// End SpiritExpr
     ///////////////////////////////////////////////////////////////////////////////
 
     // Globals
@@ -384,7 +268,7 @@
         {}
 
         template<typename T>
- bool operator()(T const &t) const
+ bool operator ()(T const &t) const
         {
             Iterator tmp = this->first;
             if((*static_cast<Derived const *>(this))(t))
@@ -404,43 +288,43 @@
 
     template<typename Iterator>
     struct parser
- : with_reset<Iterator, parser<Iterator> >
+ : spirit2::with_reset<Iterator, parser<Iterator> >
     {
- typedef with_reset<Iterator, parser<Iterator> > with_reset;
+ typedef spirit2::with_reset<Iterator, parser<Iterator> > with_reset;
 
         parser(Iterator begin, Iterator end)
           : with_reset(begin, end)
         {}
 
-#if BOOST_VERSION < 103500
+ #if BOOST_VERSION < 103500
         template<typename, typename> // used by fusion::fold
         struct apply
         {
             typedef bool type;
         };
-#else
+ #else
         typedef bool result_type; // used by fusion::fold
-#endif
+ #endif
 
         template<typename T>
- bool operator()(T const &t, bool success) const // used by fusion::fold
+ bool operator ()(T const &t, bool success) const // used by fusion::fold
         {
             return success && (*this)(t);
         }
 
         template<typename List>
- bool operator()(composite<proto::tag::bitwise_or, List> const &alternates) const
+ bool operator ()(alternate<List> const &alternates) const
         {
             return fusion::any(alternates.elems, *static_cast<with_reset const *>(this));
         }
 
         template<typename List>
- bool operator()(composite<proto::tag::shift_right, List> const &sequence) const
+ bool operator ()(sequence<List> const &sequence) const
         {
             return fusion::fold(sequence.elems, true, *this);
         }
 
- bool operator()(char_tag ch) const
+ bool operator ()(char_tag ch) const
         {
             if(this->done())
                 return false;
@@ -448,7 +332,7 @@
             return true;
         }
 
- bool operator()(char ch) const
+ bool operator ()(char ch) const
         {
             if(this->done() || ch != *this->first)
                 return false;
@@ -456,7 +340,7 @@
             return true;
         }
 
- bool operator()(ichar ich) const
+ bool operator ()(ichar ich) const
         {
             if(this->done() || !utility::char_icmp(*this->first, ich.lo_, ich.hi_))
                 return false;
@@ -464,17 +348,17 @@
             return true;
         }
 
- bool operator()(char const *sz) const
+ bool operator ()(char const *sz) const
         {
             return utility::string_cmp(sz, this->first, this->second);
         }
 
- bool operator()(istr const &s) const
+ bool operator ()(istr const &s) const
         {
             return utility::string_icmp(s.str_, this->first, this->second);
         }
 
- bool operator()(char_range rng) const
+ bool operator ()(char_range rng) const
         {
             if(this->done() || !utility::in_range(*this->first, rng.first, rng.second))
                 return false;
@@ -482,7 +366,7 @@
             return true;
         }
 
- bool operator()(ichar_range rng) const
+ bool operator ()(ichar_range rng) const
         {
             if(this->done() || !utility::in_irange(*this->first, rng.first, rng.second))
                 return false;
@@ -492,20 +376,20 @@
     };
 
     template<typename Rule, typename Iterator>
- typename enable_if<proto::matches< Rule, ToySpiritGrammar >, bool >::type
+ typename enable_if<proto::matches< Rule, SpiritExpr >, bool >::type
     parse_impl(Rule const &rule, Iterator begin, Iterator end)
     {
         mpl::false_ is_case_sensitive;
         parser<Iterator> parse_fun(begin, end);
- return parse_fun(ToySpiritGrammar::call(rule, 0, is_case_sensitive));
+ return parse_fun(SpiritExpr()(rule, 0, is_case_sensitive));
     }
 
     // 2nd overload provides a short error message for invalid rules
     template<typename Rule, typename Iterator>
- typename disable_if<proto::matches< Rule, ToySpiritGrammar >, bool >::type
+ typename disable_if<proto::matches< Rule, SpiritExpr >, bool >::type
     parse_impl(Rule const &rule, Iterator begin, Iterator end)
     {
- BOOST_MPL_ASSERT((proto::matches<Rule, ToySpiritGrammar>));
+ BOOST_MPL_ASSERT((proto::matches<Rule, SpiritExpr>));
         return false;
     }
 
@@ -519,15 +403,14 @@
 
 }}
 
-using namespace boost;
-
-void test_toy_spirit2()
+void test_toy_spirit3()
 {
- using spirit2::no_case;
+ using boost::spirit2::no_case;
+ using boost::char_;
     std::string hello("abcd");
 
     BOOST_CHECK(
- spirit2::parse(
+ boost::spirit2::parse(
             "abcd"
           , hello.begin()
           , hello.end()
@@ -535,7 +418,7 @@
     );
 
     BOOST_CHECK(
- spirit2::parse(
+ boost::spirit2::parse(
             char_ >> char_('b') >> 'c' >> char_
           , hello.begin()
           , hello.end()
@@ -543,7 +426,7 @@
     );
 
     BOOST_CHECK(
- !spirit2::parse(
+ !boost::spirit2::parse(
             char_ >> char_('b') >> 'c' >> 'D'
           , hello.begin()
           , hello.end()
@@ -551,7 +434,7 @@
     );
 
     BOOST_CHECK(
- spirit2::parse(
+ boost::spirit2::parse(
             char_ >> char_('b') >> 'c' >> 'e'
           | char_ >> no_case[char_('B') >> "C" >> char_('D','Z')]
           , hello.begin()
@@ -568,7 +451,7 @@
 {
     test_suite *test = BOOST_TEST_SUITE("test proto, grammars and tree transforms");
 
- test->add(BOOST_TEST_CASE(&test_toy_spirit2));
+ test->add(BOOST_TEST_CASE(&test_toy_spirit3));
 
     return test;
 }


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