Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2007-11-30 21:27:28


Author: eric_niebler
Date: 2007-11-30 21:27:28 EST (Fri, 30 Nov 2007)
New Revision: 41522
URL: http://svn.boost.org/trac/boost/changeset/41522

Log:
handle modifiers
Text files modified:
   branches/proto/v3/boost/xpressive/detail/static/grammar2.hpp | 26 ++++++++++++++++++++++++++
   branches/proto/v3/boost/xpressive/detail/static/modifier.hpp | 14 ++++----------
   2 files changed, 30 insertions(+), 10 deletions(-)

Modified: branches/proto/v3/boost/xpressive/detail/static/grammar2.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/static/grammar2.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/static/grammar2.hpp 2007-11-30 21:27:28 EST (Fri, 30 Nov 2007)
@@ -448,6 +448,24 @@
             }
         };
 
+ struct modify : function_transform
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Modifier, typename Visitor>
+ struct result<This(Modifier, Visitor)>
+ : Modifier::template apply<Visitor>
+ {};
+
+ template<typename Modifier, typename Visitor>
+ typename Modifier::template apply<Visitor>::type
+ operator()(Modifier const &modifier, Visitor &visitor) const
+ {
+ return modifier.call(visitor);
+ }
+ };
+
         ///////////////////////////////////////////////////////////////////////////
         // Cases
         template<typename Char, typename Gram>
@@ -802,6 +820,14 @@
>
>
             {};
+
+ template<typename Dummy>
+ struct case_<modifier_tag, Dummy>
+ : when<
+ binary_expr<modifier_tag, terminal<_>, Gram>
+ , Gram(_right, _state, modify(_arg(_left), _visitor))
+ >
+ {};
         };
 
     } // namespace detail

Modified: branches/proto/v3/boost/xpressive/detail/static/modifier.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/static/modifier.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/static/modifier.hpp 2007-11-30 21:27:28 EST (Fri, 30 Nov 2007)
@@ -32,20 +32,14 @@
 
         template<typename Expr>
         struct apply
- {
- typedef typename proto::binary_expr<
- modifier_tag
- , typename proto::terminal<Modifier>::type
- , typename proto::result_of::as_arg<Expr const>::type
- >::type type;
- };
+ : proto::result_of::make_expr<modifier_tag, Modifier, Expr const>
+ {};
 
         template<typename Expr>
- typename apply<Expr>::type const
+ typename proto::result_of::make_expr<modifier_tag, Modifier, Expr const>::type
         operator ()(Expr const &expr) const
         {
- typename apply<Expr>::type that = {{this->mod_}, proto::as_arg(expr)};
- return that;
+ return proto::make_expr<modifier_tag>(this->mod_, expr);
         }
 
         operator opt_type() const


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