update boost on linux

This commit is contained in:
Bassem Girgis
2019-08-10 16:06:25 -05:00
parent 76ad52be58
commit 861b918727
5363 changed files with 483306 additions and 116507 deletions

View File

@@ -52,14 +52,12 @@ namespace boost { namespace spirit { namespace qi
, Attribute& attr_) const
{
typedef typename attribute<Context, Iterator>::type attr_type;
typedef traits::make_attribute<attr_type, Attribute> make_attribute;
// create an attribute if one is not supplied
typedef traits::transform_attribute<
typename make_attribute::type, attr_type, domain> transform;
Attribute, attr_type, domain> transform;
typename make_attribute::type made_attr = make_attribute::call(attr_);
typename transform::type attr = transform::pre(made_attr);
typename transform::type attr = transform::pre(attr_);
Iterator save = first;
if (subject.parse(first, last, context, skipper, attr))
@@ -70,7 +68,7 @@ namespace boost { namespace spirit { namespace qi
{
// Do up-stream transformation, this integrates the results
// back into the original attribute value, if appropriate.
traits::post_transform(attr_, attr);
transform::post(attr_, attr);
return true;
}
@@ -109,14 +107,9 @@ namespace boost { namespace spirit { namespace qi
, unused_type) const
{
typedef typename attribute<Context, Iterator>::type attr_type;
typedef traits::make_attribute<attr_type, unused_type> make_attribute;
// synthesize the attribute since one is not supplied
typedef traits::transform_attribute<
typename make_attribute::type, attr_type, domain> transform;
typename make_attribute::type made_attr = make_attribute::call(unused_type());
typename transform::type attr = transform::pre(made_attr);
attr_type attr = attr_type();
Iterator save = first;
if (subject.parse(first, last, context, skipper, attr))

View File

@@ -101,7 +101,7 @@ namespace boost { namespace spirit { namespace qi
// do up-stream transformation, this mainly integrates the results
// back into the original attribute value, if appropriate
traits::post_transform(attr_param, attr_);
transform::post(attr_param, attr_);
return true;
}

View File

@@ -195,11 +195,11 @@ namespace boost { namespace spirit { namespace qi
};
///////////////////////////////////////////////////////////////////////
template <BOOST_SCOPED_ENUM(boost::endian::endianness) bits>
template <BOOST_SCOPED_ENUM(boost::spirit::endian::endianness) bits>
struct what;
template <>
struct what<boost::endian::endianness::native>
struct what<boost::spirit::endian::endianness::native>
{
static std::string is()
{
@@ -208,7 +208,7 @@ namespace boost { namespace spirit { namespace qi
};
template <>
struct what<boost::endian::endianness::little>
struct what<boost::spirit::endian::endianness::little>
{
static char const* is()
{
@@ -217,7 +217,7 @@ namespace boost { namespace spirit { namespace qi
};
template <>
struct what<boost::endian::endianness::big>
struct what<boost::spirit::endian::endianness::big>
{
static char const* is()
{
@@ -227,13 +227,13 @@ namespace boost { namespace spirit { namespace qi
}
///////////////////////////////////////////////////////////////////////////
template <typename T, BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
template <typename T, BOOST_SCOPED_ENUM(boost::spirit::endian::endianness) endian, int bits>
struct any_binary_parser : primitive_parser<any_binary_parser<T, endian, bits> >
{
template <typename Context, typename Iterator>
struct attribute
{
typedef boost::endian::endian<endian, typename T::type,
typedef boost::spirit::endian::endian<endian, typename T::type,
bits> type;
};
@@ -270,7 +270,7 @@ namespace boost { namespace spirit { namespace qi
///////////////////////////////////////////////////////////////////////////
template <typename V, typename T
, BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
, BOOST_SCOPED_ENUM(boost::spirit::endian::endianness) endian, int bits>
struct binary_lit_parser
: primitive_parser<binary_lit_parser<V, T, endian, bits> >
{
@@ -295,7 +295,7 @@ namespace boost { namespace spirit { namespace qi
// definition of C++03) it seems to be safe to assume they are
// (but in C++0x the endian types _are_ PODs).
// This allows us to treat them as a sequence of consecutive bytes.
boost::endian::endian<endian, typename T::type, bits> attr_;
boost::spirit::endian::endian<endian, typename T::type, bits> attr_;
#if defined(BOOST_MSVC)
// warning C4244: 'argument' : conversion from 'const int' to 'foo', possible loss of data
@@ -333,7 +333,7 @@ namespace boost { namespace spirit { namespace qi
///////////////////////////////////////////////////////////////////////////
// Parser generators: make_xxx function (objects)
///////////////////////////////////////////////////////////////////////////
template <typename T, BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
template <typename T, BOOST_SCOPED_ENUM(boost::spirit::endian::endianness) endian, int bits>
struct make_binary_parser
{
typedef any_binary_parser<T, endian, bits> result_type;
@@ -344,7 +344,7 @@ namespace boost { namespace spirit { namespace qi
};
template <typename V, typename T
, BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
, BOOST_SCOPED_ENUM(boost::spirit::endian::endianness) endian, int bits>
struct make_binary_lit_parser
{
typedef binary_lit_parser<V, T, endian, bits> result_type;
@@ -359,13 +359,13 @@ namespace boost { namespace spirit { namespace qi
template <typename Modifiers> \
struct make_primitive<tag::name, Modifiers> \
: make_binary_parser<detail::integer<bits>, \
boost::endian::endianness::endiantype, bits> {}; \
boost::spirit::endian::endianness::endiantype, bits> {}; \
\
template <typename Modifiers, typename A0> \
struct make_primitive< \
terminal_ex<tag::name, fusion::vector1<A0> > , Modifiers> \
: make_binary_lit_parser<A0, detail::integer<bits>, \
boost::endian::endianness::endiantype, bits> {}; \
boost::spirit::endian::endianness::endiantype, bits> {}; \
\
/***/
@@ -388,13 +388,13 @@ namespace boost { namespace spirit { namespace qi
template<typename Modifiers> \
struct make_primitive<tag::name, Modifiers> \
: make_binary_parser<detail::floating_point<bits>, \
boost::endian::endianness::endiantype, bits> {}; \
boost::spirit::endian::endianness::endiantype, bits> {}; \
\
template<typename Modifiers, typename A0> \
struct make_primitive< \
terminal_ex<tag::name, fusion::vector1<A0> >, Modifiers> \
: make_binary_lit_parser<A0, detail::floating_point<bits>, \
boost::endian::endianness::endiantype, \
boost::spirit::endian::endianness::endiantype, \
bits> {}; \
\
/***/

View File

@@ -23,16 +23,14 @@ namespace boost { namespace spirit { namespace qi { namespace detail
template <typename Variant, typename Expected>
struct find_substitute
{
// Get the typr from the variant that can be a substitute for Expected.
// Get the type from the variant that can be a substitute for Expected.
// If none is found, just return Expected
typedef Variant variant_type;
typedef typename variant_type::types types;
typedef typename mpl::end<types>::type end;
typedef typename
mpl::find_if<types, is_same<mpl::_1, Expected> >::type
iter_1;
typedef typename mpl::find<types, Expected>::type iter_1;
typedef typename
mpl::eval_if<

View File

@@ -94,16 +94,6 @@ namespace boost { namespace spirit { namespace qi
}
};
// 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&) {}
static void fail(Attribute&) {}
};
// unused_type needs some special handling as well
template <>
struct transform_attribute<unused_type, unused_type>
@@ -119,16 +109,6 @@ namespace boost { namespace spirit { namespace qi
: transform_attribute<unused_type, unused_type>
{};
template <typename Attribute>
struct transform_attribute<unused_type, Attribute>
: transform_attribute<unused_type, unused_type>
{};
template <typename Attribute>
struct transform_attribute<unused_type const, Attribute>
: transform_attribute<unused_type, unused_type>
{};
template <typename Attribute>
struct transform_attribute<Attribute, unused_type>
: transform_attribute<unused_type, unused_type>
@@ -143,33 +123,11 @@ namespace boost { namespace spirit { namespace qi
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace traits
{
template <typename Exposed, typename Transformed>
struct transform_attribute<Exposed, Transformed, qi::domain>
: qi::transform_attribute<Exposed, Transformed>
{};
template <typename Exposed, typename Transformed>
struct transform_attribute<Exposed&, Transformed, qi::domain>
: transform_attribute<Exposed, Transformed, qi::domain>
{};
template <typename Attribute>
struct transform_attribute<Attribute&, Attribute, qi::domain>
: qi::transform_attribute<Attribute&, Attribute>
{};
///////////////////////////////////////////////////////////////////////////
template <typename Exposed, typename Transformed>
void post_transform(Exposed& dest, Transformed const& attr)
{
return transform_attribute<Exposed, Transformed, qi::domain>::post(dest, attr);
}
///////////////////////////////////////////////////////////////////////////
template <typename Exposed, typename Transformed>
void fail_transform(Exposed& dest, Transformed const&)
{
return transform_attribute<Exposed, Transformed, qi::domain>::fail(dest);
namespace detail {
template <typename Exposed, typename Transformed>
struct transform_attribute_base<Exposed, Transformed, qi::domain>
: qi::transform_attribute<Exposed, Transformed>
{};
}
}}}

View File

@@ -143,20 +143,20 @@ namespace boost { namespace spirit { namespace traits
#ifdef BOOST_HAS_LONG_LONG
template <typename Iterator>
struct assign_to_attribute_from_iterators<long_long_type, Iterator>
struct assign_to_attribute_from_iterators<boost::long_long_type, Iterator>
{
static void
call(Iterator const& first, Iterator const& last, long_long_type& attr)
call(Iterator const& first, Iterator const& last, boost::long_long_type& attr)
{
Iterator first_ = first;
qi::parse(first_, last, long_long_type(), attr);
}
};
template <typename Iterator>
struct assign_to_attribute_from_iterators<ulong_long_type, Iterator>
struct assign_to_attribute_from_iterators<boost::ulong_long_type, Iterator>
{
static void
call(Iterator const& first, Iterator const& last, ulong_long_type& attr)
call(Iterator const& first, Iterator const& last, boost::ulong_long_type& attr)
{
Iterator first_ = first;
qi::parse(first_, last, ulong_long_type(), attr);

View File

@@ -0,0 +1,35 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
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)
=============================================================================*/
#if !defined(SPIRIT_EXPECTATION_FAILURE_JULY_19_2016)
#define SPIRIT_EXPECTATION_FAILURE_JULY_19_2016
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/spirit/home/support/info.hpp>
#include <boost/config.hpp> // for BOOST_SYMBOL_VISIBLE
#include <stdexcept>
namespace boost { namespace spirit { namespace qi {
template <typename Iterator>
struct BOOST_SYMBOL_VISIBLE expectation_failure : std::runtime_error
{
expectation_failure(Iterator first_, Iterator last_, info const& what)
: std::runtime_error("boost::spirit::qi::expectation_failure")
, first(first_), last(last_), what_(what)
{}
~expectation_failure() BOOST_NOEXCEPT_OR_NOTHROW {}
Iterator first;
Iterator last;
info what_;
};
}}}
#endif

View File

@@ -43,22 +43,6 @@ namespace boost { namespace spirit { namespace qi { namespace detail
return false;
}
template <typename Component, typename Attribute>
bool operator()(Component const& component, boost::optional<Attribute>& attr)
{
// return true if the parser succeeds and the slot is not yet taken
Attribute val;
if (!*taken && component.parse(first, last, context, skipper, val))
{
attr = val;
*taken = true;
++taken;
return true;
}
++taken;
return false;
}
template <typename Component>
bool operator()(Component const& component)
{

View File

@@ -22,5 +22,6 @@
#include <boost/spirit/home/qi/directive/raw.hpp>
#include <boost/spirit/home/qi/directive/repeat.hpp>
#include <boost/spirit/home/qi/directive/skip.hpp>
#include <boost/spirit/home/qi/directive/expect.hpp>
#endif

View File

@@ -0,0 +1,113 @@
/*=============================================================================
Copyright (c) 2016 Frank Hein, maxence business consulting gmbh
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)
==============================================================================*/
#if !defined (SPIRIT_EXPECT_JULY_13_2016)
#define SPIRIT_EXPECT_JULY_13_2016
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/spirit/home/qi/meta_compiler.hpp>
#include <boost/spirit/home/support/has_semantic_action.hpp>
#include <boost/spirit/home/qi/detail/attributes.hpp>
#include <boost/spirit/home/qi/detail/expectation_failure.hpp>
#include <boost/spirit/home/support/common_terminals.hpp>
#include <boost/spirit/home/support/handles_container.hpp>
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/support/info.hpp>
namespace boost { namespace spirit {
///////////////////////////////////////////////////////////////////////////
// Enablers
///////////////////////////////////////////////////////////////////////////
template <>
struct use_directive<qi::domain, tag::expect> // enables expect[p]
: mpl::true_ {};
}}
namespace boost { namespace spirit { namespace qi {
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
using spirit::expect;
#endif
using spirit::expect_type;
template <typename Subject>
struct expect_directive : unary_parser<expect_directive<Subject> >
{
typedef result_of::compile<domain, Subject> subject_type;
template <typename Context, typename Iterator>
struct attribute
{
typedef traits::attribute_of<subject_type, Context, Iterator>
type;
};
expect_directive(Subject const& subject_) : subject(subject_) {}
template <typename Iterator, typename Context
, typename Skipper, typename Attribute>
bool parse(Iterator& first, Iterator const& last
, Context& context, Skipper const& skipper
, Attribute& attr_) const
{
typedef expectation_failure<Iterator> exception;
if (!subject.parse(first, last, context, skipper, attr_))
{
boost::throw_exception(
exception(first, last, subject.what(context)));
#if defined(BOOST_NO_EXCEPTIONS)
return false; // for systems not supporting exceptions
#endif
}
return true;
}
template <typename Context>
info what(Context& context) const
{
return info("expect", subject.what(context));
}
Subject subject;
};
///////////////////////////////////////////////////////////////////////////
// Parser generators: make_xxx function (objects)
///////////////////////////////////////////////////////////////////////////
template <typename Subject, typename Modifiers>
struct make_directive<tag::expect, Subject, Modifiers>
{
typedef expect_directive<Subject> result_type;
result_type operator()
(unused_type, Subject const& subject, unused_type) const
{
return result_type(subject);
}
};
}}}
namespace boost { namespace spirit { namespace traits {
///////////////////////////////////////////////////////////////////////////
template <typename Subject>
struct has_semantic_action<qi::expect_directive<Subject> >
: unary_has_semantic_action<Subject> {};
///////////////////////////////////////////////////////////////////////////
template <typename Subject, typename Attribute
, typename Context, typename Iterator>
struct handles_container<
qi::expect_directive<Subject>, Attribute, Context, Iterator
>
: unary_handles_container<Subject, Attribute, Context, Iterator> {};
}}}
#endif

View File

@@ -14,7 +14,7 @@
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/qi/nonterminal/rule.hpp>
#include <boost/spirit/home/qi/nonterminal/debug_handler_state.hpp>
#include <boost/spirit/home/qi/operator/expect.hpp>
#include <boost/spirit/home/qi/detail/expectation_failure.hpp>
#include <boost/function.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/vector.hpp>

View File

@@ -12,10 +12,12 @@
#endif
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/config.hpp>
#include <boost/function.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/fusion/include/vector.hpp>
@@ -275,22 +277,27 @@ namespace boost { namespace spirit { namespace qi
, Context& /*context*/, Skipper const& skipper
, Attribute& attr_param) const
{
BOOST_STATIC_ASSERT_MSG((is_same<skipper_type, unused_type>::value ||
!is_same<Skipper, unused_type>::value),
"The rule was instantiated with a skipper type but you have not pass any. "
"Did you use `parse` instead of `phrase_parse`?");
BOOST_STATIC_ASSERT_MSG(
(is_convertible<Skipper const&, skipper_type>::value),
"The passed skipper is not compatible/convertible to one "
"that the rule was instantiated with");
if (f)
{
// do a preskip if this is an implied lexeme
if (is_same<skipper_type, unused_type>::value)
qi::skip_over(first, last, skipper);
typedef traits::make_attribute<attr_type, Attribute> make_attribute;
// do down-stream transformation, provides attribute for
// rhs parser
typedef traits::transform_attribute<
typename make_attribute::type, attr_type, domain>
Attribute, attr_type, domain>
transform;
typename make_attribute::type made_attr = make_attribute::call(attr_param);
typename transform::type attr_ = transform::pre(made_attr);
typename transform::type attr_ = transform::pre(attr_param);
// If you are seeing a compilation error here, you are probably
// trying to use a rule or a grammar which has inherited
@@ -305,12 +312,12 @@ namespace boost { namespace spirit { namespace qi
{
// do up-stream transformation, this integrates the results
// back into the original attribute value, if appropriate
traits::post_transform(attr_param, attr_);
transform::post(attr_param, attr_);
return true;
}
// inform attribute transformation of failed rhs
traits::fail_transform(attr_param, attr_);
transform::fail(attr_param);
}
return false;
}
@@ -321,22 +328,27 @@ namespace boost { namespace spirit { namespace qi
, Context& caller_context, Skipper const& skipper
, Attribute& attr_param, Params const& params) const
{
BOOST_STATIC_ASSERT_MSG((is_same<skipper_type, unused_type>::value ||
!is_same<Skipper, unused_type>::value),
"The rule was instantiated with a skipper type but you have not pass any. "
"Did you use `parse` instead of `phrase_parse`?");
BOOST_STATIC_ASSERT_MSG(
(is_convertible<Skipper const&, skipper_type>::value),
"The passed skipper is not compatible/convertible to one "
"that the rule was instantiated with");
if (f)
{
// do a preskip if this is an implied lexeme
if (is_same<skipper_type, unused_type>::value)
qi::skip_over(first, last, skipper);
typedef traits::make_attribute<attr_type, Attribute> make_attribute;
// do down-stream transformation, provides attribute for
// rhs parser
typedef traits::transform_attribute<
typename make_attribute::type, attr_type, domain>
Attribute, attr_type, domain>
transform;
typename make_attribute::type made_attr = make_attribute::call(attr_param);
typename transform::type attr_ = transform::pre(made_attr);
typename transform::type attr_ = transform::pre(attr_param);
// If you are seeing a compilation error here, you are probably
// trying to use a rule or a grammar which has inherited
@@ -351,12 +363,12 @@ namespace boost { namespace spirit { namespace qi
{
// do up-stream transformation, this integrates the results
// back into the original attribute value, if appropriate
traits::post_transform(attr_param, attr_);
transform::post(attr_param, attr_);
return true;
}
// inform attribute transformation of failed rhs
traits::fail_transform(attr_param, attr_);
transform::fail(attr_param);
}
return false;
}

View File

@@ -15,7 +15,6 @@
#pragma once
#endif
#include <boost/detail/iterator.hpp>
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/qi/detail/attributes.hpp>
#include <boost/spirit/home/support/char_encoding/ascii.hpp>
@@ -31,7 +30,8 @@
#include <boost/mpl/bool.hpp>
#include <boost/mpl/and.hpp>
#include <boost/limits.hpp>
#include <boost/integer_traits.hpp>
#include <boost/static_assert.hpp>
#include <iterator> // for std::iterator_traits
#if defined(BOOST_MSVC)
# pragma warning(push)
@@ -56,6 +56,9 @@ namespace boost { namespace spirit { namespace qi { namespace detail
template <typename T, unsigned Radix>
struct digits_traits;
template <int Digits, unsigned Radix>
struct digits2_to_n;
// lookup table for log2(x) : 2 <= x <= 36
#define BOOST_SPIRIT_LOG2 (#error)(#error) \
(1000000)(1584960)(2000000)(2321920)(2584960)(2807350) \
@@ -67,11 +70,10 @@ namespace boost { namespace spirit { namespace qi { namespace detail
/***/
#define BOOST_PP_LOCAL_MACRO(Radix) \
template <typename T> struct digits_traits<T, Radix> \
template <int Digits> struct digits2_to_n<Digits, Radix> \
{ \
typedef std::numeric_limits<T> numeric_limits_type; \
BOOST_STATIC_CONSTANT(int, value = static_cast<int>( \
(numeric_limits_type::digits * 1000000) / \
(Digits * 1000000) / \
BOOST_PP_SEQ_ELEM(Radix, BOOST_SPIRIT_LOG2))); \
}; \
/***/
@@ -81,6 +83,18 @@ namespace boost { namespace spirit { namespace qi { namespace detail
#undef BOOST_SPIRIT_LOG2
template <typename T, unsigned Radix>
struct digits_traits : digits2_to_n<std::numeric_limits<T>::digits, Radix>
{
BOOST_STATIC_ASSERT(std::numeric_limits<T>::radix == 2);
};
template <typename T>
struct digits_traits<T, 10>
{
static int const value = std::numeric_limits<T>::digits10;
};
///////////////////////////////////////////////////////////////////////////
//
// Traits class for radix specific number conversion
@@ -101,11 +115,9 @@ namespace boost { namespace spirit { namespace qi { namespace detail
template <typename Char>
inline static bool is_valid(Char ch)
{
if (Radix <= 10)
return (ch >= '0' && ch <= static_cast<Char>('0' + Radix -1));
return (ch >= '0' && ch <= '9')
|| (ch >= 'a' && ch <= static_cast<Char>('a' + Radix -10 -1))
|| (ch >= 'A' && ch <= static_cast<Char>('A' + Radix -10 -1));
return (ch >= '0' && ch <= (Radix > 10 ? '9' : static_cast<Char>('0' + Radix -1)))
|| (Radix > 10 && ch >= 'a' && ch <= static_cast<Char>('a' + Radix -10 -1))
|| (Radix > 10 && ch >= 'A' && ch <= static_cast<Char>('A' + Radix -10 -1));
}
template <typename Char>
@@ -116,12 +128,6 @@ namespace boost { namespace spirit { namespace qi { namespace detail
return spirit::char_encoding::ascii::tolower(ch) - 'a' + 10;
}
};
template <typename T, T Val>
struct constexpr_int
{
BOOST_STATIC_CONSTEXPR T value = Val;
};
///////////////////////////////////////////////////////////////////////////
// positive_accumulator/negative_accumulator: Accumulator policies for
@@ -142,20 +148,20 @@ namespace boost { namespace spirit { namespace qi { namespace detail
inline static bool add(T& n, Char ch, mpl::true_) // checked add
{
// Ensure n *= Radix will not overflow
typedef constexpr_int<T, boost::integer_traits<T>::const_max> max;
typedef constexpr_int<T, max::value / Radix> val;
T const max = (std::numeric_limits<T>::max)();
T const val = max / Radix;
if (n > val::value)
if (n > val)
return false;
n *= Radix;
T tmp = n * Radix;
// Ensure n += digit will not overflow
const int digit = radix_traits<Radix>::digit(ch);
if (n > max::value - digit)
if (tmp > max - digit)
return false;
n += static_cast<T>(digit);
n = tmp + static_cast<T>(digit);
return true;
}
};
@@ -174,20 +180,20 @@ namespace boost { namespace spirit { namespace qi { namespace detail
inline static bool add(T& n, Char ch, mpl::true_) // checked subtract
{
// Ensure n *= Radix will not underflow
typedef constexpr_int<T, boost::integer_traits<T>::const_min> min;
typedef constexpr_int<T, (min::value + 1) / T(Radix)> val;
T const min = (std::numeric_limits<T>::min)();
T const val = min / T(Radix);
if (n < val::value)
if (n < val)
return false;
n *= Radix;
T tmp = n * Radix;
// Ensure n -= digit will not underflow
int const digit = radix_traits<Radix>::digit(ch);
if (n < min::value + digit)
if (tmp < min + digit)
return false;
n -= static_cast<T>(digit);
n = tmp - static_cast<T>(digit);
return true;
}
};
@@ -202,9 +208,9 @@ namespace boost { namespace spirit { namespace qi { namespace detail
inline static bool
call(Char ch, std::size_t count, T& n, mpl::true_)
{
typedef constexpr_int<std::size_t, digits_traits<T, Radix>::value - 1> overflow_free;
std::size_t const overflow_free = digits_traits<T, Radix>::value - 1;
if (!AlwaysCheckOverflow && (count < overflow_free::value))
if (!AlwaysCheckOverflow && (count < overflow_free))
{
Accumulator::add(n, ch, mpl::false_());
}
@@ -278,14 +284,20 @@ namespace boost { namespace spirit { namespace qi { namespace detail
#define SPIRIT_NUMERIC_INNER_LOOP(z, x, data) \
if (!check_max_digits<MaxDigits>::call(count + leading_zeros) \
|| it == last) \
{ \
break; \
} \
ch = *it; \
if (!radix_check::is_valid(ch)) \
{ \
break; \
} \
if (!extractor::call(ch, count, val)) \
{ \
if (IgnoreOverflowDigits) \
{ \
first = it; \
} \
traits::assign_to(val, attr); \
return IgnoreOverflowDigits; \
} \
@@ -314,9 +326,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail
{
typedef radix_traits<Radix> radix_check;
typedef int_extractor<Radix, Accumulator, MaxDigits, Accumulate> extractor;
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
char_type;
typedef typename std::iterator_traits<Iterator>::value_type char_type;
Iterator it = first;
std::size_t leading_zeros = 0;
@@ -386,10 +396,14 @@ namespace boost { namespace spirit { namespace qi { namespace detail
///////////////////////////////////////////////////////////////////////////
#define SPIRIT_NUMERIC_INNER_LOOP(z, x, data) \
if (it == last) \
{ \
break; \
} \
ch = *it; \
if (!radix_check::is_valid(ch)) \
{ \
break; \
} \
if (!extractor::call(ch, count, val)) \
{ \
traits::assign_to(val, attr); \
@@ -415,9 +429,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail
{
typedef radix_traits<Radix> radix_check;
typedef int_extractor<Radix, Accumulator, -1, Accumulate> extractor;
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
char_type;
typedef typename std::iterator_traits<Iterator>::value_type char_type;
Iterator it = first;
std::size_t count = 0;
@@ -496,35 +508,6 @@ namespace boost { namespace spirit { namespace qi { namespace detail
};
#undef SPIRIT_NUMERIC_INNER_LOOP
///////////////////////////////////////////////////////////////////////////
// Cast an signed integer to an unsigned integer
///////////////////////////////////////////////////////////////////////////
template <typename T,
bool force_unsigned
= mpl::and_<is_integral<T>, is_signed<T> >::value>
struct cast_unsigned;
template <typename T>
struct cast_unsigned<T, true>
{
typedef typename make_unsigned<T>::type unsigned_type;
typedef typename make_unsigned<T>::type& unsigned_type_ref;
inline static unsigned_type_ref call(T& n)
{
return unsigned_type_ref(n);
}
};
template <typename T>
struct cast_unsigned<T, false>
{
inline static T& call(T& n)
{
return n;
}
};
}}}}
#if defined(BOOST_MSVC)

View File

@@ -32,7 +32,7 @@
namespace boost { namespace spirit { namespace traits
{
using spirit::traits::pow10;
namespace detail
{
template <typename T, typename AccT>
@@ -44,14 +44,14 @@ namespace boost { namespace spirit { namespace traits
n = T((acc_n / comp) * comp);
n += T(acc_n % comp);
}
template <typename T, typename AccT>
void compensate_roundoff(T& n, AccT acc_n, mpl::false_)
{
// no need to compensate
n = acc_n;
}
template <typename T, typename AccT>
void compensate_roundoff(T& n, AccT acc_n)
{
@@ -66,7 +66,7 @@ namespace boost { namespace spirit { namespace traits
if (exp >= 0)
{
int max_exp = std::numeric_limits<T>::max_exponent10;
// return false if exp exceeds the max_exp
// do this check only for primitive types!
if (is_floating_point<T>() && exp > max_exp)
@@ -80,13 +80,14 @@ namespace boost { namespace spirit { namespace traits
int min_exp = std::numeric_limits<T>::min_exponent10;
detail::compensate_roundoff(n, acc_n);
n /= pow10<T>(-min_exp);
// return false if (-exp + min_exp) exceeds the -min_exp
// return false if exp still exceeds the min_exp
// do this check only for primitive types!
if (is_floating_point<T>() && (-exp + min_exp) > -min_exp)
exp += -min_exp;
if (is_floating_point<T>() && exp < min_exp)
return false;
n /= pow10<T>(-exp + min_exp);
n /= pow10<T>(-exp);
}
else
{
@@ -149,20 +150,6 @@ namespace boost { namespace spirit { namespace traits
return n;
}
template <typename T>
inline bool
is_equal_to_one(T const& value)
{
return value == 1.0;
}
inline bool
is_equal_to_one(unused_type)
{
// no-op for unused_type
return false;
}
template <typename T>
struct real_accumulator : mpl::identity<T> {};
@@ -233,6 +220,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail
// to zero (0) only if we already got a number.
if (p.parse_frac_n(first, last, acc_n, frac_digits))
{
BOOST_ASSERT(frac_digits >= 0);
}
else if (!got_a_number || !p.allow_trailing_dot)
{
@@ -284,29 +272,16 @@ namespace boost { namespace spirit { namespace qi { namespace detail
// If there is no number, disregard the exponent altogether.
// by resetting 'first' prior to the exponent prefix (e|E)
first = e_pos;
n = static_cast<T>(acc_n);
// Scale the number by -frac_digits.
bool r = traits::scale(-frac_digits, n, acc_n);
BOOST_VERIFY(r);
}
}
else if (frac_digits)
{
// No exponent found. Scale the number by -frac_digits.
traits::scale(-frac_digits, n, acc_n);
}
else if (traits::is_equal_to_one(acc_n))
{
// There is a chance of having to parse one of the 1.0#...
// styles some implementations use for representing NaN or Inf.
// Check whether the number to parse is a NaN or Inf
if (p.parse_nan(first, last, n) ||
p.parse_inf(first, last, n))
{
// If we got a negative sign, negate the number
traits::assign_to(traits::negate(neg, n), attr);
return true; // got a NaN or Inf, return immediately
}
n = static_cast<T>(acc_n);
bool r = traits::scale(-frac_digits, n, acc_n);
BOOST_VERIFY(r);
}
else
{

View File

@@ -69,8 +69,7 @@ namespace boost { namespace spirit { namespace qi
extract_type;
Iterator save = first;
if (!extract_type::parse(first, last,
detail::cast_unsigned<T>::call(attr_)))
if (!extract_type::parse(first, last, attr_))
{
first = save;
return false;

View File

@@ -89,22 +89,9 @@ namespace boost { namespace spirit { namespace qi
}
///////////////////////////////////////////////////////////////////////
// The parse_nan() and parse_inf() functions get called whenever:
//
// - a number to parse does not start with a digit (after having
// successfully parsed an optional sign)
//
// or
//
// - after a floating point number of the value 1 (having no
// exponential part and a fractional part value of 0) has been
// parsed.
//
// The first call allows to recognize representations of NaN or Inf
// starting with a non-digit character (such as NaN, Inf, QNaN etc.).
//
// The second call allows to recognize representation formats starting
// with a 1.0 (such as 1.0#NAN or 1.0#INF etc.).
// The parse_nan() and parse_inf() functions get called whenever
// a number to parse does not start with a digit (after having
// successfully parsed an optional sign).
//
// The functions should return true if a Nan or Inf has been found. In
// this case the attr should be set to the matched value (NaN or

View File

@@ -14,11 +14,11 @@
#include <boost/spirit/home/qi/operator/sequence_base.hpp>
#include <boost/spirit/home/qi/detail/expect_function.hpp>
#include <boost/spirit/home/qi/detail/expectation_failure.hpp>
#include <boost/spirit/home/qi/meta_compiler.hpp>
#include <boost/spirit/home/support/has_semantic_action.hpp>
#include <boost/spirit/home/support/handles_container.hpp>
#include <boost/spirit/home/support/info.hpp>
#include <stdexcept>
namespace boost { namespace spirit
{
@@ -36,27 +36,13 @@ namespace boost { namespace spirit
namespace boost { namespace spirit { namespace qi
{
template <typename Iterator>
struct expectation_failure : std::runtime_error
{
expectation_failure(Iterator first_, Iterator last_, info const& what)
: std::runtime_error("boost::spirit::qi::expectation_failure")
, first(first_), last(last_), what_(what)
{}
~expectation_failure() throw() {}
Iterator first;
Iterator last;
info what_;
};
template <typename Elements>
struct expect : sequence_base<expect<Elements>, Elements>
struct expect_operator : sequence_base<expect_operator<Elements>, Elements>
{
friend struct sequence_base<expect<Elements>, Elements>;
friend struct sequence_base<expect_operator<Elements>, Elements>;
expect(Elements const& elements)
: sequence_base<expect<Elements>, Elements>(elements) {}
expect_operator(Elements const& elements)
: sequence_base<expect_operator<Elements>, Elements>(elements) {}
private:
@@ -73,7 +59,7 @@ namespace boost { namespace spirit { namespace qi
(first, last, context, skipper);
}
std::string id() const { return "expect"; }
std::string id() const { return "expect_operator"; }
};
///////////////////////////////////////////////////////////////////////////
@@ -81,7 +67,7 @@ namespace boost { namespace spirit { namespace qi
///////////////////////////////////////////////////////////////////////////
template <typename Elements, typename Modifiers>
struct make_composite<proto::tag::greater, Elements, Modifiers>
: make_nary_composite<Elements, expect>
: make_nary_composite<Elements, expect_operator>
{};
}}}
@@ -89,13 +75,13 @@ namespace boost { namespace spirit { namespace traits
{
///////////////////////////////////////////////////////////////////////////
template <typename Elements>
struct has_semantic_action<qi::expect<Elements> >
struct has_semantic_action<qi::expect_operator<Elements> >
: nary_has_semantic_action<Elements> {};
///////////////////////////////////////////////////////////////////////////
template <typename Elements, typename Attribute, typename Context
, typename Iterator>
struct handles_container<qi::expect<Elements>, Attribute, Context
struct handles_container<qi::expect_operator<Elements>, Attribute, Context
, Iterator>
: mpl::true_ {};
}}}

View File

@@ -21,7 +21,6 @@
#include <boost/spirit/home/support/info.hpp>
#include <boost/fusion/include/size.hpp>
#include <boost/optional.hpp>
#include <boost/foreach.hpp>
#include <boost/array.hpp>
namespace boost { namespace spirit
@@ -76,10 +75,7 @@ namespace boost { namespace spirit { namespace qi
f(first, last, context, skipper);
boost::array<bool, fusion::result_of::size<Elements>::value> flags;
BOOST_FOREACH(bool& taken, flags)
{
taken = false;
}
flags.fill(false);
// wrap the attribute in a tuple if it is not a tuple
typename traits::wrap_if_not_tuple<Attribute>::type attr_local(attr_);

View File

@@ -15,7 +15,7 @@
#include <boost/spirit/home/qi/detail/pass_function.hpp>
#include <boost/spirit/home/qi/detail/attributes.hpp>
#include <boost/spirit/home/support/detail/what_function.hpp>
#include <boost/spirit/home/support/algorithm/any_if_ns.hpp>
#include <boost/spirit/home/support/algorithm/any_if_ns_so.hpp>
#include <boost/spirit/home/support/handles_container.hpp>
#include <boost/fusion/include/as_vector.hpp>
#include <boost/fusion/include/for_each.hpp>
@@ -75,9 +75,10 @@ namespace boost { namespace spirit { namespace qi
typename traits::wrap_if_not_tuple<Attribute>::type attr_local(attr_);
// return true if *any* of the parsers succeed
// (we use the non-short-circuiting version: any_if_ns
// to force all elements to be tested)
return spirit::any_if_ns(elements, attr_local, f, predicate());
// (we use the non-short-circuiting and strict order version:
// any_if_ns_so to force all the elements to be tested and
// in the defined order: first is first, last is last)
return spirit::any_if_ns_so(elements, attr_local, f, predicate());
}
template <typename Context>

View File

@@ -15,7 +15,7 @@
#include <boost/spirit/home/support/context.hpp>
#include <boost/spirit/home/support/nonterminal/locals.hpp>
#include <boost/spirit/home/qi/detail/parse.hpp>
#include <boost/concept_check.hpp>
#include <boost/iterator/iterator_concepts.hpp>
namespace boost { namespace spirit { namespace qi
{
@@ -27,11 +27,12 @@ namespace boost { namespace spirit { namespace qi
, Iterator last
, Expr const& expr)
{
// Make sure the iterator is at least a forward_iterator. If you got a
// compilation error here, then you are using an input_iterator while
// calling this function, you need to supply at least a
// forward_iterator instead.
BOOST_CONCEPT_ASSERT((ForwardIterator<Iterator>));
// Make sure the iterator is at least a readable forward traversal iterator.
// If you got a compilation error here, then you are using a weaker iterator
// while calling this function, you need to supply a readable forward traversal
// iterator instead.
BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept<Iterator>));
BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversalConcept<Iterator>));
return detail::parse_impl<Expr>::call(first, last, expr);
}
@@ -71,11 +72,12 @@ namespace boost { namespace spirit { namespace qi
, Expr const& expr
, Attr& attr)
{
// Make sure the iterator is at least a forward_iterator. If you got a
// compilation error here, then you are using an input_iterator while
// calling this function, you need to supply at least a
// forward_iterator instead.
BOOST_CONCEPT_ASSERT((ForwardIterator<Iterator>));
// Make sure the iterator is at least a readable forward traversal iterator.
// If you got a compilation error here, then you are using a weaker iterator
// while calling this function, you need to supply a readable forward traversal
// iterator instead.
BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept<Iterator>));
BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversalConcept<Iterator>));
// Report invalid expression error as early as possible.
// If you got an error_invalid_expression error message here,
@@ -108,11 +110,12 @@ namespace boost { namespace spirit { namespace qi
, Skipper const& skipper
, BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip)
{
// Make sure the iterator is at least a forward_iterator. If you got a
// compilation error here, then you are using an input_iterator while
// calling this function, you need to supply at least a
// forward_iterator instead.
BOOST_CONCEPT_ASSERT((ForwardIterator<Iterator>));
// Make sure the iterator is at least a readable forward traversal iterator.
// If you got a compilation error here, then you are using a weaker iterator
// while calling this function, you need to supply a readable forward traversal
// iterator instead.
BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept<Iterator>));
BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversalConcept<Iterator>));
return detail::phrase_parse_impl<Expr>::call(
first, last, expr, skipper, post_skip);
@@ -142,11 +145,12 @@ namespace boost { namespace spirit { namespace qi
, BOOST_SCOPED_ENUM(skip_flag) post_skip
, Attr& attr)
{
// Make sure the iterator is at least a forward_iterator. If you got a
// compilation error here, then you are using an input_iterator while
// calling this function, you need to supply at least a
// forward_iterator instead.
BOOST_CONCEPT_ASSERT((ForwardIterator<Iterator>));
// Make sure the iterator is at least a readable forward traversal iterator.
// If you got a compilation error here, then you are using a weaker iterator
// while calling this function, you need to supply a readable forward traversal
// iterator instead.
BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept<Iterator>));
BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversalConcept<Iterator>));
// Report invalid expression error as early as possible.
// If you got an error_invalid_expression error message here,

View File

@@ -24,7 +24,7 @@ namespace boost { namespace spirit { namespace qi
template <typename Iterator, typename T>
inline void skip_over(Iterator& first, Iterator const& last, T const& skipper)
{
while (first != last && skipper.parse(first, last, unused, unused, unused))
while (skipper.parse(first, last, unused, unused, unused))
/***/;
}

View File

@@ -12,21 +12,19 @@
#endif
#include <boost/iostreams/stream.hpp>
#include <boost/detail/iterator.hpp>
#include <iterator> // for std::iterator_traits, std::distance
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace qi { namespace detail
{
///////////////////////////////////////////////////////////////////////////
template <typename Iterator>
struct iterator_source
struct base_iterator_source
{
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
char_type;
typedef typename std::iterator_traits<Iterator>::value_type char_type;
typedef boost::iostreams::seekable_device_tag category;
iterator_source (Iterator const& first_, Iterator const& last_)
base_iterator_source (Iterator const& first_, Iterator const& last_)
: first(first_), last(last_), pos(0)
{}
@@ -62,6 +60,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail
std::streampos seek(boost::iostreams::stream_offset, std::ios_base::seekdir way)
{
(void)way;
BOOST_ASSERT(way == std::ios_base::cur); // only support queries
return pos; // return current position
}
@@ -72,7 +71,56 @@ namespace boost { namespace spirit { namespace qi { namespace detail
private:
// silence MSVC warning C4512: assignment operator could not be generated
iterator_source& operator= (iterator_source const&);
base_iterator_source& operator= (base_iterator_source const&);
};
template <typename Iterator, typename Enable = void>
struct iterator_source : base_iterator_source<Iterator>
{
typedef base_iterator_source<Iterator> base_type;
iterator_source (Iterator const& first_, Iterator const& last_)
: base_type(first_, last_) {}
};
// Specialization for random-access iterators. This also allows compilers
// to fully optimize the case when the source range is contiguous
template <typename Iterator>
struct iterator_source<
Iterator,
typename boost::enable_if_c<boost::is_convertible<
typename std::iterator_traits<Iterator>::iterator_category, std::random_access_iterator_tag>::value>::type
> : base_iterator_source<Iterator>
{
typedef base_iterator_source<Iterator> base_type;
iterator_source (Iterator const& first_, Iterator const& last_)
: base_type(first_, last_) {}
typedef typename base_type::char_type char_type;
using base_type::first;
using base_type::last;
using base_type::pos;
// Read up to n characters from the input sequence into the buffer s,
// returning the number of characters read, or -1 to indicate
// end-of-sequence.
std::streamsize read (char_type* s, std::streamsize n)
{
if (first == last)
return -1;
n = (std::min)(static_cast<std::streamsize>(last - first), n);
typedef typename std::iterator_traits<Iterator>::difference_type diff_type;
// copy_n is only part of c++11, so emulate it
std::copy(first, first + static_cast<diff_type>(n), s);
first += static_cast<diff_type>(n);
pos += n;
return n;
}
};
}}}}

View File

@@ -71,7 +71,10 @@ namespace boost { namespace spirit { namespace qi
// advance the iterator if everything is ok
if (in) {
if (!in.eof()) {
std::streamsize pos = in.tellg();
typedef typename
boost::iterator_difference<Iterator>::type diff_type;
diff_type pos = static_cast<diff_type>(in.tellg());
std::advance(first, pos);
} else {
first = last;

View File

@@ -12,9 +12,7 @@
#endif
#include <boost/call_traits.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/foreach.hpp>
#include <boost/assert.hpp>
#include <iterator> // for std::iterator_traits
namespace boost { namespace spirit { namespace qi { namespace detail
{
@@ -76,7 +74,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail
while (p && i != last)
{
typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
c = filter(*i); // filter only the input
if (c == p->id)
@@ -120,7 +118,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail
for(;;)
{
typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
c = *first;
if (*pp == 0)
@@ -156,7 +154,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail
return;
typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
c = *first;
if (c == p->id)

View File

@@ -24,9 +24,8 @@
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/support/string_traits.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/range.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/shared_ptr.hpp>
#if defined(BOOST_MSVC)

View File

@@ -15,6 +15,7 @@
#include <boost/spirit/home/qi/string/detail/tst.hpp>
#include <boost/unordered_map.hpp>
#include <boost/pool/object_pool.hpp>
#include <boost/foreach.hpp>
namespace boost { namespace spirit { namespace qi
{