Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2007-12-03 16:30:52


Author: eric_niebler
Date: 2007-12-03 16:30:51 EST (Mon, 03 Dec 2007)
New Revision: 41666
URL: http://svn.boost.org/trac/boost/changeset/41666

Log:
tweaks and fixes
Text files modified:
   branches/proto/v3/boost/xpressive/detail/static/grammar.hpp | 32 +++++++++++----------------
   branches/proto/v3/boost/xpressive/proto/traits.hpp | 5 ++++
   branches/proto/v3/boost/xpressive/proto/transform/make.hpp | 46 +++++++++++++++++++++++++++++----------
   3 files changed, 52 insertions(+), 31 deletions(-)

Modified: branches/proto/v3/boost/xpressive/detail/static/grammar.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/static/grammar.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/static/grammar.hpp 2007-12-03 16:30:51 EST (Mon, 03 Dec 2007)
@@ -523,7 +523,7 @@
>
             {};
 
- template<typename Greedy, typename Tag>
+ template<typename Greedy, typename Tag, typename Base = transform_base>
             struct as_repeater
               : call<
                     _make_shift_right(
@@ -563,12 +563,12 @@
>
             {};
 
- template<typename Greedy, typename Tag>
+ template<typename Greedy, typename Tag , typename Base = transform_base >
             struct as_default_repeat
               : as_default_repeat_impl<Greedy, Tag>
             {};
 
- template<typename Greedy>
+ template<typename Greedy , typename Base = transform_base >
             struct as_simple_repeat
               : make<
                     simple_repeat_matcher<as_independent(_arg), Greedy>(
@@ -580,7 +580,7 @@
>
             {};
 
- template<typename Greedy>
+ template<typename Greedy, typename Base = transform_base>
             struct as_repeat
               : if_<
                     use_simple_repeat<_arg, Char>()
@@ -589,10 +589,7 @@
>
             {};
 
- struct as_greedy_repeat : as_repeat<greedy_t> {};
- struct as_non_greedy_repeat : as_repeat<non_greedy_t> {};
-
- template<typename Greedy>
+ template<typename Greedy, typename Base = transform_base>
             struct as_optional
               : if_<
                     matches<_, MarkedSubExpr>()
@@ -601,9 +598,6 @@
>
             {};
 
- struct as_greedy_optional : as_optional<greedy_t> {};
- struct as_non_greedy_optional : as_optional<non_greedy_t> {};
-
             struct as_list_set
               : call<
                     fill_list_set(
@@ -663,38 +657,38 @@
             template<typename Dummy>
             struct case_<tag::dereference, Dummy>
                 // *_
- : when<dereference<Gram>, as_greedy_repeat>
+ : when<dereference<Gram>, as_repeat<greedy_t> >
             {};
 
             template<typename Dummy>
             struct case_<tag::posit, Dummy>
                 // +_
- : when<posit<Gram>, as_greedy_repeat>
+ : when<posit<Gram>, as_repeat<greedy_t> >
             {};
 
             template<uint_t Min, uint_t Max, typename Dummy>
             struct case_<generic_quant_tag<Min, Max>, Dummy>
                 // repeat<0,42>(_)
- : when<unary_expr<generic_quant_tag<Min, Max>, Gram>, as_greedy_repeat>
+ : when<unary_expr<generic_quant_tag<Min, Max>, Gram>, as_repeat<greedy_t> >
             {};
 
             template<typename Dummy>
             struct case_<tag::logical_not, Dummy>
                 // !_
- : when<logical_not<Gram>, as_greedy_optional(_arg)>
+ : when<logical_not<Gram>, as_optional<greedy_t> (_arg)>
             {};
 
             template<typename Dummy>
             struct case_<tag::negate, Dummy>
               : or_<
                     // -*_
- when<negate<dereference<Gram> > , as_non_greedy_repeat(_arg)>
+ when<negate<dereference<Gram> > , as_repeat<non_greedy_t>(_arg)>
                     // -+_
- , when<negate<posit<Gram> > , as_non_greedy_repeat(_arg)>
+ , when<negate<posit<Gram> > , as_repeat<non_greedy_t>(_arg)>
                     // -repeat<0,42>(_)
- , when<negate<GenericQuant> , as_non_greedy_repeat(_arg)>
+ , when<negate<GenericQuant> , as_repeat<non_greedy_t>(_arg)>
                     // -!_
- , when<negate<logical_not<Gram> > , as_non_greedy_optional(_arg(_arg))>
+ , when<negate<logical_not<Gram> > , as_optional<non_greedy_t>(_arg(_arg))>
>
             {};
 

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-03 16:30:51 EST (Mon, 03 Dec 2007)
@@ -664,6 +664,11 @@
       : mpl::false_
     {};
 
+ template<>
+ struct is_transform<transform_base>
+ : mpl::false_
+ {};
+
     /// is_aggregate
     ///
     template<typename T>

Modified: branches/proto/v3/boost/xpressive/proto/transform/make.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/make.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/make.hpp 2007-12-03 16:30:51 EST (Mon, 03 Dec 2007)
@@ -9,11 +9,13 @@
 #ifndef BOOST_PROTO_TRANSFORM_MAKE_HPP_EAN_12_02_2007
 #define BOOST_PROTO_TRANSFORM_MAKE_HPP_EAN_12_02_2007
 
+#include <boost/mpl/eval_if.hpp>
 #include <boost/mpl/aux_/has_type.hpp>
 #include <boost/utility/result_of.hpp>
 #include <boost/utility/enable_if.hpp>
 #include <boost/xpressive/proto/proto_fwd.hpp>
 #include <boost/xpressive/proto/traits.hpp>
+#include <boost/xpressive/proto/args.hpp>
 
 namespace boost { namespace proto
 {
@@ -55,46 +57,46 @@
             template<typename R, typename Expr, typename State, typename Visitor
                 , bool IsTransform = is_transform<R>::value
>
- struct apply_lambda_;
+ struct make_if_;
 
             template<typename R, typename Expr, typename State, typename Visitor>
- struct apply_lambda_aux_
+ struct make_
             {
                 typedef R type;
                 typedef void not_applied_;
             };
 
             template<template<typename...> class R, typename... Args, typename Expr, typename State, typename Visitor>
- struct apply_lambda_aux_<R<Args...>, Expr, State, Visitor>
+ struct make_<R<Args...>, Expr, State, Visitor>
               : nested_type_if<
- R<typename apply_lambda_<Args, Expr, State, Visitor>::type...>
- , typelist<apply_lambda_<Args, Expr, State, Visitor>...>
+ R<typename make_if_<Args, Expr, State, Visitor>::type...>
+ , typelist<make_if_<Args, Expr, State, Visitor>...>
>
             {};
 
             template<typename R, typename Expr, typename State, typename Visitor>
- struct apply_lambda_<R, Expr, State, Visitor, false>
- : apply_lambda_aux_<R, Expr, State, Visitor>
+ struct make_if_<R, Expr, State, Visitor, false>
+ : make_<R, Expr, State, Visitor>
             {};
 
             template<typename R, typename Expr, typename State, typename Visitor>
- struct apply_lambda_<R, Expr, State, Visitor, true>
+ struct make_if_<R, Expr, State, Visitor, true>
               : boost::result_of<R(Expr, State, Visitor)>
             {};
 
             template<typename R, typename... Args, typename Expr, typename State, typename Visitor>
- struct apply_lambda_<R(Args...), Expr, State, Visitor, false>
+ struct make_if_<R(Args...), Expr, State, Visitor, false>
               : boost::result_of<when<_, R(Args...)>(Expr, State, Visitor)>
             {};
 
             template<typename R, typename... Args, typename Expr, typename State, typename Visitor>
- struct apply_lambda_<R(*)(Args...), Expr, State, Visitor, false>
+ struct make_if_<R(*)(Args...), Expr, State, Visitor, false>
               : boost::result_of<when<_, R(Args...)>(Expr, State, Visitor)>
             {};
 
             // work around GCC bug
             template<typename Tag, typename Args, long N, typename Expr, typename State, typename Visitor>
- struct apply_lambda_<expr<Tag, Args, N>, Expr, State, Visitor, false>
+ struct make_if_<expr<Tag, Args, N>, Expr, State, Visitor, false>
             {
                 typedef expr<Tag, Args, N> type;
                 typedef void not_applied_;
@@ -130,7 +132,7 @@
 
             template<typename This, typename Expr, typename State, typename Visitor>
             struct result<This(Expr, State, Visitor)>
- : detail::apply_lambda_<Return, Expr, State, Visitor>
+ : detail::make_<Return, Expr, State, Visitor>
             {};
 
             template<typename Expr, typename State, typename Visitor>
@@ -142,6 +144,26 @@
             }
         };
 
+ // work around gcc bug
+ template<typename T, typename A, long N, typename... Args>
+ struct make<expr<T, A, N>, Args... > : transform_base
+ {
+ template<typename Sig>
+ struct result
+ {
+ typedef expr<T, A, N> type;
+ };
+
+ template<typename Expr, typename State, typename Visitor>
+ expr<T, A, N> operator()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ proto::expr<T, A, N> that = {{
+ when<_, Args>()(expr, state, visitor)...
+ }};
+ return that;
+ }
+ };
+
         template<typename Fun, typename... Args>
         struct make<Fun(Args...)>
           : make<Fun, Args...>


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