Added boost header
This commit is contained in:
322
test/external/boost/xpressive/detail/static/transforms/as_action.hpp
vendored
Normal file
322
test/external/boost/xpressive/detail/static/transforms/as_action.hpp
vendored
Normal file
@@ -0,0 +1,322 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_action.hpp
|
||||
//
|
||||
// Copyright 2008 Eric Niebler.
|
||||
// Copyright 2008 David Jenkins.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_ACTION_HPP_EAN_04_05_2007
|
||||
#define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_ACTION_HPP_EAN_04_05_2007
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/sizeof.hpp>
|
||||
#include <boost/mpl/min_max.hpp>
|
||||
#include <boost/mpl/apply_wrap.hpp>
|
||||
#include <boost/xpressive/detail/detail_fwd.hpp>
|
||||
#include <boost/xpressive/detail/core/matcher/attr_end_matcher.hpp>
|
||||
#include <boost/xpressive/detail/static/static.hpp>
|
||||
#include <boost/xpressive/detail/static/transforms/as_quantifier.hpp>
|
||||
#include <boost/proto/core.hpp>
|
||||
#include <boost/proto/transform/arg.hpp>
|
||||
#include <boost/proto/transform/call.hpp>
|
||||
#include <boost/proto/transform/make.hpp>
|
||||
#include <boost/proto/transform/when.hpp>
|
||||
#include <boost/proto/transform/fold.hpp>
|
||||
#include <boost/proto/transform/fold_tree.hpp>
|
||||
|
||||
namespace boost { namespace xpressive { namespace detail
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// read_attr
|
||||
// Placeholder that knows the slot number of an attribute as well as the type
|
||||
// of the object stored in it.
|
||||
template<typename Nbr, typename Matcher>
|
||||
struct read_attr
|
||||
{
|
||||
typedef Nbr nbr_type;
|
||||
typedef Matcher matcher_type;
|
||||
static Nbr nbr() { return Nbr(); }
|
||||
};
|
||||
|
||||
template<typename Nbr, typename Matcher>
|
||||
struct read_attr<Nbr, Matcher &>
|
||||
{
|
||||
typedef Nbr nbr_type;
|
||||
typedef Matcher matcher_type;
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
namespace boost { namespace xpressive { namespace grammar_detail
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// FindAttr
|
||||
// Look for patterns like (a1= terminal<RHS>) and return the type of the RHS.
|
||||
template<typename Nbr>
|
||||
struct FindAttr
|
||||
: or_<
|
||||
// Ignore nested actions, because attributes are scoped
|
||||
when< subscript<_, _>, _state >
|
||||
, when< terminal<_>, _state >
|
||||
, when< proto::assign<terminal<detail::attribute_placeholder<Nbr> >, _>, call<_value(_right)> >
|
||||
, otherwise< fold<_, _state, FindAttr<Nbr> > >
|
||||
>
|
||||
{};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_read_attr
|
||||
// For patterns like (a1 = RHS)[ref(i) = a1], transform to
|
||||
// (a1 = RHS)[ref(i) = read_attr<1, RHS>] so that when reading the attribute
|
||||
// we know what type is stored in the attribute slot.
|
||||
struct as_read_attr : proto::transform<as_read_attr>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename impl::expr expr_type;
|
||||
typedef
|
||||
typename FindAttr<typename expr_type::proto_child0::nbr_type>::template impl<
|
||||
State
|
||||
, mpl::void_
|
||||
, int
|
||||
>::result_type
|
||||
attr_type;
|
||||
|
||||
typedef
|
||||
typename proto::terminal<
|
||||
detail::read_attr<
|
||||
typename expr_type::proto_child0::nbr_type
|
||||
, BOOST_PROTO_UNCVREF(attr_type)
|
||||
>
|
||||
>::type
|
||||
result_type;
|
||||
|
||||
result_type operator ()(proto::ignore, proto::ignore, proto::ignore) const
|
||||
{
|
||||
result_type that = {{}};
|
||||
return that;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// DeepCopy
|
||||
// Turn all refs into values, and also bind all attribute placeholders with
|
||||
// the types from which they are being assigned.
|
||||
struct DeepCopy
|
||||
: or_<
|
||||
when< terminal<detail::attribute_placeholder<_> >, as_read_attr>
|
||||
, when< terminal<_>, proto::_deep_copy>
|
||||
, otherwise< nary_expr<_, vararg<DeepCopy> > >
|
||||
>
|
||||
{};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// attr_nbr
|
||||
// For an attribute placeholder, return the attribute's slot number.
|
||||
struct attr_nbr : proto::transform<attr_nbr>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename impl::expr expr_type;
|
||||
typedef typename expr_type::proto_child0::nbr_type::type result_type;
|
||||
};
|
||||
};
|
||||
|
||||
struct max_attr;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// MaxAttr
|
||||
// In an action (rx)[act], find the largest attribute slot being used.
|
||||
struct MaxAttr
|
||||
: or_<
|
||||
when< terminal<detail::attribute_placeholder<_> >, attr_nbr>
|
||||
, when< terminal<_>, make<mpl::int_<0> > >
|
||||
// Ignore nested actions, because attributes are scoped:
|
||||
, when< subscript<_, _>, make<mpl::int_<0> > >
|
||||
, otherwise< fold<_, make<mpl::int_<0> >, max_attr> >
|
||||
>
|
||||
{};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// max_attr
|
||||
// Take the maximum of the current attr slot number and the state.
|
||||
struct max_attr : proto::transform<max_attr>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef
|
||||
typename mpl::max<
|
||||
typename impl::state
|
||||
, typename MaxAttr::template impl<Expr, State, Data>::result_type
|
||||
>::type
|
||||
result_type;
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_attr_matcher
|
||||
// turn a1=matcher into attr_matcher<Matcher>(1)
|
||||
struct as_attr_matcher : proto::transform<as_attr_matcher>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename impl::expr expr_type;
|
||||
typedef typename impl::data data_type;
|
||||
typedef
|
||||
detail::attr_matcher<
|
||||
typename proto::result_of::value<typename expr_type::proto_child1>::type
|
||||
, typename data_type::traits_type
|
||||
, typename data_type::icase_type
|
||||
>
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
return result_type(
|
||||
proto::value(proto::left(expr)).nbr()
|
||||
, proto::value(proto::right(expr))
|
||||
, data.traits()
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// add_attrs
|
||||
// Wrap an expression in attr_begin_matcher/attr_end_matcher pair
|
||||
struct add_attrs : proto::transform<add_attrs>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef
|
||||
detail::attr_begin_matcher<
|
||||
typename MaxAttr::template impl<Expr, mpl::int_<0>, int>::result_type
|
||||
>
|
||||
begin_type;
|
||||
|
||||
typedef typename impl::expr expr_type;
|
||||
|
||||
typedef
|
||||
typename shift_right<
|
||||
typename terminal<begin_type>::type
|
||||
, typename shift_right<
|
||||
Expr
|
||||
, terminal<detail::attr_end_matcher>::type
|
||||
>::type
|
||||
>::type
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param
|
||||
) const
|
||||
{
|
||||
begin_type begin;
|
||||
detail::attr_end_matcher end;
|
||||
result_type that = {{begin}, {expr, {end}}};
|
||||
return that;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// InsertAttrs
|
||||
struct InsertAttrs
|
||||
: if_<MaxAttr, add_attrs, _>
|
||||
{};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// CheckAssertion
|
||||
struct CheckAssertion
|
||||
: proto::function<terminal<detail::check_tag>, _>
|
||||
{};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// action_transform
|
||||
// Turn A[B] into (mark_begin(n) >> A >> mark_end(n) >> action_matcher<B>(n))
|
||||
// If A and B use attributes, wrap the above expression in
|
||||
// a attr_begin_matcher<Count> / attr_end_matcher pair, where Count is
|
||||
// the number of attribute slots used by the pattern/action.
|
||||
struct as_action : proto::transform<as_action>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename proto::result_of::left<Expr>::type expr_type;
|
||||
typedef typename proto::result_of::right<Expr>::type action_type;
|
||||
|
||||
typedef
|
||||
typename DeepCopy::impl<action_type, expr_type, int>::result_type
|
||||
action_copy_type;
|
||||
|
||||
typedef
|
||||
typename InsertMark::impl<expr_type, State, Data>::result_type
|
||||
marked_expr_type;
|
||||
|
||||
typedef
|
||||
typename mpl::if_c<
|
||||
proto::matches<action_type, CheckAssertion>::value
|
||||
, detail::predicate_matcher<action_copy_type>
|
||||
, detail::action_matcher<action_copy_type>
|
||||
>::type
|
||||
matcher_type;
|
||||
|
||||
typedef
|
||||
typename proto::shift_right<
|
||||
marked_expr_type
|
||||
, typename proto::terminal<matcher_type>::type
|
||||
>::type
|
||||
no_attr_type;
|
||||
|
||||
typedef
|
||||
typename InsertAttrs::impl<no_attr_type, State, Data>::result_type
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param state
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
int dummy = 0;
|
||||
marked_expr_type marked_expr =
|
||||
InsertMark::impl<expr_type, State, Data>()(proto::left(expr), state, data);
|
||||
|
||||
no_attr_type that = {
|
||||
marked_expr
|
||||
, {
|
||||
matcher_type(
|
||||
DeepCopy::impl<action_type, expr_type, int>()(
|
||||
proto::right(expr)
|
||||
, proto::left(expr)
|
||||
, dummy
|
||||
)
|
||||
, proto::value(proto::left(marked_expr)).mark_number_
|
||||
)
|
||||
}
|
||||
};
|
||||
return InsertAttrs::impl<no_attr_type, State, Data>()(that, state, data);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
131
test/external/boost/xpressive/detail/static/transforms/as_alternate.hpp
vendored
Normal file
131
test/external/boost/xpressive/detail/static/transforms/as_alternate.hpp
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_alternate.hpp
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_ALTERNATE_HPP_EAN_04_01_2007
|
||||
#define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_ALTERNATE_HPP_EAN_04_01_2007
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/proto/core.hpp>
|
||||
#include <boost/xpressive/detail/detail_fwd.hpp>
|
||||
#include <boost/xpressive/detail/static/static.hpp>
|
||||
#include <boost/xpressive/detail/core/matcher/alternate_matcher.hpp>
|
||||
#include <boost/xpressive/detail/utility/cons.hpp>
|
||||
|
||||
namespace boost { namespace xpressive
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// alternates_list
|
||||
// a fusion-compatible sequence of alternate expressions, that also keeps
|
||||
// track of the list's width and purity.
|
||||
template<typename Head, typename Tail>
|
||||
struct alternates_list
|
||||
: fusion::cons<Head, Tail>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(std::size_t, width = Head::width == Tail::width ? Head::width : detail::unknown_width::value);
|
||||
BOOST_STATIC_CONSTANT(bool, pure = Head::pure && Tail::pure);
|
||||
|
||||
alternates_list(Head const &head, Tail const &tail)
|
||||
: fusion::cons<Head, Tail>(head, tail)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Head>
|
||||
struct alternates_list<Head, fusion::nil>
|
||||
: fusion::cons<Head, fusion::nil>
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(std::size_t, width = Head::width);
|
||||
BOOST_STATIC_CONSTANT(bool, pure = Head::pure);
|
||||
|
||||
alternates_list(Head const &head, fusion::nil const &tail)
|
||||
: fusion::cons<Head, fusion::nil>(head, tail)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace grammar_detail
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// in_alternate_list
|
||||
template<typename Grammar, typename Callable = proto::callable>
|
||||
struct in_alternate_list : proto::transform<in_alternate_list<Grammar, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef
|
||||
detail::alternates_list<
|
||||
typename Grammar::template impl<
|
||||
Expr
|
||||
, detail::alternate_end_xpression
|
||||
, Data
|
||||
>::result_type
|
||||
, State
|
||||
>
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param state
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
return result_type(
|
||||
typename Grammar::template impl<Expr, detail::alternate_end_xpression, Data>()(
|
||||
expr
|
||||
, detail::alternate_end_xpression()
|
||||
, data
|
||||
)
|
||||
, state
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_alternate_matcher
|
||||
template<typename Grammar, typename Callable = proto::callable>
|
||||
struct as_alternate_matcher : proto::transform<as_alternate_matcher<Grammar, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename impl::data data_type;
|
||||
typedef
|
||||
detail::alternate_matcher<
|
||||
typename Grammar::template impl<Expr, State, Data>::result_type
|
||||
, typename data_type::traits_type
|
||||
>
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param state
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
return result_type(
|
||||
typename Grammar::template impl<Expr, State, Data>()(expr, state, data)
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
215
test/external/boost/xpressive/detail/static/transforms/as_independent.hpp
vendored
Normal file
215
test/external/boost/xpressive/detail/static/transforms/as_independent.hpp
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_independent.hpp
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_INDEPENDENT_HPP_EAN_04_05_2007
|
||||
#define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_INDEPENDENT_HPP_EAN_04_05_2007
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/sizeof.hpp>
|
||||
#include <boost/xpressive/detail/detail_fwd.hpp>
|
||||
#include <boost/xpressive/detail/static/static.hpp>
|
||||
#include <boost/proto/core.hpp>
|
||||
#include <boost/proto/transform/arg.hpp>
|
||||
#include <boost/proto/transform/when.hpp>
|
||||
#include <boost/proto/transform/fold.hpp>
|
||||
#include <boost/proto/transform/fold_tree.hpp>
|
||||
|
||||
namespace boost { namespace xpressive { namespace detail
|
||||
{
|
||||
struct keeper_tag
|
||||
{};
|
||||
|
||||
struct lookahead_tag
|
||||
{};
|
||||
|
||||
struct lookbehind_tag
|
||||
{};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace xpressive { namespace grammar_detail
|
||||
{
|
||||
// A grammar that only accepts static regexes that
|
||||
// don't have semantic actions.
|
||||
struct NotHasAction
|
||||
: proto::switch_<struct NotHasActionCases>
|
||||
{};
|
||||
|
||||
struct NotHasActionCases
|
||||
{
|
||||
template<typename Tag, int Dummy = 0>
|
||||
struct case_
|
||||
: proto::nary_expr<Tag, proto::vararg<NotHasAction> >
|
||||
{};
|
||||
|
||||
template<int Dummy>
|
||||
struct case_<proto::tag::terminal, Dummy>
|
||||
: not_< or_<
|
||||
proto::terminal<detail::tracking_ptr<detail::regex_impl<_> > >,
|
||||
proto::terminal<reference_wrapper<_> >
|
||||
> >
|
||||
{};
|
||||
|
||||
template<int Dummy>
|
||||
struct case_<proto::tag::comma, Dummy>
|
||||
: proto::_ // because (set='a','b') can't contain an action
|
||||
{};
|
||||
|
||||
template<int Dummy>
|
||||
struct case_<proto::tag::complement, Dummy>
|
||||
: proto::_ // because in ~X, X can't contain an unscoped action
|
||||
{};
|
||||
|
||||
template<int Dummy>
|
||||
struct case_<detail::lookahead_tag, Dummy>
|
||||
: proto::_ // because actions in lookaheads are scoped
|
||||
{};
|
||||
|
||||
template<int Dummy>
|
||||
struct case_<detail::lookbehind_tag, Dummy>
|
||||
: proto::_ // because actions in lookbehinds are scoped
|
||||
{};
|
||||
|
||||
template<int Dummy>
|
||||
struct case_<detail::keeper_tag, Dummy>
|
||||
: proto::_ // because actions in keepers are scoped
|
||||
{};
|
||||
|
||||
template<int Dummy>
|
||||
struct case_<proto::tag::subscript, Dummy>
|
||||
: proto::subscript<detail::set_initializer_type, _>
|
||||
{}; // only accept set[...], not actions!
|
||||
};
|
||||
|
||||
struct IndependentEndXpression
|
||||
: or_<
|
||||
when<NotHasAction, detail::true_xpression()>
|
||||
, otherwise<detail::independent_end_xpression()>
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Grammar, typename Callable = proto::callable>
|
||||
struct as_lookahead : proto::transform<as_lookahead<Grammar, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename proto::result_of::child<Expr>::type arg_type;
|
||||
|
||||
typedef
|
||||
typename IndependentEndXpression::impl<arg_type, int, int>::result_type
|
||||
end_xpr_type;
|
||||
|
||||
typedef
|
||||
typename Grammar::template impl<arg_type, end_xpr_type, Data>::result_type
|
||||
xpr_type;
|
||||
|
||||
typedef
|
||||
detail::lookahead_matcher<xpr_type>
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
int i = 0;
|
||||
return result_type(
|
||||
typename Grammar::template impl<arg_type, end_xpr_type, Data>()(
|
||||
proto::child(expr)
|
||||
, IndependentEndXpression::impl<arg_type, int, int>()(proto::child(expr), i, i)
|
||||
, data
|
||||
)
|
||||
, false
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Grammar, typename Callable = proto::callable>
|
||||
struct as_lookbehind : proto::transform<as_lookbehind<Grammar, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename proto::result_of::child<Expr>::type arg_type;
|
||||
|
||||
typedef
|
||||
typename IndependentEndXpression::impl<arg_type, int, int>::result_type
|
||||
end_xpr_type;
|
||||
|
||||
typedef
|
||||
typename Grammar::template impl<arg_type, end_xpr_type, Data>::result_type
|
||||
xpr_type;
|
||||
|
||||
typedef
|
||||
detail::lookbehind_matcher<xpr_type>
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
int i = 0;
|
||||
xpr_type expr2 = typename Grammar::template impl<arg_type, end_xpr_type, Data>()(
|
||||
proto::child(expr)
|
||||
, IndependentEndXpression::impl<arg_type, int, int>()(proto::child(expr), i, i)
|
||||
, data
|
||||
);
|
||||
std::size_t width = expr2.get_width().value();
|
||||
return result_type(expr2, width, false);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Grammar, typename Callable = proto::callable>
|
||||
struct as_keeper : proto::transform<as_keeper<Grammar, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename proto::result_of::child<Expr>::type arg_type;
|
||||
|
||||
typedef
|
||||
typename IndependentEndXpression::impl<arg_type, int, int>::result_type
|
||||
end_xpr_type;
|
||||
|
||||
typedef
|
||||
typename Grammar::template impl<arg_type, end_xpr_type, Data>::result_type
|
||||
xpr_type;
|
||||
|
||||
typedef
|
||||
detail::keeper_matcher<xpr_type>
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
int i = 0;
|
||||
return result_type(
|
||||
typename Grammar::template impl<arg_type, end_xpr_type, Data>()(
|
||||
proto::child(expr)
|
||||
, IndependentEndXpression::impl<arg_type, int, int>()(proto::child(expr), i, i)
|
||||
, data
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
94
test/external/boost/xpressive/detail/static/transforms/as_inverse.hpp
vendored
Normal file
94
test/external/boost/xpressive/detail/static/transforms/as_inverse.hpp
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_inverse.hpp
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_INVERSE_HPP_EAN_04_05_2007
|
||||
#define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_INVERSE_HPP_EAN_04_05_2007
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/sizeof.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/xpressive/detail/detail_fwd.hpp>
|
||||
#include <boost/xpressive/detail/static/static.hpp>
|
||||
#include <boost/proto/core.hpp>
|
||||
|
||||
#define UNCV(x) typename remove_const<x>::type
|
||||
#define UNREF(x) typename remove_reference<x>::type
|
||||
#define UNCVREF(x) UNCV(UNREF(x))
|
||||
|
||||
namespace boost { namespace xpressive { namespace grammar_detail
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
struct inverter
|
||||
{
|
||||
typedef T type;
|
||||
static T call(T t)
|
||||
{
|
||||
t.inverse();
|
||||
return t;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Traits, typename ICase, typename Not>
|
||||
struct inverter<detail::literal_matcher<Traits, ICase, Not> >
|
||||
{
|
||||
typedef detail::literal_matcher<Traits, ICase, typename mpl::not_<Not>::type> type;
|
||||
static type call(detail::literal_matcher<Traits, ICase, Not> t)
|
||||
{
|
||||
return type(t.ch_);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Traits>
|
||||
struct inverter<detail::logical_newline_matcher<Traits> >
|
||||
{
|
||||
// ~_ln matches any one character that is not in the "newline" character class
|
||||
typedef detail::posix_charset_matcher<Traits> type;
|
||||
static type call(detail::logical_newline_matcher<Traits> t)
|
||||
{
|
||||
return type(t.newline(), true);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Traits>
|
||||
struct inverter<detail::assert_word_matcher<detail::word_boundary<mpl::true_>, Traits> >
|
||||
{
|
||||
typedef detail::assert_word_matcher<detail::word_boundary<mpl::false_>, Traits> type;
|
||||
static type call(detail::assert_word_matcher<detail::word_boundary<mpl::true_>, Traits> t)
|
||||
{
|
||||
return type(t.word());
|
||||
}
|
||||
};
|
||||
|
||||
struct as_inverse : proto::callable
|
||||
{
|
||||
template<typename Sig>
|
||||
struct result;
|
||||
|
||||
template<typename This, typename Matcher>
|
||||
struct result<This(Matcher)>
|
||||
: inverter<UNCVREF(Matcher)>
|
||||
{};
|
||||
|
||||
template<typename Matcher>
|
||||
typename inverter<Matcher>::type operator ()(Matcher const &matcher) const
|
||||
{
|
||||
return inverter<Matcher>::call(matcher);
|
||||
}
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#undef UNCV
|
||||
#undef UNREF
|
||||
#undef UNCVREF
|
||||
|
||||
#endif
|
||||
58
test/external/boost/xpressive/detail/static/transforms/as_marker.hpp
vendored
Normal file
58
test/external/boost/xpressive/detail/static/transforms/as_marker.hpp
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_marker.hpp
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_MARKER_HPP_EAN_04_01_2007
|
||||
#define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_MARKER_HPP_EAN_04_01_2007
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/xpressive/detail/detail_fwd.hpp>
|
||||
#include <boost/xpressive/detail/static/static.hpp>
|
||||
#include <boost/proto/core.hpp>
|
||||
|
||||
namespace boost { namespace xpressive { namespace grammar_detail
|
||||
{
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_marker
|
||||
// Insert mark tags before and after the expression
|
||||
struct as_marker : proto::transform<as_marker>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef
|
||||
typename shift_right<
|
||||
terminal<detail::mark_begin_matcher>::type
|
||||
, typename shift_right<
|
||||
typename proto::result_of::right<typename impl::expr>::type
|
||||
, terminal<detail::mark_end_matcher>::type
|
||||
>::type
|
||||
>::type
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param
|
||||
) const
|
||||
{
|
||||
int mark_nbr = detail::get_mark_number(proto::left(expr));
|
||||
detail::mark_begin_matcher begin(mark_nbr);
|
||||
detail::mark_end_matcher end(mark_nbr);
|
||||
|
||||
result_type that = {{begin}, {proto::right(expr), {end}}};
|
||||
return that;
|
||||
}
|
||||
};
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
48
test/external/boost/xpressive/detail/static/transforms/as_matcher.hpp
vendored
Normal file
48
test/external/boost/xpressive/detail/static/transforms/as_matcher.hpp
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_matcher.hpp
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_MATCHER_HPP_EAN_04_01_2007
|
||||
#define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_MATCHER_HPP_EAN_04_01_2007
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/xpressive/detail/detail_fwd.hpp>
|
||||
#include <boost/xpressive/detail/static/static.hpp>
|
||||
|
||||
namespace boost { namespace xpressive { namespace grammar_detail
|
||||
{
|
||||
struct as_matcher : proto::transform<as_matcher>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename impl::data data_type;
|
||||
|
||||
typedef
|
||||
typename data_type::template apply<
|
||||
typename proto::result_of::value<typename impl::expr>::type
|
||||
>::type
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
return data.call(proto::value(expr));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
85
test/external/boost/xpressive/detail/static/transforms/as_modifier.hpp
vendored
Normal file
85
test/external/boost/xpressive/detail/static/transforms/as_modifier.hpp
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_modifier.hpp
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_MODIFIER_HPP_EAN_04_05_2007
|
||||
#define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_MODIFIER_HPP_EAN_04_05_2007
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/sizeof.hpp>
|
||||
#include <boost/xpressive/detail/detail_fwd.hpp>
|
||||
#include <boost/xpressive/detail/static/static.hpp>
|
||||
#include <boost/proto/core.hpp>
|
||||
|
||||
#define UNCV(x) typename remove_const<x>::type
|
||||
#define UNREF(x) typename remove_reference<x>::type
|
||||
#define UNCVREF(x) UNCV(UNREF(x))
|
||||
|
||||
namespace boost { namespace xpressive { namespace detail
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// regex operator tags
|
||||
struct modifier_tag
|
||||
{};
|
||||
|
||||
}}}
|
||||
|
||||
namespace boost { namespace xpressive { namespace grammar_detail
|
||||
{
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_modifier
|
||||
template<typename Grammar, typename Callable = proto::callable>
|
||||
struct as_modifier : proto::transform<as_modifier<Grammar, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef
|
||||
typename proto::result_of::value<
|
||||
typename proto::result_of::left<typename impl::expr>::type
|
||||
>::type
|
||||
modifier_type;
|
||||
|
||||
typedef
|
||||
typename modifier_type::template apply<typename impl::data>::type
|
||||
visitor_type;
|
||||
|
||||
typedef
|
||||
typename proto::result_of::right<Expr>::type
|
||||
expr_type;
|
||||
|
||||
typedef
|
||||
typename Grammar::template impl<expr_type, State, visitor_type &>::result_type
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param state
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
visitor_type new_visitor(proto::value(proto::left(expr)).call(data));
|
||||
return typename Grammar::template impl<expr_type, State, visitor_type &>()(
|
||||
proto::right(expr)
|
||||
, state
|
||||
, new_visitor
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#undef UNCV
|
||||
#undef UNREF
|
||||
#undef UNCVREF
|
||||
|
||||
#endif
|
||||
378
test/external/boost/xpressive/detail/static/transforms/as_quantifier.hpp
vendored
Normal file
378
test/external/boost/xpressive/detail/static/transforms/as_quantifier.hpp
vendored
Normal file
@@ -0,0 +1,378 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_quantifier.hpp
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_QUANTIFIER_HPP_EAN_04_01_2007
|
||||
#define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_QUANTIFIER_HPP_EAN_04_01_2007
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/xpressive/detail/detail_fwd.hpp>
|
||||
#include <boost/xpressive/detail/static/static.hpp>
|
||||
#include <boost/proto/core.hpp>
|
||||
|
||||
namespace boost { namespace xpressive { namespace detail
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// generic_quant_tag
|
||||
template<uint_t Min, uint_t Max>
|
||||
struct generic_quant_tag
|
||||
{
|
||||
typedef mpl::integral_c<uint_t, Min> min_type;
|
||||
typedef mpl::integral_c<uint_t, Max> max_type;
|
||||
};
|
||||
}}}
|
||||
|
||||
namespace boost { namespace xpressive { namespace grammar_detail
|
||||
{
|
||||
using detail::uint_t;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// min_type / max_type
|
||||
template<typename Tag>
|
||||
struct min_type : Tag::min_type {};
|
||||
|
||||
template<>
|
||||
struct min_type<proto::tag::unary_plus> : mpl::integral_c<uint_t, 1> {};
|
||||
|
||||
template<>
|
||||
struct min_type<proto::tag::dereference> : mpl::integral_c<uint_t, 0> {};
|
||||
|
||||
template<>
|
||||
struct min_type<proto::tag::logical_not> : mpl::integral_c<uint_t, 0> {};
|
||||
|
||||
template<typename Tag>
|
||||
struct max_type : Tag::max_type {};
|
||||
|
||||
template<>
|
||||
struct max_type<proto::tag::unary_plus> : mpl::integral_c<uint_t, UINT_MAX-1> {};
|
||||
|
||||
template<>
|
||||
struct max_type<proto::tag::dereference> : mpl::integral_c<uint_t, UINT_MAX-1> {};
|
||||
|
||||
template<>
|
||||
struct max_type<proto::tag::logical_not> : mpl::integral_c<uint_t, 1> {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_simple_quantifier
|
||||
template<typename Grammar, typename Greedy, typename Callable = proto::callable>
|
||||
struct as_simple_quantifier : proto::transform<as_simple_quantifier<Grammar, Greedy, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef
|
||||
typename proto::result_of::child<Expr>::type
|
||||
arg_type;
|
||||
|
||||
typedef
|
||||
typename Grammar::template impl<arg_type, detail::true_xpression, Data>::result_type
|
||||
xpr_type;
|
||||
|
||||
typedef
|
||||
detail::simple_repeat_matcher<xpr_type, Greedy>
|
||||
matcher_type;
|
||||
|
||||
typedef
|
||||
typename proto::terminal<matcher_type>::type
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
xpr_type xpr = typename Grammar::template impl<arg_type, detail::true_xpression, Data>()(
|
||||
proto::child(expr)
|
||||
, detail::true_xpression()
|
||||
, data
|
||||
);
|
||||
|
||||
typedef typename impl::expr expr_type;
|
||||
matcher_type matcher(
|
||||
xpr
|
||||
, (uint_t)min_type<typename expr_type::proto_tag>::value
|
||||
, (uint_t)max_type<typename expr_type::proto_tag>::value
|
||||
, xpr.get_width().value()
|
||||
);
|
||||
|
||||
return result_type::make(matcher);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// add_hidden_mark
|
||||
struct add_hidden_mark : proto::transform<add_hidden_mark>
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename impl::expr expr_type;
|
||||
typedef
|
||||
typename shift_right<
|
||||
terminal<detail::mark_begin_matcher>::type
|
||||
, typename shift_right<
|
||||
Expr
|
||||
, terminal<detail::mark_end_matcher>::type
|
||||
>::type
|
||||
>::type
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
// we're inserting a hidden mark ... so grab the next hidden mark number.
|
||||
int mark_nbr = data.get_hidden_mark();
|
||||
detail::mark_begin_matcher begin(mark_nbr);
|
||||
detail::mark_end_matcher end(mark_nbr);
|
||||
|
||||
result_type that = {{begin}, {expr, {end}}};
|
||||
return that;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// InsertMark
|
||||
struct InsertMark
|
||||
: or_<
|
||||
when<proto::assign<detail::basic_mark_tag, _>, _>
|
||||
, otherwise<add_hidden_mark>
|
||||
>
|
||||
{};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_default_quantifier_impl
|
||||
template<typename Greedy, uint_t Min, uint_t Max>
|
||||
struct as_default_quantifier_impl : proto::transform<as_default_quantifier_impl<Greedy, Min, Max> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef
|
||||
typename proto::result_of::child<Expr>::type
|
||||
xpr_type;
|
||||
|
||||
typedef
|
||||
typename InsertMark::impl<xpr_type, State, Data>::result_type
|
||||
marked_sub_type;
|
||||
|
||||
typedef
|
||||
typename shift_right<
|
||||
terminal<detail::repeat_begin_matcher>::type
|
||||
, typename shift_right<
|
||||
marked_sub_type
|
||||
, typename terminal<detail::repeat_end_matcher<Greedy> >::type
|
||||
>::type
|
||||
>::type
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param state
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
// Ensure this sub-expression is book-ended with mark matchers
|
||||
marked_sub_type marked_sub =
|
||||
InsertMark::impl<xpr_type, State, Data>()(proto::child(expr), state, data);
|
||||
|
||||
// Get the mark_number from the begin_mark_matcher
|
||||
int mark_number = proto::value(proto::left(marked_sub)).mark_number_;
|
||||
BOOST_ASSERT(0 != mark_number);
|
||||
|
||||
typedef typename impl::expr expr_type;
|
||||
uint_t min_ = (uint_t)min_type<typename expr_type::proto_tag>();
|
||||
uint_t max_ = (uint_t)max_type<typename expr_type::proto_tag>();
|
||||
|
||||
detail::repeat_begin_matcher begin(mark_number);
|
||||
detail::repeat_end_matcher<Greedy> end(mark_number, min_, max_);
|
||||
|
||||
result_type that = {{begin}, {marked_sub, {end}}};
|
||||
return that;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// optional_tag
|
||||
template<typename Greedy>
|
||||
struct optional_tag
|
||||
{};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_default_optional
|
||||
template<typename Grammar, typename Greedy, typename Callable = proto::callable>
|
||||
struct as_default_optional : proto::transform<as_default_optional<Grammar, Greedy, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef
|
||||
detail::alternate_end_xpression
|
||||
end_xpr;
|
||||
|
||||
typedef
|
||||
detail::optional_matcher<
|
||||
typename Grammar::template impl<Expr, end_xpr, Data>::result_type
|
||||
, Greedy
|
||||
>
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
return result_type(
|
||||
typename Grammar::template impl<Expr, end_xpr, Data>()(expr, end_xpr(), data)
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_mark_optional
|
||||
template<typename Grammar, typename Greedy, typename Callable = proto::callable>
|
||||
struct as_mark_optional : proto::transform<as_mark_optional<Grammar, Greedy, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef
|
||||
detail::alternate_end_xpression
|
||||
end_xpr;
|
||||
|
||||
typedef
|
||||
detail::optional_mark_matcher<
|
||||
typename Grammar::template impl<Expr, end_xpr, Data>::result_type
|
||||
, Greedy
|
||||
>
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
int mark_number = proto::value(proto::left(expr)).mark_number_;
|
||||
|
||||
return result_type(
|
||||
typename Grammar::template impl<Expr, end_xpr, Data>()(expr, end_xpr(), data)
|
||||
, mark_number
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// IsMarkerOrRepeater
|
||||
struct IsMarkerOrRepeater
|
||||
: or_<
|
||||
shift_right<terminal<detail::repeat_begin_matcher>, _>
|
||||
, assign<terminal<detail::mark_placeholder>, _>
|
||||
>
|
||||
{};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_optional
|
||||
template<typename Grammar, typename Greedy>
|
||||
struct as_optional
|
||||
: or_<
|
||||
when<IsMarkerOrRepeater, as_mark_optional<Grammar, Greedy> >
|
||||
, otherwise<as_default_optional<Grammar, Greedy> >
|
||||
>
|
||||
{};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// make_optional_
|
||||
template<typename Greedy, typename Callable = proto::callable>
|
||||
struct make_optional_ : proto::transform<make_optional_<Greedy, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename impl::expr expr_type;
|
||||
typedef
|
||||
typename unary_expr<
|
||||
optional_tag<Greedy>
|
||||
, Expr
|
||||
>::type
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param
|
||||
) const
|
||||
{
|
||||
result_type that = {expr};
|
||||
return that;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_default_quantifier_impl
|
||||
template<typename Greedy, uint_t Max>
|
||||
struct as_default_quantifier_impl<Greedy, 0, Max>
|
||||
: call<make_optional_<Greedy>(as_default_quantifier_impl<Greedy, 1, Max>)>
|
||||
{};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_default_quantifier_impl
|
||||
template<typename Greedy>
|
||||
struct as_default_quantifier_impl<Greedy, 0, 1>
|
||||
: call<make_optional_<Greedy>(_child)>
|
||||
{};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_default_quantifier
|
||||
template<typename Greedy, typename Callable = proto::callable>
|
||||
struct as_default_quantifier : proto::transform<as_default_quantifier<Greedy, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename impl::expr expr_type;
|
||||
typedef
|
||||
as_default_quantifier_impl<
|
||||
Greedy
|
||||
, min_type<typename expr_type::proto_tag>::value
|
||||
, max_type<typename expr_type::proto_tag>::value
|
||||
>
|
||||
other;
|
||||
|
||||
typedef
|
||||
typename other::template impl<Expr, State, Data>::result_type
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param state
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
return typename other::template impl<Expr, State, Data>()(expr, state, data);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
52
test/external/boost/xpressive/detail/static/transforms/as_sequence.hpp
vendored
Normal file
52
test/external/boost/xpressive/detail/static/transforms/as_sequence.hpp
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_sequence.hpp
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_SEQUENCE_HPP_EAN_04_01_2007
|
||||
#define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_SEQUENCE_HPP_EAN_04_01_2007
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/xpressive/detail/detail_fwd.hpp>
|
||||
#include <boost/xpressive/detail/static/static.hpp>
|
||||
|
||||
namespace boost { namespace xpressive { namespace grammar_detail
|
||||
{
|
||||
template<typename Grammar, typename Callable = proto::callable>
|
||||
struct in_sequence : proto::transform<in_sequence<Grammar, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef
|
||||
detail::static_xpression<
|
||||
typename Grammar::template impl<Expr, State, Data>::result_type
|
||||
, State
|
||||
>
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param state
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
return result_type(
|
||||
typename Grammar::template impl<Expr, State, Data>()(expr, state, data)
|
||||
, state
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
224
test/external/boost/xpressive/detail/static/transforms/as_set.hpp
vendored
Normal file
224
test/external/boost/xpressive/detail/static/transforms/as_set.hpp
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_set.hpp
|
||||
//
|
||||
// Copyright 2008 Eric Niebler. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_SET_HPP_EAN_04_05_2007
|
||||
#define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_SET_HPP_EAN_04_05_2007
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/proto/core.hpp>
|
||||
#include <boost/xpressive/detail/detail_fwd.hpp>
|
||||
#include <boost/xpressive/detail/static/static.hpp>
|
||||
#include <boost/xpressive/detail/utility/chset/chset.hpp>
|
||||
#include <boost/xpressive/detail/utility/traits_utils.hpp>
|
||||
|
||||
namespace boost { namespace xpressive { namespace grammar_detail
|
||||
{
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CharLiteral
|
||||
template<typename Char>
|
||||
struct CharLiteral
|
||||
: or_<
|
||||
terminal<char>
|
||||
, terminal<Char>
|
||||
>
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct CharLiteral<char>
|
||||
: terminal<char>
|
||||
{};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ListSet
|
||||
// matches expressions like (set= 'a','b','c')
|
||||
// calculates the size of the set
|
||||
template<typename Char>
|
||||
struct ListSet
|
||||
: or_<
|
||||
when<
|
||||
comma<ListSet<Char>, CharLiteral<Char> >
|
||||
, make<mpl::next<call<ListSet<Char>(_left)> > > // TODO make a custom transform for this...
|
||||
>
|
||||
, when<
|
||||
assign<detail::set_initializer_type, CharLiteral<Char> >
|
||||
, make<mpl::int_<1> >
|
||||
>
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename Char, typename Traits>
|
||||
void fill_list_set(Char *&, detail::set_initializer_type, Traits const &)
|
||||
{}
|
||||
|
||||
template<typename Char, typename Expr, typename Traits>
|
||||
void fill_list_set(Char *&buffer, Expr const &expr, Traits const &traits)
|
||||
{
|
||||
fill_list_set(buffer, proto::left(expr), traits);
|
||||
*buffer++ = traits.translate(detail::char_cast<Char>(proto::value(proto::right(expr)), traits));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// as_list_set_matcher
|
||||
template<typename Char, typename Callable = proto::callable>
|
||||
struct as_list_set_matcher : proto::transform<as_list_set_matcher<Char, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename impl::data data_type;
|
||||
typedef
|
||||
detail::set_matcher<
|
||||
typename data_type::traits_type
|
||||
, typename ListSet<Char>::template impl<Expr, State, Data>::result_type
|
||||
>
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
result_type set;
|
||||
typedef typename impl::data data_type;
|
||||
typename data_type::char_type *buffer = set.set_;
|
||||
fill_list_set(buffer, expr, data.traits());
|
||||
return set;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// merge_charset
|
||||
//
|
||||
template<typename Grammar, typename CharSet, typename Data>
|
||||
struct merge_charset
|
||||
{
|
||||
typedef typename Data::traits_type traits_type;
|
||||
typedef typename CharSet::char_type char_type;
|
||||
typedef typename CharSet::icase_type icase_type;
|
||||
|
||||
merge_charset(CharSet &charset, Data &data)
|
||||
: charset_(charset)
|
||||
, visitor_(data)
|
||||
{}
|
||||
|
||||
template<typename Expr>
|
||||
void operator ()(Expr const &expr) const
|
||||
{
|
||||
this->call_(expr, typename Expr::proto_tag());
|
||||
}
|
||||
|
||||
private:
|
||||
merge_charset &operator =(merge_charset const &);
|
||||
|
||||
template<typename Expr, typename Tag>
|
||||
void call_(Expr const &expr, Tag) const
|
||||
{
|
||||
this->set_(
|
||||
typename Grammar::template impl<Expr const &, detail::end_xpression, Data &>()(
|
||||
expr
|
||||
, detail::end_xpression()
|
||||
, this->visitor_
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
template<typename Expr>
|
||||
void call_(Expr const &expr, tag::bitwise_or) const
|
||||
{
|
||||
(*this)(proto::left(expr));
|
||||
(*this)(proto::right(expr));
|
||||
}
|
||||
|
||||
template<typename Not>
|
||||
void set_(detail::literal_matcher<traits_type, icase_type, Not> const &ch) const
|
||||
{
|
||||
// BUGBUG fixme!
|
||||
BOOST_MPL_ASSERT_NOT((Not));
|
||||
set_char(this->charset_.charset_, ch.ch_, this->visitor_.traits(), icase_type());
|
||||
}
|
||||
|
||||
void set_(detail::range_matcher<traits_type, icase_type> const &rg) const
|
||||
{
|
||||
// BUGBUG fixme!
|
||||
BOOST_ASSERT(!rg.not_);
|
||||
set_range(this->charset_.charset_, rg.ch_min_, rg.ch_max_, this->visitor_.traits(), icase_type());
|
||||
}
|
||||
|
||||
template<typename Size>
|
||||
void set_(detail::set_matcher<traits_type, Size> const &set_) const
|
||||
{
|
||||
// BUGBUG fixme!
|
||||
BOOST_ASSERT(!set_.not_);
|
||||
for(int i = 0; i < Size::value; ++i)
|
||||
{
|
||||
set_char(this->charset_.charset_, set_.set_[i], this->visitor_.traits(), icase_type());
|
||||
}
|
||||
}
|
||||
|
||||
void set_(detail::posix_charset_matcher<traits_type> const &posix) const
|
||||
{
|
||||
set_class(this->charset_.charset_, posix.mask_, posix.not_, this->visitor_.traits());
|
||||
}
|
||||
|
||||
CharSet &charset_;
|
||||
Data &visitor_;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
template<typename Grammar, typename Callable = proto::callable>
|
||||
struct as_set_matcher : proto::transform<as_set_matcher<Grammar, Callable> >
|
||||
{
|
||||
template<typename Expr, typename State, typename Data>
|
||||
struct impl : proto::transform_impl<Expr, State, Data>
|
||||
{
|
||||
typedef typename impl::data data_type;
|
||||
typedef typename data_type::char_type char_type;
|
||||
|
||||
// if sizeof(char_type)==1, merge everything into a basic_chset
|
||||
// BUGBUG this is not optimal.
|
||||
typedef
|
||||
typename mpl::if_c<
|
||||
detail::is_narrow_char<char_type>::value
|
||||
, detail::basic_chset<char_type>
|
||||
, detail::compound_charset<typename data_type::traits_type>
|
||||
>::type
|
||||
charset_type;
|
||||
|
||||
typedef
|
||||
detail::charset_matcher<
|
||||
typename data_type::traits_type
|
||||
, typename data_type::icase_type
|
||||
, charset_type
|
||||
>
|
||||
result_type;
|
||||
|
||||
result_type operator ()(
|
||||
typename impl::expr_param expr
|
||||
, typename impl::state_param
|
||||
, typename impl::data_param data
|
||||
) const
|
||||
{
|
||||
result_type matcher;
|
||||
merge_charset<Grammar, result_type, typename impl::data> merge(matcher, data);
|
||||
merge(expr); // Walks the tree and fills in the charset
|
||||
return matcher;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user