Update of /cvsroot/boost/boost/boost/xpressive/detail/static/productions
In directory
sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19839/detail/static/productions
Modified Files:
complement_compiler.hpp noop_compiler.hpp transmogrify.hpp
visitor.hpp
Log Message:
basic_regex uses proto::extends<>, eliminate regex_operators.hpp and
as_matcher(), as_xpr() is simply proto::as_expr()
Index: complement_compiler.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/boost/xpressive/detail/static/productions/complement_compiler.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- complement_compiler.hpp 3 Feb 2007 00:14:32 -0000 1.12
+++ complement_compiler.hpp 12 Mar 2007 22:11:29 -0000 1.13
@@ -24,34 +24,73 @@
///////////////////////////////////////////////////////////////////////////////
//
- template<typename Term>
- struct complement_terminal
+ template<typename Type>
+ struct uncomplementible_terminal
{
// If your compile breaks here, then you are applying the complement
operator ~
- // to something that does not support it. For instance, ~(_ >> 'a')
will trigger this
- // assertion because the sub-expression (_ >> 'a') has no complement.
- BOOST_MPL_ASSERT((never_true<Term>));
+ // to something that does not support it. For instance,
~as_xpr("hello") will trigger this
+ // assertion because the sub-expression as_xpr("hello") has no
complement.
+ BOOST_MPL_ASSERT((never_true<Type>));
+ template<typename> struct apply : proto::terminal<Type> {};
+ static Type const &call(Type const &t, dont_care) { return t; }
};
///////////////////////////////////////////////////////////////////////////////
//
- template<typename Char, typename Not>
- struct complement_terminal<literal_placeholder<Char, Not> >
+ template<typename Term>
+ struct complement_terminal // complement a character literal
{
template<typename>
struct apply
- : proto::terminal<literal_placeholder<Char, typename
mpl::not_<Not>::type> >
+ : proto::terminal<not_literal_placeholder<Term> >
{};
template<typename Expr, typename Visitor>
static typename apply<Visitor>::type call(Expr const &expr, Visitor &)
{
typedef typename apply<Visitor>::type type;
- type that = {{proto::arg(expr).ch_}};
+ type that = {{proto::arg(expr)}};
return that;
}
};
+ template<typename Char>
+ struct complement_terminal<Char *>
+ : uncomplementible_terminal<Char *>
+ {};
+
+ template<typename Char, std::size_t N>
+ struct complement_terminal<Char (&)[N]>
+ : uncomplementible_terminal<Char (&)[N]>
+ {};
+
+ template<typename Char, std::size_t N>
+ struct complement_terminal<Char const (&)[N]>
+ : uncomplementible_terminal<Char const (&)[N]>
+ {};
+
+ template<typename BidiIter>
+ struct complement_terminal<tracking_ptr<regex_impl<BidiIter> > >
+ : uncomplementible_terminal<tracking_ptr<regex_impl<BidiIter> > >
+ {};
+
+
///////////////////////////////////////////////////////////////////////////////
+ //
+ template<typename Char>
+ struct complement_terminal<not_literal_placeholder<Char> >
+ {
+ template<typename>
+ struct apply
+ : proto::terminal<Char>
+ {};
+
+ template<typename Expr, typename Visitor>
+ static typename apply<Visitor>::type call(Expr const &expr, Visitor &)
+ {
+ return proto::terminal<Char>::type::make(proto::arg(expr).ch_);
+ }
+ };
+
///////////////////////////////////////////////////////////////////////////////
//
template<typename Traits, int Size>
Index: noop_compiler.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/boost/xpressive/detail/static/productions/noop_compiler.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- noop_compiler.hpp 3 Feb 2007 00:14:33 -0000 1.9
+++ noop_compiler.hpp 12 Mar 2007 22:11:29 -0000 1.10
@@ -23,20 +23,19 @@
template<typename Expr, typename State, typename Visitor>
struct apply
{
- typedef typename proto::result_of::arg<Expr>::type arg_type;
- typedef typename as_matcher_type<arg_type>::type matcher1;
- typedef typename Visitor::BOOST_NESTED_TEMPLATE
apply<matcher1>::type matcher2;
- typedef static_xpression<matcher2, State> type;
+ typedef static_xpression<
+ typename Visitor::BOOST_NESTED_TEMPLATE apply<
+ typename proto::result_of::arg<Expr>::type
+ >::type
+ , State
+ > 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 make_static(
- visitor.call(detail::as_matcher(proto::arg(expr)))
- , state
- );
+ return make_static(visitor.call(proto::arg(expr)), state);
}
};
Index: transmogrify.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/boost/xpressive/detail/static/productions/transmogrify.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- transmogrify.hpp 13 Nov 2006 15:53:45 -0000 1.6
+++ transmogrify.hpp 12 Mar 2007 22:11:29 -0000 1.7
@@ -17,6 +17,8 @@
#include <boost/mpl/if.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/is_array.hpp>
+#include <boost/type_traits/remove_reference.hpp>
#include <boost/xpressive/detail/detail_fwd.hpp>
#include <boost/xpressive/detail/core/matchers.hpp>
#include <boost/xpressive/detail/static/placeholders.hpp>
@@ -25,11 +27,54 @@
namespace boost { namespace xpressive { namespace detail
{
+ template<typename T>
+ struct is_string_literal
+ : is_array<typename remove_reference<T>::type>
+ {};
+
+ template<typename T>
+ struct is_string_literal<T *>
+ : mpl::true_
+ {};
+
///////////////////////////////////////////////////////////////////////////////
// transmogrify
//
+ template<typename BidiIter, typename ICase, typename Traits, typename
Matcher, typename EnableIf = void>
+ struct default_transmogrify
+ {
+ typedef typename iterator_value<BidiIter>::type char_type;
+ typedef std::basic_string<char_type> string_type;
+
+ typedef typename mpl::if_
+ <
+ is_string_literal<Matcher>
+ , string_matcher<Traits, ICase::value>
+ , literal_matcher<Traits, ICase::value, false>
+ >::type type;
+
+ template<typename Matcher2, typename Visitor>
+ static type call(Matcher2 const &m, Visitor &visitor)
+ {
+ return default_transmogrify::call_(m, visitor,
is_string_literal<Matcher2>());
+ }
+
+ template<typename Matcher2, typename Visitor>
+ static type call_(Matcher2 const &m, Visitor &visitor, mpl::false_)
+ {
+ char_type ch = char_cast<char_type>(m, visitor.traits());
+ return type(ch, visitor.traits());
+ }
+
+ template<typename Matcher2, typename Visitor>
+ static type call_(Matcher2 const &m, Visitor &visitor, mpl::true_)
+ {
+ return type(string_cast<char_type>(string_type(m),
visitor.traits()), visitor.traits());
+ }
+ };
+
template<typename BidiIter, typename ICase, typename Traits, typename
Matcher>
- struct transmogrify
+ struct default_transmogrify<BidiIter, ICase, Traits, Matcher, typename
Matcher::is_boost_xpressive_xpression_>
{
typedef Matcher type;
@@ -40,8 +85,13 @@
}
};
+ template<typename BidiIter, typename ICase, typename Traits, typename
Matcher>
+ struct transmogrify
+ : default_transmogrify<BidiIter, ICase, Traits, Matcher>
+ {};
+
template<typename BidiIter, typename ICase, typename Traits>
- struct transmogrify<BidiIter, ICase, Traits, assert_bol_placeholder>
+ struct transmogrify<BidiIter, ICase, Traits, assert_bol_placeholder >
{
typedef assert_bol_matcher<Traits> type;
@@ -53,7 +103,7 @@
};
template<typename BidiIter, typename ICase, typename Traits>
- struct transmogrify<BidiIter, ICase, Traits, assert_eol_placeholder>
+ struct transmogrify<BidiIter, ICase, Traits, assert_eol_placeholder >
{
typedef assert_eol_matcher<Traits> type;
@@ -65,7 +115,7 @@
};
template<typename BidiIter, typename ICase, typename Traits>
- struct transmogrify<BidiIter, ICase, Traits, logical_newline_placeholder>
+ struct transmogrify<BidiIter, ICase, Traits, logical_newline_placeholder >
{
typedef logical_newline_matcher<Traits> type;
@@ -76,11 +126,11 @@
}
};
- template<typename BidiIter, typename ICase, typename Traits, typename
Char, typename Not>
- struct transmogrify<BidiIter, ICase, Traits, literal_placeholder<Char,
Not> >
+ template<typename BidiIter, typename ICase, typename Traits, typename Char>
+ struct transmogrify<BidiIter, ICase, Traits, not_literal_placeholder<Char>
>
{
typedef typename iterator_value<BidiIter>::type char_type;
- typedef literal_matcher<Traits, ICase::value, Not::value> type;
+ typedef literal_matcher<Traits, ICase::value, true> type;
template<typename Matcher2, typename Visitor>
static type call(Matcher2 const &m, Visitor &visitor)
@@ -105,21 +155,8 @@
}
};
- template<typename BidiIter, typename ICase, typename Traits, typename Char>
- struct transmogrify<BidiIter, ICase, Traits, string_placeholder<Char> >
- {
- typedef typename iterator_value<BidiIter>::type char_type;
- typedef string_matcher<Traits, ICase::value> type;
-
- template<typename Matcher2, typename Visitor>
- static type call(Matcher2 const &m, Visitor &visitor)
- {
- return type(string_cast<char_type>(m.str_, visitor.traits()),
visitor.traits());
- }
- };
-
template<typename BidiIter, typename ICase, typename Traits>
- struct transmogrify<BidiIter, ICase, Traits, mark_placeholder>
+ struct transmogrify<BidiIter, ICase, Traits, mark_placeholder >
{
typedef mark_matcher<Traits, ICase::value> type;
@@ -131,7 +168,7 @@
};
template<typename BidiIter, typename ICase, typename Traits>
- struct transmogrify<BidiIter, ICase, Traits, posix_charset_placeholder>
+ struct transmogrify<BidiIter, ICase, Traits, posix_charset_placeholder >
{
typedef posix_charset_matcher<Traits> type;
@@ -168,15 +205,10 @@
}
};
- template<typename BidiIter, typename ICase, typename Traits, typename
ByRef>
- struct transmogrify<BidiIter, ICase, Traits, regex_placeholder<BidiIter,
ByRef> >
+ template<typename BidiIter, typename ICase, typename Traits>
+ struct transmogrify<BidiIter, ICase, Traits,
regex_byref_placeholder<BidiIter> >
{
- typedef typename mpl::if_
- <
- ByRef
- , regex_byref_matcher<BidiIter>
- , regex_matcher<BidiIter>
- >::type type;
+ typedef regex_byref_matcher<BidiIter> type;
template<typename Matcher2>
static type call(Matcher2 const &m, dont_care)
@@ -186,7 +218,19 @@
};
template<typename BidiIter, typename ICase, typename Traits>
- struct transmogrify<BidiIter, ICase, Traits, self_placeholder>
+ struct transmogrify<BidiIter, ICase, Traits,
tracking_ptr<regex_impl<BidiIter> > >
+ {
+ typedef regex_matcher<BidiIter> type;
+
+ template<typename Matcher2>
+ static type call(Matcher2 const &m, dont_care)
+ {
+ return type(m.get());
+ }
+ };
+
+ template<typename BidiIter, typename ICase, typename Traits>
+ struct transmogrify<BidiIter, ICase, Traits, self_placeholder >
{
typedef regex_byref_matcher<BidiIter> type;
Index: visitor.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/boost/xpressive/detail/static/productions/visitor.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- visitor.hpp 13 Nov 2006 15:53:45 -0000 1.8
+++ visitor.hpp 12 Mar 2007 22:11:29 -0000 1.9
@@ -63,13 +63,18 @@
{
}
- template<typename ByRef>
- void visit_(regex_placeholder<BidiIter, ByRef> const &rex)
+ void visit_(regex_byref_placeholder<BidiIter> const &rex)
{
// when visiting an embedded regex, track the references
this->self_->track_reference(*rex.impl_);
}
+ void visit_(tracking_ptr<regex_impl<BidiIter> > const &rex)
+ {
+ // when visiting an embedded regex, track the references
+ this->self_->track_reference(*rex.get());
+ }
+
void visit_(mark_placeholder const &backref)
{
// keep track of the largest mark number found
-------------------------------------------------------------------------
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