updated boost on windows
This commit is contained in:
@@ -7,11 +7,11 @@
|
||||
#if !defined(BOOST_SPIRIT_X3_DETAIL_RULE_JAN_08_2012_0326PM)
|
||||
#define BOOST_SPIRIT_X3_DETAIL_RULE_JAN_08_2012_0326PM
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
#include <boost/spirit/home/x3/auxiliary/guard.hpp>
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
#include <boost/spirit/home/x3/core/skip_over.hpp>
|
||||
#include <boost/spirit/home/x3/directive/expect.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/make_attribute.hpp>
|
||||
#include <boost/spirit/home/x3/support/utility/sfinae.hpp>
|
||||
#include <boost/spirit/home/x3/nonterminal/detail/transform_attribute.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
@@ -138,7 +138,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
|
||||
template <typename ID, typename RHS, typename Context>
|
||||
Context const&
|
||||
make_rule_context(RHS const& rhs, Context const& context
|
||||
make_rule_context(RHS const& /* rhs */, Context const& context
|
||||
, mpl::false_ /* is_default_parse_rule */)
|
||||
{
|
||||
return context;
|
||||
@@ -156,8 +156,8 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
{
|
||||
template <typename Iterator, typename Context, typename ActualAttribute>
|
||||
static bool call_on_success(
|
||||
Iterator& first, Iterator const& last
|
||||
, Context const& context, ActualAttribute& attr
|
||||
Iterator& /* first */, Iterator const& /* last */
|
||||
, Context const& /* context */, ActualAttribute& /* attr */
|
||||
, mpl::false_ /* No on_success handler */ )
|
||||
{
|
||||
return true;
|
||||
@@ -285,7 +285,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
static bool parse_rhs(
|
||||
RHS const& rhs
|
||||
, Iterator& first, Iterator const& last
|
||||
, Context const& context, RContext& rcontext, ActualAttribute& attr
|
||||
, Context const& context, RContext& rcontext, ActualAttribute& /* attr */
|
||||
, mpl::true_)
|
||||
{
|
||||
return parse_rhs_main(rhs, first, last, context, rcontext, unused);
|
||||
@@ -300,18 +300,16 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
, Context const& context, ActualAttribute& attr
|
||||
, ExplicitAttrPropagation)
|
||||
{
|
||||
typedef traits::make_attribute<Attribute, ActualAttribute> make_attribute;
|
||||
boost::ignore_unused(rule_name);
|
||||
|
||||
// do down-stream transformation, provides attribute for
|
||||
// rhs parser
|
||||
typedef traits::transform_attribute<
|
||||
typename make_attribute::type, Attribute, parser_id>
|
||||
ActualAttribute, Attribute, parser_id>
|
||||
transform;
|
||||
|
||||
typedef typename make_attribute::value_type value_type;
|
||||
typedef typename transform::type transform_attr;
|
||||
value_type made_attr = make_attribute::call(attr);
|
||||
transform_attr attr_ = transform::pre(made_attr);
|
||||
transform_attr attr_ = transform::pre(attr);
|
||||
|
||||
bool ok_parse
|
||||
//Creates a place to hold the result of parse_rhs
|
||||
@@ -322,12 +320,11 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
// the #if...#endif) to call it's DTOR before any
|
||||
// modifications are made to the attribute, attr_ passed
|
||||
// to parse_rhs (such as might be done in
|
||||
// traits::post_transform when, for example,
|
||||
// transform::post when, for example,
|
||||
// ActualAttribute is a recursive variant).
|
||||
#if defined(BOOST_SPIRIT_X3_DEBUG)
|
||||
typedef typename make_attribute::type dbg_attribute_type;
|
||||
context_debug<Iterator, dbg_attribute_type>
|
||||
dbg(rule_name, first, last, dbg_attribute_type(attr_), ok_parse);
|
||||
context_debug<Iterator, transform_attr>
|
||||
dbg(rule_name, first, last, attr_, ok_parse);
|
||||
#endif
|
||||
ok_parse = parse_rhs(rhs, first, last, context, attr_, attr_
|
||||
, mpl::bool_
|
||||
@@ -341,7 +338,7 @@ namespace boost { namespace spirit { namespace x3 { namespace detail
|
||||
{
|
||||
// do up-stream transformation, this integrates the results
|
||||
// back into the original attribute value, if appropriate
|
||||
traits::post_transform(attr, std::forward<transform_attr>(attr_));
|
||||
transform::post(attr, std::forward<transform_attr>(attr_));
|
||||
}
|
||||
return ok_parse;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <boost/spirit/home/x3/support/traits/transform_attribute.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/move_to.hpp>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -44,15 +45,6 @@ namespace boost { namespace spirit { namespace x3
|
||||
struct transform_attribute
|
||||
: default_transform_attribute<Exposed, Transformed> {};
|
||||
|
||||
// reference types need special handling
|
||||
template <typename Attribute>
|
||||
struct transform_attribute<Attribute&, Attribute>
|
||||
{
|
||||
typedef Attribute& type;
|
||||
static Attribute& pre(Attribute& val) { return val; }
|
||||
static void post(Attribute&, Attribute const&) {}
|
||||
};
|
||||
|
||||
// unused_type needs some special handling as well
|
||||
template <>
|
||||
struct transform_attribute<unused_type, unused_type>
|
||||
@@ -88,23 +80,13 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
|
||||
{
|
||||
template <typename Exposed, typename Transformed>
|
||||
struct transform_attribute<Exposed, Transformed, x3::parser_id>
|
||||
: x3::transform_attribute<Exposed, Transformed> {};
|
||||
|
||||
template <typename Exposed, typename Transformed>
|
||||
struct transform_attribute<Exposed&, Transformed, x3::parser_id>
|
||||
: transform_attribute<Exposed, Transformed, x3::parser_id> {};
|
||||
|
||||
template <typename Attribute>
|
||||
struct transform_attribute<Attribute&, Attribute, x3::parser_id>
|
||||
: x3::transform_attribute<Attribute&, Attribute> {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
template <typename Exposed, typename Transformed>
|
||||
void post_transform(Exposed& dest, Transformed&& attr)
|
||||
: x3::transform_attribute<Exposed, Transformed>
|
||||
{
|
||||
return transform_attribute<Exposed, Transformed, x3::parser_id>
|
||||
::post(dest, std::forward<Transformed>(attr));
|
||||
}
|
||||
static_assert(!std::is_reference<Exposed>::value,
|
||||
"Exposed cannot be a reference type");
|
||||
static_assert(!std::is_reference<Transformed>::value,
|
||||
"Transformed cannot be a reference type");
|
||||
};
|
||||
}}}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <boost/preprocessor/variadic/to_seq.hpp>
|
||||
#include <boost/preprocessor/variadic/elem.hpp>
|
||||
#include <boost/preprocessor/seq/for_each.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
#if !defined(BOOST_SPIRIT_X3_NO_RTTI)
|
||||
#include <typeinfo>
|
||||
@@ -20,15 +21,12 @@
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template <typename ID>
|
||||
struct identity {};
|
||||
|
||||
// default parse_rule implementation
|
||||
template <typename ID, typename Attribute, typename Iterator
|
||||
, typename Context, typename ActualAttribute>
|
||||
inline detail::default_parse_rule_result
|
||||
parse_rule(
|
||||
rule<ID, Attribute> rule_
|
||||
rule<ID, Attribute> /* rule_ */
|
||||
, Iterator& first, Iterator const& last
|
||||
, Context const& context, ActualAttribute& attr)
|
||||
{
|
||||
@@ -78,7 +76,7 @@ namespace boost { namespace spirit { namespace x3
|
||||
typedef ID id;
|
||||
typedef Attribute attribute_type;
|
||||
static bool const has_attribute =
|
||||
!is_same<Attribute, unused_type>::value;
|
||||
!std::is_same<std::remove_const_t<Attribute>, unused_type>::value;
|
||||
static bool const handles_container =
|
||||
traits::is_container<Attribute>::value;
|
||||
static bool const force_attribute = force_attribute_;
|
||||
@@ -113,7 +111,32 @@ namespace boost { namespace spirit { namespace x3
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, unused_type, Attribute_& attr) const
|
||||
{
|
||||
return parse_rule(*this, first, last, context, attr);
|
||||
static_assert(has_attribute,
|
||||
"The rule does not have an attribute. Check your parser.");
|
||||
|
||||
using transform = traits::transform_attribute<
|
||||
Attribute_, attribute_type, parser_id>;
|
||||
|
||||
using transform_attr = typename transform::type;
|
||||
transform_attr attr_ = transform::pre(attr);
|
||||
|
||||
if (parse_rule(*this, first, last, context, attr_)) {
|
||||
transform::post(attr, std::forward<transform_attr>(attr_));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename Iterator, typename Context>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, unused_type, unused_type) const
|
||||
{
|
||||
static_assert(!has_attribute,
|
||||
"The rule requires an input attribute. Check your parser.");
|
||||
|
||||
// make sure we pass exactly the rule attribute type
|
||||
attribute_type no_attr;
|
||||
return parse_rule(*this, first, last, context, no_attr);
|
||||
}
|
||||
|
||||
char const* name;
|
||||
@@ -137,44 +160,61 @@ namespace boost { namespace spirit { namespace x3
|
||||
typedef std::string result_type;
|
||||
std::string operator()(T const& r) const
|
||||
{
|
||||
return r.name;
|
||||
BOOST_ASSERT_MSG(r.name, "uninitialized rule"); // static initialization order fiasco
|
||||
return r.name? r.name : "uninitialized";
|
||||
}
|
||||
};
|
||||
|
||||
#define BOOST_SPIRIT_DECLARE_(r, data, rule_type) \
|
||||
template <typename Iterator, typename Context, typename Attribute> \
|
||||
template <typename Iterator, typename Context> \
|
||||
bool parse_rule( \
|
||||
rule_type rule_ \
|
||||
, Iterator& first, Iterator const& last \
|
||||
, Context const& context, Attribute& attr); \
|
||||
, Context const& context, rule_type::attribute_type& attr); \
|
||||
/***/
|
||||
|
||||
#define BOOST_SPIRIT_DECLARE(...) BOOST_PP_SEQ_FOR_EACH( \
|
||||
BOOST_SPIRIT_DECLARE_, _, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) \
|
||||
/***/
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||
#define BOOST_SPIRIT_DEFINE_(r, data, rule_name) \
|
||||
template <typename Iterator, typename Context, typename Attribute> \
|
||||
using BOOST_PP_CAT(rule_name, _synonym) = decltype(rule_name); \
|
||||
template <typename Iterator, typename Context> \
|
||||
inline bool parse_rule( \
|
||||
decltype(rule_name) rule_ \
|
||||
BOOST_PP_CAT(rule_name, _synonym) /* rule_ */ \
|
||||
, Iterator& first, Iterator const& last \
|
||||
, Context const& context, Attribute& attr) \
|
||||
, Context const& context, BOOST_PP_CAT(rule_name, _synonym)::attribute_type& attr) \
|
||||
{ \
|
||||
using boost::spirit::x3::unused; \
|
||||
static auto const def_ = (rule_name = BOOST_PP_CAT(rule_name, _def)); \
|
||||
return def_.parse(first, last, context, unused, attr); \
|
||||
} \
|
||||
/***/
|
||||
#else
|
||||
#define BOOST_SPIRIT_DEFINE_(r, data, rule_name) \
|
||||
template <typename Iterator, typename Context> \
|
||||
inline bool parse_rule( \
|
||||
decltype(rule_name) /* rule_ */ \
|
||||
, Iterator& first, Iterator const& last \
|
||||
, Context const& context, decltype(rule_name)::attribute_type& attr) \
|
||||
{ \
|
||||
using boost::spirit::x3::unused; \
|
||||
static auto const def_ = (rule_name = BOOST_PP_CAT(rule_name, _def)); \
|
||||
return def_.parse(first, last, context, unused, attr); \
|
||||
} \
|
||||
/***/
|
||||
#endif
|
||||
|
||||
#define BOOST_SPIRIT_DEFINE(...) BOOST_PP_SEQ_FOR_EACH( \
|
||||
BOOST_SPIRIT_DEFINE_, _, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) \
|
||||
/***/
|
||||
|
||||
#define BOOST_SPIRIT_INSTANTIATE(rule_type, Iterator, Context) \
|
||||
template bool parse_rule<Iterator, Context, rule_type::attribute_type>( \
|
||||
template bool parse_rule<Iterator, Context>( \
|
||||
rule_type rule_ \
|
||||
, Iterator& first, Iterator const& last \
|
||||
, Context const& context, rule_type::attribute_type& attr); \
|
||||
, Context const& context, rule_type::attribute_type&); \
|
||||
/***/
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <boost/spirit/home/x3/support/traits/print_token.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/print_attribute.hpp>
|
||||
#include <boost/spirit/home/x3/nonterminal/debug_handler_state.hpp>
|
||||
#include <boost/fusion/include/out.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <iostream>
|
||||
|
||||
@@ -102,11 +101,6 @@ namespace boost { namespace spirit { namespace x3
|
||||
<< "</attributes>";
|
||||
out << std::endl;
|
||||
}
|
||||
//~ if (!fusion::empty(context.locals))
|
||||
//~ out
|
||||
//~ << "<locals>"
|
||||
//~ << context.locals
|
||||
//~ << "</locals>";
|
||||
print_indent(--indent);
|
||||
out
|
||||
<< "</" << rule_name << '>'
|
||||
|
||||
Reference in New Issue
Block a user