Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2007-12-05 01:52:46


Author: eric_niebler
Date: 2007-12-05 01:52:45 EST (Wed, 05 Dec 2007)
New Revision: 41737
URL: http://svn.boost.org/trac/boost/changeset/41737

Log:
holy crap, test_actions passes! wow.
Text files modified:
   branches/proto/v3/boost/xpressive/proto/traits.hpp | 6 +-
   branches/proto/v3/boost/xpressive/regex_actions.hpp | 16 +++++++
   branches/proto/v3/boost/xpressive/regex_primitives.hpp | 83 ++++++++++++++++++---------------------
   3 files changed, 57 insertions(+), 48 deletions(-)

Modified: branches/proto/v3/boost/xpressive/proto/traits.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/traits.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/traits.hpp 2007-12-05 01:52:45 EST (Wed, 05 Dec 2007)
@@ -186,10 +186,10 @@
             typename result<binary_expr(Expr, State, Visitor)>::type
             operator()(Expr const &expr, State const &state, Visitor &visitor) const
             {
- typename result<binary_expr(Expr, State, Visitor)>::type that = {
+ typename result<binary_expr(Expr, State, Visitor)>::type that = {{
                     T()(proto::arg_c<0>(expr), state, visitor)
- , U()(proto::arg_c<1>(expr), state, visitor)
- };
+ , {U()(proto::arg_c<1>(expr), state, visitor)}
+ }};
                 return that;
             }
         };

Modified: branches/proto/v3/boost/xpressive/regex_actions.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/regex_actions.hpp (original)
+++ branches/proto/v3/boost/xpressive/regex_actions.hpp 2007-12-05 01:52:45 EST (Wed, 05 Dec 2007)
@@ -686,6 +686,22 @@
         }
     };
 
+ template<typename T, typename A>
+ typename proto::result_of::make_expr<
+ proto::tag::function
+ , proto::default_domain
+ , op::as<T> const
+ , A
+ >::type as(A &&a)
+ {
+ return proto::result_of::make_expr<
+ proto::tag::function
+ , proto::default_domain
+ , op::as<T> const
+ , A
+ >::call(op::as<T>(), a);
+ }
+
     ///// as (a.k.a., lexical_cast)
     /////
     //BOOST_PROTO_DEFINE_FUNCTION_TEMPLATE(

Modified: branches/proto/v3/boost/xpressive/regex_primitives.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/regex_primitives.hpp (original)
+++ branches/proto/v3/boost/xpressive/regex_primitives.hpp 2007-12-05 01:52:45 EST (Wed, 05 Dec 2007)
@@ -52,51 +52,44 @@
         using proto::extends<basic_mark_tag, mark_tag>::operator =;
     };
 
- //template<typename Grammar>
- //struct push_back_sub
- // //: proto::transform::identity<Grammar>
- // : proto::_expr
- //{
- // template<typename Sub>
- // static int to_sub(Sub const &sub, proto::tag::terminal)
- // {
- // return proto::arg(sub).mark_number_;
- // }
-
- // template<typename Sub>
- // static int to_sub(Sub const &, proto::tag::negate)
- // {
- // return -1;
- // }
-
- // template<typename Expr, typename State, typename Visitor>
- // static Expr const &call(Expr const &expr, State const &, Visitor &subs)
- // {
- // subs.push_back(push_back_sub::to_sub(expr, typename Expr::proto_tag()));
- // return expr;
- // }
- //};
-
- //// s1 or -s1
- //struct SubMatch
- // : push_back_sub<proto::or_<basic_mark_tag, proto::negate<basic_mark_tag > > >
- //{};
-
- //struct SubMatchList
- // : proto::or_<SubMatch, proto::comma<SubMatchList, SubMatch> >
- //{};
-
- //template<typename Subs>
- //typename enable_if<
- // mpl::and_<proto::is_expr<Subs>, proto::matches<Subs, SubMatchList> >
- // , std::vector<int>
- //>::type
- //to_vector(Subs const &subs)
- //{
- // std::vector<int> subs_;
- // SubMatchList::call(subs, 0, subs_);
- // return subs_;
- //}
+ struct push_back : proto::transform_base
+ {
+ typedef int result_type;
+
+ template<typename Subs>
+ int operator()(Subs &subs, int i) const
+ {
+ subs.push_back(i);
+ return i;
+ }
+ };
+
+ struct negative_one : mpl::int_<-1> {};
+ using grammar_detail::mark_number;
+
+ // s1 or -s1
+ struct SubMatch
+ : proto::or_<
+ proto::when<basic_mark_tag, push_back(proto::_visitor, mark_number(proto::_arg))>
+ , proto::when<proto::negate<basic_mark_tag >, push_back(proto::_visitor, negative_one())>
+ >
+ {};
+
+ struct SubMatchList
+ : proto::or_<SubMatch, proto::comma<SubMatchList, SubMatch> >
+ {};
+
+ template<typename Subs>
+ typename enable_if<
+ mpl::and_<proto::is_expr<Subs>, proto::matches<Subs, SubMatchList> >
+ , std::vector<int>
+ >::type
+ to_vector(Subs const &subs)
+ {
+ std::vector<int> subs_;
+ SubMatchList()(subs, 0, subs_);
+ return subs_;
+ }
 
 
 /*


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