updated boost on windows

This commit is contained in:
Bassem Girgis
2019-08-13 21:48:48 -05:00
parent 7d77d485fd
commit b40a3bee82
5162 changed files with 473027 additions and 116452 deletions

View File

@@ -11,6 +11,7 @@
#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/spirit/home/classic/core/parser.hpp>
#include <boost/spirit/home/classic/core/composite/composite.hpp>
#include <boost/core/ignore_unused.hpp>
namespace boost { namespace spirit {
@@ -107,7 +108,7 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
typedef typename ScannerT::iterator_t iterator_t;
typedef typename parser_result<self_t, ScannerT>::type result_t;
scan.at_end(); // allow skipper to take effect
ignore_unused(scan.at_end()); // allow skipper to take effect
iterator_t save = scan.first;
result_t hit = this->subject().parse(scan);
if (hit)

View File

@@ -16,6 +16,11 @@
#include <boost/spirit/home/classic/core/composite/composite.hpp>
#include <boost/spirit/home/classic/core/composite/no_actions.hpp>
#if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable: 4800) // forcing value to bool 'true' or 'false'
#endif
////////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit {
@@ -273,4 +278,8 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_END
}} // namespace BOOST_SPIRIT_CLASSIC_NS
#ifdef BOOST_MSVC
# pragma warning (pop)
#endif
#endif

View File

@@ -38,10 +38,10 @@ struct no_actions_action_policy:
template<typename ActorT, typename AttrT, typename IteratorT>
void
do_action(
ActorT const& actor,
AttrT& val,
IteratorT const& first,
IteratorT const& last) const
ActorT const& /*actor*/,
AttrT& /*val*/,
IteratorT const& /*first*/,
IteratorT const& /*last*/) const
{}
};

View File

@@ -17,6 +17,8 @@
#include <boost/spirit/home/classic/core/safe_bool.hpp>
#include <boost/spirit/home/classic/core/impl/match_attr_traits.ipp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/is_reference.hpp>
namespace boost { namespace spirit {
@@ -62,12 +64,20 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
template <typename T = nil_t>
class match : public safe_bool<match<T> >
{
typedef typename
conditional<
is_reference<T>::value
, T
, typename add_reference<
typename add_const<T>::type
>::type
>::type attr_ref_t;
public:
typedef typename boost::optional<T> optional_type;
typedef typename optional_type::argument_type ctor_param_t;
typedef typename optional_type::reference_const_type return_t;
typedef attr_ref_t ctor_param_t;
typedef attr_ref_t return_t;
typedef T attr_t;
match();

View File

@@ -15,7 +15,7 @@
#include <boost/spirit/home/classic/core/non_terminal/impl/object_with_id.ipp>
#include <algorithm>
#include <functional>
#include <memory> // for std::auto_ptr
#include <boost/move/unique_ptr.hpp>
#include <boost/weak_ptr.hpp>
#endif
@@ -70,7 +70,7 @@ struct grammar_definition
{ // Does _not_ copy the helpers member !
}
grammar_helper_list& operator=(grammar_helper_list const& x)
grammar_helper_list& operator=(grammar_helper_list const& /*x*/)
{ // Does _not_ copy the helpers member !
return *this;
}
@@ -156,7 +156,7 @@ struct grammar_definition
if (definitions[id]!=0)
return *definitions[id];
std::auto_ptr<definition_t>
boost::movelib::unique_ptr<definition_t>
result(new definition_t(target_grammar->derived()));
#ifdef BOOST_SPIRIT_THREADSAFE
@@ -286,18 +286,10 @@ struct grammar_definition
helper_list_t& helpers =
grammartract_helper_list::do_(self);
# if defined(BOOST_INTEL_CXX_VERSION)
typedef typename helper_list_t::vector_t::reverse_iterator iterator_t;
for (iterator_t i = helpers.rbegin(); i != helpers.rend(); ++i)
(*i)->undefine(self);
# else
typedef impl::grammar_helper_base<GrammarT> helper_base_t;
std::for_each(helpers.rbegin(), helpers.rend(),
std::bind2nd(std::mem_fun(&helper_base_t::undefine), self));
# endif
#else
(void)self;
#endif

View File

@@ -375,6 +375,12 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
return to_char_type<wchar_t>(towupper(to_int_type(c)));
}
inline bool
isblank_(bool)
{
return false;
}
#endif // !defined(BOOST_NO_CWCTYPE)
}

View File

@@ -49,6 +49,12 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
{
typedef typename ScannerT::value_t value_t;
typedef typename ScannerT::iterator_t iterator_t;
typedef scanner_policies<
no_skipper_iteration_policy<
BOOST_DEDUCED_TYPENAME ScannerT::iteration_policy_t>,
BOOST_DEDUCED_TYPENAME ScannerT::match_policy_t,
BOOST_DEDUCED_TYPENAME ScannerT::action_policy_t
> policies_t;
if (!scan.at_end())
{
@@ -56,7 +62,7 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
if (this->derived().test(ch))
{
iterator_t save(scan.first);
++scan.first;
++scan.change_policies(policies_t(scan));
return scan.create_match(1, ch, save, scan.first);
}
}
@@ -584,19 +590,26 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
typename parser_result<self_t, ScannerT>::type
parse(ScannerT const& scan) const
{
typedef scanner_policies<
no_skipper_iteration_policy<
BOOST_DEDUCED_TYPENAME ScannerT::iteration_policy_t>,
BOOST_DEDUCED_TYPENAME ScannerT::match_policy_t,
BOOST_DEDUCED_TYPENAME ScannerT::action_policy_t
> policies_t;
typename ScannerT::iterator_t save = scan.first;
std::size_t len = 0;
if (!scan.at_end() && *scan == '\r') // CR
{
++scan.first;
++scan.change_policies(policies_t(scan));
++len;
}
// Don't call skipper here
if (scan.first != scan.last && *scan == '\n') // LF
{
++scan.first;
++scan.change_policies(policies_t(scan));
++len;
}

View File

@@ -98,12 +98,12 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
ParserT const& p,
SkipT const& skip)
{
typedef skip_parser_iteration_policy<SkipT> iter_policy_t;
typedef scanner_policies<iter_policy_t> scanner_policies_t;
typedef scanner<IteratorT, scanner_policies_t> scanner_t;
typedef skip_parser_iteration_policy<SkipT> it_policy_t;
typedef scanner_policies<it_policy_t> scan_policies_t;
typedef scanner<IteratorT, scan_policies_t> scanner_t;
iter_policy_t iter_policy(skip);
scanner_policies_t policies(iter_policy);
it_policy_t iter_policy(skip);
scan_policies_t policies(iter_policy);
IteratorT first = first_;
scanner_t scan(first, last, policies);
match<nil_t> hit = p.parse(scan);
@@ -124,9 +124,9 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
ParserT const& p,
space_parser const&)
{
typedef skipper_iteration_policy<> iter_policy_t;
typedef scanner_policies<iter_policy_t> scanner_policies_t;
typedef scanner<IteratorT, scanner_policies_t> scanner_t;
typedef skipper_iteration_policy<> it_policy_t;
typedef scanner_policies<it_policy_t> scan_policies_t;
typedef scanner<IteratorT, scan_policies_t> scanner_t;
IteratorT first = first_;
scanner_t scan(first, last);

View File

@@ -13,7 +13,6 @@
#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/spirit/home/classic/core/match.hpp>
#include <boost/spirit/home/classic/core/non_terminal/parser_id.hpp>
#include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits
#include <boost/spirit/home/classic/core/scanner/scanner_fwd.hpp>
@@ -219,9 +218,9 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
typedef IteratorT iterator_t;
typedef PoliciesT policies_t;
typedef typename boost::detail::
typedef typename std::
iterator_traits<IteratorT>::value_type value_t;
typedef typename boost::detail::
typedef typename std::
iterator_traits<IteratorT>::reference ref_t;
typedef typename boost::
call_traits<IteratorT>::param_type iter_param_t;

View File

@@ -95,7 +95,7 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
// from numerics.hpp
template <typename T, int Radix, unsigned MinDigits, int MaxDigits>
inline std::string
parser_name(uint_parser<T, Radix, MinDigits, MaxDigits> const& p)
parser_name(uint_parser<T, Radix, MinDigits, MaxDigits> const& /*p*/)
{
BOOST_SPIRIT_SSTREAM stream;
stream << Radix << ", " << MinDigits << ", " << MaxDigits;
@@ -106,7 +106,7 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
template <typename T, int Radix, unsigned MinDigits, int MaxDigits>
inline std::string
parser_name(int_parser<T, Radix, MinDigits, MaxDigits> const& p)
parser_name(int_parser<T, Radix, MinDigits, MaxDigits> const& /*p*/)
{
BOOST_SPIRIT_SSTREAM stream;
stream << Radix << ", " << MinDigits << ", " << MaxDigits;
@@ -117,7 +117,7 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
template <typename T, typename RealPoliciesT>
inline std::string
parser_name(real_parser<T, RealPoliciesT> const& p)
parser_name(real_parser<T, RealPoliciesT> const& /*p*/)
{
return std::string("real_parser");
}
@@ -218,7 +218,7 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
// from parser.hpp
template <typename DerivedT>
inline std::string
parser_name(parser<DerivedT> const& p)
parser_name(parser<DerivedT> const& /*p*/)
{
return std::string("parser");
}
@@ -227,7 +227,7 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
// from primitives.hpp
template <typename DerivedT>
inline std::string
parser_name(char_parser<DerivedT> const &p)
parser_name(char_parser<DerivedT> const &/*p*/)
{
return std::string("char_parser");
}

View File

@@ -108,15 +108,13 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
typename parser_result<self_t, ScannerT>::type
parse(ScannerT const &scan) const
{
typedef typename parser_result<self_t, ScannerT>::type
result_t;
typedef typename parser_result<parser_t, ScannerT>::type
body_result_t;
typename ScannerT::iterator_t save(scan.first);
std::size_t length = 0;
int eval_length = 0;
std::ptrdiff_t eval_length = 0;
this->init();
while ((eval_length = this->evaluate(scan))>=0)

View File

@@ -12,6 +12,7 @@
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/inc.hpp>
@@ -328,8 +329,8 @@ struct compound_case_parser
case_chain<self_t>::depth < BOOST_SPIRIT_SWITCH_CASE_LIMIT
);
typedef case_parser<N1, ParserT1, IsDefault1> right_t;
return compound_case_parser<self_t, right_t, IsDefault1>(*this, p);
typedef case_parser<N1, ParserT1, IsDefault1> rhs_t;
return compound_case_parser<self_t, rhs_t, IsDefault1>(*this, p);
}
};
@@ -445,7 +446,7 @@ inline typename parser_result<
compound_case_parser<LeftT, RightT, IsDefault>::
parse(ScannerT const& scan, CondT const &cond) const
{
scan.at_end(); // allow skipper to take effect
ignore_unused(scan.at_end()); // allow skipper to take effect
return parse_switch<value, case_chain<self_t>::depth, is_default>::
do_(*this, scan, cond(scan), scan.first);
}

View File

@@ -71,7 +71,7 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
iterator_t save(scan.first);
std::size_t length = 0;
int eval_length = 0;
std::ptrdiff_t eval_length = 0;
bool dont_check_condition = is_do_parser;

View File

@@ -34,12 +34,12 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
// to allow a single catch handler to catch all exceptions.
//
///////////////////////////////////////////////////////////////////////////
class parser_error_base : public std::exception
class BOOST_SYMBOL_VISIBLE parser_error_base : public std::exception
{
protected:
parser_error_base() {}
virtual ~parser_error_base() throw() {}
virtual ~parser_error_base() BOOST_NOEXCEPT_OR_NOTHROW {}
public:
@@ -87,10 +87,10 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
}
virtual
~parser_error() throw() {}
~parser_error() BOOST_NOEXCEPT_OR_NOTHROW {}
virtual const char*
what() const throw()
what() const BOOST_NOEXCEPT_OR_NOTHROW
{
return "BOOST_SPIRIT_CLASSIC_NS::parser_error";
}
@@ -140,7 +140,6 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
parse(ScannerT const& scan) const
{
typedef typename parser_result<ParserT, ScannerT>::type result_t;
typedef typename ScannerT::iterator_t iterator_t;
result_t hit = this->subject().parse(scan);
if (!hit)

View File

@@ -130,7 +130,7 @@ public:
void advance(std::ptrdiff_t n)
{
m_pos += n * sizeof(CharT);
m_pos += static_cast<long>(n) * sizeof(CharT);
update_char();
}
@@ -141,14 +141,14 @@ public:
private:
boost::shared_ptr<std::FILE> m_file;
std::size_t m_pos;
long m_pos;
CharT m_curChar;
bool m_eof;
void update_char(void)
{
using namespace std;
if ((std::size_t)ftell(m_file.get()) != m_pos)
if (ftell(m_file.get()) != m_pos)
fseek(m_file.get(), m_pos, SEEK_SET);
m_eof = (fread(&m_curChar, sizeof(CharT), 1, m_file.get()) < 1);

View File

@@ -17,7 +17,7 @@
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/spirit/home/classic/core/nil.hpp> // for nil_t
#include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits
#include <iterator> // for std::iterator_traits
namespace boost { namespace spirit {
@@ -91,6 +91,16 @@ private:
/* namespace boost::spirit { */ namespace iterator_ { namespace impl {
template <typename T>
struct make_const : boost::add_const<T>
{};
template <typename T>
struct make_const<T&>
{
typedef typename boost::add_const<T>::type& type;
};
///////////////////////////////////////////////////////////////////////////////
//
// position_iterator_base_generator
@@ -104,9 +114,10 @@ template <typename MainIterT, typename ForwardIterT, typename PositionT>
struct position_iterator_base_generator
{
private:
typedef boost::detail::iterator_traits<ForwardIterT> traits;
typedef std::iterator_traits<ForwardIterT> traits;
typedef typename traits::value_type value_type;
typedef typename traits::iterator_category iter_category_t;
typedef typename traits::reference reference;
// Position iterator is always a non-mutable iterator
typedef typename boost::add_const<value_type>::type const_value_type;
@@ -125,7 +136,8 @@ public:
main_iter_t,
ForwardIterT,
const_value_type,
boost::forward_traversal_tag
boost::forward_traversal_tag,
typename make_const<reference>::type
> type;
};

View File

@@ -16,12 +16,10 @@
#include <algorithm> // for std::swap
#include <exception> // for std::exception
#include <boost/limits.hpp>
#include <boost/iterator.hpp>
#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/spirit/home/classic/core/assert.hpp> // for BOOST_SPIRIT_ASSERT
#include <boost/spirit/home/classic/iterator/fixed_size_queue.hpp>
#include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits
#include <boost/spirit/home/classic/iterator/multi_pass_fwd.hpp>
@@ -147,15 +145,15 @@ class first_owner
// thrown by buf_id_check CheckingPolicy if an instance of an iterator is
// used after another one has invalidated the queue
///////////////////////////////////////////////////////////////////////////////
class illegal_backtracking : public std::exception
class BOOST_SYMBOL_VISIBLE illegal_backtracking : public std::exception
{
public:
illegal_backtracking() throw() {}
~illegal_backtracking() throw() {}
illegal_backtracking() BOOST_NOEXCEPT_OR_NOTHROW {}
~illegal_backtracking() BOOST_NOEXCEPT_OR_NOTHROW {}
virtual const char*
what() const throw()
what() const BOOST_NOEXCEPT_OR_NOTHROW
{ return "BOOST_SPIRIT_CLASSIC_NS::illegal_backtracking"; }
};
@@ -492,7 +490,7 @@ class inner
{
private:
typedef
typename boost::detail::iterator_traits<InputT>::value_type
typename std::iterator_traits<InputT>::value_type
result_type;
public:
@@ -517,13 +515,13 @@ class inner
public:
typedef
typename boost::detail::iterator_traits<InputT>::difference_type
typename std::iterator_traits<InputT>::difference_type
difference_type;
typedef
typename boost::detail::iterator_traits<InputT>::pointer
typename std::iterator_traits<InputT>::pointer
pointer;
typedef
typename boost::detail::iterator_traits<InputT>::reference
typename std::iterator_traits<InputT>::reference
reference;
protected:
@@ -551,7 +549,7 @@ class inner
}
typedef
typename boost::detail::iterator_traits<InputT>::value_type
typename std::iterator_traits<InputT>::value_type
value_t;
void swap(inner& x)
{
@@ -760,24 +758,19 @@ class inner
namespace iterator_ { namespace impl {
// Meta-function to generate a std::iterator<> base class for multi_pass. This
// is used mainly to improve conformance of compilers not supporting PTS
// and thus relying on inheritance to recognize an iterator.
// We are using boost::iterator<> because it offers an automatic workaround
// for broken std::iterator<> implementations.
// Meta-function to generate a std::iterator<>-like base class for multi_pass.
template <typename InputPolicyT, typename InputT>
struct iterator_base_creator
{
typedef typename InputPolicyT::BOOST_NESTED_TEMPLATE inner<InputT> input_t;
typedef boost::iterator
<
std::forward_iterator_tag,
typename input_t::value_type,
typename input_t::difference_type,
typename input_t::pointer,
typename input_t::reference
> type;
struct type {
typedef std::forward_iterator_tag iterator_category;
typedef typename input_t::value_type value_type;
typedef typename input_t::difference_type difference_type;
typedef typename input_t::pointer pointer;
typedef typename input_t::reference reference;
};
};
}}

View File

@@ -10,7 +10,7 @@
#define BOOST_SPIRIT_POSITION_ITERATOR_FWD_HPP
#include <string>
#include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits
#include <iterator> // for std::iterator_traits
#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/spirit/home/classic/core/nil.hpp>
@@ -32,7 +32,7 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
typename ForwardIteratorT,
typename PositionT = file_position_base<
std::basic_string<
typename boost::detail::iterator_traits<ForwardIteratorT>::value_type
typename std::iterator_traits<ForwardIteratorT>::value_type
>
>,
typename SelfT = nil_t
@@ -44,7 +44,7 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
typename ForwardIteratorT,
typename PositionT = file_position_base<
std::basic_string<
typename boost::detail::iterator_traits<ForwardIteratorT>::value_type
typename std::iterator_traits<ForwardIteratorT>::value_type
>
>
>

View File

@@ -324,7 +324,7 @@ namespace impl {
>
static typename parser_result<ParserT, ScannerT>::type
parse(ParserT const &, ScannerT const& scan, ActionT const &action,
NestedT const& nested_d)
NestedT const& /*nested_d*/)
{
return action.parse(scan);
}

View File

@@ -10,6 +10,7 @@
///////////////////////////////////////////////////////////////////////////////
#include <boost/spirit/home/classic/phoenix/tuples.hpp>
#include <boost/type_traits/remove_reference.hpp>
///////////////////////////////////////////////////////////////////////////////
namespace phoenix {
@@ -120,7 +121,7 @@ template <typename ActorT, typename TupleT>
struct actor_result {
typedef typename ActorT::template result<TupleT>::type type;
typedef typename remove_reference<type>::type plain_type;
typedef typename boost::remove_reference<type>::type plain_type;
};
//////////////////////////////////

View File

@@ -1374,13 +1374,13 @@ namespace impl {
<OperationT, actor<BaseT>, B>::type type;
static type
construct(actor<BaseT> const& _0, B const& _1)
construct(actor<BaseT> const& _0_, B const& _1_)
{
typedef typename make_composite
<OperationT, actor<BaseT>, B>::composite_type
ret_t;
return ret_t(OperationT(), _0, as_actor<B>::convert(_1));
return ret_t(OperationT(), _0_, as_actor<B>::convert(_1_));
}
};
@@ -1392,13 +1392,13 @@ namespace impl {
<OperationT, A, actor<BaseT> >::type type;
static type
construct(A const& _0, actor<BaseT> const& _1)
construct(A const& _0_, actor<BaseT> const& _1_)
{
typedef typename make_composite
<OperationT, A, actor<BaseT> >::composite_type
ret_t;
return ret_t(OperationT(), as_actor<A>::convert(_0), _1);
return ret_t(OperationT(), as_actor<A>::convert(_0_), _1_);
}
};
@@ -1410,13 +1410,13 @@ namespace impl {
<OperationT, actor<BaseA>, actor<BaseB> >::type type;
static type
construct(actor<BaseA> const& _0, actor<BaseB> const& _1)
construct(actor<BaseA> const& _0_, actor<BaseB> const& _1_)
{
typedef typename make_composite
<OperationT, actor<BaseA>, actor<BaseB> >::composite_type
ret_t;
return ret_t(OperationT(), _0, _1);
return ret_t(OperationT(), _0_, _1_);
}
};

View File

@@ -20,6 +20,7 @@
///////////////////////////////////////////////////////////////////////////////
#include <boost/spirit/home/classic/phoenix/operators.hpp>
#include <iosfwd>
#include <complex>
///////////////////////////////////////////////////////////////////////////////
#if defined(_STLPORT_VERSION) && defined(__STL_USE_OWN_NAMESPACE)
@@ -29,18 +30,6 @@
#define PHOENIX_STD std
#endif
///////////////////////////////////////////////////////////////////////////////
//#if !defined(PHOENIX_NO_STD_NAMESPACE)
namespace PHOENIX_STD
{
//#endif
template<typename T> class complex;
//#if !defined(PHOENIX_NO_STD_NAMESPACE)
}
//#endif
///////////////////////////////////////////////////////////////////////////////
namespace phoenix
{

View File

@@ -207,7 +207,7 @@ struct tuple_element
typedef nil_t& rtype;
typedef nil_t const& crtype;
static nil_t get(TupleT const& t) { return nil_t(); }
static nil_t get(TupleT const&) { return nil_t(); }
};
//////////////////////////////////

View File

@@ -10,7 +10,7 @@
#define BOOST_SPIRIT_TST_IPP
///////////////////////////////////////////////////////////////////////////////
#include <memory> // for std::auto_ptr
#include <boost/move/unique_ptr.hpp>
#include <boost/spirit/home/classic/core/assert.hpp>
///////////////////////////////////////////////////////////////////////////////
@@ -62,7 +62,7 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
tst_node*
clone() const
{
std::auto_ptr<tst_node> copy(new tst_node(value));
boost::movelib::unique_ptr<tst_node> copy(new tst_node(value));
if (left)
copy->left = left->clone();
@@ -75,7 +75,7 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
}
else
{
std::auto_ptr<T> mid_data(new T(*middle.data));
boost::movelib::unique_ptr<T> mid_data(new T(*middle.data));
copy->middle.data = mid_data.release();
}

View File

@@ -301,15 +301,15 @@ ast_parse(
SkipT const& skip_,
AstFactoryT const & /*dummy_*/ = AstFactoryT())
{
typedef skip_parser_iteration_policy<SkipT> iter_policy_t;
typedef skip_parser_iteration_policy<SkipT> it_policy_t;
typedef ast_match_policy<IteratorT, AstFactoryT> ast_match_policy_t;
typedef
scanner_policies<iter_policy_t, ast_match_policy_t>
scanner_policies_t;
typedef scanner<IteratorT, scanner_policies_t> scanner_t;
scanner_policies<it_policy_t, ast_match_policy_t>
scan_policies_t;
typedef scanner<IteratorT, scan_policies_t> scanner_t;
iter_policy_t iter_policy(skip_);
scanner_policies_t policies(iter_policy);
it_policy_t iter_policy(skip_);
scan_policies_t policies(iter_policy);
IteratorT first = first_;
scanner_t scan(first, last_, policies);
tree_match<IteratorT, AstFactoryT> hit = parser.derived().parse(scan);

View File

@@ -26,7 +26,6 @@
#include <boost/call_traits.hpp>
#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/spirit/home/classic/core.hpp>
#include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits
#include <boost/assert.hpp>
#if defined(BOOST_SPIRIT_DEBUG) && \
@@ -37,6 +36,8 @@
#include <boost/spirit/home/classic/tree/common_fwd.hpp>
#include <iterator> // for std::iterator_traits, std::distance
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
@@ -242,7 +243,7 @@ template <typename IteratorT = char const*, typename ValueT = nil_t>
struct node_val_data
{
typedef
typename boost::detail::iterator_traits<IteratorT>::value_type
typename std::iterator_traits<IteratorT>::value_type
value_type;
#if !defined(BOOST_SPIRIT_USE_BOOST_ALLOCATOR_FOR_TREES)

View File

@@ -210,15 +210,15 @@ pt_parse(
SkipT const& skip,
NodeFactoryT const& /*dummy_*/ = NodeFactoryT())
{
typedef skip_parser_iteration_policy<SkipT> iter_policy_t;
typedef skip_parser_iteration_policy<SkipT> it_policy_t;
typedef pt_match_policy<IteratorT, NodeFactoryT> pt_match_policy_t;
typedef
scanner_policies<iter_policy_t, pt_match_policy_t>
scanner_policies_t;
typedef scanner<IteratorT, scanner_policies_t> scanner_t;
scanner_policies<it_policy_t, pt_match_policy_t>
scan_policies_t;
typedef scanner<IteratorT, scan_policies_t> scanner_t;
iter_policy_t iter_policy(skip);
scanner_policies_t policies(iter_policy);
it_policy_t iter_policy(skip);
scan_policies_t policies(iter_policy);
IteratorT first = first_;
scanner_t scan(first, last, policies);
tree_match<IteratorT, NodeFactoryT> hit = p.derived().parse(scan);

View File

@@ -34,7 +34,9 @@
// Utility.Support
#include <boost/spirit/home/classic/utility/flush_multi_pass.hpp>
#ifdef BOOST_SPIRIT_THREADSAFE
#include <boost/spirit/home/classic/utility/scoped_lock.hpp>
#endif
#endif // !defined(BOOST_SPIRIT_UTILITY_MAIN_HPP)

View File

@@ -33,7 +33,7 @@ const unsigned long lex_escapes = c_escapes << 1;
namespace impl {
//////////////////////////////////
#if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310))
#if defined(BOOST_MSVC)
#pragma warning(push)
#pragma warning(disable:4127)
#endif

View File

@@ -14,6 +14,8 @@
#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/spirit/home/classic/core/parser.hpp>
#include <boost/spirit/home/classic/core/composite/composite.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit {

View File

@@ -47,7 +47,7 @@
#include <boost/spirit/home/classic/meta/as_parser.hpp>
#include <boost/spirit/home/classic/core/parser.hpp>
#include <boost/spirit/home/classic/utility/impl/regex.ipp>
#include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits
#include <iterator> // for std::iterator_traits
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit {
@@ -75,7 +75,7 @@ struct rxstrlit : public parser<rxstrlit<CharT> > {
// forward iterators do not work here.
typedef typename ScannerT::iterator_t iterator_t;
typedef
typename boost::detail::iterator_traits<iterator_t>::iterator_category
typename std::iterator_traits<iterator_t>::iterator_category
iterator_category;
BOOST_STATIC_ASSERT((

View File

@@ -8,23 +8,12 @@
#if !defined(SPIRIT_CLASSIC_VERSION_HPP)
#define SPIRIT_CLASSIC_VERSION_HPP
///////////////////////////////////////////////////////////////////////////////
//
// This checks, whether the used Boost library is at least V1.32.0
//
///////////////////////////////////////////////////////////////////////////////
#include <boost/version.hpp>
#if BOOST_VERSION < 103200
#error "Spirit v1.8.x needs at least Boost V1.32.0 to compile successfully."
#endif
///////////////////////////////////////////////////////////////////////////////
//
// This is the version of the current Spirit distribution
//
///////////////////////////////////////////////////////////////////////////////
#define SPIRIT_VERSION 0x1806
#define SPIRIT_VERSION 0x1811
#define SPIRIT_PIZZA_VERSION SPIRIT_MEGA_VEGGI // :-)
#endif // defined(SPIRIT_VERSION_HPP)

View File

@@ -53,16 +53,14 @@ namespace boost { namespace spirit { namespace karma
, Attribute const& attr_) const
{
typedef typename attribute<Context, unused_type>::type attr_type;
typedef traits::make_attribute<attr_type, Attribute> make_attribute;
// create a attribute if none is supplied
// this creates a _copy_ of the attribute because the semantic
// action will likely change parts of this
typedef traits::transform_attribute<
typename make_attribute::type, attr_type, domain> transform;
Attribute const, attr_type, domain> transform;
typename transform::type attr =
traits::pre_transform<domain, attr_type>(make_attribute::call(attr_));
attr_type attr = transform::pre(attr_);
// call the function, passing the attribute, the context and a bool
// flag that the client can set to false to fail generating.

View File

@@ -31,9 +31,7 @@ namespace boost { namespace spirit
namespace boost { namespace spirit { namespace karma
{
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
using spirit::attr_cast;
#endif
///////////////////////////////////////////////////////////////////////////
// attr_cast_generator consumes the attribute of subject generator without

View File

@@ -59,7 +59,7 @@ namespace boost { namespace spirit { namespace karma
, typename Delimiter, typename Attribute>
bool lazy_generate_impl(Generator const& g, OutputIterator& sink
, Context& context, Delimiter const& delim
, Attribute const& attr, mpl::true_)
, Attribute const& /* attr */, mpl::true_)
{
// If DeducedAuto is false (semantic actions is present), the
// component's attribute is unused.

View File

@@ -194,11 +194,11 @@ namespace boost { namespace spirit { namespace karma
};
///////////////////////////////////////////////////////////////////////
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 info is()
{
@@ -207,7 +207,7 @@ namespace boost { namespace spirit { namespace karma
};
template <>
struct what<boost::endian::endianness::little>
struct what<boost::spirit::endian::endianness::little>
{
static info is()
{
@@ -216,7 +216,7 @@ namespace boost { namespace spirit { namespace karma
};
template <>
struct what<boost::endian::endianness::big>
struct what<boost::spirit::endian::endianness::big>
{
static info is()
{
@@ -226,7 +226,7 @@ namespace boost { namespace spirit { namespace karma
}
///////////////////////////////////////////////////////////////////////////
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_generator
: primitive_generator<any_binary_generator<T, endian, bits> >
{
@@ -245,7 +245,7 @@ namespace boost { namespace spirit { namespace karma
// Even if the endian types are not pod's (at least not in the
// definition of C++03) it seems to be safe to assume they are.
// This allows us to treat them as a sequence of consecutive bytes.
boost::endian::endian<endian, typename T::type, bits> p;
boost::spirit::endian::endian<endian, typename T::type, bits> p;
#if defined(BOOST_MSVC)
// warning C4244: 'argument' : conversion from 'const int' to 'foo', possible loss of data
@@ -293,7 +293,7 @@ namespace boost { namespace spirit { namespace karma
};
///////////////////////////////////////////////////////////////////////////
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 literal_binary_generator
: primitive_generator<literal_binary_generator<T, endian, bits> >
{
@@ -344,7 +344,7 @@ namespace boost { namespace spirit { namespace karma
return karma::detail::what<endian>::is();
}
typedef boost::endian::endian<endian, typename T::type,
typedef boost::spirit::endian::endian<endian, typename T::type,
bits> data_type;
data_type data_;
@@ -355,7 +355,7 @@ namespace boost { namespace spirit { namespace karma
///////////////////////////////////////////////////////////////////////////
namespace detail
{
template <typename T, BOOST_SCOPED_ENUM(boost::endian::endianness) endian
template <typename T, BOOST_SCOPED_ENUM(boost::spirit::endian::endianness) endian
, int bits>
struct basic_binary
{
@@ -368,7 +368,7 @@ namespace boost { namespace spirit { namespace karma
};
template <typename Modifiers, typename T
, BOOST_SCOPED_ENUM(boost::endian::endianness) endian, int bits>
, BOOST_SCOPED_ENUM(boost::spirit::endian::endianness) endian, int bits>
struct basic_binary_literal
{
typedef literal_binary_generator<T, endian, bits> result_type;
@@ -385,13 +385,13 @@ namespace boost { namespace spirit { namespace karma
template <typename Modifiers> \
struct make_primitive<tag::name, Modifiers> \
: detail::basic_binary<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> \
: detail::basic_binary_literal<Modifiers, detail::integer<bits> \
, boost::endian::endianness::endiantype, bits> {}; \
, boost::spirit::endian::endianness::endiantype, bits> {}; \
\
/***/
@@ -414,13 +414,13 @@ namespace boost { namespace spirit { namespace karma
template <typename Modifiers> \
struct make_primitive<tag::name, Modifiers> \
: detail::basic_binary<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> \
: detail::basic_binary_literal<Modifiers, detail::floating_point<bits> \
, boost::endian::endianness::endiantype, bits> {}; \
, boost::spirit::endian::endianness::endiantype, bits> {}; \
\
/***/

View File

@@ -180,7 +180,7 @@ namespace boost { namespace spirit { namespace karma
bool test(Attribute const& attr, CharParam& ch_, Context&) const
{
// fail if attribute isn't matched my immediate literal
ch_ = attr;
ch_ = static_cast<char_type>(attr);
return attr == ch;
}

View File

@@ -90,7 +90,7 @@ namespace boost { namespace spirit { namespace karma { namespace detail
component; // suppresses warning: C4100: 'component' : unreferenced formal parameter
#endif
return call(component, sink, ctx, d, attr
, spirit::traits::not_is_variant<Attribute, karma::domain>());
, spirit::traits::not_is_variant_or_variant_in_optional<Attribute, karma::domain>());
}
template <typename OutputIterator, typename Context, typename Delimiter>

View File

@@ -44,22 +44,6 @@ namespace boost { namespace spirit { namespace karma
// Karma only, no post() and no fail() required
};
// reference types need special handling
template <typename Exposed, typename Transformed>
struct transform_attribute<Exposed&, Transformed>
: transform_attribute<Exposed, Transformed>
{};
template <typename Exposed, typename Transformed>
struct transform_attribute<Exposed const&, Transformed>
: transform_attribute<Exposed const, Transformed>
{};
template <typename Attribute>
struct transform_attribute<Attribute const&, Attribute>
: transform_attribute<Attribute const, Attribute>
{};
// unused_type needs some special handling as well
template <>
struct transform_attribute<unused_type, unused_type>
@@ -73,16 +57,6 @@ namespace boost { namespace spirit { namespace karma
: 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>
@@ -95,14 +69,12 @@ namespace boost { namespace spirit { namespace karma
}}}
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace traits
namespace boost { namespace spirit { namespace traits { namespace detail
{
template <typename Exposed, typename Transformed>
struct transform_attribute<Exposed, Transformed, karma::domain>
struct transform_attribute_base<Exposed, Transformed, karma::domain>
: karma::transform_attribute<Exposed, Transformed>
{};
}}}
}}}}
#endif

View File

@@ -44,40 +44,45 @@ namespace boost { namespace spirit { namespace traits
}
// This is the default case: the plain attribute values
template <typename Attribute, typename Exposed, typename Enable/*= void*/>
struct extract_from_attribute
template <typename Attribute, typename Exposed
, bool IsOneElemSeq = traits::one_element_sequence<Attribute>::value>
struct extract_from_attribute_base
{
typedef typename traits::one_element_sequence<Attribute>::type
is_one_element_sequence;
typedef typename mpl::eval_if<
is_one_element_sequence
, detail::value_at_c<Attribute, 0>
, mpl::identity<Attribute const&>
>::type type;
typedef Attribute const& type;
template <typename Context>
static type call(Attribute const& attr, Context&, mpl::false_)
static type call(Attribute const& attr, Context&)
{
return attr;
}
};
// This handles the case where the attribute is a single element fusion
// sequence. We silently extract the only element and treat it as the
// attribute to generate output from.
template <typename Context>
static type call(Attribute const& attr, Context& ctx, mpl::true_)
{
return extract_from<Exposed>(fusion::at_c<0>(attr), ctx);
}
// This handles the case where the attribute is a single element fusion
// sequence. We silently extract the only element and treat it as the
// attribute to generate output from.
template <typename Attribute, typename Exposed>
struct extract_from_attribute_base<Attribute, Exposed, true>
{
typedef typename remove_const<
typename remove_reference<
typename fusion::result_of::at_c<Attribute, 0>::type
>::type
>::type elem_type;
typedef typename result_of::extract_from<Exposed, elem_type>::type type;
template <typename Context>
static type call(Attribute const& attr, Context& ctx)
{
return call(attr, ctx, is_one_element_sequence());
return extract_from<Exposed>(fusion::at_c<0>(attr), ctx);
}
};
template <typename Attribute, typename Exposed, typename Enable/*= void*/>
struct extract_from_attribute
: extract_from_attribute_base<Attribute, Exposed>
{};
// This handles optional attributes.
template <typename Attribute, typename Exposed>
struct extract_from_attribute<boost::optional<Attribute>, Exposed>

View File

@@ -12,6 +12,7 @@
#include <boost/spirit/home/support/unused.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <iterator> // for std::iterator_traits
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace karma { namespace detail
@@ -23,13 +24,13 @@ namespace boost { namespace spirit { namespace karma { namespace detail
class indirect_iterator
: public boost::iterator_facade<
indirect_iterator<Iterator>
, typename boost::detail::iterator_traits<Iterator>::value_type
, typename std::iterator_traits<Iterator>::value_type
, boost::forward_traversal_tag
, typename boost::detail::iterator_traits<Iterator>::reference>
, typename std::iterator_traits<Iterator>::reference>
{
typedef typename boost::detail::iterator_traits<Iterator>::value_type
typedef typename std::iterator_traits<Iterator>::value_type
base_value_type;
typedef typename boost::detail::iterator_traits<Iterator>::reference
typedef typename std::iterator_traits<Iterator>::reference
base_reference_type;
typedef boost::iterator_facade<

View File

@@ -191,7 +191,7 @@ namespace boost { namespace spirit { namespace karma { namespace detail
// wchar_t is only 16-bits on Windows. If BOOST_SPIRIT_UNICODE is
// defined, the character type is 32-bits wide so we need to make
// sure the buffer is at least that wide.
#if defined(BOOST_MSVC) && defined(BOOST_SPIRIT_UNICODE)
#if (defined(_WIN32) || defined(__CYGWIN__)) && defined(BOOST_SPIRIT_UNICODE)
typedef spirit::char_encoding::unicode::char_type buffer_char_type;
#else
typedef wchar_t buffer_char_type;
@@ -304,7 +304,7 @@ namespace boost { namespace spirit { namespace karma { namespace detail
struct no_buffering_policy
{
no_buffering_policy() {}
no_buffering_policy(no_counting_policy const&) {}
no_buffering_policy(no_buffering_policy const&) {}
template <typename T>
bool output(T const& /*value*/)

View File

@@ -26,7 +26,6 @@
#include <boost/spirit/home/support/unused.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/integer_traits.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/utility/enable_if.hpp>

View File

@@ -26,7 +26,6 @@
#include <boost/spirit/home/support/handles_container.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/integer_traits.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/utility/enable_if.hpp>

View File

@@ -26,7 +26,6 @@
#include <boost/spirit/home/support/unused.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/detail/workaround.hpp>
///////////////////////////////////////////////////////////////////////////////

View File

@@ -26,7 +26,6 @@
#include <boost/spirit/home/support/unused.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/integer_traits.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/utility/enable_if.hpp>

View File

@@ -178,7 +178,7 @@ namespace boost { namespace spirit { namespace karma
}
template <typename Auto, typename Expr>
static void define(rule& lhs, Expr const& expr, mpl::false_)
static void define(rule& /* lhs */, Expr const& /* expr */, mpl::false_)
{
// Report invalid expression error as early as possible.
// If you got an error_invalid_expression error message here,
@@ -286,15 +286,11 @@ namespace boost { namespace spirit { namespace karma
if (f)
{
// Create an attribute if none is supplied.
typedef traits::make_attribute<attr_type, Attribute>
make_attribute;
typedef traits::transform_attribute<
typename make_attribute::type, attr_type, domain>
Attribute const, attr_type, domain>
transform;
typename transform::type attr_ =
traits::pre_transform<domain, attr_type>(
make_attribute::call(attr));
typename transform::type attr_ = transform::pre(attr);
// If you are seeing a compilation error here, you are probably
// trying to use a rule or a grammar which has inherited
@@ -326,15 +322,11 @@ namespace boost { namespace spirit { namespace karma
if (f)
{
// Create an attribute if none is supplied.
typedef traits::make_attribute<attr_type, Attribute>
make_attribute;
typedef traits::transform_attribute<
typename make_attribute::type, attr_type, domain>
Attribute const, attr_type, domain>
transform;
typename transform::type attr_ =
traits::pre_transform<domain, attr_type>(
make_attribute::call(attr));
typename transform::type attr_ = transform::pre(attr);
// If you are seeing a compilation error here, you are probably
// trying to use a rule or a grammar which has inherited

View File

@@ -14,6 +14,7 @@
#include <boost/config/no_tr1/cmath.hpp>
#include <boost/limits.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/spirit/home/support/char_class.hpp>
#include <boost/spirit/home/support/unused.hpp>
@@ -68,7 +69,11 @@ namespace boost { namespace spirit { namespace traits
typedef unsignedtype type; \
static type call(signedtype n) \
{ \
return (n >= 0) ? n : (unsignedtype)(-n); \
/* implementation is well-defined for one's complement, */ \
/* two's complement, and signed magnitude architectures */ \
/* by the C++ Standard. [conv.integral] [expr.unary.op] */ \
return (n >= 0) ? static_cast<type>(n) \
: -static_cast<type>(n); \
} \
} \
/**/
@@ -84,6 +89,11 @@ namespace boost { namespace spirit { namespace traits
} \
/**/
#if defined(BOOST_MSVC)
# pragma warning(push)
// unary minus operator applied to unsigned type, result still unsigned
# pragma warning(disable: 4146)
#endif
BOOST_SPIRIT_ABSOLUTE_VALUE(signed char, unsigned char);
BOOST_SPIRIT_ABSOLUTE_VALUE(char, unsigned char);
BOOST_SPIRIT_ABSOLUTE_VALUE(short, unsigned short);
@@ -97,6 +107,9 @@ namespace boost { namespace spirit { namespace traits
BOOST_SPIRIT_ABSOLUTE_VALUE(boost::long_long_type, boost::ulong_long_type);
BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED(boost::ulong_long_type);
#endif
#if defined(BOOST_MSVC)
# pragma warning(pop)
#endif
#undef BOOST_SPIRIT_ABSOLUTE_VALUE
#undef BOOST_SPIRIT_ABSOLUTE_VALUE_UNSIGNED
@@ -285,7 +298,7 @@ namespace boost { namespace spirit { namespace traits
{
static bool call(T n)
{
if (!std::numeric_limits<T>::has_infinity)
if (!std::numeric_limits<T>::has_infinity)
return false;
return (n == std::numeric_limits<T>::infinity()) ? true : false;
}
@@ -771,4 +784,3 @@ namespace boost { namespace spirit { namespace karma
}}}
#endif

View File

@@ -105,7 +105,13 @@ namespace boost { namespace spirit { namespace karma
if (exp != -dim)
++exp;
dim = static_cast<U>(-exp);
n *= spirit::traits::pow10<U>(exp);
// detect and handle denormalized numbers to prevent overflow in pow10
if (exp > std::numeric_limits<U>::max_exponent10)
{
n *= spirit::traits::pow10<U>(std::numeric_limits<U>::max_exponent10);
n *= spirit::traits::pow10<U>(exp - std::numeric_limits<U>::max_exponent10);
} else
n *= spirit::traits::pow10<U>(exp);
}
}

View File

@@ -25,9 +25,13 @@ namespace boost { namespace spirit { namespace karma
typename T, typename Elem = char
, typename Traits = std::char_traits<Elem> >
class ostream_iterator
: public std::iterator<std::output_iterator_tag, void, void, void, void>
{
public:
typedef std::output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
typedef Elem char_type;
typedef Traits traits_type;
typedef std::basic_ostream<Elem, Traits> ostream_type;

View File

@@ -20,10 +20,10 @@
#include <boost/spirit/home/lex/lexer/token_def.hpp>
#include <boost/assert.hpp>
#include <boost/noncopyable.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/range/iterator_range.hpp>
#include <iterator> // for std::iterator_traits
#include <string>
namespace boost { namespace spirit { namespace lex
@@ -83,7 +83,7 @@ namespace boost { namespace spirit { namespace lex
if (first != last) {
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
token_type;
token_type const& t = *first;
@@ -376,8 +376,16 @@ namespace boost { namespace spirit { namespace lex
typedef detail::lexer_def_<lexer> lexer_def;
typedef std::basic_string<char_type> string_type;
lexer(unsigned int flags = match_flags::match_default
, id_type first_id = id_type(min_token_id))
// if `id_type` was specified but `first_id` is not provided
// the `min_token_id` value may be out of range for `id_type`,
// but it will be a problem only if unique ids feature is in use.
lexer(unsigned int flags = match_flags::match_default)
: lexer_type(flags)
, next_token_id(min_token_id)
, self(this_(), lexer_type::initial_state())
{}
lexer(unsigned int flags, id_type first_id)
: lexer_type(flags)
, next_token_id(first_id)
, self(this_(), lexer_type::initial_state())

View File

@@ -11,10 +11,10 @@
#endif
#include <boost/mpl/bool.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/spirit/home/lex/lexer/pass_flags.hpp>
#include <boost/assert.hpp>
#include <iterator> // for std::iterator_traits
#if 0 != __COMO_VERSION__ || !BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
#define BOOST_SPIRIT_STATIC_EOF 1
@@ -66,7 +66,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
{
public:
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
char_type;
private:
@@ -98,11 +98,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
};
public:
functor()
#if defined(__PGI)
: eof()
#endif
{}
functor() {}
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
// somehow VC7.1 needs this (meaningless) assignment operator

View File

@@ -19,6 +19,7 @@
#include <boost/spirit/home/lex/lexer/lexertl/wrap_action.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/optional.hpp>
#include <iterator> // for std::iterator_traits
namespace boost { namespace spirit { namespace lex { namespace lexertl
{
@@ -36,7 +37,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
{
protected:
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
char_type;
public:

View File

@@ -19,7 +19,6 @@
#include <boost/spirit/home/support/detail/lexer/debug.hpp>
#include <boost/spirit/home/lex/lexer/lexertl/static_version.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/scoped_array.hpp>
///////////////////////////////////////////////////////////////////////////////
@@ -156,9 +155,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
os_ << "struct lexer" << suffix << "\n{\n";
os_ << " // version number and feature-set of compatible static lexer engine\n";
os_ << " enum\n";
os_ << " {\n static_version = "
<< boost::lexical_cast<std::basic_string<Char> >(SPIRIT_STATIC_LEXER_VERSION)
<< ",\n";
os_ << " {\n static_version = " << SPIRIT_STATIC_LEXER_VERSION << ",\n";
os_ << " supports_bol = " << std::boolalpha << bol << ",\n";
os_ << " supports_eol = " << std::boolalpha << eol << "\n";
os_ << " };\n\n";
@@ -415,7 +412,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
{
os_ << " std::size_t index = *curr_++\n";
}
os_ << " bol = (index == '\n') ? true : false;\n";
os_ << " bol = (index == '\\n') ? true : false;\n";
os_ << " std::size_t const state_ = ptr_[\n";
os_ << " lookup_[static_cast<std::size_t>(index)]];\n";
@@ -442,7 +439,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
{
os_ << " std::size_t index = *curr_++\n";
}
os_ << " bol = (index == '\n') ? true : false;\n";
os_ << " bol = (index == '\\n') ? true : false;\n";
os_ << " std::size_t const state_ = ptr_[\n";
os_ << " lookup_[static_cast<std::size_t>(index)]];\n";
@@ -469,7 +466,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
{
os_ << " std::size_t index = *curr_++\n";
}
os_ << " bol = (index == '\n') ? true : false;\n";
os_ << " bol = (index == '\\n') ? true : false;\n";
os_ << " std::size_t const state_ = ptr_[\n";
os_ << " lookup_[static_cast<std::size_t>(index)]];\n";
@@ -577,7 +574,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
if (sm_.data()._seen_BOL_assertion)
{
os_ << " bol_ = (*start_token_ == '\n') ? true : false;\n";
os_ << " bol_ = (*start_token_ == '\\n') ? true : false;\n";
}
os_ << " id_ = npos;\n";
@@ -749,7 +746,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
}
if (iter_->eol_index != boost::lexer::npos)
{
os_ << "\n if (ch_ == '\n') goto state" << dfa_
os_ << "\n if (ch_ == '\\n') goto state" << dfa_
<< '_' << iter_->eol_index << ";\n";
}
os_ << " ++curr_;\n";
@@ -911,7 +908,6 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
os_ << "#if !defined(BOOST_SPIRIT_LEXER_NEXT_TOKEN_" << guard << ")\n";
os_ << "#define BOOST_SPIRIT_LEXER_NEXT_TOKEN_" << guard << "\n\n";
os_ << "#include <boost/detail/iterator.hpp>\n";
os_ << "#include <boost/spirit/home/support/detail/lexer/char_traits.hpp>\n\n";
generate_delimiter(os_);

View File

@@ -10,11 +10,11 @@
#pragma once
#endif
#include <boost/detail/iterator.hpp>
#include <boost/spirit/home/support/detail/lexer/state_machine.hpp>
#include <boost/spirit/home/support/detail/lexer/consts.hpp>
#include <boost/spirit/home/support/detail/lexer/size_t.hpp>
#include <boost/spirit/home/support/detail/lexer/char_traits.hpp>
#include <iterator> // for std::iterator_traits
#include <vector>
namespace boost { namespace spirit { namespace lex { namespace lexertl
@@ -25,8 +25,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
{
public:
typedef std::vector<std::size_t> size_t_vector;
typedef typename boost::detail::iterator_traits<Iterator>::value_type
char_type;
typedef typename std::iterator_traits<Iterator>::value_type char_type;
static std::size_t next (
boost::lexer::basic_state_machine<char_type> const& state_machine_
@@ -74,7 +73,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
else
{
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
value_type;
typedef typename
boost::lexer::char_traits<value_type>::index_type
@@ -188,7 +187,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
else
{
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
value_type;
typedef typename
boost::lexer::char_traits<value_type>::index_type

View File

@@ -27,6 +27,8 @@
#include <boost/foreach.hpp>
#include <iterator> // for std::iterator_traits
namespace boost { namespace spirit { namespace lex { namespace lexertl
{
///////////////////////////////////////////////////////////////////////////
@@ -158,8 +160,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
operator safe_bool() const
{ return initialized_dfa_ ? &dummy::true_ : 0; }
typedef typename boost::detail::iterator_traits<Iterator>::value_type
char_type;
typedef typename std::iterator_traits<Iterator>::value_type char_type;
typedef std::basic_string<char_type> string_type;
typedef boost::lexer::basic_rules<char_type> basic_rules_type;

View File

@@ -23,7 +23,6 @@
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/value_at.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/variant.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/bool.hpp>

View File

@@ -18,6 +18,7 @@
#include <boost/spirit/home/lex/lexer/lexertl/wrap_action.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <iterator> // for std::iterator_traits
namespace boost { namespace spirit { namespace lex { namespace lexertl
{
@@ -48,7 +49,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
{
protected:
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
char_type;
public:

View File

@@ -18,6 +18,7 @@
#if defined(BOOST_SPIRIT_DEBUG)
#include <boost/spirit/home/support/detail/lexer/debug.hpp>
#endif
#include <iterator> // for std::iterator_traits
namespace boost { namespace spirit { namespace lex { namespace lexertl
{
@@ -119,8 +120,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
// object is always valid
operator safe_bool() const { return &dummy::true_; }
typedef typename boost::detail::iterator_traits<Iterator>::value_type
char_type;
typedef typename std::iterator_traits<Iterator>::value_type char_type;
typedef std::basic_string<char_type> string_type;
// Every lexer type to be used as a lexer for Spirit has to conform to

View File

@@ -23,7 +23,6 @@
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/value_at.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/variant.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/vector.hpp>
@@ -33,6 +32,7 @@
#include <boost/mpl/vector.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/type_traits/integral_promotion.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/static_assert.hpp>
@@ -155,10 +155,10 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
// this default conversion operator is needed to allow the direct
// usage of tokens in conjunction with the primitive parsers defined
// in Qi
operator id_type() const { return id_; }
operator id_type() const { return static_cast<id_type>(id_); }
// Retrieve or set the token id of this token instance.
id_type id() const { return id_; }
id_type id() const { return static_cast<id_type>(id_); }
void id(id_type newid) { id_ = newid; }
std::size_t state() const { return 0; } // always '0' (INITIAL state)
@@ -187,7 +187,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl
#endif
protected:
id_type id_; // token id, 0 if nothing has been matched
typename boost::integral_promotion<id_type>::type id_; // token id, 0 if nothing has been matched
};
#if defined(BOOST_SPIRIT_DEBUG)

View File

@@ -24,10 +24,10 @@
#include <boost/fusion/include/vector.hpp>
#include <boost/mpl/if.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/variant.hpp>
#include <iterator> // for std::iterator_traits
#include <string>
#include <cstdlib>
@@ -92,7 +92,7 @@ namespace boost { namespace spirit { namespace lex
if (first != last) {
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
token_type;
// If the following assertion fires you probably forgot to

View File

@@ -26,6 +26,7 @@
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/lexical_cast.hpp>
#include <iterator> // for std::iterator_traits
namespace boost { namespace spirit
{
@@ -85,7 +86,7 @@ namespace boost { namespace spirit { namespace qi
// been initialized with
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
token_type;
typedef typename token_type::id_type id_type;

View File

@@ -27,6 +27,7 @@
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/lexical_cast.hpp>
#include <iterator> // for std::iterator_traits
namespace boost { namespace spirit
{
@@ -102,7 +103,7 @@ namespace boost { namespace spirit { namespace qi
// been initialized with
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
token_type;
typedef typename token_type::id_type id_type;
@@ -154,12 +155,12 @@ namespace boost { namespace spirit { namespace qi
// been initialized with
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
token_type;
typedef typename token_type::id_type id_type;
token_type const& t = *first;
if (id_type(idmin) >= t.id() && id_type(idmin) <= t.id())
if (id_type(idmax) >= t.id() && id_type(idmin) <= t.id())
{
spirit::traits::assign_to(t, attr);
++first;

View File

@@ -27,6 +27,7 @@
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/lexical_cast.hpp>
#include <iterator> // for std::iterator_traits
namespace boost { namespace spirit
{
@@ -104,7 +105,7 @@ namespace boost { namespace spirit { namespace qi
// been initialized with
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
token_type;
typedef typename token_type::id_type id_type;
@@ -155,7 +156,7 @@ namespace boost { namespace spirit { namespace qi
// been initialized with
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
token_type;
typedef typename token_type::id_type id_type;

View File

@@ -26,6 +26,7 @@
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/lexical_cast.hpp>
#include <iterator> // for std::iterator_traits
namespace boost { namespace spirit
{
@@ -84,7 +85,7 @@ namespace boost { namespace spirit { namespace qi
// been initialized with
typedef typename
boost::detail::iterator_traits<Iterator>::value_type
std::iterator_traits<Iterator>::value_type
token_type;
typedef typename token_type::id_type id_type;

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
{

View File

@@ -193,14 +193,25 @@ namespace boost { namespace spirit { namespace traits
struct extract_from_attribute<
fusion::extension::adt_attribute_proxy<T, N, Const>, Exposed>
{
typedef
typename fusion::extension::adt_attribute_proxy<T, N, Const>::type
get_return_type;
typedef typename remove_const<
typename remove_reference<
typename fusion::extension::adt_attribute_proxy<T, N, Const>::type
get_return_type
>::type
>::type embedded_type;
typedef
typename spirit::result_of::extract_from<Exposed, embedded_type>::type
type;
extracted_type;
// If adt_attribute_proxy returned a value we must pass the attribute
// by value, otherwise we will end up with a reference to a temporary
// that will expire out of scope of the function call.
typedef typename mpl::if_c<is_reference<get_return_type>::value
, extracted_type
, typename remove_reference<extracted_type>::type
>::type type;
template <typename Context>
static type

View File

@@ -48,7 +48,10 @@ namespace boost { namespace spirit
any_if_ns(First1 const& first1, First2 const& first2
, Last1 const& last1, Last2 const& last2, F& f, mpl::false_)
{
return (0 != (f(*first1, spirit::detail::attribute_value<Pred, First1, Last2>(first2)) |
typename result_of::attribute_value<First1, First2, Last2, Pred>::type
attribute = spirit::detail::attribute_value<Pred, First1, Last2>(first2);
return (0 != (f(*first1, attribute) |
detail::any_if_ns<Pred>(
fusion::next(first1)
, attribute_next<Pred, First1, Last2>(first2)

View File

@@ -0,0 +1,95 @@
/*=============================================================================
Copyright (c) 2001-2011 Hartmut Kaiser
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(BOOST_SPIRIT_ANY_IF_NS_SO_DECEMBER_03_2017_0826PM)
#define BOOST_SPIRIT_ANY_IF_NS_SO_DECEMBER_03_2017_0826PM
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/spirit/home/support/algorithm/any_ns_so.hpp>
namespace boost { namespace spirit
{
///////////////////////////////////////////////////////////////////////////
// This is a special version for a binary fusion::any. The predicate
// is used to decide whether to advance the second iterator or not.
// This is needed for sequences containing components with unused
// attributes. The second iterator is advanced only if the attribute
// of the corresponding component iterator is not unused.
//
// This is a non-short circuiting (ns) strict order (so) version of the
// any_if algorithm.
///////////////////////////////////////////////////////////////////////////
namespace detail
{
template <
typename Pred, typename First1, typename Last1, typename First2
, typename Last2, typename F
>
inline bool
any_if_ns_so(First1 const&, First2 const&, Last1 const&, Last2 const&
, F const&, mpl::true_)
{
return false;
}
template <
typename Pred, typename First1, typename Last1, typename First2
, typename Last2, typename F
>
inline bool
any_if_ns_so(First1 const& first1, First2 const& first2
, Last1 const& last1, Last2 const& last2, F& f, mpl::false_)
{
typename result_of::attribute_value<First1, First2, Last2, Pred>::type
attribute = spirit::detail::attribute_value<Pred, First1, Last2>(first2);
bool head = f(*first1, attribute);
bool tail =
detail::any_if_ns_so<Pred>(
fusion::next(first1)
, attribute_next<Pred, First1, Last2>(first2)
, last1, last2
, f
, fusion::result_of::equal_to<
typename fusion::result_of::next<First1>::type, Last1>());
return head || tail;
}
}
template <typename Pred, typename Sequence1, typename Sequence2, typename F>
inline bool
any_if_ns_so(Sequence1 const& seq1, Sequence2& seq2, F f, Pred)
{
return detail::any_if_ns_so<Pred>(
fusion::begin(seq1), fusion::begin(seq2)
, fusion::end(seq1), fusion::end(seq2)
, f
, fusion::result_of::equal_to<
typename fusion::result_of::begin<Sequence1>::type
, typename fusion::result_of::end<Sequence1>::type>());
}
template <typename Pred, typename Sequence, typename F>
inline bool
any_if_ns_so(Sequence const& seq, unused_type const, F f, Pred)
{
return detail::any_ns_so(
fusion::begin(seq)
, fusion::end(seq)
, f
, fusion::result_of::equal_to<
typename fusion::result_of::begin<Sequence>::type
, typename fusion::result_of::end<Sequence>::type>());
}
}}
#endif

View File

@@ -0,0 +1,106 @@
/*=============================================================================
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(BOOST_SPIRIT_ANY_NS_SO_DECEMBER_03_2017_0826PM)
#define BOOST_SPIRIT_ANY_NS_SO_DECEMBER_03_2017_0826PM
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/mpl/bool.hpp>
#include <boost/fusion/include/equal_to.hpp>
#include <boost/fusion/include/next.hpp>
#include <boost/fusion/include/deref.hpp>
#include <boost/fusion/include/begin.hpp>
#include <boost/fusion/include/end.hpp>
#include <boost/fusion/include/any.hpp>
#include <boost/spirit/home/support/unused.hpp>
namespace boost { namespace spirit
{
// A non-short circuiting (ns) strict order (so) version of the any
// algorithm
namespace detail
{
template <typename First1, typename Last, typename First2, typename F>
inline bool
any_ns_so(First1 const&, First2 const&, Last const&, F const&, mpl::true_)
{
return false;
}
template <typename First1, typename Last, typename First2, typename F>
inline bool
any_ns_so(First1 const& first1, First2 const& first2, Last const& last, F& f, mpl::false_)
{
bool head = f(*first1, *first2);
bool tail =
detail::any_ns_so(
fusion::next(first1)
, fusion::next(first2)
, last
, f
, fusion::result_of::equal_to<
typename fusion::result_of::next<First1>::type, Last>());
return head || tail;
}
template <typename First, typename Last, typename F>
inline bool
any_ns_so(First const&, Last const&, F const&, mpl::true_)
{
return false;
}
template <typename First, typename Last, typename F>
inline bool
any_ns_so(First const& first, Last const& last, F& f, mpl::false_)
{
bool head = f(*first);
bool tail =
detail::any_ns_so(
fusion::next(first)
, last
, f
, fusion::result_of::equal_to<
typename fusion::result_of::next<First>::type, Last>());
return head || tail;
}
}
template <typename Sequence1, typename Sequence2, typename F>
inline bool
any_ns_so(Sequence1 const& seq1, Sequence2& seq2, F f)
{
return detail::any_ns_so(
fusion::begin(seq1)
, fusion::begin(seq2)
, fusion::end(seq1)
, f
, fusion::result_of::equal_to<
typename fusion::result_of::begin<Sequence1>::type
, typename fusion::result_of::end<Sequence1>::type>());
}
template <typename Sequence, typename F>
inline bool
any_ns_so(Sequence const& seq, unused_type, F f)
{
return detail::any_ns_so(
fusion::begin(seq)
, fusion::end(seq)
, f
, fusion::result_of::equal_to<
typename fusion::result_of::begin<Sequence>::type
, typename fusion::result_of::end<Sequence>::type>());
}
}}
#endif

View File

@@ -28,10 +28,9 @@
#include <boost/fusion/include/for_each.hpp>
#include <boost/fusion/include/is_view.hpp>
#include <boost/fusion/include/mpl.hpp>
#include <boost/foreach.hpp>
#include <boost/utility/value_init.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/end.hpp>
#include <boost/mpl/find_if.hpp>
@@ -46,6 +45,7 @@
#include <boost/variant.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/config.hpp>
#include <iterator> // for std::iterator_traits, std::distance
#include <vector>
#include <utility>
#include <ios>
@@ -279,11 +279,6 @@ namespace boost { namespace spirit { namespace traits
: mpl::false_
{};
template <typename T, typename Domain>
struct not_is_variant<boost::optional<T>, Domain>
: not_is_variant<T, Domain>
{};
// we treat every type as if it where the variant (as this meta function is
// invoked for variant types only)
template <typename T>
@@ -296,6 +291,11 @@ namespace boost { namespace spirit { namespace traits
: variant_type<T>
{};
template <typename T, typename Domain>
struct not_is_variant_or_variant_in_optional
: not_is_variant<typename variant_type<T>::type, Domain>
{};
///////////////////////////////////////////////////////////////////////////
// The compute_compatible_component_variant
///////////////////////////////////////////////////////////////////////////
@@ -339,7 +339,7 @@ namespace boost { namespace spirit { namespace traits
template <typename Variant, typename Expected>
struct compute_compatible_component_variant<Variant, Expected, mpl::false_
, typename enable_if<detail::has_types<Variant> >::type>
, typename enable_if<detail::has_types<typename variant_type<Variant>::type> >::type>
{
typedef typename traits::variant_type<Variant>::type variant_type;
typedef typename variant_type::types types;
@@ -372,7 +372,7 @@ namespace boost { namespace spirit { namespace traits
template <typename Expected, typename Attribute, typename Domain>
struct compute_compatible_component
: compute_compatible_component_variant<Attribute, Expected
, typename spirit::traits::not_is_variant<Attribute, Domain>::type> {};
, typename not_is_variant_or_variant_in_optional<Attribute, Domain>::type> {};
template <typename Expected, typename Domain>
struct compute_compatible_component<Expected, unused_type, Domain>
@@ -560,12 +560,12 @@ namespace boost { namespace spirit { namespace traits
template <typename Iterator>
struct attribute_size<iterator_range<Iterator> >
{
typedef typename boost::detail::iterator_traits<Iterator>::
typedef typename std::iterator_traits<Iterator>::
difference_type type;
static type call(iterator_range<Iterator> const& r)
{
return boost::detail::distance(r.begin(), r.end());
return std::distance(r.begin(), r.end());
}
};
@@ -924,6 +924,23 @@ namespace boost { namespace spirit { namespace traits
type;
};
namespace detail {
// Domain-agnostic class template partial specializations and
// type agnostic domain partial specializations are ambious.
// To resolve the ambiguity type agnostic domain partial
// specializations are dispatched via intermediate type.
template <typename Exposed, typename Transformed, typename Domain>
struct transform_attribute_base;
template <typename Attribute>
struct synthesize_attribute
{
typedef Attribute type;
static Attribute pre(unused_type) { return Attribute(); }
static void post(unused_type, Attribute const&) {}
static void fail(unused_type) {}
};
}
///////////////////////////////////////////////////////////////////////////
// transform_attribute
//
@@ -931,91 +948,32 @@ namespace boost { namespace spirit { namespace traits
// attributes. This template can be used as a customization point, where
// the user is able specify specific transformation rules for any attribute
// type.
//
// Note: the transformations involving unused_type are internal details
// and may be subject to change at any time.
//
///////////////////////////////////////////////////////////////////////////
template <typename Exposed, typename Transformed, typename Domain
, typename Enable/* = void*/>
struct transform_attribute;
///////////////////////////////////////////////////////////////////////////
template <typename Domain, typename Transformed, typename Exposed>
typename spirit::result_of::pre_transform<Exposed, Transformed, Domain>::type
pre_transform(Exposed& attr BOOST_PROTO_DISABLE_IF_IS_CONST(Exposed))
struct transform_attribute
: detail::transform_attribute_base<Exposed, Transformed, Domain>
{
return transform_attribute<Exposed, Transformed, Domain>::pre(attr);
}
template <typename Domain, typename Transformed, typename Exposed>
typename spirit::result_of::pre_transform<Exposed const, Transformed, Domain>::type
pre_transform(Exposed const& attr)
{
return transform_attribute<Exposed const, Transformed, Domain>::pre(attr);
}
///////////////////////////////////////////////////////////////////////////
// make_attribute
//
// All parsers and generators have specific attribute types.
// Spirit parsers and generators are passed an attribute; these are either
// references to the expected type, or an unused_type -- to flag that we do
// not care about the attribute. For semantic actions, however, we need to
// have a real value to pass to the semantic action. If the client did not
// provide one, we will have to synthesize the value. This class takes care
// of that. *Note that this behavior has changed. From Boost 1.47, semantic
// actions always take in the passed attribute as-is if the PP constant:
// BOOST_SPIRIT_ACTIONS_ALLOW_ATTR_COMPAT is defined.
///////////////////////////////////////////////////////////////////////////
template <typename Attribute, typename ActualAttribute>
struct make_attribute
{
typedef typename remove_const<Attribute>::type attribute_type;
typedef typename
mpl::if_<
is_same<typename remove_const<ActualAttribute>::type, unused_type>
, attribute_type
, ActualAttribute&>::type
type;
typedef typename
mpl::if_<
is_same<typename remove_const<ActualAttribute>::type, unused_type>
, attribute_type
, ActualAttribute>::type
value_type;
static Attribute call(unused_type)
{
// synthesize the attribute/parameter
return boost::get(value_initialized<attribute_type>());
}
template <typename T>
static T& call(T& value)
{
return value; // just pass the one provided
}
BOOST_STATIC_ASSERT_MSG(!is_reference<Exposed>::value,
"Exposed cannot be a reference type");
BOOST_STATIC_ASSERT_MSG(!is_reference<Transformed>::value,
"Transformed cannot be a reference type");
};
template <typename Attribute, typename ActualAttribute>
struct make_attribute<Attribute&, ActualAttribute>
: make_attribute<Attribute, ActualAttribute>
template <typename Transformed, typename Domain>
struct transform_attribute<unused_type, Transformed, Domain>
: detail::synthesize_attribute<Transformed>
{};
template <typename Attribute, typename ActualAttribute>
struct make_attribute<Attribute const&, ActualAttribute>
: make_attribute<Attribute const, ActualAttribute>
template <typename Transformed, typename Domain>
struct transform_attribute<unused_type const, Transformed, Domain>
: detail::synthesize_attribute<Transformed>
{};
template <typename ActualAttribute>
struct make_attribute<unused_type, ActualAttribute>
{
typedef unused_type type;
typedef unused_type value_type;
static unused_type call(unused_type)
{
return unused;
}
};
///////////////////////////////////////////////////////////////////////////
// swap_impl
//
@@ -1032,8 +990,7 @@ namespace boost { namespace spirit { namespace traits
template <typename T>
void swap_impl(T& a, T& b)
{
using namespace std;
swap(a, b);
boost::swap(a, b);
}
template <typename A>
@@ -1383,14 +1340,4 @@ namespace boost { namespace spirit { namespace traits
}
}}}
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit { namespace result_of
{
template <typename Exposed, typename Transformed, typename Domain>
struct pre_transform
: traits::transform_attribute<Exposed, Transformed, Domain>
{};
}}}
#endif

View File

@@ -30,9 +30,6 @@ namespace boost { namespace spirit { namespace result_of
template <typename T, typename Attribute>
struct attribute_as;
template <typename Exposed, typename Transformed, typename Domain>
struct pre_transform;
template <typename T>
struct optional_value;

View File

@@ -83,6 +83,7 @@ namespace boost { namespace spirit
( strict, strict_type )
( relaxed, relaxed_type )
( duplicate, duplicate_type )
( expect, expect_type )
)
// Our extended terminals

View File

@@ -15,7 +15,6 @@
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/support/attributes_fwd.hpp>
#include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits
#include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/optional.hpp>
@@ -23,6 +22,7 @@
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/repeat.hpp>
#include <boost/range/iterator_range.hpp>
#include <iterator> // for std::iterator_traits
namespace boost { namespace spirit { namespace traits
{
@@ -465,7 +465,7 @@ namespace boost { namespace spirit { namespace traits
template <typename Iterator, typename Enable/* = void*/>
struct deref_iterator
{
typedef typename boost::detail::iterator_traits<Iterator>::reference type;
typedef typename std::iterator_traits<Iterator>::reference type;
static type call(Iterator& it)
{
return *it;

View File

@@ -34,9 +34,13 @@
#endif
#include <boost/config.hpp>
#include <boost/detail/endian.hpp>
#include <boost/predef/other/endian.h>
#ifndef BOOST_MINIMAL_INTEGER_COVER_OPERATORS
#define BOOST_MINIMAL_INTEGER_COVER_OPERATORS
#endif
#ifndef BOOST_NO_IO_COVER_OPERATORS
#define BOOST_NO_IO_COVER_OPERATORS
#endif
#include <boost/spirit/home/support/detail/endian/cover_operators.hpp>
#undef BOOST_NO_IO_COVER_OPERATORS
#undef BOOST_MINIMAL_INTEGER_COVER_OPERATORS
@@ -52,10 +56,10 @@
# error Platforms with CHAR_BIT != 8 are not supported
# endif
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT {} // C++03
# define BOOST_SPIRIT_ENDIAN_DEFAULT_CONSTRUCT {} // C++03
# if defined(BOOST_ENDIAN_FORCE_PODNESS)
# define BOOST_ENDIAN_NO_CTORS
# if defined(BOOST_ENDIAN_NO_CTORS) || defined(BOOST_ENDIAN_FORCE_PODNESS)
# define BOOST_SPIRIT_ENDIAN_NO_CTORS
# endif
@@ -315,8 +319,8 @@ namespace boost { namespace spirit
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
public:
typedef T value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
# ifndef BOOST_SPIRIT_ENDIAN_NO_CTORS
endian() BOOST_SPIRIT_ENDIAN_DEFAULT_CONSTRUCT
explicit endian(T val)
{
# ifdef BOOST_ENDIAN_LOG
@@ -347,8 +351,8 @@ namespace boost { namespace spirit
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
public:
typedef T value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
# ifndef BOOST_SPIRIT_ENDIAN_NO_CTORS
endian() BOOST_SPIRIT_ENDIAN_DEFAULT_CONSTRUCT
explicit endian(T val)
{
# ifdef BOOST_ENDIAN_LOG
@@ -379,15 +383,15 @@ namespace boost { namespace spirit
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
public:
typedef T value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
# ifdef BOOST_BIG_ENDIAN
# ifndef BOOST_SPIRIT_ENDIAN_NO_CTORS
endian() BOOST_SPIRIT_ENDIAN_DEFAULT_CONSTRUCT
# if BOOST_ENDIAN_BIG_BYTE
explicit endian(T val) { detail::store_big_endian<T, n_bits/8>(m_value, val); }
# else
explicit endian(T val) { detail::store_little_endian<T, n_bits/8>(m_value, val); }
# endif
# endif
# ifdef BOOST_BIG_ENDIAN
# if BOOST_ENDIAN_BIG_BYTE
endian & operator=(T val) { detail::store_big_endian<T, n_bits/8>(m_value, val); return *this; }
operator T() const { return detail::load_big_endian<T, n_bits/8>(m_value); }
# else
@@ -410,15 +414,15 @@ namespace boost { namespace spirit
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
public:
typedef T value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
# ifdef BOOST_BIG_ENDIAN
# ifndef BOOST_SPIRIT_ENDIAN_NO_CTORS
endian() BOOST_SPIRIT_ENDIAN_DEFAULT_CONSTRUCT
# if BOOST_ENDIAN_BIG_BYTE
endian(T val) : m_value(val) { }
# else
explicit endian(T val) { detail::store_big_endian<T, sizeof(T)>(&m_value, val); }
# endif
# endif
# ifdef BOOST_BIG_ENDIAN
# if BOOST_ENDIAN_BIG_BYTE
endian & operator=(T val) { m_value = val; return *this; }
operator T() const { return m_value; }
# else
@@ -438,15 +442,15 @@ namespace boost { namespace spirit
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
public:
typedef T value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
# ifdef BOOST_LITTLE_ENDIAN
# ifndef BOOST_SPIRIT_ENDIAN_NO_CTORS
endian() BOOST_SPIRIT_ENDIAN_DEFAULT_CONSTRUCT
# if BOOST_ENDIAN_LITTLE_BYTE
endian(T val) : m_value(val) { }
# else
explicit endian(T val) { detail::store_little_endian<T, sizeof(T)>(&m_value, val); }
# endif
# endif
# ifdef BOOST_LITTLE_ENDIAN
# if BOOST_ENDIAN_LITTLE_BYTE
endian & operator=(T val) { m_value = val; return *this; }
operator T() const { return m_value; }
#else
@@ -519,10 +523,6 @@ namespace boost { namespace spirit
typedef endian< endianness::native, uint_least64_t, 56 > unative56_t;
typedef endian< endianness::native, uint_least64_t, 64 > unative64_t;
#define BOOST_HAS_INT16_T
#define BOOST_HAS_INT32_T
#define BOOST_HAS_INT64_T
// These types only present if platform has exact size integers:
// aligned big endian signed integer types
// aligned big endian unsigned integer types
@@ -532,35 +532,32 @@ namespace boost { namespace spirit
// aligned native endian typedefs are not provided because
// <cstdint> types are superior for this use case
# if defined(BOOST_HAS_INT16_T)
#ifdef INT16_MAX
typedef endian< endianness::big, int16_t, 16, alignment::aligned > aligned_big16_t;
typedef endian< endianness::big, uint16_t, 16, alignment::aligned > aligned_ubig16_t;
typedef endian< endianness::little, int16_t, 16, alignment::aligned > aligned_little16_t;
typedef endian< endianness::little, uint16_t, 16, alignment::aligned > aligned_ulittle16_t;
# endif
#endif
# if defined(BOOST_HAS_INT32_T)
#ifdef INT32_MAX
typedef endian< endianness::big, int32_t, 32, alignment::aligned > aligned_big32_t;
typedef endian< endianness::big, uint32_t, 32, alignment::aligned > aligned_ubig32_t;
typedef endian< endianness::little, int32_t, 32, alignment::aligned > aligned_little32_t;
typedef endian< endianness::little, uint32_t, 32, alignment::aligned > aligned_ulittle32_t;
# endif
#endif
# if defined(BOOST_HAS_INT64_T)
#ifdef INT64_MAX
typedef endian< endianness::big, int64_t, 64, alignment::aligned > aligned_big64_t;
typedef endian< endianness::big, uint64_t, 64, alignment::aligned > aligned_ubig64_t;
typedef endian< endianness::little, int64_t, 64, alignment::aligned > aligned_little64_t;
typedef endian< endianness::little, uint64_t, 64, alignment::aligned > aligned_ulittle64_t;
# endif
#endif
} // namespace endian
}} // namespace boost::spirit
// import the namespace above into boost::endian
namespace boost { namespace endian
{
using namespace boost::spirit::endian;
}}
#undef BOOST_SPIRIT_ENDIAN_DEFAULT_CONSTRUCT
#undef BOOST_SPIRIT_ENDIAN_NO_CTORS
#if defined(__BORLANDC__) || defined( __CODEGEARC__)
# pragma pack(pop)

Some files were not shown because too many files have changed in this diff Show More