|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2008-03-03 18:48:17
Author: eric_niebler
Date: 2008-03-03 18:48:17 EST (Mon, 03 Mar 2008)
New Revision: 43484
URL: http://svn.boost.org/trac/boost/changeset/43484
Log:
handle static regexes with actions nested in dynamic independent subexpressions
Text files modified:
trunk/boost/xpressive/detail/dynamic/parser.hpp | 16 ++++++++++++++++
trunk/boost/xpressive/regex_compiler.hpp | 12 +++---------
2 files changed, 19 insertions(+), 9 deletions(-)
Modified: trunk/boost/xpressive/detail/dynamic/parser.hpp
==============================================================================
--- trunk/boost/xpressive/detail/dynamic/parser.hpp (original)
+++ trunk/boost/xpressive/detail/dynamic/parser.hpp 2008-03-03 18:48:17 EST (Mon, 03 Mar 2008)
@@ -335,6 +335,22 @@
);
}
+///////////////////////////////////////////////////////////////////////////////
+// make_independent_end_xpression
+//
+template<typename BidiIter>
+inline sequence<BidiIter> make_independent_end_xpression(bool pure)
+{
+ if(pure)
+ {
+ return detail::make_dynamic<BidiIter>(detail::true_matcher());
+ }
+ else
+ {
+ return detail::make_dynamic<BidiIter>(detail::independent_end_matcher());
+ }
+}
+
}}} // namespace boost::xpressive::detail
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
Modified: trunk/boost/xpressive/regex_compiler.hpp
==============================================================================
--- trunk/boost/xpressive/regex_compiler.hpp (original)
+++ trunk/boost/xpressive/regex_compiler.hpp 2008-03-03 18:48:17 EST (Mon, 03 Mar 2008)
@@ -320,25 +320,16 @@
negative = true; // fall-through
case token_positive_lookahead:
lookahead = true;
- // If we ever support actions in dynamic regexes, then this should
- // be independent_end_matcher:
- seq_end = detail::make_dynamic<BidiIter>(detail::true_matcher());
break;
case token_negative_lookbehind:
negative = true; // fall-through
case token_positive_lookbehind:
lookbehind = true;
- // If we ever support actions in dynamic regexes, then this should
- // be independent_end_matcher:
- seq_end = detail::make_dynamic<BidiIter>(detail::true_matcher());
break;
case token_independent_sub_expression:
keeper = true;
- // If we ever support actions in dynamic regexes, then this should
- // be independent_end_matcher:
- seq_end = detail::make_dynamic<BidiIter>(detail::true_matcher());
break;
case token_comment:
@@ -436,16 +427,19 @@
typedef detail::shared_matchable<BidiIter> xpr_type;
if(lookahead)
{
+ seq += detail::make_independent_end_xpression<BidiIter>(seq.pure());
detail::lookahead_matcher<xpr_type> lookahead(seq.xpr(), negative, seq.pure());
seq = detail::make_dynamic<BidiIter>(lookahead);
}
else if(lookbehind)
{
+ seq += detail::make_independent_end_xpression<BidiIter>(seq.pure());
detail::lookbehind_matcher<xpr_type> lookbehind(seq.xpr(), seq.width().value(), negative, seq.pure());
seq = detail::make_dynamic<BidiIter>(lookbehind);
}
else if(keeper) // independent sub-expression
{
+ seq += detail::make_independent_end_xpression<BidiIter>(seq.pure());
detail::keeper_matcher<xpr_type> keeper(seq.xpr(), seq.pure());
seq = detail::make_dynamic<BidiIter>(keeper);
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk