Update of /cvsroot/boost/boost/boost/xpressive
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19839

Modified Files:
        basic_regex.hpp match_results.hpp regex_compiler.hpp 
        regex_primitives.hpp 
Log Message:
basic_regex uses proto::extends<>, eliminate regex_operators.hpp and 
as_matcher(), as_xpr() is simply proto::as_expr()

Index: basic_regex.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/basic_regex.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- basic_regex.hpp     3 Feb 2007 00:14:32 -0000       1.12
+++ basic_regex.hpp     12 Mar 2007 22:11:29 -0000      1.13
@@ -19,7 +19,7 @@
 # include <iostream>
 #endif
 #include <boost/mpl/bool.hpp>
-#include <boost/xpressive/proto/proto_fwd.hpp>
+#include <boost/xpressive/proto/extends.hpp>
 #include <boost/xpressive/regex_constants.hpp>
 #include <boost/xpressive/detail/detail_fwd.hpp>
 #include <boost/xpressive/detail/core/regex_impl.hpp>
@@ -34,7 +34,16 @@
 /// \brief Class template basic_regex\<\> is a class for holding a compiled 
regular expression.
 template<typename BidiIter>
 struct basic_regex
+  : proto::extends<
+        typename 
proto::terminal<detail::tracking_ptr<detail::regex_impl<BidiIter> > >::type
+      , basic_regex<BidiIter>
+    >
 {
+private:
+    typedef typename 
proto::terminal<detail::tracking_ptr<detail::regex_impl<BidiIter> > >::type 
pimpl_type;
+    typedef proto::extends<pimpl_type, basic_regex<BidiIter> > base_type;
+
+public:
     typedef BidiIter iterator_type;
     typedef typename iterator_value<BidiIter>::type char_type;
     typedef std::basic_string<char_type> string_type;
@@ -43,7 +52,7 @@
     /// \post regex_id()    == 0
     /// \post mark_count()  == 0
     basic_regex()
-      : impl_()
+      : base_type()
     {
     }
 
@@ -51,7 +60,7 @@
     /// \post regex_id()    == that.regex_id()
     /// \post mark_count()  == that.mark_count()
     basic_regex(basic_regex<BidiIter> const &that)
-      : impl_(that.impl_)
+      : base_type(that)
     {
     }
 
@@ -61,7 +70,7 @@
     /// \return *this
     basic_regex<BidiIter> &operator =(basic_regex<BidiIter> const &that)
     {
-        this->impl_ = that.impl_;
+        proto::arg(*this) = proto::arg(that);
         return *this;
     }
 
@@ -73,7 +82,7 @@
     /// \post   mark_count() \>= 0
     template<typename Expr>
     basic_regex(Expr const &expr)
-      : impl_()
+      : base_type()
     {
         this->operator =(expr);
     }
@@ -90,7 +99,7 @@
     basic_regex<BidiIter> &operator =(Expr const &expr)
     {
         BOOST_XPRESSIVE_CHECK_GRAMMAR(Expr, char_type);
-        detail::static_compile(expr, this->impl_.get());
+        detail::static_compile(expr, proto::arg(*this).get());
         return *this;
     }
 
@@ -98,14 +107,14 @@
     ///
     std::size_t mark_count() const
     {
-        return this->impl_ ? this->impl_->mark_count_ : 0;
+        return proto::arg(*this) ? proto::arg(*this)->mark_count_ : 0;
     }
 
     /// Returns a token which uniquely identifies this regular expression.
     ///
     regex_id_type regex_id() const
     {
-        return this->impl_ ? this->impl_->xpr_.get() : 0;
+        return proto::arg(*this) ? proto::arg(*this)->xpr_.get() : 0;
     }
 
     /// Swaps the contents of this basic_regex object with another.
@@ -118,7 +127,7 @@
     /// \throw nothrow
     void swap(basic_regex<BidiIter> &that) // throw()
     {
-        this->impl_.swap(that.impl_);
+        proto::arg(*this).swap(proto::arg(that));
     }
 
     /// Factory method for building a regex object from a string.
@@ -131,24 +140,6 @@
         return regex_compiler<BidiIter>().compile(str, flags);
     }
 
-    // for binding actions to this regex when it is nested statically in 
another regex
-    /// INTERNAL ONLY
-    template<typename Action>
-    typename proto::right_shift
-    <
-        typename proto::terminal<basic_regex<BidiIter> >::type
-      , typename proto::terminal<Action>::type
-    >::type const
-    operator [](detail::action_matcher<Action> const &action) const
-    {
-        typename proto::right_shift
-        <
-            typename proto::terminal<basic_regex<BidiIter> >::type
-          , typename proto::terminal<Action>::type
-        >::type that = {{*this}, {*static_cast<Action const *>(&action)}};
-        return that;
-    }
-
     //{{AFX_DEBUG
     #ifdef BOOST_XPRESSIVE_DEBUG_TRACKING_POINTER
     // BUGBUG debug only
@@ -177,22 +168,18 @@
     /// INTERNAL ONLY
     bool match_(detail::state_type<BidiIter> &state) const
     {
-        return this->impl_->xpr_->match(state);
+        return proto::arg(*this)->xpr_->match(state);
     }
 
     // Returns true if this basic_regex object does not contain a valid 
regular expression.
     /// INTERNAL ONLY
     bool invalid_() const
     {
-        return !this->impl_ || !this->impl_->xpr_;
+        return !proto::arg(*this) || !proto::arg(*this)->xpr_;
     }
 
     /// INTERNAL ONLY
     void dump_(std::ostream &sout) const;
-
-    // the tracking_ptr manages lazy-init, COW, cycle-breaking, and
-    // reference/dependency tracking.
-    detail::tracking_ptr<detail::regex_impl<BidiIter> > impl_;
 };
 
 //{{AFX_DEBUG
@@ -203,13 +190,13 @@
 template<typename BidiIter>
 inline void basic_regex<BidiIter>::dump_(std::ostream &sout) const
 {
-    if(!this->impl_)
+    if(!proto::arg(*this))
     {
         sout << "<null> refs={} deps={}";
     }
     else
     {
-        sout << *this->impl_;
+        sout << *proto::arg(*this);
     }
 }
 #endif
@@ -234,4 +221,30 @@
 
 }} // namespace boost::xpressive
 
+
+namespace boost { namespace proto
+{
+    // Turn off the operator & overload on regex terminals
+    template<typename Domain, typename Expr>
+    struct is_allowed<
+        Domain
+      , Expr
+      , typename enable_if<
+            matches<
+                Expr
+              , address_of<
+                    terminal<
+                        xpressive::detail::tracking_ptr<
+                            xpressive::detail::regex_impl<_>
+                        >
+                    >
+                >
+            >
+        >::type
+    >
+      : mpl::false_
+    {};
+
+}}
+
 #endif // BOOST_XPRESSIVE_REGEX_HPP_EAN_10_04_2005

Index: match_results.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/match_results.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- match_results.hpp   2 Nov 2006 06:56:42 -0000       1.6
+++ match_results.hpp   12 Mar 2007 22:11:29 -0000      1.7
@@ -186,7 +186,7 @@
     ///
     difference_type length(size_type sub = 0) const
     {
-        return (*this)[ sub ].length();
+        return this->sub_matches_[ sub ].length();
     }
 
     /// If !(*this)[sub].matched then returns -1. Otherwise returns 
std::distance(base, (*this)[sub].first),
@@ -194,14 +194,14 @@
     /// of a repeated search with a regex_iterator then base is the same as 
prefix().first – end note]
     difference_type position(size_type sub = 0) const
     {
-        return (*this)[ sub ].matched ? std::distance(this->base_, (*this)[ 
sub ].first) : -1;
+        return this->sub_matches_[ sub ].matched ? std::distance(this->base_, 
this->sub_matches_[ sub ].first) : -1;
     }
 
     /// Returns string_type((*this)[sub]).
     ///
     string_type str(size_type sub = 0) const
     {
-        return (*this)[ sub ].str();
+        return this->sub_matches_[ sub ].str();
     }
 
     /// Returns a reference to the sub_match object representing the sequence 
that
@@ -256,14 +256,14 @@
     ///
     operator bool_type() const
     {
-        return (*this)[ 0 ].matched ? &dummy::i_ : 0;
+        return this->sub_matches_[ 0 ].matched ? &dummy::i_ : 0;
     }
 
     /// Returns true if empty() || !(*this)[0].matched, else returns false.
     ///
     bool operator !() const
     {
-        return this->empty() || !(*this)[ 0 ].matched;
+        return this->empty() || !this->sub_matches_[ 0 ].matched;
     }
 
     /// Returns the id of the basic_regex object most recently used with this 
match_results object.
@@ -317,7 +317,7 @@
             else if(BOOST_XPR_CHAR_(char_type, '&') == *cur) // whole match
             {
                 ++cur;
-                out = std::copy((*this)[ 0 ].first, (*this)[ 0 ].second, out);
+                out = std::copy(this->sub_matches_[ 0 ].first, 
this->sub_matches_[ 0 ].second, out);
             }
             else if(BOOST_XPR_CHAR_(char_type, '`') == *cur) // prefix
             {
@@ -332,9 +332,9 @@
             else if(-1 != traits.value(*cur, 10)) // a sub-match
             {
                 int max = static_cast<int>(this->size() - 1);
-                int br_nbr = detail::toi(cur, end, traits, 10, max);
-                detail::ensure(0 != br_nbr, regex_constants::error_subreg, 
"invalid back-reference");
-                out = std::copy((*this)[ br_nbr ].first, (*this)[ br_nbr 
].second, out);
+                int sub = detail::toi(cur, end, traits, 10, max);
+                detail::ensure(0 != sub, regex_constants::error_subreg, 
"invalid back-reference");
+                out = std::copy(this->sub_matches_[ sub ].first, 
this->sub_matches_[ sub ].second, out);
             }
             else
             {
@@ -446,10 +446,10 @@
         this->base_ = begin;
 
         this->prefix_.first = begin;
-        this->prefix_.second = (*this)[ 0 ].first;
+        this->prefix_.second = this->sub_matches_[ 0 ].first;
         this->prefix_.matched = this->prefix_.first != this->prefix_.second;
 
-        this->suffix_.first = (*this)[ 0 ].second;
+        this->suffix_.first = this->sub_matches_[ 0 ].second;
         this->suffix_.second = end;
         this->suffix_.matched = this->suffix_.first != this->suffix_.second;
 

Index: regex_compiler.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/regex_compiler.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- regex_compiler.hpp  7 Mar 2007 01:21:26 -0000       1.10
+++ regex_compiler.hpp  12 Mar 2007 22:11:29 -0000      1.11
@@ -101,22 +101,23 @@
         this->reset();
         this->traits_.flags(flags);
 
+        basic_regex<BidiIter> rextmp, *prex = &rextmp;
         string_iterator begin = pat.begin(), end = pat.end(), tmp = begin;
 
         // Check if this regex is a named rule:
         std::string name;
-        basic_regex<BidiIter> rextmp, *prex = &rextmp;
         if(token_group_begin == this->traits_.get_token(tmp, end) &&
+           detail::ensure(tmp != end, error_paren, "mismatched parenthesis") &&
            token_rule_assign == this->traits_.get_group_type(tmp, end, name))
         {
             begin = tmp;
-            prex = &this->rules_[name];
             detail::ensure
             (
                 begin != end && token_group_end == 
this->traits_.get_token(begin, end)
               , error_paren
               , "mismatched parenthesis"
             );
+            prex = &this->rules_[name];
         }
 
         this->self_ = detail::core_access<BidiIter>::get_regex_impl(*prex);

Index: regex_primitives.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/regex_primitives.hpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- regex_primitives.hpp        15 Feb 2007 23:06:56 -0000      1.24
+++ regex_primitives.hpp        12 Mar 2007 22:11:29 -0000      1.25
@@ -18,12 +18,10 @@
 #include <boost/xpressive/detail/core/icase.hpp>
 #include <boost/xpressive/detail/core/action.hpp>
 #include <boost/xpressive/detail/core/matchers.hpp>
-#include <boost/xpressive/detail/static/as_xpr.hpp>
 #include <boost/xpressive/detail/static/compile.hpp>
 #include <boost/xpressive/detail/static/grammar.hpp>
 #include <boost/xpressive/detail/static/modifier.hpp>
 #include <boost/xpressive/detail/utility/ignore_unused.hpp>
-#include <boost/xpressive/detail/static/regex_operators.hpp>
 #include <boost/xpressive/detail/static/productions/productions.hpp>
 
 namespace boost { namespace xpressive { namespace detail
@@ -317,7 +315,7 @@
 /// that is not a newline.
 ///
 /// \attention ~_n is like '.' in perl without the /s modifier.
-proto::terminal<detail::literal_placeholder<char> >::type const _n = {{'\n'}};
+proto::terminal<char>::type const _n = {'\n'};
 
 ///////////////////////////////////////////////////////////////////////////////
 /// \brief Matches a logical newline sequence.
@@ -392,7 +390,8 @@
 // NOTE: For the purpose of xpressive's documentation, make icase() look like 
an
 // ordinary function. In reality, it is a function object defined in 
detail/icase.hpp
 // so that it can serve double-duty as regex_constants::icase, the 
syntax_option_type.
-// Do the same for as_xpr(), which is actually defined in 
detail/static/as_xpr.hpp
+// Do the same for as_xpr(), which is actually defined below using proto's 
as_expr
+// function object.
 #ifdef BOOST_XPRESSIVE_DOXYGEN_INVOKED
 ///////////////////////////////////////////////////////////////////////////////
 /// \brief Makes a literal into a regular expression.
@@ -407,10 +406,10 @@
 /// character literal, as with ~as_xpr('a'). This will match any one character
 /// that is not an 'a'.
 template<typename Literal>
-inline typename detail::as_xpr_type<Literal>::type
+inline typename proto::result_of::as_expr<Literal>::type
 as_xpr(Literal const &literal)
 {
-    return detail::as_xpr_type<Literal>::call(expr);
+    return proto::as_expr(literal);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -423,7 +422,7 @@
 inline typename proto::binary_expr<
     modifier_tag
   , detail::icase_modifier
-  , typename detail::as_xpr_type<Expr>::type
+  , typename proto::result_of::as_expr<Expr>::type
 >::type const
 icase(Expr const &expr)
 {
@@ -431,10 +430,13 @@
     typename proto::binary_expr<
         modifier_tag
       , detail::icase_modifier
-      , typename detail::as_xpr_type<Expr>::type
-    >::type that = {mod, as_xpr(expr)};
+      , typename proto::result_of::as_expr<Expr>::type
+    >::type that = {mod, proto::as_expr(expr)};
     return that;
 }
+#else
+// Re-use proto's as_expr function object as xpressive's as_xpr() function.
+proto::op::as_expr const as_xpr = {};
 #endif
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -442,13 +444,13 @@
 ///
 /// \param rex The basic_regex object to embed by reference.
 template<typename BidiIter>
-inline typename proto::terminal<detail::regex_placeholder<BidiIter, 
mpl::true_> >::type const
+inline typename proto::terminal<detail::regex_byref_placeholder<BidiIter> 
>::type const
 by_ref(basic_regex<BidiIter> const &rex)
 {
     typedef detail::core_access<BidiIter> access;
     shared_ptr<detail::regex_impl<BidiIter> > impl = 
access::get_regex_impl(rex);
-    detail::regex_placeholder<BidiIter, mpl::true_> rex_ref(impl);
-    return proto::terminal<detail::regex_placeholder<BidiIter, mpl::true_> 
>::type::make(rex_ref);
+    detail::regex_byref_placeholder<BidiIter> rex_ref(impl);
+    return proto::terminal<detail::regex_byref_placeholder<BidiIter> 
>::type::make(rex_ref);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -472,13 +474,13 @@
 /// \param expr The sub-expression to make optional.
 template<typename Expr>
 inline typename proto::logical_not<
-    typename detail::as_xpr_type<Expr>::type
+    typename proto::result_of::as_expr<Expr>::type
 >::type const
 optional(Expr const &expr)
 {
     typename proto::logical_not<
-        typename detail::as_xpr_type<Expr>::type
-    >::type that = {as_xpr(expr)};
+        typename proto::result_of::as_expr<Expr>::type
+    >::type that = {proto::as_expr(expr)};
     return that;
 }
 
@@ -497,15 +499,15 @@
 inline typename proto::unary_expr
 <
     detail::generic_quant_tag<Min, Max>
-  , typename detail::as_xpr_type<Expr>::type
+  , typename proto::result_of::as_expr<Expr>::type
 >::type const
 repeat(Expr const &expr)
 {
     typename proto::unary_expr
     <
         detail::generic_quant_tag<Min, Max>
-      , typename detail::as_xpr_type<Expr>::type
-    >::type that = {as_xpr(expr)};
+      , typename proto::result_of::as_expr<Expr>::type
+    >::type that = {proto::as_expr(expr)};
     return that;
 }
 
@@ -515,15 +517,15 @@
 inline typename proto::unary_expr
 <
     detail::generic_quant_tag<Count, Count>
-  , typename detail::as_xpr_type<Xpr2>::type
+  , typename proto::result_of::as_expr<Xpr2>::type
 >::type const
 repeat(Xpr2 const &expr)
 {
     typename proto::unary_expr
     <
         detail::generic_quant_tag<Count, Count>
-      , typename detail::as_xpr_type<Xpr2>::type
-    >::type that = {as_xpr(expr)};
+      , typename proto::result_of::as_expr<Xpr2>::type
+    >::type that = {proto::as_expr(expr)};
     return that;
 }
 
@@ -541,15 +543,15 @@
 inline typename proto::unary_expr
 <
     detail::keeper_tag
-  , typename detail::as_xpr_type<Expr>::type
+  , typename proto::result_of::as_expr<Expr>::type
 >::type const
 keep(Expr const &expr)
 {
     typename proto::unary_expr
     <
         detail::keeper_tag
-      , typename detail::as_xpr_type<Expr>::type
-    >::type that = {as_xpr(expr)};
+      , typename proto::result_of::as_expr<Expr>::type
+    >::type that = {proto::as_expr(expr)};
     return that;
 }
 
@@ -570,15 +572,15 @@
 inline typename proto::unary_expr
 <
     detail::lookahead_tag<true>
-  , typename detail::as_xpr_type<Expr>::type
+  , typename proto::result_of::as_expr<Expr>::type
 >::type const
 before(Expr const &expr)
 {
     typename proto::unary_expr
     <
         detail::lookahead_tag<true>
-      , typename detail::as_xpr_type<Expr>::type
-    >::type that = {as_xpr(expr)};
+      , typename proto::result_of::as_expr<Expr>::type
+    >::type that = {proto::as_expr(expr)};
     return that;
 }
 
@@ -601,15 +603,15 @@
 inline typename proto::unary_expr
 <
     detail::lookbehind_tag<true>
-  , typename detail::as_xpr_type<Expr>::type
+  , typename proto::result_of::as_expr<Expr>::type
 >::type const
 after(Expr const &expr)
 {
     typename proto::unary_expr
     <
         detail::lookbehind_tag<true>
-      , typename detail::as_xpr_type<Expr>::type
-    >::type that = {as_xpr(expr)};
+      , typename proto::result_of::as_expr<Expr>::type
+    >::type that = {proto::as_expr(expr)};
     return that;
 }
 


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