|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2007-11-29 16:16:32
Author: eric_niebler
Date: 2007-11-29 16:16:30 EST (Thu, 29 Nov 2007)
New Revision: 41474
URL: http://svn.boost.org/trac/boost/changeset/41474
Log:
support ~_n, ~_ln, ~alpha and ~_b, fix bugs
Text files modified:
branches/proto/v3/boost/xpressive/detail/core/matcher/assert_word_matcher.hpp | 6 +-
branches/proto/v3/boost/xpressive/detail/core/matcher/literal_matcher.hpp | 18 +++------
branches/proto/v3/boost/xpressive/detail/core/peeker.hpp | 6 +-
branches/proto/v3/boost/xpressive/detail/detail_fwd.hpp | 4 +-
branches/proto/v3/boost/xpressive/detail/dynamic/parser.hpp | 6 +-
branches/proto/v3/boost/xpressive/detail/static/grammar2.hpp | 72 +++++++++++++++++++++++++++++++++++++++
branches/proto/v3/boost/xpressive/detail/static/transmogrify.hpp | 6 +-
branches/proto/v3/boost/xpressive/proto3/expr.hpp | 2
branches/proto/v3/boost/xpressive/regex_compiler.hpp | 4 +-
branches/proto/v3/boost/xpressive/regex_primitives.hpp | 2
branches/proto/v3/boost/xpressive/xpressive_typeof.hpp | 4 +-
11 files changed, 98 insertions(+), 32 deletions(-)
Modified: branches/proto/v3/boost/xpressive/detail/core/matcher/assert_word_matcher.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/core/matcher/assert_word_matcher.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/core/matcher/assert_word_matcher.hpp 2007-11-29 16:16:30 EST (Thu, 29 Nov 2007)
@@ -24,7 +24,7 @@
///////////////////////////////////////////////////////////////////////////////
// word_boundary
//
- template<bool IsBoundary>
+ template<typename IsBoundary>
struct word_boundary
{
template<typename BidiIter>
@@ -32,10 +32,10 @@
{
if((state.flags_.match_not_bow_ && state.bos()) || (state.flags_.match_not_eow_ && state.eos()))
{
- return !IsBoundary;
+ return !IsBoundary::value;
}
- return IsBoundary == (prevword != thisword);
+ return IsBoundary::value == (prevword != thisword);
}
};
Modified: branches/proto/v3/boost/xpressive/detail/core/matcher/literal_matcher.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/core/matcher/literal_matcher.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/core/matcher/literal_matcher.hpp 2007-11-29 16:16:30 EST (Thu, 29 Nov 2007)
@@ -24,28 +24,24 @@
///////////////////////////////////////////////////////////////////////////////
// literal_matcher
//
- template<typename Traits, bool ICase, bool Not>
+ template<typename Traits, typename ICase, typename Not>
struct literal_matcher
: quant_style_fixed_width<1>
{
typedef typename Traits::char_type char_type;
- typedef mpl::bool_<Not> not_type;
- typedef mpl::bool_<ICase> icase_type;
+ typedef Not not_type;
+ typedef ICase icase_type;
char_type ch_;
- typedef literal_matcher<Traits, ICase, !Not> inverse_type;
- explicit literal_matcher(inverse_type that)
- : ch_(that.ch_)
- {}
-
- literal_matcher(char_type ch, Traits const &traits)
- : ch_(detail::translate(ch, traits, icase_type()))
+ template<typename Char>
+ literal_matcher(Char ch, Traits const &traits)
+ : ch_(detail::translate(detail::char_cast<char_type>(ch, traits), traits, icase_type()))
{}
template<typename BidiIter, typename Next>
bool match(match_state<BidiIter> &state, Next const &next) const
{
- if(state.eos() || Not ==
+ if(state.eos() || Not::value ==
(detail::translate(*state.cur_, traits_cast<Traits>(state), icase_type()) == this->ch_))
{
return false;
Modified: branches/proto/v3/boost/xpressive/detail/core/peeker.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/core/peeker.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/core/peeker.hpp 2007-11-29 16:16:30 EST (Thu, 29 Nov 2007)
@@ -142,10 +142,10 @@
return mpl::true_();
}
- template<typename Traits, bool ICase>
- mpl::false_ accept(literal_matcher<Traits, ICase, false> const &xpr)
+ template<typename Traits, typename ICase>
+ mpl::false_ accept(literal_matcher<Traits, ICase, false_> const &xpr)
{
- this->bset_.set_char(xpr.ch_, ICase, this->get_traits_<Traits>());
+ this->bset_.set_char(xpr.ch_, ICase::value, this->get_traits_<Traits>());
return mpl::false_();
}
Modified: branches/proto/v3/boost/xpressive/detail/detail_fwd.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/detail_fwd.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/detail_fwd.hpp 2007-11-29 16:16:30 EST (Thu, 29 Nov 2007)
@@ -128,7 +128,7 @@
template<typename Greedy>
struct repeat_end_matcher;
- template<typename Traits, bool ICase, bool Not>
+ template<typename Traits, typename ICase, typename Not>
struct literal_matcher;
template<typename Traits, bool ICase>
@@ -188,7 +188,7 @@
template<typename Xpr>
struct lookbehind_matcher;
- template<bool IsBoundary>
+ template<typename IsBoundary>
struct word_boundary;
template<typename BidiIter, typename Matcher>
Modified: branches/proto/v3/boost/xpressive/detail/dynamic/parser.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/dynamic/parser.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/dynamic/parser.hpp 2007-11-29 16:16:30 EST (Thu, 29 Nov 2007)
@@ -58,12 +58,12 @@
{
if(0 != (regex_constants::icase_ & flags))
{
- literal_matcher<Traits, true, false> matcher(ch, traits);
+ literal_matcher<Traits, true_, false_> matcher(ch, traits);
return make_dynamic<BidiIter>(matcher);
}
else
{
- literal_matcher<Traits, false, false> matcher(ch, traits);
+ literal_matcher<Traits, false_, false_> matcher(ch, traits);
return make_dynamic<BidiIter>(matcher);
}
}
@@ -81,7 +81,7 @@
using namespace regex_constants;
typedef typename iterator_value<BidiIter>::type char_type;
typedef set_matcher<Traits, mpl::integral_c<int, 2> > set_matcher;
- typedef literal_matcher<Traits, false, true> literal_matcher;
+ typedef literal_matcher<Traits, false_, true_> literal_matcher;
char_type const newline = traits.widen('\n');
set_matcher s;
Modified: branches/proto/v3/boost/xpressive/detail/static/grammar2.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/static/grammar2.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/static/grammar2.hpp 2007-11-29 16:16:30 EST (Thu, 29 Nov 2007)
@@ -207,12 +207,60 @@
template<typename Visitor>
typename Visitor::traits_type const &
- operator()(Visitor &visitor)
+ operator()(Visitor &visitor) const
{
return visitor.traits();
}
};
+ struct newline : function_transform
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Traits>
+ struct result<This(Traits)>
+ {
+ typedef typename Traits::char_class_type type;
+ };
+
+ template<typename Traits>
+ typename Traits::char_class_type
+ operator()(Traits const &traits) const
+ {
+ return lookup_classname(traits, "newline");
+ }
+ };
+
+ struct as_posix_charset : function_transform
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Posix, typename Visitor, typename YesNo>
+ struct result<This(Posix, Visitor, YesNo)>
+ {
+ typedef posix_charset_matcher<typename Visitor::traits_type> type;
+ };
+
+ template<typename Posix, typename Visitor>
+ posix_charset_matcher<typename Visitor::traits_type>
+ operator()(Posix const &posix, Visitor const &visitor, bool yes_no) const
+ {
+ char const *name_end = posix.name_ + std::strlen(posix.name_);
+ return posix_charset_matcher<typename Visitor::traits_type>(
+ visitor.traits().lookup_classname(posix.name_, name_end, Visitor::icase_type::value)
+ , yes_no == posix.not_
+ );
+ }
+ };
+
+ template<typename Visitor>
+ struct icase
+ {
+ typedef typename Visitor::icase_type type;
+ };
+
// BUGBUG make_expr uses as_expr, not as_arg. Is that right?
typedef functional::make_expr<tag::shift_right> _make_shift_right;
typedef functional::make_expr<tag::terminal> _make_terminal;
@@ -569,13 +617,35 @@
template<typename Dummy>
struct case_<tag::complement, Dummy>
: or_<
+ // ~_b
when<
+ complement<terminal<assert_word_placeholder<word_boundary<true_> > > >
+ , assert_word_matcher<word_boundary<false_>, traits(_visitor)>(traits(_visitor))
+ >
+ // ~_n
+ , when<
+ complement<CharLiteral<Char> >
+ , literal_matcher<traits(_visitor), icase<_visitor>, true_>(_arg(_arg), traits(_visitor))
+ >
+ // ~_ln
+ , when<
+ complement<terminal<logical_newline_placeholder> >
+ , posix_charset_matcher<traits(_visitor)>(newline(traits(_visitor)), true_())
+ >
+ // ~alpha
+ , when<
+ complement<terminal<posix_charset_placeholder> >
+ , as_posix_charset(_arg(_arg), _visitor, false_())
+ >
+ // ~before(...)
+ , when<
complement<unary_expr<lookahead_tag, Gram> >
, lookahead_matcher<as_independent(_arg(_arg))>(
as_independent(_arg(_arg))
, true_()
)
>
+ // ~after(...)
, when<
complement<unary_expr<lookbehind_tag, Gram> >
, lookbehind_matcher<as_independent(_arg(_arg))>(
Modified: branches/proto/v3/boost/xpressive/detail/static/transmogrify.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/static/transmogrify.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/static/transmogrify.hpp 2007-11-29 16:16:30 EST (Thu, 29 Nov 2007)
@@ -44,7 +44,7 @@
typedef typename mpl::if_
<
is_char_literal<Matcher, char_type>
- , literal_matcher<Traits, ICase::value, false>
+ , literal_matcher<Traits, ICase, false_>
, string_matcher<Traits, ICase::value>
>::type type;
@@ -57,8 +57,8 @@
template<typename Matcher2, typename Visitor>
static type call_(Matcher2 const &m, Visitor &visitor, mpl::true_)
{
- char_type ch = char_cast<char_type>(m, visitor.traits());
- return type(ch, visitor.traits());
+ //char_type ch = char_cast<char_type>(m, visitor.traits());
+ return type(m, visitor.traits());
}
template<typename Matcher2, typename Visitor>
Modified: branches/proto/v3/boost/xpressive/proto3/expr.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto3/expr.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto3/expr.hpp 2007-11-29 16:16:30 EST (Thu, 29 Nov 2007)
@@ -122,7 +122,7 @@
operator address_of_hack_type_() const
{
- return boost::addressof(this->arg0.expr);
+ return boost::addressof(this->proto_args_.car);
}
template<typename A>
Modified: branches/proto/v3/boost/xpressive/regex_compiler.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/regex_compiler.hpp (original)
+++ branches/proto/v3/boost/xpressive/regex_compiler.hpp 2007-11-29 16:16:30 EST (Thu, 29 Nov 2007)
@@ -502,10 +502,10 @@
return detail::make_assert_end_line<BidiIter>(this->traits_.flags(), this->rxtraits());
case token_assert_word_boundary:
- return detail::make_assert_word<BidiIter>(detail::word_boundary<true>(), this->rxtraits());
+ return detail::make_assert_word<BidiIter>(detail::word_boundary<detail::true_>(), this->rxtraits());
case token_assert_not_word_boundary:
- return detail::make_assert_word<BidiIter>(detail::word_boundary<false>(), this->rxtraits());
+ return detail::make_assert_word<BidiIter>(detail::word_boundary<detail::false_>(), this->rxtraits());
case token_assert_word_begin:
return detail::make_assert_word<BidiIter>(detail::word_begin(), this->rxtraits());
Modified: branches/proto/v3/boost/xpressive/regex_primitives.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/regex_primitives.hpp (original)
+++ branches/proto/v3/boost/xpressive/regex_primitives.hpp 2007-11-29 16:16:30 EST (Thu, 29 Nov 2007)
@@ -31,7 +31,7 @@
namespace boost { namespace xpressive { namespace detail
{
- typedef assert_word_placeholder<word_boundary<true> > assert_word_boundary;
+ typedef assert_word_placeholder<word_boundary<true_> > assert_word_boundary;
typedef assert_word_placeholder<word_begin> assert_word_begin;
typedef assert_word_placeholder<word_end> assert_word_end;
Modified: branches/proto/v3/boost/xpressive/xpressive_typeof.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/xpressive_typeof.hpp (original)
+++ branches/proto/v3/boost/xpressive/xpressive_typeof.hpp 2007-11-29 16:16:30 EST (Thu, 29 Nov 2007)
@@ -38,7 +38,7 @@
BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::word_end)
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::generic_quant_tag, (unsigned int)(unsigned int))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::basic_regex, (typename))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::word_boundary, (bool))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::word_boundary, (typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::value, (typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::reference, (typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::local, (typename))
@@ -80,7 +80,7 @@
BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::attr_end_matcher)
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::assert_bol_matcher, (typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::assert_eol_matcher, (typename))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::literal_matcher, (typename)(bool)(bool))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::literal_matcher, (typename)(typename)(typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::string_matcher, (typename)(bool))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::charset_matcher, (typename)(bool)(typename))
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::logical_newline_matcher, (typename))
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