Update of /cvsroot/boost/boost/boost/xpressive/detail/static/transforms
In directory 
sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv21383/detail/static/transforms

Modified Files:
        as_quantifier.hpp transform.hpp 
Log Message:
more work on as_quant transforms

Index: as_quantifier.hpp
===================================================================
RCS file: 
/cvsroot/boost/boost/boost/xpressive/detail/static/transforms/as_quantifier.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- as_quantifier.hpp   3 Apr 2007 06:32:17 -0000       1.2
+++ as_quantifier.hpp   5 Apr 2007 06:41:13 -0000       1.3
@@ -22,6 +22,7 @@
 #include <boost/xpressive/detail/utility/cons.hpp>
 #include <boost/xpressive/proto/transform/branch.hpp>
 #include <boost/xpressive/proto/transform/arg.hpp>
+#include <boost/xpressive/proto/transform/compose.hpp>
 #include <boost/xpressive/proto/transform/conditional.hpp>
 
 // BUGBUG move quant traits here
@@ -106,13 +107,10 @@
     {};
 
     
///////////////////////////////////////////////////////////////////////////////
-    // as_defult_quantifier
-    template<typename Grammar, bool Greedy>
-    struct as_default_quantifier
-      : Grammar
+    // as_default_quantifier_impl
+    template<bool Greedy, uint_t Min, uint_t Max>
+    struct as_default_quantifier_impl
     {
-        as_default_quantifier();
-
         template<typename Expr, typename State, typename Visitor>
         struct apply
           : proto::right_shift<
@@ -148,80 +146,97 @@
         }
     };
 
-    struct MarkerPattern;
-    struct DefaultGreedyQuantifier;
+    // TODO use optional_matcher and optional_mark_matcher
+    template<bool Greedy>
+    struct make_optional_
+    {
+        template<typename Expr, typename State, typename Visitor>
+        struct apply
+          : proto::bitwise_or<
+                Expr
+              , proto::terminal<epsilon_matcher>::type
+            >
+        {};
 
-    struct OptionalMark
-      : proto::unary_expr<proto::_, proto::or_<MarkerPattern, 
DefaultGreedyQuantifier> > 
-    {};
+        template<typename Expr, typename State, typename Visitor>
+        static typename apply<Expr, State, Visitor>::type
+        call(Expr const &expr, State const &state, Visitor &visitor)
+        {
+            typename apply<Expr, State, Visitor>::type that = {expr, 
{epsilon_matcher()}};
+            return that;
+        }
+    };
 
-    
///////////////////////////////////////////////////////////////////////////////
-    // as_default_optional
-    template<typename Grammar, bool Greedy>
-    struct as_default_optional
-      : Grammar
+    template<>
+    struct make_optional_<false>
     {
-        as_default_optional();
-
         template<typename Expr, typename State, typename Visitor>
         struct apply
-        {
-            typedef optional_matcher<
-                typename Grammar::template apply<Expr, 
alternate_end_xpression, Visitor>::type
-              , Greedy
-            > type;
-        };
+          : proto::bitwise_or<
+                proto::terminal<epsilon_matcher>::type
+              , Expr
+            >
+        {};
 
         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)
-            );
+            typename apply<Expr, State, Visitor>::type that = 
{{epsilon_matcher()}, expr};
+            return that;
         }
     };
 
+
     
///////////////////////////////////////////////////////////////////////////////
-    // as_mark_optional
+    // as_default_quantifier_impl
+    template<bool Greedy, uint_t Max>
+    struct as_default_quantifier_impl<Greedy, 0, Max>
+      : proto::trans::compose<
+            as_default_quantifier_impl<Greedy, 1, Max>
+          , make_optional_<Greedy>
+        >
+    {};
+
+    
///////////////////////////////////////////////////////////////////////////////
+    // as_default_quantifier_impl
+    template<bool Greedy>
+    struct as_default_quantifier_impl<Greedy, 0, 1>
+      : proto::trans::compose<
+            proto::trans::arg<proto::_>
+          , make_optional_<Greedy>
+        >
+    {};
+
+    
///////////////////////////////////////////////////////////////////////////////
+    // as_default_quantifier
     template<typename Grammar, bool Greedy>
-    struct as_mark_optional
+    struct as_default_quantifier
       : Grammar
     {
-        as_mark_optional();
+        as_default_quantifier();
 
         template<typename Expr, typename State, typename Visitor>
         struct apply
-        {
-            typedef optional_mark_matcher<
-                typename Grammar::template apply<Expr, 
alternate_end_xpression, Visitor>::type
-              , Greedy
-            > type;
-        };
+          : as_default_quantifier_impl<
+                Greedy
+              , min_type<typename Expr::tag_type>::value
+              , max_type<typename Expr::tag_type>::value
+            >::template apply<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 Grammar::template apply<Expr, alternate_end_xpression, 
Visitor>::type const &
-                marked_expr = Grammar::call(expr, alternate_end_xpression(), 
visitor);
-            return typename apply<Expr, State, Visitor>::type(marked_expr, 
marked_expr.mark_number_);
+            return as_default_quantifier_impl<
+                Greedy
+              , min_type<typename Expr::tag_type>::value
+              , max_type<typename Expr::tag_type>::value
+            >::call(expr, state, visitor);
         }
     };
 
-    
///////////////////////////////////////////////////////////////////////////////
-    // as_optional
-    template<typename Grammar, bool Greedy>
-    struct as_optional
-      : proto::trans::conditional<
-            proto::matches<mpl::_, OptionalMark>
-          , as_mark_optional<Grammar, Greedy>
-          , as_default_optional<Grammar, Greedy>
-        >
-    {
-        as_optional();
-    };
-
 }}}
 
 #endif

Index: transform.hpp
===================================================================
RCS file: 
/cvsroot/boost/boost/boost/xpressive/detail/static/transforms/transform.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- transform.hpp       3 Apr 2007 06:32:17 -0000       1.2
+++ transform.hpp       5 Apr 2007 06:41:13 -0000       1.3
@@ -26,15 +26,15 @@
 
 namespace boost { namespace xpressive { namespace detail
 {
-    //template<typename Tag>
-    //struct is_generic_quant_tag
-    //  : mpl::false_
-    //{};
+    template<typename Tag>
+    struct is_generic_quant_tag
+      : mpl::false_
+    {};
 
-    //template<unsigned Min, unsigned Max>
-    //struct is_generic_quant_tag<generic_quant_tag<Min, Max> >
-    //  : mpl::true_
-    //{};
+    template<unsigned Min, unsigned Max>
+    struct is_generic_quant_tag<generic_quant_tag<Min, Max> >
+      : mpl::true_
+    {};
 
     struct Grammar;
     
@@ -58,26 +58,14 @@
       : proto::or_<
             proto::unary_plus<Grammar>
           , proto::unary_star<Grammar>
-          //, proto::and_<
-          //      proto::unary_expr<proto::_, Grammar>
-          //    , proto::if_<is_generic_quant_tag<proto::tag_of<mpl::_> > >
-          //  >
-        >
-    {};
-
-    struct GreedyOptional
-      : proto::trans::arg<
-            //proto::or_<
-                proto::logical_not<Grammar>
-            //  , proto::unary_expr<generic_quant_tag<0, 1>, Grammar>
-            //>
+          , proto::logical_not<Grammar>
+          , proto::and_<
+                proto::unary_expr<proto::_, Grammar>
+              , proto::if_<is_generic_quant_tag<proto::tag_of<mpl::_> > >
+            >
         >
     {};
 
-    struct NonGreedyQuantifier
-      : proto::unary_minus<GreedyQuantifier>
-    {};
-
     struct SimpleGreedyQuantifier
       : proto::and_<
             GreedyQuantifier
@@ -99,18 +87,16 @@
       : proto::or_<
             as_matcher<Terminal>
           , as_alternate<Alternate>
-          , as_optional<GreedyOptional, false>
-          , proto::trans::arg<proto::unary_minus<as_optional<GreedyOptional, 
true> > >
-          , as_simple_quantifier<SimpleGreedyQuantifier, false>
-          , 
proto::trans::arg<proto::unary_minus<as_simple_quantifier<SimpleGreedyQuantifier,
 true> > >
+          , as_simple_quantifier<SimpleGreedyQuantifier, true>
+          , 
proto::trans::arg<proto::unary_minus<as_simple_quantifier<SimpleGreedyQuantifier,
 false> > >
         >
     {};
 
     // These sub-expressions require further processing.
     struct Transforms
       : proto::or_<
-            as_default_quantifier<DefaultGreedyQuantifier, false>
-          , 
proto::trans::arg<proto::unary_minus<as_default_quantifier<DefaultGreedyQuantifier,
 true> > >
+            as_default_quantifier<DefaultGreedyQuantifier, true>
+          , 
proto::trans::arg<proto::unary_minus<as_default_quantifier<DefaultGreedyQuantifier,
 false> > >
           , as_marker<Mark>
         >
     {};


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to