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

Modified Files:
        transform.hpp 
Added Files:
        as_independent.hpp 
Log Message:
add transforms for look-ahead, look-behind, and keeper

--- NEW FILE: as_independent.hpp ---
///////////////////////////////////////////////////////////////////////////////
// as_independent.hpp
//
//  Copyright 2004 Eric Niebler. Distributed under the Boost
//  Software License, Version 1.0. (See accompanying file
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef 
BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_INDEPENDENT_HPP_EAN_04_05_2007
#define 
BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_INDEPENDENT_HPP_EAN_04_05_2007

// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif

#include <boost/mpl/sizeof.hpp>
#include <boost/xpressive/detail/detail_fwd.hpp>
#include <boost/xpressive/detail/static/static.hpp>
#include <boost/xpressive/proto/proto.hpp>
#include <boost/xpressive/proto/context.hpp>
#include <boost/xpressive/proto/transform/arg.hpp>

namespace boost { namespace xpressive { namespace detail
{

    template<typename Grammar>
    struct as_lookahead
      : Grammar
    {
        as_lookahead();

        template<typename Expr, typename State, typename Visitor>
        struct apply
        {
            typedef lookahead_matcher<
                typename Grammar::template apply<Expr, true_xpression, 
Visitor>::type
            > type;
        };

        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, true_xpression(), visitor)
              , false
            );
        }
    };

    template<typename Grammar>
    struct as_lookbehind
      : Grammar
    {
        as_lookbehind();

        template<typename Expr, typename State, typename Visitor>
        struct apply
        {
            typedef lookbehind_matcher<
                typename Grammar::template apply<Expr, true_xpression, 
Visitor>::type
            > type;
        };

        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, true_xpression, 
Visitor>::type const &
                expr2 = Grammar::call(expr, true_xpression(), visitor);
            std::size_t width = expr2.get_width().value();
            return typename apply<Expr, State, Visitor>::type(expr2, width, 
false);
        }
    };

    template<typename Grammar>
    struct as_keeper
      : Grammar
    {
        as_keeper();

        template<typename Expr, typename State, typename Visitor>
        struct apply
        {
            typedef keeper_matcher<
                typename Grammar::template apply<Expr, true_xpression, 
Visitor>::type
            > type;
        };

        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, true_xpression(), visitor)
            );
        }
    };

}}}

#endif

Index: transform.hpp
===================================================================
RCS file: 
/cvsroot/boost/boost/boost/xpressive/detail/static/transforms/transform.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- transform.hpp       5 Apr 2007 20:49:11 -0000       1.4
+++ transform.hpp       5 Apr 2007 23:56:25 -0000       1.5
@@ -23,6 +23,7 @@
 #include <boost/xpressive/detail/static/transforms/as_quantifier.hpp>
 #include <boost/xpressive/detail/static/transforms/as_marker.hpp>
 #include <boost/xpressive/detail/static/transforms/as_set.hpp>
+#include <boost/xpressive/detail/static/transforms/as_independent.hpp>
 #include <boost/xpressive/proto/transform/arg.hpp>
 #include <boost/xpressive/proto/transform/compose.hpp>
 
@@ -68,10 +69,17 @@
         >
     {};
 
+    typedef
+        use_simple_repeat<
+            proto::result_of::arg<mpl::_>
+          , proto::tag_of<proto::result_of::arg<mpl::_> >
+        >
+    UseSimpleRepeat;
+
     struct SimpleGreedyQuantifier
       : proto::and_<
             GreedyQuantifier
-          , proto::if_<use_simple_repeat<proto::result_of::arg<mpl::_>, 
proto::tag_of<proto::result_of::arg<mpl::_> > > >
+          , proto::if_<UseSimpleRepeat>
           , proto::trans::arg<GreedyQuantifier>
         >
     {};
@@ -79,7 +87,7 @@
     struct DefaultGreedyQuantifier
       : proto::and_<
             GreedyQuantifier
-          , 
proto::if_<mpl::not_<use_simple_repeat<proto::result_of::arg<mpl::_>, 
proto::tag_of<proto::result_of::arg<mpl::_> > > > >
+          , proto::if_<mpl::not_<UseSimpleRepeat> >
         >
     {};
 
@@ -90,10 +98,12 @@
         >
     {};
 
-    struct SetMatcher
+    struct InvertibleMatcher
       : proto::or_<
             as_list_set<ListSet>
           , proto::trans::right<proto::subscript<set_initializer_type, 
as_set<Grammar> > >
+          , proto::trans::arg<proto::unary_expr<lookahead_tag<true>, 
as_lookahead<Grammar> > >
+          , proto::trans::arg<proto::unary_expr<lookbehind_tag<true>, 
as_lookbehind<Grammar> > >
         >
     {};
 
@@ -107,8 +117,10 @@
           , as_simple_quantifier<SimpleGreedyQuantifier, true>
           , 
proto::trans::arg<proto::unary_minus<as_simple_quantifier<SimpleGreedyQuantifier,
 false> > >
 
-          , SetMatcher
-          , inverse<proto::trans::arg<proto::complement<SetMatcher> > >
+          , InvertibleMatcher
+          , inverse<proto::trans::arg<proto::complement<InvertibleMatcher> > >
+
+          , proto::trans::arg<proto::unary_expr<keeper_tag, as_keeper<Grammar> 
> >
         >
     {};
 


-------------------------------------------------------------------------
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