Update of /cvsroot/boost/boost/boost/xpressive
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv20055
Modified Files:
regex_compiler.hpp
Log Message:
add support for (?R) for self-recursive dynamic regexes
Index: regex_compiler.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/regex_compiler.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- regex_compiler.hpp 18 Apr 2006 07:52:49 -0000 1.7
+++ regex_compiler.hpp 4 Mar 2007 18:07:03 -0000 1.8
@@ -54,6 +54,7 @@
, hidden_mark_count_(0)
, traits_(traits)
, upper_(0)
+ , self_()
{
this->upper_ = lookup_classname(this->rxtraits(), "upper");
BOOST_ASSERT(0 != this->upper_);
@@ -99,6 +100,9 @@
string_iterator begin = pat.begin(), end = pat.end();
+ basic_regex<BidiIter> rex;
+ this->self_ = detail::core_access<BidiIter>::get_regex_impl(rex);
+
// at the top level, a regex is a sequence of alternates
detail::sequence<BidiIter> seq = this->parse_alternates(begin, end);
detail::ensure(begin == end, regex_constants::error_paren, "mismatched
parenthesis");
@@ -107,14 +111,13 @@
seq += detail::make_dynamic<BidiIter>(detail::end_matcher());
// bundle the regex information into a regex_impl object
- basic_regex<BidiIter> rex;
- shared_ptr<detail::regex_impl<BidiIter> > const &impl =
detail::core_access<BidiIter>::get_regex_impl(rex);
- detail::common_compile(seq.xpr().matchable(), *impl, this->rxtraits());
+ detail::common_compile(seq.xpr().matchable(), *this->self_,
this->rxtraits());
- impl->traits_ = new
detail::traits_holder<RegexTraits>(this->rxtraits());
- impl->mark_count_ = this->mark_count_;
- impl->hidden_mark_count_ = this->hidden_mark_count_;
+ this->self_->traits_ = new
detail::traits_holder<RegexTraits>(this->rxtraits());
+ this->self_->mark_count_ = this->mark_count_;
+ this->self_->hidden_mark_count_ = this->hidden_mark_count_;
+ this->self_.reset();
return rex;
}
@@ -236,6 +239,15 @@
}
break;
+ case token_recurse_self:
+ detail::ensure
+ (
+ begin != end && token_group_end ==
this->traits_.get_token(begin, end)
+ , error_paren
+ , "mismatched parenthesis"
+ );
+ return
detail::make_dynamic<BidiIter>(detail::regex_byref_matcher<BidiIter>(this->self_));
+
default:
mark_nbr = static_cast<int>(++this->mark_count_);
seq =
detail::make_dynamic<BidiIter>(detail::mark_begin_matcher(mark_nbr));
@@ -540,6 +552,7 @@
std::size_t hidden_mark_count_;
CompilerTraits traits_;
typename RegexTraits::char_class_type upper_;
+ shared_ptr<detail::regex_impl<BidiIter> > self_;
};
}} // namespace boost::xpressive
-------------------------------------------------------------------------
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