switch proto::matches from using mpl::_ to using proto::_, which has an identity transform

[SVN r36789]
This commit is contained in:
Eric Niebler 2007-01-26 03:06:15 +00:00
parent 051ca1b052
commit a4565ad5ab
12 changed files with 66 additions and 70 deletions

View File

@ -1,8 +1,12 @@
[section Preface]
[:['Wife:] It's a floor wax!\n
['Husband:] No, it's a dessert topping!\n
['Announcer:] Stop! You're both right. It's a floor wax ['and] a dessert topping!]
[:['Wife:] New Shimmer is a floor wax!\n
['Husband:] No, new Shimmer is a dessert topping!\n
['Wife:] It's a floor wax!\n
['Husband:] It's a dessert topping!\n
['Wife:] It's a floor wax, I'm telling you!\n
['Husband:] It's a dessert topping, you cow!\n
['Announcer:] Hey, hey, hey, calm down, you two. New Shimmer is both a floor wax ['and] a dessert topping!]
[:[*['-- Saturday Night Live]]]
[h2 Description]

View File

@ -54,8 +54,8 @@ namespace boost { namespace xpressive { namespace detail
struct XpressiveLocaleModifier
: proto::meta::binary_expr<
modifier_tag
, proto::meta::terminal<locale_modifier<mpl::_> >
, mpl::_
, proto::meta::terminal<locale_modifier<proto::_> >
, proto::_
>
{};

View File

@ -224,26 +224,26 @@ namespace boost { namespace xpressive
template<typename Char>
struct XpressiveModifiedSubExpression
: proto::meta::binary_expr<detail::modifier_tag, mpl::_, XpressiveGrammar<Char> >
: proto::meta::binary_expr<detail::modifier_tag, proto::_, XpressiveGrammar<Char> >
{};
template<typename Char>
struct XpressiveComplementedCharacterLiteral
: proto::or_<
proto::meta::complement<proto::meta::terminal<detail::literal_placeholder<Char, mpl::_> > >
, proto::meta::complement<proto::meta::terminal<detail::literal_placeholder<char, mpl::_> > >
proto::meta::complement<proto::meta::terminal<detail::literal_placeholder<Char, proto::_> > >
, proto::meta::complement<proto::meta::terminal<detail::literal_placeholder<char, proto::_> > >
>
{};
template<>
struct XpressiveComplementedCharacterLiteral<char>
: proto::meta::complement<proto::meta::terminal<detail::literal_placeholder<char, mpl::_> > >
: proto::meta::complement<proto::meta::terminal<detail::literal_placeholder<char, proto::_> > >
{};
template<typename Char>
struct XpressiveComplementedExpression
: proto::and_<
proto::meta::complement<mpl::_>
proto::meta::complement<proto::_>
, proto::or_<
proto::meta::complement<proto::meta::terminal<detail::posix_charset_placeholder> >
, proto::meta::complement<proto::meta::terminal<detail::logical_newline_placeholder> >
@ -258,7 +258,7 @@ namespace boost { namespace xpressive
struct XpressiveTerminal
: proto::or_<
proto::and_<
proto::meta::terminal<mpl::_>
proto::meta::terminal<proto::_>
, proto::if_<detail::is_xpressive_terminal<Char, proto::meta::arg<mpl::_> > >
>
, XpressiveComplementedExpression<Char>
@ -275,11 +275,11 @@ namespace boost { namespace xpressive
template<typename Char>
struct XpressiveQuantified
: proto::and_<
proto::meta::unary_expr<mpl::_, XpressiveGrammar<Char> >
proto::meta::unary_expr<proto::_, XpressiveGrammar<Char> >
, proto::or_<
proto::meta::unary_star< mpl::_ >
, proto::meta::unary_plus< mpl::_ >
, proto::meta::logical_not< mpl::_ >
proto::meta::unary_star< proto::_ >
, proto::meta::unary_plus< proto::_ >
, proto::meta::logical_not< proto::_ >
, proto::if_<detail::is_generic_repeat<proto::meta::tag<mpl::_> > >
>
>

View File

@ -21,7 +21,7 @@ namespace boost { namespace xpressive { namespace detail
// MarkerPattern
// (s1= ...) is a marker
struct MarkerPattern
: proto::meta::assign<basic_mark_tag, mpl::_>
: proto::meta::assign<basic_mark_tag, proto::_>
{};
///////////////////////////////////////////////////////////////////////////////

View File

@ -37,7 +37,7 @@ namespace boost { namespace xpressive { namespace detail
{
template<typename Expr, typename, typename>
struct apply
: proto::matches<Expr, proto::meta::subscript<set_initializer_type, mpl::_> >
: proto::matches<Expr, proto::meta::subscript<set_initializer_type, proto::_> >
{};
};

View File

@ -23,7 +23,7 @@ namespace boost { namespace xpressive { namespace detail
///////////////////////////////////////////////////////////////////////////////
// RepeaterPattern
struct RepeaterPattern
: proto::meta::right_shift<proto::meta::terminal<repeat_begin_matcher>, mpl::_>
: proto::meta::right_shift<proto::meta::terminal<repeat_begin_matcher>, proto::_>
{};
///////////////////////////////////////////////////////////////////////////////

View File

@ -21,7 +21,7 @@ namespace boost { namespace xpressive { namespace detail
// MarkerPattern
// (s1= ...) is a marker
struct MarkerPattern
: proto::meta::assign<basic_mark_tag, mpl::_>
: proto::meta::assign<basic_mark_tag, proto::_>
{};
///////////////////////////////////////////////////////////////////////////////

View File

@ -37,7 +37,7 @@ namespace boost { namespace xpressive { namespace detail
{
template<typename Expr, typename, typename>
struct apply
: proto::matches<Expr, proto::meta::subscript<set_initializer_type, mpl::_> >
: proto::matches<Expr, proto::meta::subscript<set_initializer_type, proto::_> >
{};
};

View File

@ -23,7 +23,7 @@ namespace boost { namespace xpressive { namespace detail
///////////////////////////////////////////////////////////////////////////////
// RepeaterPattern
struct RepeaterPattern
: proto::meta::right_shift<proto::meta::terminal<repeat_begin_matcher>, mpl::_>
: proto::meta::right_shift<proto::meta::terminal<repeat_begin_matcher>, proto::_>
{};
///////////////////////////////////////////////////////////////////////////////

View File

@ -32,8 +32,6 @@
#include <boost/mpl/apply.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/xpressive/proto/proto_fwd.hpp>
#include <boost/xpressive/proto/traits.hpp>
@ -45,9 +43,6 @@
namespace detail
{
template<typename Expr>
struct deref;
template<typename Expr, typename Grammar>
struct matches_impl;
@ -56,7 +51,7 @@
struct or1
: mpl::bool_<B>
{
typedef G0 grammar;
typedef G0 which;
};
template<bool B>
@ -70,7 +65,13 @@
template<typename T>
struct wrap_terminal
{
wrap_terminal(typename add_reference<typename add_const<T>::type>::type);
wrap_terminal(T const &);
};
template<typename T>
struct wrap_terminal<T &>
{
wrap_terminal(T &);
};
// terminal_matches
@ -80,7 +81,7 @@
{};
template<typename Expr>
struct terminal_matches<Expr, mpl::_>
struct terminal_matches<Expr, proto::_>
: mpl::true_
{};
@ -94,22 +95,6 @@
: terminal_matches<Expr0, Grammar0>
{};
// by default, assume parameter is an expression generator ...
// (this also works for expr<>, ref<> and extends<> types because
// they are also expression generators)
template<typename Expr>
struct deref
{
typedef typename Expr::type type;
};
// ... or the placeholder
template<>
struct deref<mpl::_>
{
typedef mpl::_ type;
};
// matches_impl
template<typename Expr, typename Grammar>
struct matches_impl
@ -117,7 +102,7 @@
{};
template<typename Expr>
struct matches_impl< Expr, mpl::_ >
struct matches_impl< Expr, proto::_ >
: mpl::true_
{};
@ -125,15 +110,15 @@
struct matches_impl< expr<Tag, Args1, 1>, expr<Tag, Args2, 1> >
: matches_impl<
typename Args1::arg0::type
, typename deref<typename Args2::arg0>::type
, typename Args2::arg0::type
>
{};
template<typename Tag, typename Args1, typename Args2>
struct matches_impl< expr<Tag, Args1, 1>, expr<mpl::_, Args2, 1> >
struct matches_impl< expr<Tag, Args1, 1>, expr<proto::_, Args2, 1> >
: matches_impl<
typename Args1::arg0::type
, typename deref<typename Args2::arg0>::type
, typename Args2::arg0::type
>
{};
@ -146,7 +131,7 @@
{};
template<typename Args1, typename Args2>
struct matches_impl< expr<tag::terminal, Args1, 1>, expr<mpl::_, Args2, 1> >
struct matches_impl< expr<tag::terminal, Args1, 1>, expr<proto::_, Args2, 1> >
: terminal_matches<
typename Args1::arg0
, typename Args2::arg0
@ -156,13 +141,13 @@
#define BOOST_PROTO_MATCHES_N_FUN(z, n, data)\
matches_impl<\
typename Args1::BOOST_PP_CAT(arg, n)::type\
, typename deref<typename Args2::BOOST_PP_CAT(arg, n)>::type\
, typename Args2::BOOST_PP_CAT(arg, n)::type\
>
#define BOOST_PROTO_DEFINE_MATCHES(z, n, data)\
matches_impl<\
typename Expr::type\
, typename deref<BOOST_PP_CAT(G, n)>::type\
, typename BOOST_PP_CAT(G, n)::type\
>
#define BOOST_PROTO_DEFINE_TERMINAL_MATCHES(z, n, data)\
@ -189,7 +174,7 @@
template<typename Expr, typename Grammar>
struct matches
: detail::matches_impl<typename Expr::type, typename detail::deref<Grammar>::type>
: detail::matches_impl<typename Expr::type, typename Grammar::type>
{};
template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, typename G)>
@ -200,16 +185,16 @@
template<typename Expr, typename State, typename Visitor>
struct apply
{
typedef typename detail::matches_impl<Expr, or_>::grammar grammar_type;
typedef typename grammar_type::template apply<Expr, State, Visitor>::type type;
typedef typename detail::matches_impl<Expr, or_>::which which;
typedef typename which::template apply<Expr, State, Visitor>::type type;
};
template<typename Expr, typename State, typename Visitor>
static typename apply<Expr, State, Visitor>::type
call(Expr const &expr, State const &state, Visitor &visitor)
{
typedef typename apply<Expr, State, Visitor>::grammar_type grammar_type;
return grammar_type::call(expr, state, visitor);
typedef typename detail::matches_impl<Expr, or_>::which which;
return which::call(expr, state, visitor);
}
};
@ -221,19 +206,24 @@
template<typename Expr, typename State, typename Visitor>
struct apply
{
typedef typename detail::last<and_>::type grammar_type;
typedef typename grammar_type::template apply<Expr, State, Visitor>::type type;
typedef typename detail::last<and_>::type which;
typedef typename which::template apply<Expr, State, Visitor>::type type;
};
template<typename Expr, typename State, typename Visitor>
static typename apply<Expr, State, Visitor>::type
call(Expr const &expr, State const &state, Visitor &visitor)
{
typedef typename apply<Expr, State, Visitor>::grammar_type grammar_type;
return grammar_type::call(expr, state, visitor);
typedef typename detail::last<and_>::type which;
return which::call(expr, state, visitor);
}
};
struct _ : has_identity_transform
{
typedef _ type;
};
template<typename Pred>
struct if_ : has_identity_transform
{
@ -270,9 +260,9 @@
template<bool B, typename Expr, BOOST_PP_ENUM_PARAMS(N, typename G)>
struct BOOST_PP_CAT(or, N)
: BOOST_PP_CAT(or, BOOST_PP_DEC(N))<
matches_impl<Expr, typename deref<G1>::type>::value
matches_impl<Expr, typename G1::type>::value
, Expr
BOOST_PP_COMMA_IF(BOOST_PP_DEC(N)) BOOST_PP_ENUM_SHIFTED_PARAMS(N, G)
, BOOST_PP_ENUM_SHIFTED_PARAMS(N, G)
>
{};
@ -280,7 +270,7 @@
struct BOOST_PP_CAT(or, N)<true, Expr, BOOST_PP_ENUM_PARAMS(N, G)>
: mpl::true_
{
typedef G0 grammar;
typedef G0 which;
};
template<bool B, BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(N), typename P)>
@ -317,7 +307,7 @@
{};
template<typename Tag, typename Args1, typename Args2>
struct matches_impl< expr<Tag, Args1, N>, expr<mpl::_, Args2, N> >
struct matches_impl< expr<Tag, Args1, N>, expr<proto::_, Args2, N> >
: BOOST_PP_CAT(and, N)<
BOOST_PROTO_MATCHES_N_FUN(~, 0, N)::value,
BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_MATCHES_N_FUN, N)
@ -328,7 +318,7 @@
template<typename Expr, BOOST_PP_ENUM_PARAMS(N, typename G)>
struct matches_impl<Expr, proto::or_<BOOST_PP_ENUM_PARAMS(N, G)> >
: BOOST_PP_CAT(or, N)<
matches_impl<typename Expr::type, typename deref<G0>::type>::value,
matches_impl<typename Expr::type, typename G0::type>::value,
typename Expr::type, BOOST_PP_ENUM_PARAMS(N, G)
>
{};

View File

@ -441,6 +441,8 @@ namespace boost { namespace proto
template<typename Grammar>
struct has_pass_through_transform;
struct _;
}} // namespace boost::proto
#endif

View File

@ -53,10 +53,10 @@ struct placeholder_arity
struct LambdaGrammar
: max_arity<
proto::or_<
placeholder_arity< proto::meta::terminal<placeholder<mpl::_> > >
, proto::trans::always< proto::meta::terminal<mpl::_>, mpl::int_<0> >
, proto::trans::arg< proto::meta::unary_expr<mpl::_, LambdaGrammar> >
, proto::trans::fold< proto::meta::binary_expr<mpl::_, LambdaGrammar, LambdaGrammar> >
placeholder_arity< proto::meta::terminal<placeholder<proto::_> > >
, proto::trans::always< proto::meta::terminal<proto::_>, mpl::int_<0> >
, proto::trans::arg< proto::meta::unary_expr<proto::_, LambdaGrammar> >
, proto::trans::fold< proto::meta::binary_expr<proto::_, LambdaGrammar, LambdaGrammar> >
>
>
{};