$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: eric_at_[hidden]
Date: 2007-12-04 02:19:14
Author: eric_niebler
Date: 2007-12-04 02:19:14 EST (Tue, 04 Dec 2007)
New Revision: 41677
URL: http://svn.boost.org/trac/boost/changeset/41677
Log:
bug fixes, add proto::otherwise
Text files modified: 
   branches/proto/v3/boost/xpressive/detail/static/grammar.hpp |    47 ++++++++++++++++++++++++++++++--------- 
   branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp       |     4 +++                                     
   branches/proto/v3/boost/xpressive/proto/traits.hpp          |    47 +++++++++++++++++++++++++++------------ 
   branches/proto/v3/boost/xpressive/proto/transform/when.hpp  |     5 ++++                                    
   4 files changed, 77 insertions(+), 26 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-04 02:19:14 EST (Tue, 04 Dec 2007)
@@ -475,6 +475,17 @@
               : assign<terminal<mark_placeholder>, _>
             {};
 
+            struct MarkedSubExprEx
+              : or_<
+                    assign<terminal<mark_placeholder>, _>
+                  , shift_right<terminal<mark_begin_matcher>, _>
+                  , shift_right<
+                        terminal<repeat_begin_matcher>
+                      , shift_right<shift_right<terminal<mark_begin_matcher>, _>, _>
+                    >
+                >
+            {};
+
             struct GenericQuant
               : and_<
                     if_<is_generic_quant_tag<tag_of<_> >()>
@@ -516,10 +527,9 @@
             {};
 
             struct add_hidden_mark
-              : if_<
-                    matches<_, MarkedSubExpr>()
-                  , _
-                  , _make_assign(mark_placeholder(get_hidden_mark(_visitor)), _)
+              : or_<
+                    when<MarkedSubExpr, _>
+                  , otherwise<_make_assign(mark_placeholder(get_hidden_mark(_visitor)), _)>
                 >
             {};
 
@@ -549,8 +559,8 @@
             struct as_default_repeat_impl<Greedy, Tag, 0, Max>
               : if_<
                     Greedy()
-                  , _make_negate(_make_logical_not(as_default_repeat_impl<Greedy, generic_quant_tag<1, Max> >))
                   , _make_logical_not(as_default_repeat_impl<Greedy, generic_quant_tag<1, Max> >)
+                  , _make_negate(_make_logical_not(as_default_repeat_impl<Greedy, generic_quant_tag<1, Max> >))
                 >
             {};
 
@@ -558,8 +568,8 @@
             struct as_default_repeat_impl<Greedy, Tag, 0, 1>
               : if_<
                     Greedy()
-                  , _make_negate(_make_logical_not(_arg))
                   , _make_logical_not(_arg)
+                  , _make_negate(_make_logical_not(_arg))
                 >
             {};
 
@@ -591,10 +601,15 @@
 
             template<typename Greedy, typename Base = transform_base>
             struct as_optional
-              : if_<
-                    matches<_, MarkedSubExpr>()
-                  , optional_mark_matcher<as_alternate, Greedy>(as_alternate, mark_number(_arg(_left)))
-                  , optional_matcher<as_alternate, Greedy>(as_alternate)
+                // BUGBUG if_< matches<_, Foo>() ... Foo can be treated as a transform!
+              : or_<
+                    when<
+                        MarkedSubExprEx
+                      , optional_mark_matcher<as_alternate, Greedy>(as_alternate, mark_number(_arg(_left)))
+                    >
+                  , otherwise<
+                        optional_matcher<as_alternate, Greedy>(as_alternate)
+                    >
                 >
             {};
 
@@ -675,7 +690,7 @@
             template<typename Dummy>
             struct case_<tag::logical_not, Dummy>
                 // !_
-              : when<logical_not<Gram>, as_optional<greedy_t> (_arg)>
+              : when<logical_not<Gram>, as_optional<greedy_t>(_arg)>
             {};
 
             template<typename Dummy>
@@ -784,6 +799,11 @@
                           , true_()
                         )
                     >
+                    // ~set[~alpha]
+                  , when<
+                        complement<subscript<terminal<set_initializer>, complement<terminal<_> > > >
+                      , as_matcher(_arg(_arg(_right(_arg))), _visitor)
+                    >
                     // ~set['a'] or ~(set='a')
                   , when<
                         or_<
@@ -816,6 +836,11 @@
                         subscript<terminal<set_initializer>, terminal<_> >
                       , as_matcher(_arg(_right), _visitor)
                     >
+                    // set[~alpha]
+                  , when<
+                        subscript<terminal<set_initializer>, complement<terminal<_> > >
+                      , as_regex(_right)
+                    >
                 >
             {};
 
Modified: branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp	(original)
+++ branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp	2007-12-04 02:19:14 EST (Tue, 04 Dec 2007)
@@ -343,6 +343,9 @@
         template<typename Grammar, typename Fun = Grammar>
         struct when;
 
+        template<typename Fun>
+        struct otherwise;
+
         template<typename Fun, typename... Args>
         struct call;
 
@@ -392,6 +395,7 @@
     }
 
     using transform::when;
+    using transform::otherwise;
     using transform::_arg0;
     using transform::_arg1;
     using transform::_arg2;
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-04 02:19:14 EST (Tue, 04 Dec 2007)
@@ -275,44 +275,61 @@
 
         namespace detail
         {
-            // TODO unroll this loop with a few extra specializations
-            template<typename Head, typename... Tail, long N>
-            struct arg_c<argsns_::cons<Head, Tail...>, N>
+            template<typename Cons, long N>
+            struct arg_c
             {
-                typedef arg_c<argsns_::cons<Tail...>, N-1> base_type;
+                typedef arg_c<typename Cons::cdr_type::cdr_type, N-2> base_type;
                 typedef typename base_type::type type;
                 typedef typename base_type::reference reference;
                 typedef typename base_type::const_reference const_reference;
 
-                static reference call(argsns_::cons<Head, Tail...> &args)
+                static reference call(Cons &args)
                 {
-                    return base_type::call(args.cdr);
+                    return base_type::call(args.cdr.cdr);
                 }
 
-                static const_reference call(argsns_::cons<Head, Tail...> const &args)
+                static const_reference call(Cons const &args)
                 {
-                    return base_type::call(args.cdr);
+                    return base_type::call(args.cdr.cdr);
                 }
             };
 
-            template<typename Head, typename... Tail>
-            struct arg_c<argsns_::cons<Head, Tail...>, 0>
+            template<typename Cons>
+            struct arg_c<Cons, 0>
             {
-                typedef UNCVREF(Head) type;
-                typedef REF(Head) reference;
-                typedef CVREF(Head) const_reference;
+                typedef UNCVREF(typename Cons::car_type) type;
+                typedef REF(typename Cons::car_type) reference;
+                typedef CVREF(typename Cons::car_type) const_reference;
 
-                static reference call(argsns_::cons<Head, Tail...> &args)
+                static reference call(Cons &args)
                 {
                     return args.car;
                 }
 
-                static const_reference call(argsns_::cons<Head, Tail...> const &args)
+                static const_reference call(Cons const &args)
                 {
                     return args.car;
                 }
             };
 
+            template<typename Cons>
+            struct arg_c<Cons, 1>
+            {
+                typedef UNCVREF(typename Cons::cdr_type::car_type) type;
+                typedef REF(typename Cons::cdr_type::car_type) reference;
+                typedef CVREF(typename Cons::cdr_type::car_type) const_reference;
+
+                static reference call(Cons &args)
+                {
+                    return args.cdr.car;
+                }
+
+                static const_reference call(Cons const &args)
+                {
+                    return args.cdr.car;
+                }
+            };
+
         } // namespace detail
 
         template<typename Expr, long N>
Modified: branches/proto/v3/boost/xpressive/proto/transform/when.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/when.hpp	(original)
+++ branches/proto/v3/boost/xpressive/proto/transform/when.hpp	2007-12-04 02:19:14 EST (Tue, 04 Dec 2007)
@@ -66,6 +66,11 @@
         }
     };
 
+    template<typename Fun>
+    struct otherwise
+      : when<_, Fun>
+    {};
+
 }}} // namespace boost::proto::transform
 
 #endif