diff options
author | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
commit | 08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch) | |
tree | 7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/spirit | |
parent | bb4dd8289b351fae6b55e303f189127a394a1edd (diff) | |
download | boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2 boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip |
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/spirit')
407 files changed, 13673 insertions, 12982 deletions
diff --git a/boost/spirit/home/classic/core/composite/impl/directives.ipp b/boost/spirit/home/classic/core/composite/impl/directives.ipp index b25b25fdc0..96b2dd79c5 100644 --- a/boost/spirit/home/classic/core/composite/impl/directives.ipp +++ b/boost/spirit/home/classic/core/composite/impl/directives.ipp @@ -151,169 +151,6 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN return s.parse(scan); } -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - - /////////////////////////////////////////////////////////////////////// - // - // from spirit 1.1 (copyright (c) 2001 Bruce Florman) - // various workarounds to support longest and shortest directives - // - /////////////////////////////////////////////////////////////////////// - template <typename T> - struct is_alternative - { - // Determine at compile time (without partial specialization) - // whether a given type is an instance of the alternative<A,B> - - static T t(); - template <typename A, typename B> - static char test_(alternative<A, B> const&); // no implementation - static int test_(...); // no implementation - enum { r = sizeof(char) == sizeof(test_(t())) }; - typedef mpl::bool_<r> value; - }; - - template <typename T> struct select_to_longest; - - template <typename T> - struct to_longest_alternative - { - typedef typename select_to_longest<T>::result_t result_t; - typedef typename select_to_longest<T>::plain_t plain_t; - typedef typename select_to_longest<T>::choose_t choose_t; - static result_t convert(T const& a); - }; - - template <typename T> - struct to_longest_generic - { - typedef T const& result_t; - typedef T plain_t; - typedef mpl::false_ choose_t; - }; - - template <typename T> - inline T const& - to_longest_convert(T const& a, mpl::false_) - { return a; } - - template <typename T> - struct to_longest_recursive - { - typedef typename to_longest_alternative< - typename T::left_t>::plain_t a_t; - typedef typename to_longest_alternative< - typename T::right_t>::plain_t b_t; - - typedef longest_alternative<a_t, b_t> result_t; - - typedef result_t plain_t; - typedef mpl::true_ choose_t; - }; - - template <typename A, typename B> - inline typename to_longest_alternative<alternative<A, B> >::result_t - to_longest_convert(alternative<A, B> const& alt, mpl::true_) - { - typedef typename to_longest_alternative< - alternative<A, B> >::result_t result_t; - return result_t( - to_longest_alternative<A>::convert(alt.left()), - to_longest_alternative<B>::convert(alt.right())); - } - - template <typename T> - inline typename to_longest_alternative<T>::result_t - to_longest_alternative<T>::convert(T const& a) - { - return to_longest_convert( - a, to_longest_alternative<T>::choose_t()); - } - - template <typename T> - struct select_to_longest - { - typedef typename mpl::if_< - is_alternative<T> // IF - , to_longest_recursive<T> // THEN - , to_longest_generic<T> // ELSE - >::type type; - - typedef typename select_to_longest::type::result_t result_t; - typedef typename select_to_longest::type::plain_t plain_t; - typedef typename select_to_longest::type::choose_t choose_t; - }; - - template <typename T> struct select_to_shortest; - - template <typename T> - struct to_shortest_alternative - { - typedef typename select_to_shortest<T>::result_t result_t; - typedef typename select_to_shortest<T>::plain_t plain_t; - typedef typename select_to_shortest<T>::choose_t choose_t; - static result_t convert(T const& a); - }; - - template <typename T> - struct to_shortest_generic - { - typedef T const& result_t; - typedef T plain_t; - typedef mpl::false_ choose_t; - }; - - template <typename T> - inline T const& - to_shortest_convert(T const& a, mpl::false_) { return a; } - - template <typename T> - struct to_shortest_recursive - { - typedef typename to_shortest_alternative< - typename T::left_t>::plain_t a_t; - typedef typename to_shortest_alternative< - typename T::right_t>::plain_t b_t; - - typedef shortest_alternative<a_t, b_t> result_t; - - typedef result_t plain_t; - typedef mpl::true_ choose_t; - }; - - template <typename A, typename B> - inline typename to_shortest_alternative<alternative<A, B> >::result_t - to_shortest_convert(alternative<A, B> const& alt, mpl::true_) - { - typedef typename to_shortest_alternative< - alternative<A, B> >::result_t result_t; - return result_t( - to_shortest_alternative<A>::convert(alt.left()), - to_shortest_alternative<B>::convert(alt.right())); - } - - template <typename T> - inline typename to_shortest_alternative<T>::result_t - to_shortest_alternative<T>::convert(T const& a) - { - return to_shortest_convert( - a, to_shortest_alternative<T>::choose_t()); - } - - template <typename T> - struct select_to_shortest - { - typedef typename mpl::if_< - is_alternative<T> // IF - , to_shortest_recursive<T> // THEN - , to_shortest_generic<T> // ELSE - >::type type; - - typedef typename select_to_shortest::type::result_t result_t; - typedef typename select_to_shortest::type::plain_t plain_t; - typedef typename select_to_shortest::type::choose_t choose_t; - }; -#else template <typename T> struct to_longest_alternative { @@ -363,7 +200,6 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN to_shortest_alternative<B>::convert(alt.right())); } }; -#endif } BOOST_SPIRIT_CLASSIC_NAMESPACE_END diff --git a/boost/spirit/home/classic/core/non_terminal/grammar.hpp b/boost/spirit/home/classic/core/non_terminal/grammar.hpp index ae7b2658f3..153bc40c3e 100644 --- a/boost/spirit/home/classic/core/non_terminal/grammar.hpp +++ b/boost/spirit/home/classic/core/non_terminal/grammar.hpp @@ -79,7 +79,6 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_END }} // namespace BOOST_SPIRIT_CLASSIC_NS #undef BOOST_SPIRIT_GRAMMAR_ID -#undef BOOST_SPIRIT_GRAMMAR_ACCESS #undef BOOST_SPIRIT_GRAMMAR_STATE #endif diff --git a/boost/spirit/home/classic/core/non_terminal/impl/grammar.ipp b/boost/spirit/home/classic/core/non_terminal/impl/grammar.ipp index 3b25b3d2e3..b26f534751 100644 --- a/boost/spirit/home/classic/core/non_terminal/impl/grammar.ipp +++ b/boost/spirit/home/classic/core/non_terminal/impl/grammar.ipp @@ -33,19 +33,6 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN template <typename DerivedT, typename ContextT> struct grammar; -#if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) - -BOOST_SPIRIT_DEPENDENT_TEMPLATE_WRAPPER(grammar_definition_wrapper, definition); - -////////////////////////////////// -template <typename GrammarT, typename ScannerT> -struct grammar_definition -{ - typedef typename impl::grammar_definition_wrapper<GrammarT> - ::template result_<ScannerT>::param_t type; -}; - -#else ////////////////////////////////// template <typename GrammarT, typename ScannerT> @@ -54,7 +41,6 @@ struct grammar_definition typedef typename GrammarT::template definition<ScannerT> type; }; -#endif namespace impl { @@ -122,8 +108,7 @@ struct grammar_definition ////////////////////////////////// struct grammartract_helper_list; -#if !defined(BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE) \ - && (!defined(__GNUC__) || (__GNUC__ > 2)) +#if !defined(BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE) struct grammartract_helper_list { @@ -162,11 +147,7 @@ struct grammar_definition define(grammar_t const* target_grammar) { grammar_helper_list<GrammarT> &helpers = -#if !defined(__GNUC__) || (__GNUC__ > 2) - grammartract_helper_list::do_(target_grammar); -#else - target_grammar->helpers; -#endif + grammartract_helper_list::do_(target_grammar); typename grammar_t::object_id id = target_grammar->get_object_id(); if (definitions.size()<=id) @@ -252,7 +233,6 @@ struct grammar_definition #endif } -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template <int N> struct call_helper { @@ -263,11 +243,6 @@ struct grammar_definition result = def.template get_start_parser<N>()->parse(scan); } }; -#else - // The grammar_def stuff isn't supported for compilers, which do not - // support partial template specialization - template <int N> struct call_helper; -#endif template <> struct call_helper<0> { @@ -310,14 +285,9 @@ struct grammar_definition typedef typename helper_list_t::vector_t::reverse_iterator iterator_t; helper_list_t& helpers = -# if !defined(__GNUC__) || (__GNUC__ > 2) - grammartract_helper_list::do_(self); -# else - self->helpers; -# endif + grammartract_helper_list::do_(self); -# if (defined(BOOST_MSVC) && (BOOST_MSVC < 1300)) \ - || defined(BOOST_INTEL_CXX_VERSION) +# if defined(BOOST_INTEL_CXX_VERSION) for (iterator_t i = helpers.rbegin(); i != helpers.rend(); ++i) (*i)->undefine(self); # else @@ -383,16 +353,9 @@ struct grammar_definition #endif /////////////////////////////////////// -#if !defined(__GNUC__) || (__GNUC__ > 2) -#define BOOST_SPIRIT_GRAMMAR_ACCESS private: -#else -#define BOOST_SPIRIT_GRAMMAR_ACCESS -#endif - -/////////////////////////////////////// #if !defined(BOOST_SPIRIT_SINGLE_GRAMMAR_INSTANCE) #define BOOST_SPIRIT_GRAMMAR_STATE \ - BOOST_SPIRIT_GRAMMAR_ACCESS \ + private: \ friend struct impl::grammartract_helper_list; \ mutable impl::grammar_helper_list<self_t> helpers; #else diff --git a/boost/spirit/home/classic/core/non_terminal/impl/subrule.ipp b/boost/spirit/home/classic/core/non_terminal/impl/subrule.ipp index 4651cc31ec..f6bdaaf40d 100644 --- a/boost/spirit/home/classic/core/non_terminal/impl/subrule.ipp +++ b/boost/spirit/home/classic/core/non_terminal/impl/subrule.ipp @@ -22,76 +22,6 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN namespace impl { - #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - - template <int N, typename ListT> - struct get_subrule; - - template <int N, typename ListT> - struct get_subrule_chooser - { - static ListT t(); - static char test(nil_t); - static int test(...); - - // Set value to - // 0: ListT is empty - // 1: ListT's first item has same ID - // 2: ListT's first item has a different ID - - enum - { - id = ListT::first_t::id, - is_same_id = N == id, - is_nil_t = sizeof(char) == sizeof(test(t())), - value = is_nil_t ? 0 : (is_same_id ? 1 : 2) - }; - }; - - template <int N> - struct subrule_chooser; - - template <> - struct subrule_chooser<0> - { - // First case. ListT is empty - - template <int N, typename ListT> - struct result - { typedef nil_t type; }; - }; - - template <> - struct subrule_chooser<1> - { - // Second case. ListT is non-empty and the list's - // first item has the ID we are looking for. - - template <int N, typename ListT> - struct result - { typedef typename ListT::first_t::def_t type; }; - }; - - template <> - struct subrule_chooser<2> - { - // Third case. ListT is non-empty but the list's - // first item does not have the ID we are looking for. - - template <int N, typename ListT> - struct result - { typedef typename get_subrule<N, ListT::rest_t>::type type; }; - }; - - template <int N, typename ListT> - struct get_subrule - { - enum { n = get_subrule_chooser<N, ListT>::value }; - typedef typename subrule_chooser<n>::template - result<N, ListT>::type type; - }; - - #else template <int N, typename ListT> struct get_subrule @@ -122,7 +52,6 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN typedef nil_t type; }; - #endif template <typename T1, typename T2> struct get_result_t { diff --git a/boost/spirit/home/classic/core/non_terminal/rule.hpp b/boost/spirit/home/classic/core/non_terminal/rule.hpp index e905689431..1d4336bcc9 100644 --- a/boost/spirit/home/classic/core/non_terminal/rule.hpp +++ b/boost/spirit/home/classic/core/non_terminal/rule.hpp @@ -15,7 +15,7 @@ // Spirit predefined maximum number of simultaneously usable different // scanner types. // -// This limit defines the maximum number of of possible different scanner +// This limit defines the maximum number of possible different scanner // types for which a specific rule<> may be used. If this isn't defined, a // rule<> may be used with one scanner type only (multiple scanner support // is disabled). diff --git a/boost/spirit/home/classic/core/primitives/impl/primitives.ipp b/boost/spirit/home/classic/core/primitives/impl/primitives.ipp index 152e5b11be..8a52251ac6 100644 --- a/boost/spirit/home/classic/core/primitives/impl/primitives.ipp +++ b/boost/spirit/home/classic/core/primitives/impl/primitives.ipp @@ -10,21 +10,12 @@ #if !defined(BOOST_SPIRIT_PRIMITIVES_IPP) #define BOOST_SPIRIT_PRIMITIVES_IPP -// This should eventually go to a config file. -#if defined(__GNUC__) && (__GNUC__ < 3) && !defined(_STLPORT_VERSION) -# ifndef BOOST_SPIRIT_NO_CHAR_TRAITS -# define BOOST_SPIRIT_NO_CHAR_TRAITS -# endif -#endif - #include <cctype> #if !defined(BOOST_NO_CWCTYPE) #include <cwctype> #endif -#ifndef BOOST_SPIRIT_NO_CHAR_TRAITS -# include <string> // char_traits -#endif +#include <string> // char_traits #if defined(BOOST_MSVC) # pragma warning (push) @@ -79,80 +70,6 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN // /////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_SPIRIT_NO_CHAR_TRAITS -# define BOOST_SPIRIT_CHAR_TRAITS_NAMESPACE std -#else - - template <typename CharT> - struct char_traits - { - typedef CharT int_type; - typedef CharT char_type; - }; - - template<> - struct char_traits<char> - { - typedef int int_type; - typedef char char_type; - - static char_type - to_char_type(int_type c) - { - return static_cast<char_type>(c); - } - - static int - to_int_type(char c) - { - return static_cast<unsigned char>(c); - } - }; - - template<> - struct char_traits<unsigned char> - { - typedef int int_type; - typedef unsigned char char_type; - - static char_type - to_char_type(int_type c) - { - return static_cast<char_type>(c); - } - - static int - to_int_type(unsigned char c) - { - return c; - } - }; - -# define BOOST_SPIRIT_CHAR_TRAITS_NAMESPACE impl -# ifndef BOOST_NO_CWCTYPE - - template<> - struct char_traits<wchar_t> - { - typedef wint_t int_type; - typedef wchar_t char_type; - - static char_type - to_char_type(int_type c) - { - return static_cast<char_type>(c); - } - - static wint_t - to_int_type(wchar_t c) - { - return c; - } - }; - -# endif -#endif // BOOST_SPIRIT_NO_CHAR_TRAITS - // Use char_traits for char and wchar_t only, as these are the only // specializations provided in the standard. Other types are on their // own. @@ -182,19 +99,16 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN struct char_type_char_traits_helper { typedef CharT char_type; - typedef typename BOOST_SPIRIT_CHAR_TRAITS_NAMESPACE - ::char_traits<CharT>::int_type int_type; + typedef typename std::char_traits<CharT>::int_type int_type; static int_type to_int_type(CharT c) { - return BOOST_SPIRIT_CHAR_TRAITS_NAMESPACE - ::char_traits<CharT>::to_int_type(c); + return std::char_traits<CharT>::to_int_type(c); } static char_type to_char_type(int_type i) { - return BOOST_SPIRIT_CHAR_TRAITS_NAMESPACE - ::char_traits<CharT>::to_char_type(i); + return std::char_traits<CharT>::to_char_type(i); } }; diff --git a/boost/spirit/home/classic/dynamic/impl/conditions.ipp b/boost/spirit/home/classic/dynamic/impl/conditions.ipp index 713958463c..3a7b530eb2 100644 --- a/boost/spirit/home/classic/dynamic/impl/conditions.ipp +++ b/boost/spirit/home/classic/dynamic/impl/conditions.ipp @@ -36,13 +36,6 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN typedef typename T::embed_t type; }; -#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - template <> struct embed_t_accessor<int> - { - typedef int type; - }; -#endif - template <typename ConditionT> struct condition_parser_selector { diff --git a/boost/spirit/home/classic/dynamic/impl/switch.ipp b/boost/spirit/home/classic/dynamic/impl/switch.ipp index ffaa3ebb8b..b881f9d121 100644 --- a/boost/spirit/home/classic/dynamic/impl/switch.ipp +++ b/boost/spirit/home/classic/dynamic/impl/switch.ipp @@ -410,7 +410,7 @@ struct parse_switch; return delegate_parse( \ chain_parser< \ case_chain<ParserT>::depth, ParserT \ - >::left(p), scan, save); \ + >::left(p), scan, save); \ \ BOOST_PP_REPEAT_FROM_TO_ ## z(1, BOOST_PP_INC(N), \ BOOST_SPIRIT_PARSE_SWITCH_CASES, _) \ diff --git a/boost/spirit/home/classic/dynamic/stored_rule.hpp b/boost/spirit/home/classic/dynamic/stored_rule.hpp index 5661ef8855..5248ba18fa 100644 --- a/boost/spirit/home/classic/dynamic/stored_rule.hpp +++ b/boost/spirit/home/classic/dynamic/stored_rule.hpp @@ -101,17 +101,11 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN friend class impl::rule_base_access; friend class stored_rule<T0, T1, T2, !EmbedByValue>; -#if defined(__GNUC__) && (__GNUC__ < 3) - public: -#endif abstract_parser_t* get() const { return ptr.get(); } -#if defined(__GNUC__) && (__GNUC__ < 3) - private: -#endif stored_rule(shared_ptr<abstract_parser_t> const& ptr) : ptr(ptr) {} diff --git a/boost/spirit/home/classic/iterator/impl/file_iterator.ipp b/boost/spirit/home/classic/iterator/impl/file_iterator.ipp index 4227b69665..0fb92c72a3 100644 --- a/boost/spirit/home/classic/iterator/impl/file_iterator.ipp +++ b/boost/spirit/home/classic/iterator/impl/file_iterator.ipp @@ -285,11 +285,7 @@ public: } private: -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION typedef boost::remove_pointer<HANDLE>::type handle_t; -#else - typedef void handle_t; -#endif boost::shared_ptr<CharT> m_mem; std::size_t m_filesize; diff --git a/boost/spirit/home/classic/iterator/multi_pass.hpp b/boost/spirit/home/classic/iterator/multi_pass.hpp index ec8e01c976..fd9482ef31 100644 --- a/boost/spirit/home/classic/iterator/multi_pass.hpp +++ b/boost/spirit/home/classic/iterator/multi_pass.hpp @@ -194,7 +194,7 @@ class buf_id_check } // called to verify that everything is okay. - void check() const + void check_if_valid() const { if (buf_id != *shared_buf_id) { @@ -226,7 +226,7 @@ class no_check no_check(no_check const&) {} void destroy() {} void swap(no_check&) {} - void check() const {} + void check_if_valid() const {} void clear_queue() {} }; @@ -1000,7 +1000,7 @@ reference multi_pass<InputT, InputPolicy, OwnershipPolicy, CheckingPolicy, StoragePolicy>:: operator*() const { - CHP::check(); + CHP::check_if_valid(); return SP::dereference(*this); } @@ -1034,7 +1034,7 @@ multi_pass<InputT, InputPolicy, OwnershipPolicy, CheckingPolicy, StoragePolicy>& multi_pass<InputT, InputPolicy, OwnershipPolicy, CheckingPolicy, StoragePolicy>:: operator++() { - CHP::check(); + CHP::check_if_valid(); SP::increment(*this); return *this; } diff --git a/boost/spirit/home/classic/meta/impl/fundamental.ipp b/boost/spirit/home/classic/meta/impl/fundamental.ipp index 798f22b61a..7b1d1aa669 100644 --- a/boost/spirit/home/classic/meta/impl/fundamental.ipp +++ b/boost/spirit/home/classic/meta/impl/fundamental.ipp @@ -15,10 +15,6 @@ namespace boost { namespace spirit { BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN -#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) - BOOST_SPIRIT_DEPENDENT_TEMPLATE_WRAPPER2(count_wrapper, count); -#endif // defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) - namespace impl { /////////////////////////////////////////////////////////////////////////// @@ -42,68 +38,6 @@ namespace impl }; }; -#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) - - template <> - struct nodes<unary_parser_category> { - - template <typename ParserT, typename LeafCountT> - struct count { - - typedef typename ParserT::subject_t subject_t; - typedef typename subject_t::parser_category_t subject_category_t; - - typedef nodes<subject_category_t> nodes_t; - typedef typename count_wrapper<nodes_t> - ::template result_<subject_t, LeafCountT> count_t; - - BOOST_STATIC_CONSTANT(int, value = count_t::value + 1); - }; - }; - - template <> - struct nodes<action_parser_category> { - - template <typename ParserT, typename LeafCountT> - struct count { - - typedef typename ParserT::subject_t subject_t; - typedef typename subject_t::parser_category_t subject_category_t; - - typedef nodes<subject_category_t> nodes_t; - typedef typename count_wrapper<nodes_t> - ::template result_<subject_t, LeafCountT> count_t; - - BOOST_STATIC_CONSTANT(int, value = count_t::value + 1); - }; - }; - - template <> - struct nodes<binary_parser_category> { - - template <typename ParserT, typename LeafCountT> - struct count { - - typedef typename ParserT::left_t left_t; - typedef typename ParserT::right_t right_t; - typedef typename left_t::parser_category_t left_category_t; - typedef typename right_t::parser_category_t right_category_t; - - typedef nodes<left_category_t> left_nodes_t; - typedef typename count_wrapper<left_nodes_t> - ::template result_<left_t, LeafCountT> left_count_t; - - typedef nodes<right_category_t> right_nodes_t; - typedef typename count_wrapper<right_nodes_t> - ::template result_<right_t, LeafCountT> right_count_t; - - BOOST_STATIC_CONSTANT(int, - value = (left_count_t::value + right_count_t::value + 1)); - }; - }; - -#else - template <> struct nodes<unary_parser_category> { @@ -158,8 +92,6 @@ namespace impl }; }; -#endif - /////////////////////////////////////////////////////////////////////////// // // Helper template for counting the number of leaf nodes contained in a @@ -181,68 +113,6 @@ namespace impl }; }; -#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) - - template <> - struct leafs<unary_parser_category> { - - template <typename ParserT, typename LeafCountT> - struct count { - - typedef typename ParserT::subject_t subject_t; - typedef typename subject_t::parser_category_t subject_category_t; - - typedef leafs<subject_category_t> nodes_t; - typedef typename count_wrapper<nodes_t> - ::template result_<subject_t, LeafCountT> count_t; - - BOOST_STATIC_CONSTANT(int, value = count_t::value); - }; - }; - - template <> - struct leafs<action_parser_category> { - - template <typename ParserT, typename LeafCountT> - struct count { - - typedef typename ParserT::subject_t subject_t; - typedef typename subject_t::parser_category_t subject_category_t; - - typedef leafs<subject_category_t> nodes_t; - typedef typename count_wrapper<nodes_t> - ::template result_<subject_t, LeafCountT> count_t; - - BOOST_STATIC_CONSTANT(int, value = count_t::value); - }; - }; - - template <> - struct leafs<binary_parser_category> { - - template <typename ParserT, typename LeafCountT> - struct count { - - typedef typename ParserT::left_t left_t; - typedef typename ParserT::right_t right_t; - typedef typename left_t::parser_category_t left_category_t; - typedef typename right_t::parser_category_t right_category_t; - - typedef leafs<left_category_t> left_nodes_t; - typedef typename count_wrapper<left_nodes_t> - ::template result_<left_t, LeafCountT> left_count_t; - - typedef leafs<right_category_t> right_nodes_t; - typedef typename count_wrapper<right_nodes_t> - ::template result_<right_t, LeafCountT> right_count_t; - - BOOST_STATIC_CONSTANT(int, - value = (left_count_t::value + right_count_t::value)); - }; - }; - -#else - template <> struct leafs<unary_parser_category> { @@ -297,8 +167,6 @@ namespace impl }; }; -#endif - } // namespace impl /////////////////////////////////////////////////////////////////////////////// diff --git a/boost/spirit/home/classic/meta/impl/parser_traits.ipp b/boost/spirit/home/classic/meta/impl/parser_traits.ipp index e648acd4d0..846a58b75f 100644 --- a/boost/spirit/home/classic/meta/impl/parser_traits.ipp +++ b/boost/spirit/home/classic/meta/impl/parser_traits.ipp @@ -21,80 +21,6 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN namespace impl { -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - - /////////////////////////////////////////////////////////////////////////// - // - // from spirit 1.1 (copyright (c) 2001 Bruce Florman) - // various workarounds to support compile time decisions without partial - // template specialization whether a given type is an instance of a - // concrete parser type. - // - /////////////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////////////// - template <typename T> - struct parser_type_traits - { - // Determine at compile time (without partial specialization) - // whether a given type is an instance of the alternative<A,B> - - static T t(); - - typedef struct { char dummy[1]; } size1_t; - typedef struct { char dummy[2]; } size2_t; - typedef struct { char dummy[3]; } size3_t; - typedef struct { char dummy[4]; } size4_t; - typedef struct { char dummy[5]; } size5_t; - typedef struct { char dummy[6]; } size6_t; - typedef struct { char dummy[7]; } size7_t; - typedef struct { char dummy[8]; } size8_t; - typedef struct { char dummy[9]; } size9_t; - typedef struct { char dummy[10]; } size10_t; - - // the following functions need no implementation - template <typename A, typename B> - static size1_t test_(alternative<A, B> const&); - template <typename A, typename B> - static size2_t test_(sequence<A, B> const&); - template <typename A, typename B> - static size3_t test_(sequential_or<A, B> const&); - template <typename A, typename B> - static size4_t test_(intersection<A, B> const&); - template <typename A, typename B> - static size5_t test_(difference<A, B> const&); - template <typename A, typename B> - static size6_t test_(exclusive_or<A, B> const&); - template <typename S> - static size7_t test_(optional<S> const&); - template <typename S> - static size8_t test_(kleene_star<S> const&); - template <typename S> - static size9_t test_(positive<S> const&); - - static size10_t test_(...); - - BOOST_STATIC_CONSTANT(bool, - is_alternative = (sizeof(size1_t) == sizeof(test_(t()))) ); - BOOST_STATIC_CONSTANT(bool, - is_sequence = (sizeof(size2_t) == sizeof(test_(t()))) ); - BOOST_STATIC_CONSTANT(bool, - is_sequential_or = (sizeof(size3_t) == sizeof(test_(t()))) ); - BOOST_STATIC_CONSTANT(bool, - is_intersection = (sizeof(size4_t) == sizeof(test_(t()))) ); - BOOST_STATIC_CONSTANT(bool, - is_difference = (sizeof(size5_t) == sizeof(test_(t()))) ); - BOOST_STATIC_CONSTANT(bool, - is_exclusive_or = (sizeof(size6_t) == sizeof(test_(t()))) ); - BOOST_STATIC_CONSTANT(bool, - is_optional = (sizeof(size7_t) == sizeof(test_(t()))) ); - BOOST_STATIC_CONSTANT(bool, - is_kleene_star = (sizeof(size8_t) == sizeof(test_(t()))) ); - BOOST_STATIC_CONSTANT(bool, - is_positive = (sizeof(size9_t) == sizeof(test_(t()))) ); - }; - -#else /////////////////////////////////////////////////////////////////////////// struct parser_type_traits_base { @@ -180,7 +106,6 @@ namespace impl BOOST_STATIC_CONSTANT(bool, is_positive = true); }; -#endif // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) } // namespace impl /////////////////////////////////////////////////////////////////////////////// diff --git a/boost/spirit/home/classic/phoenix/special_ops.hpp b/boost/spirit/home/classic/phoenix/special_ops.hpp index 7fc2f6d78d..4a007b23ae 100644 --- a/boost/spirit/home/classic/phoenix/special_ops.hpp +++ b/boost/spirit/home/classic/phoenix/special_ops.hpp @@ -79,31 +79,6 @@ template <typename T> struct rank<PHOENIX_STD::complex<T> > // specializations for std::istream // /////////////////////////////////////////////////////////////////////////////// -#if defined(__GNUC__) && (__GNUC__ < 3) - #if defined(_STLPORT_VERSION) - #define PHOENIX_ISTREAM _IO_istream_withassign - #else - #define PHOENIX_ISTREAM PHOENIX_STD::_IO_istream_withassign - #endif -#else -// #if (defined(__ICL) && defined(_STLPORT_VERSION)) -// #define PHOENIX_ISTREAM istream_withassign -// #else - #define PHOENIX_ISTREAM PHOENIX_STD::istream -// #endif -#endif - -////////////////////////////////// -#if defined(__GNUC__) && (__GNUC__ < 3) -// || (defined(__ICL) && defined(_STLPORT_VERSION)) -template <typename T1> -struct binary_operator<shift_r_op, PHOENIX_ISTREAM, T1> -{ - typedef PHOENIX_STD::istream& result_type; - static result_type eval(PHOENIX_STD::istream& out, T1& rhs) - { return out >> rhs; } -}; -#endif ////////////////////////////////// template <typename T1> @@ -117,45 +92,19 @@ struct binary_operator<shift_r_op, PHOENIX_STD::istream, T1> ////////////////////////////////// template <typename BaseT> inline typename impl::make_binary3 - <shift_r_op, variable<PHOENIX_ISTREAM>, BaseT>::type -operator>>(PHOENIX_ISTREAM& _0, actor<BaseT> const& _1) + <shift_r_op, variable<PHOENIX_STD::istream>, BaseT>::type +operator>>(PHOENIX_STD::istream& _0, actor<BaseT> const& _1) { return impl::make_binary3 - <shift_r_op, variable<PHOENIX_ISTREAM>, BaseT> + <shift_r_op, variable<PHOENIX_STD::istream>, BaseT> ::construct(var(_0), _1); } -#undef PHOENIX_ISTREAM /////////////////////////////////////////////////////////////////////////////// // // specializations for std::ostream // /////////////////////////////////////////////////////////////////////////////// -#if defined(__GNUC__) && (__GNUC__ < 3) - #if defined(_STLPORT_VERSION) - #define PHOENIX_OSTREAM _IO_ostream_withassign - #else - #define PHOENIX_OSTREAM PHOENIX_STD::_IO_ostream_withassign - #endif -#else -// #if (defined(__ICL) && defined(_STLPORT_VERSION)) -// #define PHOENIX_OSTREAM ostream_withassign -// #else - #define PHOENIX_OSTREAM PHOENIX_STD::ostream -// #endif -#endif - -////////////////////////////////// -#if defined(__GNUC__) && (__GNUC__ < 3) -// || (defined(__ICL) && defined(_STLPORT_VERSION)) -template <typename T1> -struct binary_operator<shift_l_op, PHOENIX_OSTREAM, T1> -{ - typedef PHOENIX_STD::ostream& result_type; - static result_type eval(PHOENIX_STD::ostream& out, T1 const& rhs) - { return out << rhs; } -}; -#endif ////////////////////////////////// template <typename T1> @@ -169,16 +118,14 @@ struct binary_operator<shift_l_op, PHOENIX_STD::ostream, T1> ////////////////////////////////// template <typename BaseT> inline typename impl::make_binary3 - <shift_l_op, variable<PHOENIX_OSTREAM>, BaseT>::type -operator<<(PHOENIX_OSTREAM& _0, actor<BaseT> const& _1) + <shift_l_op, variable<PHOENIX_STD::ostream>, BaseT>::type +operator<<(PHOENIX_STD::ostream& _0, actor<BaseT> const& _1) { return impl::make_binary3 - <shift_l_op, variable<PHOENIX_OSTREAM>, BaseT> + <shift_l_op, variable<PHOENIX_STD::ostream>, BaseT> ::construct(var(_0), _1); } -#undef PHOENIX_OSTREAM - /////////////////////////////////////////////////////////////////////////////// // // specializations for std::strstream / stringstream @@ -228,8 +175,6 @@ operator<<(PHOENIX_STD::PHOENIX_SSTREAM& _0, actor<BaseT> const& _1) // I/O manipulator specializations // /////////////////////////////////////////////////////////////////////////////// -#if (!defined(__GNUC__) || (__GNUC__ > 2)) -// && !(defined(__ICL) && defined(_STLPORT_VERSION)) typedef PHOENIX_STD::ios_base& (*iomanip_t)(PHOENIX_STD::ios_base&); typedef PHOENIX_STD::istream& (*imanip_t)(PHOENIX_STD::istream&); @@ -300,7 +245,6 @@ operator<<(actor<BaseT> const& _0, iomanip_t _1) } #endif // __BORLANDC__ -#endif // !defined(__GNUC__) || (__GNUC__ > 2) /////////////////////////////////////////////////////////////////////////////// // diff --git a/boost/spirit/home/classic/phoenix/statements.hpp b/boost/spirit/home/classic/phoenix/statements.hpp index 25e6b1dd45..7726a99d4b 100644 --- a/boost/spirit/home/classic/phoenix/statements.hpp +++ b/boost/spirit/home/classic/phoenix/statements.hpp @@ -86,7 +86,7 @@ operator,(actor<BaseT0> const& _0, actor<BaseT1> const& _1) // is true, the true_statement (again an actor) is executed // otherwise, the false_statement (another actor) is executed. The // result type of this is void. Note the trailing underscore after -// if_ and the the leading dot and the trailing underscore before +// if_ and the leading dot and the trailing underscore before // and after .else_. // /////////////////////////////////////////////////////////////////////////////// diff --git a/boost/spirit/home/classic/phoenix/tuples.hpp b/boost/spirit/home/classic/phoenix/tuples.hpp index 50cec6bf3f..a52b4e1118 100644 --- a/boost/spirit/home/classic/phoenix/tuples.hpp +++ b/boost/spirit/home/classic/phoenix/tuples.hpp @@ -8,10 +8,6 @@ #ifndef PHOENIX_TUPLES_HPP #define PHOENIX_TUPLES_HPP -#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) -#error "Sorry, Phoenix does not support VC6 and VC7. Please upgrade to at least VC7.1" -#endif - /////////////////////////////////////////////////////////////////////////////// // // Phoenix predefined maximum limit. This limit defines the maximum diff --git a/boost/spirit/home/classic/tree/common.hpp b/boost/spirit/home/classic/tree/common.hpp index f25d4915ef..c086ff48d5 100644 --- a/boost/spirit/home/classic/tree/common.hpp +++ b/boost/spirit/home/classic/tree/common.hpp @@ -520,9 +520,6 @@ namespace impl { // as Koenig lookup rules will find only the classname::swap // member function not the global declaration, so use cp_swap // as a forwarding function (JM): -#if __GNUC__ == 2 - using ::std::swap; -#endif template <typename T> inline void cp_swap(T& t1, T& t2) { diff --git a/boost/spirit/home/classic/tree/impl/tree_to_xml.ipp b/boost/spirit/home/classic/tree/impl/tree_to_xml.ipp index 2f0da8bf44..36b7e10192 100644 --- a/boost/spirit/home/classic/tree/impl/tree_to_xml.ipp +++ b/boost/spirit/home/classic/tree/impl/tree_to_xml.ipp @@ -21,6 +21,7 @@ #include <iostream> #include <boost/config.hpp> #include <boost/assert.hpp> +#include <boost/scoped_array.hpp> #ifdef BOOST_NO_STRINGSTREAM #include <strstream> @@ -68,7 +69,7 @@ namespace impl { { using namespace std; // some systems have size_t in ns std size_t len = strlen(source); - std::auto_ptr<wchar_t> result (new wchar_t[len+1]); + boost::scoped_array<wchar_t> result (new wchar_t[len+1]); result.get()[len] = '\0'; // working with wide character streams is supported only if the diff --git a/boost/spirit/home/classic/utility/grammar_def.hpp b/boost/spirit/home/classic/utility/grammar_def.hpp index 6ddfcab647..bc9b11f993 100644 --- a/boost/spirit/home/classic/utility/grammar_def.hpp +++ b/boost/spirit/home/classic/utility/grammar_def.hpp @@ -26,7 +26,7 @@ /////////////////////////////////////////////////////////////////////////////// // // Spirit predefined maximum grammar start parser limit. This limit defines -// the maximum number of of possible different parsers exposed from a +// the maximum number of possible different parsers exposed from a // particular grammar. This number defaults to 3. // The actual maximum is rounded up in multiples of 3. Thus, if this value // is 4, the actual limit is 6. The ultimate maximum limit in this diff --git a/boost/spirit/home/classic/utility/impl/chset.ipp b/boost/spirit/home/classic/utility/impl/chset.ipp index 3017035106..6e2130b222 100644 --- a/boost/spirit/home/classic/utility/impl/chset.ipp +++ b/boost/spirit/home/classic/utility/impl/chset.ipp @@ -71,38 +71,6 @@ namespace utility { namespace impl { } } - ////////////////////////////////// - -#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) - - template <typename CharT, typename FakeT> - void chset_negated_set(boost::shared_ptr<basic_chset<CharT> > &ptr, chlit<CharT> const &ch, - FakeT) - { - if(ch.ch != (std::numeric_limits<CharT>::min)()) { - ptr->set((std::numeric_limits<CharT>::min)(), ch.ch - 1); - } - if(ch.ch != (std::numeric_limits<CharT>::max)()) { - ptr->set(ch.ch + 1, (std::numeric_limits<CharT>::max)()); - } - } - - template <typename CharT, typename FakeT> - void chset_negated_set(boost::shared_ptr<basic_chset<CharT> > &ptr, - spirit::range<CharT> const &rng, FakeT) - { - if(rng.first != (std::numeric_limits<CharT>::min)()) { - ptr->set((std::numeric_limits<CharT>::min)(), rng.first - 1); - } - if(rng.last != (std::numeric_limits<CharT>::max)()) { - ptr->set(rng.last + 1, (std::numeric_limits<CharT>::max)()); - } - } - -#endif // BOOST_WORKAROUND(BOOST_MSVC, < 1300) - -////////////////////////////////// - }} // namespace utility::impl template <typename CharT> @@ -142,8 +110,6 @@ inline chset<CharT>::chset(range<CharT> const& arg_) : ptr(new basic_chset<CharT>()) { ptr->set(arg_.first, arg_.last); } -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - template <typename CharT> inline chset<CharT>::chset(negated_char_parser<chlit<CharT> > const& arg_) : ptr(new basic_chset<CharT>()) @@ -158,8 +124,6 @@ inline chset<CharT>::chset(negated_char_parser<range<CharT> > const& arg_) set(arg_); } -#endif // !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - template <typename CharT> inline chset<CharT>::~chset() {} @@ -218,8 +182,6 @@ chset<CharT>::operator=(range<CharT> const& rhs) return *this; } -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - template <typename CharT> inline chset<CharT>& chset<CharT>::operator=(negated_char_parser<chlit<CharT> > const& rhs) @@ -238,8 +200,6 @@ chset<CharT>::operator=(negated_char_parser<range<CharT> > const& rhs) return *this; } -#endif // !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - template <typename CharT> inline void chset<CharT>::set(range<CharT> const& arg_) @@ -248,8 +208,6 @@ chset<CharT>::set(range<CharT> const& arg_) ptr->set(arg_.first, arg_.last); } -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - template <typename CharT> inline void chset<CharT>::set(negated_char_parser<chlit<CharT> > const& arg_) @@ -278,8 +236,6 @@ chset<CharT>::set(negated_char_parser<range<CharT> > const& arg_) } } -#endif // !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - template <typename CharT> inline void chset<CharT>::clear(range<CharT> const& arg_) diff --git a/boost/spirit/home/classic/utility/impl/chset_operators.ipp b/boost/spirit/home/classic/utility/impl/chset_operators.ipp index 4319c9b2a8..842a679d6d 100644 --- a/boost/spirit/home/classic/utility/impl/chset_operators.ipp +++ b/boost/spirit/home/classic/utility/impl/chset_operators.ipp @@ -285,78 +285,6 @@ operator^(chlit<CharT> const& a, chset<CharT> const& b) return chset<CharT>(a.ch) ^ b; } -#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) - -/////////////////////////////////////////////////////////////////////////////// -// -// negated_char_parser <--> chset free operators implementation -// -/////////////////////////////////////////////////////////////////////////////// -template <typename CharT, typename ParserT> -inline chset<CharT> -operator|(chset<CharT> const& a, negated_char_parser<ParserT> const& b) -{ - return a | chset<CharT>(b); -} - -////////////////////////////////// -template <typename CharT, typename ParserT> -inline chset<CharT> -operator&(chset<CharT> const& a, negated_char_parser<ParserT> const& b) -{ - return a & chset<CharT>(b); -} - -////////////////////////////////// -template <typename CharT, typename ParserT> -inline chset<CharT> -operator-(chset<CharT> const& a, negated_char_parser<ParserT> const& b) -{ - return a - chset<CharT>(b); -} - -////////////////////////////////// -template <typename CharT, typename ParserT> -inline chset<CharT> -operator^(chset<CharT> const& a, negated_char_parser<ParserT> const& b) -{ - return a ^ chset<CharT>(b); -} - -////////////////////////////////// -template <typename CharT, typename ParserT> -inline chset<CharT> -operator|(negated_char_parser<ParserT> const& a, chset<CharT> const& b) -{ - return chset<CharT>(a) | b; -} - -////////////////////////////////// -template <typename CharT, typename ParserT> -inline chset<CharT> -operator&(negated_char_parser<ParserT> const& a, chset<CharT> const& b) -{ - return chset<CharT>(a) & b; -} - -////////////////////////////////// -template <typename CharT, typename ParserT> -inline chset<CharT> -operator-(negated_char_parser<ParserT> const& a, chset<CharT> const& b) -{ - return chset<CharT>(a) - b; -} - -////////////////////////////////// -template <typename CharT, typename ParserT> -inline chset<CharT> -operator^(negated_char_parser<ParserT> const& a, chset<CharT> const& b) -{ - return chset<CharT>(a) ^ b; -} - -#else // BOOST_WORKAROUND(BOOST_MSVC, < 1300) - /////////////////////////////////////////////////////////////////////////////// // // negated_char_parser<range> <--> chset free operators implementation @@ -493,8 +421,6 @@ operator^(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b) return chset<CharT>(a) ^ b; } -#endif // BOOST_WORKAROUND(BOOST_MSVC, < 1300) - /////////////////////////////////////////////////////////////////////////////// // // anychar_parser <--> chset free operators diff --git a/boost/spirit/home/classic/utility/rule_parser.hpp b/boost/spirit/home/classic/utility/rule_parser.hpp index 9cacb49940..08aba694f5 100644 --- a/boost/spirit/home/classic/utility/rule_parser.hpp +++ b/boost/spirit/home/classic/utility/rule_parser.hpp @@ -16,7 +16,7 @@ // // Using a typeof operator or Boost.Typeof to automatically set the type of // variables (as done in the Spirit example demonstrating typeof) is by far not -// all we can do to tighten up our grammars as there are some significant +// all we can do to tighten up our grammars as there are some significant // drawbacks of this approach: // - the types complexity scales with the complexity of the grammar (sooner or // later hitting the limits of the compiler), @@ -32,242 +32,242 @@ // In practice manually applying this technique leads to rather lengthy code and // overthis requires the user to have a solid understanding of Spirit details. // -// Here is a generalized, macro-based approach to easily create typeof-based +// Here is a generalized, macro-based approach to easily create typeof-based // grammars that can be recursive and arbitrarily complex. // // // Quick manual: // ============ -// +// // 1. Setup -// -// Before the rule parser macro (the protagonist of the facility) can be used -// the the user must define the macro BOOST_SPIRIT__NAMESPACE (note the double +// +// Before the rule parser macro (the protagonist of the facility) can be used +// the user must define the macro BOOST_SPIRIT__NAMESPACE (note the double // underscore characeter) and setup a registration group for Boost.Typeof. -// +// // Examples: -// +// // // should come after regular #includeS // #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() -// +// // // [...] -// +// // #define BOOST_SPIRIT__NAMESPACE (2,(my_project, my_module)) // // | | +- outer +- inner // // ! space ! -+ | namespace namespace // // | // // +--- number of nested namespaces -// +// // namespace my_project { namespace my_module { -// +// // // [...] -// +// // --- -// +// // // should come after regular #includeS // #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() -// +// // // [...] -// +// // #define BOOST_SPIRIT__NAMESPACE (2,(my_project, (anonymous) )) -// +// // namespace my_project { namespace { -// +// // // [...] -// +// // --- -// +// // // should come after regular #includeS // #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() -// +// // // [...] -// -// +// +// // #define BOOST_SPIRIT__NAMESPACE - // // we're working at root namespace -// -// +// +// // Why do I have to do this? -// +// // Boost.Typeof needs to assign a unique ID for each registration. This ID is -// created composed of the line number and the registration group. The +// created composed of the line number and the registration group. The // facility performs Typeof registration and thus requires the source file to // have its own registration group. Further Boost.Typeof requires registration // to happen at root namespace so we have to close and reopen the namespace // we're in. // -// +// // 2. The rule parser macro -// +// // A simple rule parser definition looks like that: -// +// // // we're at namespace scope here -// +// // // Skip parser for C/C++ comments and whitespace -// BOOST_SPIRIT_RULE_PARSER(skipper, -// -,-,-, -// -// +( confix_p("//",*anychar_p,eol_p) +// BOOST_SPIRIT_RULE_PARSER(skipper, +// -,-,-, +// +// +( confix_p("//",*anychar_p,eol_p) // | confix_p("/*",*anychar_p,"*/") -// | space_p +// | space_p // ) // ) -// +// // Now we can use 'skipper' in other Spirit expressions. -// -// The code above creates a parser (template) class 'skpper_t' and (in this -// case, because there are no parameters) a static const instance 'skipper' of +// +// The code above creates a parser (template) class 'skpper_t' and (in this +// case, because there are no parameters) a static const instance 'skipper' of // that class. The class is automatically registered with Boost.Typeof. The type // name our parser is skipper_t here. -// -// +// +// // 2.1. Parametrized rule parsers -// +// // Rule parser definitions can have parameters. -// +// // Parameters are passed to the BOOST_SPIRIT_RULE_PARSER macro as its second -// argument (just pass '-' if there are no parameters) with the following +// argument (just pass '-' if there are no parameters) with the following // format: -// +// // (N,( param1,param2, / ... / paramN )) // +-- number of parameters -// +// // Example of a whole rule parser: -// +// // BOOST_SPIRIT_RULE_PARSER(new_name, // (1,( symbol_table )),-,-, -// +// // lexeme_d[ (alpha_p >> *alnum_p)[ symbol_table.add ] ] // ) -// +// // The expression 'new_name(my_symbols)' parses a string literal and adds it to // the symbol table 'my_symbols'. -// +// // The rule parser macro creates a function template as called 'new_name' that // takes one parameter of deduced reference type and returns a specialization of // 'new_name_t' in this case. -// -// Since parsers that require to be fast and lightweight often also require to -// be reentrant, it's quite common to pass in some semantic controller (the +// +// Since parsers that require to be fast and lightweight often also require to +// be reentrant, it's quite common to pass in some semantic controller (the // symbol table in the example above). -// However, parameters are templated so they can be anything (including parsers +// However, parameters are templated so they can be anything (including parsers // of course) so refactoring tasks can be abstracted with rule parsers as well. -// +// // BOOST_SPIRIT_RULE_PARSER(enumeration_parser, // (2,( element_parser, delimiter_parser )),-,-, -// +// // element_parser >> *(delimiter_parser >> element_parser) -// ) -// -// The expression 'enumeration_parser(int_p[ some_action ], ',')' creates a +// ) +// +// The expression 'enumeration_parser(int_p[ some_action ], ',')' creates a // parser for a comma-separated list of integers. -// -// +// +// // 2.2. Rule parsrs and semantic actions -// +// // While semantic actions can be globally attached to a rule parser or passed -// to a parametrized rule parser as (part of) an argument, even more control is +// to a parametrized rule parser as (part of) an argument, even more control is // possible by using action placeholders. E.g: -// +// // BOOST_SPIRIT_ACTION_PLACEHOLDER(int_action) -// +// // BOOST_SPIRIT_RULE_PARSER(int_list, // -,(1,( int_action )),-, -// +// // int_p[ int_action ] >> *(',' >> int_p[ int_action ]) // ) -// -// The expression 'int_list[ my_action ]' parses a comma separated list of +// +// The expression 'int_list[ my_action ]' parses a comma separated list of // integers and calls 'my_action' for every integer parsed therein. -// -// Of course multiple actions can be attached to one placeholder as usual (in +// +// Of course multiple actions can be attached to one placeholder as usual (in // this case 'int_list[ my_action1 ][ my_action2 ] would call two actions). -// +// // Further there can be multiple action placeholders for a single rule parser: -// +// // BOOST_SPIRIT_ACTION_PLACEHOLDER(feed_int) // BOOST_SPIRIT_ACTION_PLACEHOLDER(next_int) -// +// // BOOST_SPIRIT_RULE_PARSER(int_list, // -,(2,( feed_int, next_int )),-, -// +// // int_p[ feed_int ] >> *(',' >> int_p[ next_int ][ feed_int ]) // ) -// +// // The expression 'int_list[ (feed_int = my_action1), (next_int = my_action2) ]' -// creates a parser for a comma separated list of integers with the actions +// creates a parser for a comma separated list of integers with the actions // attached appropriately. -// +// // int_list[ feed_int = my_action1,my_action2, next_int = my_action3 ] -// -// works too (in this case the action placeholder 'feed_int' has two actions +// +// works too (in this case the action placeholder 'feed_int' has two actions // attached to it). -// -// You can both override and append actions associated with an action +// +// You can both override and append actions associated with an action // placeholder: -// +// // var = int_list[ feed_int = my_action1, next_int = my_action2 ] -// +// // // [...] -// -// ... var[ feed_int = another_action ] +// +// ... var[ feed_int = another_action ] // // 'another_action' overrides the actions previously attached to 'feed_int' -// +// // ... var[ next_int += another_action ] -// // 'another_action' is appended to the list of actions attached to +// // 'another_action' is appended to the list of actions attached to // // 'next_int' -// +// // Action placeholders are not entirely for free -- they add to the size and the -// initialization time of the rule parser. However, the impact on an already +// initialization time of the rule parser. However, the impact on an already // initialized rule parser instance should be quite small. -// -// +// +// // 2.3. Member variables -// -// You can add member variables to the rule parser class using the third +// +// You can add member variables to the rule parser class using the third // parameter of the rule parser macro: -// +// // BOOST_SPIRIT_RULE_PARSER( calc, // -, // -, // (3,( ((subrule<0>),expression,()), // ((subrule<1>),term,()), // ((subrule<2>),factor,() )) ), -// +// // // [...] -// +// // adds three subrules to the rule parser. // Each parameter must have the following type to allow commas to be handled // safely from within the preprocessing code: -// +// // ((type)),name,(constructor argument(s))) -// +// // // 2.4. The opaque rule parser // -// Rule parsers usually are templates. Building large grammars pushes the -// compiler really hard (and eventually to its limits) because of the +// Rule parsers usually are templates. Building large grammars pushes the +// compiler really hard (and eventually to its limits) because of the // metafunction complexity involved. -// If a rule parser without parameters and action placeholders is defined, a +// If a rule parser without parameters and action placeholders is defined, a // non-template class is created. Non-templated rule parsers can also be created -// explicitly by using BOOST_SPIRIT_OPAQUE_RULE_PARSER. +// explicitly by using BOOST_SPIRIT_OPAQUE_RULE_PARSER. // Opaque rule parsers can have parameters and member variables (note: no action -// placeholders are possible). The parameters of an opaque rule parsers are +// placeholders are possible). The parameters of an opaque rule parsers are // strictly typed, e.g: // // BOOST_SPIRIT_OPAQUE_RULE_PARSER(new_identifier, // (1,( ((my_symbol_table_t &),symbol_table) )) // ,-, // (alpha_p >> *alnum_p) [ symbol_table.add ] -// ) +// ) // -// Note it's also possible to have opaque rule parsers accept parameters of +// Note it's also possible to have opaque rule parsers accept parameters of // non-const reference types which is not possible with regular rule parsers. // // // 3. Utilities for by-reference embedding -// -// When using parsers mutiple times or recursively it can be helpful to embed +// +// When using parsers mutiple times or recursively it can be helpful to embed // them by-reference into the final parser expression. // For this purpose the library provides a wrapper template 'parser_reference'. // There is also a function template to create a wrapped parser which can deduce @@ -349,22 +349,22 @@ namespace boost // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RP_REGISTER_TEMPLATE // -// Boost.Typeof registration from within BOOST_SPIRIT__NAMESPACE +// Boost.Typeof registration from within BOOST_SPIRIT__NAMESPACE # define BOOST_SPIRIT_RP_REGISTER_TEMPLATE(name,params) \ BOOST_SPIRIT_RP_EMIT(NS_CLOSE,BOOST_SPIRIT__NAMESPACE,-) \ BOOST_TYPEOF_REGISTER_TEMPLATE( \ BOOST_SPIRIT_RP_EMIT(NS_QUALIFY,BOOST_SPIRIT__NAMESPACE,-) name, \ params) \ - BOOST_SPIRIT_RP_EMIT(NS_OPEN,BOOST_SPIRIT__NAMESPACE,-) + BOOST_SPIRIT_RP_EMIT(NS_OPEN,BOOST_SPIRIT__NAMESPACE,-) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RP_REGISTER_TYPE // -// Boost.Typeof registration from within BOOST_SPIRIT__NAMESPACE +// Boost.Typeof registration from within BOOST_SPIRIT__NAMESPACE # define BOOST_SPIRIT_RP_REGISTER_TYPE(name) \ BOOST_SPIRIT_RP_EMIT(NS_CLOSE,BOOST_SPIRIT__NAMESPACE,-) \ BOOST_TYPEOF_REGISTER_TYPE( \ BOOST_SPIRIT_RP_EMIT(NS_QUALIFY,BOOST_SPIRIT__NAMESPACE,-) name ) \ - BOOST_SPIRIT_RP_EMIT(NS_OPEN,BOOST_SPIRIT__NAMESPACE,-) + BOOST_SPIRIT_RP_EMIT(NS_OPEN,BOOST_SPIRIT__NAMESPACE,-) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RP_AP_IMPL // @@ -385,7 +385,7 @@ namespace boost { return ns :: action_chain< name, ns :: append, Action> (__a); } \ }; \ } \ - __action_placeholder:: name const name = __action_placeholder:: name (); + __action_placeholder:: name const name = __action_placeholder:: name (); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RP_IMPL_I // @@ -409,7 +409,7 @@ namespace boost \ template< BOOST_SPIRIT_RP_TPL_PARAMS(pars,acts,typename __,1) > \ class name_t \ - : public ::BOOST_SPIRIT_CLASSIC_NS::parser< name_t \ + : public ::BOOST_SPIRIT_CLASSIC_NS::parser< name_t \ < BOOST_SPIRIT_RP_TPL_PARAMS(pars,acts,__,0) > > \ { \ class __rule \ @@ -419,7 +419,7 @@ namespace boost BOOST_SPIRIT_RP_EMIT(MV_STATIC,mbrs,BOOST_PP_IDENTITY(typename)) \ public: \ BOOST_TYPEOF_NESTED_TYPEDEF_TPL(__expr, \ - ::BOOST_SPIRIT_CLASSIC_NS::type_of::depend_on_type<__Dummy>(x) ) \ + ::BOOST_SPIRIT_CLASSIC_NS::type_of::depend_on_type<__Dummy>(x) ) \ }; \ \ public: \ @@ -471,7 +471,7 @@ namespace boost BOOST_PP_IF(np,BOOST_SPIRIT_RP_GEN_FUNC,BOOST_SPIRIT_RP_GLOB_VAR) \ (name,name_t,np,na) \ BOOST_SPIRIT_RP_REGISTER_TEMPLATE \ - (name_t,BOOST_PP_INC(BOOST_PP_ADD(np,na))) + (name_t,BOOST_PP_INC(BOOST_PP_ADD(np,na))) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RP_OPAQUE_IMPL_I // @@ -536,7 +536,7 @@ namespace boost BOOST_PP_IF(np,BOOST_SPIRIT_RP_GEN_OPAQUE,BOOST_SPIRIT_RP_GLOB_OPAQUE) \ (name,name_t,np,pars) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// RP_AP_HANDLER +// RP_AP_HANDLER // // Part of the rule parser definition for handling action placeholders # define BOOST_SPIRIT_RP_AP_HANDLER(name_t,np,acts,na,ns) \ @@ -590,7 +590,7 @@ namespace boost # define BOOST_SPIRIT_RP_AP_EXTRA_MBRS(np,na) \ private: \ BOOST_PP_REPEAT(np,BOOST_SPIRIT_RP_PM_MBRS,-) \ - BOOST_PP_REPEAT(na,BOOST_SPIRIT_RP_AP_MBRS,-) + BOOST_PP_REPEAT(na,BOOST_SPIRIT_RP_AP_MBRS,-) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RP_PM_MBRS // @@ -617,7 +617,7 @@ namespace boost // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RP_TPL_PARAMS // -// Expands to the template parameters or arguments of the rule parser template +// Expands to the template parameters or arguments of the rule parser template # define BOOST_SPIRIT_RP_TPL_PARAMS(pars,acts,prefix,defaults) \ prefix ## Dummy \ BOOST_SPIRIT_RP_EMIT(PM_TEMPLATE_PARAMS,pars,prefix ## T) \ @@ -679,7 +679,7 @@ namespace boost // PM_CTOR_PARAMS # define BOOST_SPIRIT_RP__PM_CTOR_PARAMS(r,data,i,elem) \ BOOST_PP_COMMA_IF(i) \ - typename ::boost::call_traits< data ## i >::param_type elem + typename ::boost::call_traits< data ## i >::param_type elem // PM_CTOR_ARGS # define BOOST_SPIRIT_RP__PM_CTOR_ARGS(r,data,i,elem) \ @@ -777,7 +777,7 @@ namespace boost // AP_REBOUND_TPL_ARGS # define BOOST_SPIRIT_RP__AP_REBOUND_TPL_ARGS(r,data,i,elem) \ , typename ::BOOST_SPIRIT_CLASSIC_NS::type_of::placeholdee< \ - __action_placeholder:: elem , __A ## i, data >::type + __action_placeholder:: elem , __A ## i, data >::type // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // PP_EMIT @@ -787,7 +787,7 @@ namespace boost # define BOOST_SPIRIT_RP_EMIT(op, array, data) \ BOOST_SPIRIT_RP_ARRAY_FOR_EACH_I(BOOST_SPIRIT_RP__ ## op,data,array) // --- --- - - --- - - --- - - - - --- - - - - - - - - - - - - - - - - - - - - - -// RP_ARRAY_FOR_EACH_I +// RP_ARRAY_FOR_EACH_I // // Iterates an optional array. That is you can pass e.g.'-' or 'none' to denote // emptiness. @@ -796,13 +796,13 @@ namespace boost BOOST_SPIRIT_RP_ARRAY_FOR_EACH_I_IMPL, \ BOOST_PP_TUPLE_EAT(3))(macro,data,optional_array) -// RP_ARRAY_FOR_EACH_I_IMPL +// RP_ARRAY_FOR_EACH_I_IMPL # define BOOST_SPIRIT_RP_ARRAY_FOR_EACH_I_IMPL(macro,data,array) \ BOOST_SPIRIT_RP_IF(BOOST_PP_ARRAY_SIZE(array),PP_SEQ_FOR_EACH_I,3) \ (macro,data, BOOST_SPIRIT_RP_IF(BOOST_PP_ARRAY_SIZE(array), \ PP_TUPLE_TO_SEQ,2) array) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// RP_ARRAY_SIZE +// RP_ARRAY_SIZE // // Expands to the size of an "optional array". // @@ -818,7 +818,7 @@ namespace boost BOOST_PP_ARRAY_SIZE, 0 BOOST_PP_TUPLE_EAT(1))(optional_array) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RP_OPTIONAL -// +// // Expands to nothing if the argument is parenthesized. // // Examples: @@ -827,7 +827,7 @@ namespace boost // BOOST_SPIRIT_RP_OPTIONAL( (none) ) // evaluates to nothing // # define BOOST_SPIRIT_RP_OPTIONAL(elem) \ - BOOST_PP_EXPR_IIF(BOOST_PP_COMPL(BOOST_PP_IS_UNARY(elem)),elem) + BOOST_PP_EXPR_IIF(BOOST_PP_COMPL(BOOST_PP_IS_UNARY(elem)),elem) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // RP_COMMA_IF_OR // @@ -851,13 +851,13 @@ namespace boost // Wrapper and gernator function to embed a parser by reference //------------------------------------------------------------------------------ -namespace boost { namespace spirit { +namespace boost { namespace spirit { BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN // Wrapper to embed a parser by reference - template<class P> class parser_reference + template<class P> class parser_reference : public parser< parser_reference<P> > { P const & ref_that; @@ -868,19 +868,19 @@ BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN { } typedef parser_reference<P> self_t; - typedef self_t const & embed_t; + typedef self_t const & embed_t; typedef typename P::parser_category_t parser_category_t; - template<typename ScannerT> struct result + template<typename ScannerT> struct result { typedef typename P::BOOST_NESTED_TEMPLATE result<ScannerT>::type type; }; - template<typename ScannerT> + template<typename ScannerT> typename result<ScannerT>::type parse(ScannerT const & scan) const { return this->ref_that.parse(scan); } }; - template<class P> parser_reference<P> + template<class P> parser_reference<P> embed_by_reference(::BOOST_SPIRIT_CLASSIC_NS::parser<P> & p) { return p; } @@ -894,18 +894,18 @@ BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::parser_reference, 1) // Expression templates for action placeholders. //------------------------------------------------------------------------------ -namespace boost { namespace spirit { +namespace boost { namespace spirit { BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN -namespace type_of { +namespace type_of { // No-operation functor - struct nop_functor + struct nop_functor { template<typename T> - bool operator()(T const &) const + bool operator()(T const &) const { return false; } template<typename T, typename U> bool operator()(T const &, U const &) const @@ -949,26 +949,26 @@ namespace type_of { { typedef Action type; - static type concatenate(nop_functor const &, Action const & a) + static type concatenate(nop_functor const &, Action const & a) { return a; } }; template<typename Action> struct action_concatenator<Action, nop_functor> { typedef Action type; - static type concatenate(Action const & a, nop_functor const &) + static type concatenate(Action const & a, nop_functor const &) { return a; } }; template<> struct action_concatenator<nop_functor, nop_functor> { typedef nop_functor type; - static type concatenate(nop_functor const &, nop_functor const &) + static type concatenate(nop_functor const &, nop_functor const &) { return nop_functor(); } }; template<typename Action1, typename Action2> - typename action_concatenator<Action1,Action2>::type + typename action_concatenator<Action1,Action2>::type concatenate_actions(Action1 const & a1, Action2 const & a2) { return action_concatenator<Action1,Action2>::concatenate(a1,a2); @@ -1017,17 +1017,17 @@ namespace type_of { head_type const & head() const { return obj_head; } tail_type const & tail() const { return obj_tail; } - }; + }; // Action chain concatenation template<class Head, class Tail> action_chains<Head,Tail> make_chain(Head const & h, Tail const & t) { return action_chains<Head,Tail>(h,t); } - template<class PH1, action_chain_mode M1, typename A1, + template<class PH1, action_chain_mode M1, typename A1, class PH2, action_chain_mode M2, typename A2> action_chains< action_chain<PH1,M1,A1>, action_chain<PH2,M2,A2> > - operator, (action_chain<PH1,M1,A1> const & h, + operator, (action_chain<PH1,M1,A1> const & h, action_chain<PH2,M2,A2> const & t) { return make_chain(h,t); } @@ -1037,12 +1037,12 @@ namespace type_of { { return make_chain(h,t); } - // Extract the (maybe composite) action associated with an action + // Extract the (maybe composite) action associated with an action // placeholders from the chains with a fold algorithm. template<class Placeholder, typename StartAction, class NewChainOrChains> struct placeholdee { - typedef StartAction type; + typedef StartAction type; static type get(StartAction const & a, NewChainOrChains const &) { return a; } @@ -1054,7 +1054,7 @@ namespace type_of { get_placeholdee(StartAction const & a, NewChainOrChains const & c) { return placeholdee<Placeholder,StartAction,NewChainOrChains>::get(a,c); } - template<class Placeholder, typename StartAction, class Head, class Tail> + template<class Placeholder, typename StartAction, class Head, class Tail> struct placeholdee < Placeholder, StartAction, action_chains<Head,Tail> > { @@ -1075,7 +1075,7 @@ namespace type_of { { typedef A type; - static type get(StartAction const &, + static type get(StartAction const &, action_chain<Placeholder,replace,A> const & c) { return c.action(); } }; @@ -1086,12 +1086,12 @@ namespace type_of { { typedef typename action_concatenator<StartAction,A>::type type; - static type get(StartAction const & a, + static type get(StartAction const & a, action_chain<Placeholder,append,A> const & c) { return concatenate_actions(a,c.action()); } }; -} +} BOOST_SPIRIT_CLASSIC_NAMESPACE_END @@ -1104,7 +1104,7 @@ BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::type_of::composite_actio // Misc.utilities //------------------------------------------------------------------------------ -namespace boost { namespace spirit { +namespace boost { namespace spirit { BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN @@ -1113,7 +1113,7 @@ namespace type_of { // Utility function to create a dependency to a template argument. template<typename T, typename X> - X const & depend_on_type(X const & x) + X const & depend_on_type(X const & x) { return x; } // Utility to allow use parenthesized type expressions with commas inside @@ -1130,13 +1130,13 @@ namespace type_of { template<typename T> struct remove_special_fptr< special_result & (*)(T) > { typedef T type; }; -} +} BOOST_SPIRIT_CLASSIC_NAMESPACE_END } } // namespace ::BOOST_SPIRIT_CLASSIC_NS::type_of //------------------------------------------------------------------------------ -#endif +#endif //------------------------------------------------------------------------------ diff --git a/boost/spirit/home/karma.hpp b/boost/spirit/home/karma.hpp index 90bb3fd393..464b5d7f4c 100644 --- a/boost/spirit/home/karma.hpp +++ b/boost/spirit/home/karma.hpp @@ -1,6 +1,6 @@ // Copyright (c) 2001-2011 Hartmut Kaiser -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying +// +// 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_KARMA_CORE_MARCH_06_2007_0833PM) diff --git a/boost/spirit/home/karma/auto/auto.hpp b/boost/spirit/home/karma/auto/auto.hpp index acbfcee340..5d1a0a17bd 100644 --- a/boost/spirit/home/karma/auto/auto.hpp +++ b/boost/spirit/home/karma/auto/auto.hpp @@ -90,7 +90,7 @@ namespace boost { namespace spirit { namespace karma // without providing any attribute, as the generator doesn't 'know' // what to output. The following assertion fires if this situation // is detected in your code. - BOOST_SPIRIT_ASSERT_MSG(false, auto_not_usable_without_attribute, ()); + BOOST_SPIRIT_ASSERT_FAIL(OutputIterator, auto_not_usable_without_attribute, ()); return false; } diff --git a/boost/spirit/home/karma/binary/binary.hpp b/boost/spirit/home/karma/binary/binary.hpp index cbb190018e..4f88617dbe 100644 --- a/boost/spirit/home/karma/binary/binary.hpp +++ b/boost/spirit/home/karma/binary/binary.hpp @@ -280,7 +280,7 @@ namespace boost { namespace spirit { namespace karma // without providing any attribute, as the generator doesn't 'know' // what to output. The following assertion fires if this situation // is detected in your code. - BOOST_SPIRIT_ASSERT_MSG(false, + BOOST_SPIRIT_ASSERT_FAIL(OutputIterator, binary_generator_not_usable_without_attribute, ()); return false; } diff --git a/boost/spirit/home/karma/char/char.hpp b/boost/spirit/home/karma/char/char.hpp index de26cf476f..0d9b4f6b28 100644 --- a/boost/spirit/home/karma/char/char.hpp +++ b/boost/spirit/home/karma/char/char.hpp @@ -137,7 +137,7 @@ namespace boost { namespace spirit { namespace karma // providing any attribute, as the generator doesn't 'know' what // character to output. The following assertion fires if this // situation is detected in your code. - BOOST_SPIRIT_ASSERT_MSG(false, char_not_usable_without_attribute, ()); + BOOST_SPIRIT_ASSERT_FAIL(CharParam, char_not_usable_without_attribute, ()); return false; } @@ -230,11 +230,11 @@ namespace boost { namespace spirit { namespace karma template <typename CharParam, typename Context> bool test(unused_type, CharParam&, Context&) const { - // It is not possible (doesn't make sense) to use char_ generators - // without providing any attribute, as the generator doesn't 'know' + // It is not possible (doesn't make sense) to use char_ generators + // without providing any attribute, as the generator doesn't 'know' // what to output. The following assertion fires if this situation // is detected in your code. - BOOST_SPIRIT_ASSERT_MSG(false + BOOST_SPIRIT_ASSERT_FAIL(CharParam , char_range_not_usable_without_attribute, ()); return false; } @@ -316,11 +316,11 @@ namespace boost { namespace spirit { namespace karma template <typename CharParam, typename Context> bool test(unused_type, CharParam&, Context&) const { - // It is not possible (doesn't make sense) to use char_ generators - // without providing any attribute, as the generator doesn't 'know' + // It is not possible (doesn't make sense) to use char_ generators + // without providing any attribute, as the generator doesn't 'know' // what to output. The following assertion fires if this situation // is detected in your code. - BOOST_SPIRIT_ASSERT_MSG(false + BOOST_SPIRIT_ASSERT_FAIL(CharParam , char_set_not_usable_without_attribute, ()); return false; } diff --git a/boost/spirit/home/karma/char/char_class.hpp b/boost/spirit/home/karma/char/char_class.hpp index f3c7ab1821..30858b1691 100644 --- a/boost/spirit/home/karma/char/char_class.hpp +++ b/boost/spirit/home/karma/char/char_class.hpp @@ -95,11 +95,11 @@ namespace boost { namespace spirit { namespace karma template <typename CharParam, typename Context> bool test(unused_type, CharParam&, Context&) const { - // It is not possible (doesn't make sense) to use char_ generators - // without providing any attribute, as the generator doesn't 'know' + // It is not possible (doesn't make sense) to use char_ generators + // without providing any attribute, as the generator doesn't 'know' // what to output. The following assertion fires if this situation // is detected in your code. - BOOST_SPIRIT_ASSERT_MSG(false + BOOST_SPIRIT_ASSERT_FAIL(CharParam , char_class_not_usable_without_attribute, ()); return false; } diff --git a/boost/spirit/home/karma/detail/indirect_iterator.hpp b/boost/spirit/home/karma/detail/indirect_iterator.hpp index fdd12f3b49..a9f3cc80c1 100644 --- a/boost/spirit/home/karma/detail/indirect_iterator.hpp +++ b/boost/spirit/home/karma/detail/indirect_iterator.hpp @@ -25,14 +25,16 @@ namespace boost { namespace spirit { namespace karma { namespace detail indirect_iterator<Iterator> , typename boost::detail::iterator_traits<Iterator>::value_type , boost::forward_traversal_tag - , typename boost::detail::iterator_traits<Iterator>::value_type const&> + , typename boost::detail::iterator_traits<Iterator>::reference> { typedef typename boost::detail::iterator_traits<Iterator>::value_type base_value_type; + typedef typename boost::detail::iterator_traits<Iterator>::reference + base_reference_type; typedef boost::iterator_facade< indirect_iterator<Iterator>, base_value_type - , boost::forward_traversal_tag, base_value_type const& + , boost::forward_traversal_tag, base_reference_type > base_type; public: @@ -56,7 +58,7 @@ namespace boost { namespace spirit { namespace karma { namespace detail return *iter_ == *other.iter_; } - typename base_type::reference dereference() const + base_reference_type dereference() const { return **iter_; } diff --git a/boost/spirit/home/karma/detail/output_iterator.hpp b/boost/spirit/home/karma/detail/output_iterator.hpp index 34dc070f44..f49c8a0407 100644 --- a/boost/spirit/home/karma/detail/output_iterator.hpp +++ b/boost/spirit/home/karma/detail/output_iterator.hpp @@ -22,6 +22,10 @@ #include <boost/spirit/home/support/iterators/ostream_iterator.hpp> #include <boost/spirit/home/support/unused.hpp> +#if defined(BOOST_MSVC) && defined(BOOST_SPIRIT_UNICODE) +#include <boost/spirit/home/support/char_encoding/unicode.hpp> +#endif + namespace boost { namespace spirit { namespace karma { namespace detail { /////////////////////////////////////////////////////////////////////////// @@ -64,7 +68,7 @@ namespace boost { namespace spirit { namespace karma { namespace detail template <typename T> void output(T const& value) - { + { // track position in the output track_position_data.output(value); } @@ -110,7 +114,7 @@ namespace boost { namespace spirit { namespace karma { namespace detail } void output() - { + { ++count; } std::size_t get_count() const { return count; } @@ -147,7 +151,7 @@ namespace boost { namespace spirit { namespace karma { namespace detail template <typename T> void output(T const&) - { + { // count characters, if appropriate if (NULL != count) count->output(); @@ -172,24 +176,33 @@ namespace boost { namespace spirit { namespace karma { namespace detail /////////////////////////////////////////////////////////////////////////// class buffer_sink : boost::noncopyable { + // 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) + typedef spirit::char_encoding::unicode::char_type buffer_char_type; +#else + typedef wchar_t buffer_char_type; +#endif + public: buffer_sink() : width(0) {} ~buffer_sink() - { + { tidy(); } void enable(std::size_t width_) - { + { tidy(); // release existing buffer width = (width_ == std::size_t(-1)) ? 0 : width_; buffer.reserve(width); } void tidy() - { + { buffer.clear(); width = 0; } @@ -197,18 +210,18 @@ namespace boost { namespace spirit { namespace karma { namespace detail template <typename T> void output(T const& value) { - BOOST_STATIC_ASSERT(sizeof(T) <= sizeof(wchar_t)); + BOOST_STATIC_ASSERT(sizeof(T) <= sizeof(buffer_char_type)); buffer.push_back(value); } template <typename OutputIterator_> bool copy(OutputIterator_& sink, std::size_t maxwidth) const - { + { #if defined(BOOST_MSVC) #pragma warning(push) #pragma warning(disable: 4267) #endif - typename std::basic_string<wchar_t>::const_iterator end = + typename std::basic_string<buffer_char_type>::const_iterator end = buffer.begin() + (std::min)(buffer.size(), maxwidth); #if defined(BOOST_MSVC) @@ -219,12 +232,12 @@ namespace boost { namespace spirit { namespace karma { namespace detail } template <typename RestIterator> bool copy_rest(RestIterator& sink, std::size_t start_at) const - { + { #if defined(BOOST_MSVC) #pragma warning(push) #pragma warning(disable: 4267) #endif - typename std::basic_string<wchar_t>::const_iterator begin = + typename std::basic_string<buffer_char_type>::const_iterator begin = buffer.begin() + (std::min)(buffer.size(), start_at); #if defined(BOOST_MSVC) @@ -235,13 +248,13 @@ namespace boost { namespace spirit { namespace karma { namespace detail } std::size_t buffer_size() const - { + { return buffer.size(); } private: std::size_t width; - std::basic_string<wchar_t> buffer; + std::basic_string<buffer_char_type> buffer; }; /////////////////////////////////////////////////////////////////////////// @@ -452,6 +465,9 @@ namespace boost { namespace spirit { namespace karma { namespace detail // plain output iterators are considered to be good all the time bool good() const { return true; } + // allow to access underlying output iterator + OutputIterator& base() { return *sink; } + protected: // this is the wrapped user supplied output iterator OutputIterator* sink; diff --git a/boost/spirit/home/karma/detail/pass_container.hpp b/boost/spirit/home/karma/detail/pass_container.hpp index 07f2dad3c1..41c253d4b0 100644 --- a/boost/spirit/home/karma/detail/pass_container.hpp +++ b/boost/spirit/home/karma/detail/pass_container.hpp @@ -188,7 +188,7 @@ namespace boost { namespace spirit { namespace karma { namespace detail {}; // If both, the containers value type and the exposed attribute type are - // optionals we are allowed to pass through the the container only if the + // optionals we are allowed to pass through the container only if the // embedded types of those optionals are not compatible. template <typename Container, typename ValueType, typename Attribute , typename Sequence> @@ -203,6 +203,25 @@ namespace boost { namespace spirit { namespace karma { namespace detail // We pass through the container attribute if at least one of the embedded // types in the variant requires to pass through the attribute +#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) + template <typename Container, typename ValueType, typename Sequence + , typename T> + struct pass_through_container<Container, ValueType, boost::variant<T> + , Sequence> + : pass_through_container<Container, ValueType, T, Sequence> + {}; + + template <typename Container, typename ValueType, typename Sequence + , typename T0, typename ...TN> + struct pass_through_container<Container, ValueType + , boost::variant<T0, TN...>, Sequence> + : mpl::bool_<pass_through_container< + Container, ValueType, T0, Sequence + >::type::value || pass_through_container< + Container, ValueType, boost::variant<TN...>, Sequence + >::type::value> + {}; +#else #define BOOST_SPIRIT_PASS_THROUGH_CONTAINER(z, N, _) \ pass_through_container<Container, ValueType, \ BOOST_PP_CAT(T, N), Sequence>::type::value || \ @@ -224,6 +243,7 @@ namespace boost { namespace spirit { namespace karma { namespace detail {}; #undef BOOST_SPIRIT_PASS_THROUGH_CONTAINER +#endif }}}} /////////////////////////////////////////////////////////////////////////////// @@ -242,27 +262,51 @@ namespace boost { namespace spirit { namespace traits namespace boost { namespace spirit { namespace karma { namespace detail { + template <typename Iterator> + struct pass_container_base + { + pass_container_base(Iterator begin, Iterator end) + : iter(begin), end(end) + {} + + mutable Iterator iter; + mutable Iterator end; + }; + + template <typename Iterator> + struct pass_container_base<Iterator&> + { + pass_container_base(Iterator& begin, Iterator& end) + : iter(begin), end(end) + {} + + Iterator& iter; + Iterator& end; + }; + /////////////////////////////////////////////////////////////////////////// // This function handles the case where the attribute (Attr) given // to the sequence is an STL container. This is a wrapper around F. // The function F does the actual generating. template <typename F, typename Attr, typename Iterator, typename Sequence> - struct pass_container + struct pass_container : pass_container_base<Iterator> { + typedef pass_container_base<Iterator> base_type; typedef typename F::context_type context_type; pass_container(F const& f, Iterator begin, Iterator end) - : f(f), iter(begin), end(end) + : base_type(begin, end) + , f(f) {} bool is_at_end() const { - return traits::compare(iter, end); + return traits::compare(this->iter, this->end); } void next() { - traits::next(iter); + traits::next(this->iter); } // this is for the case when the current element expects an attribute @@ -271,10 +315,10 @@ namespace boost { namespace spirit { namespace karma { namespace detail bool dispatch_container(Component const& component, mpl::false_) const { // get the next value to generate from container - if (!is_at_end() && !f(component, traits::deref(iter))) + if (!is_at_end() && !f(component, traits::deref(this->iter))) { // needs to return false as long as everything is ok - traits::next(iter); + traits::next(this->iter); return false; } @@ -288,7 +332,7 @@ namespace boost { namespace spirit { namespace karma { namespace detail template <typename Component> bool dispatch_container(Component const& component, mpl::true_) const { - return f(component, make_iterator_range(iter, end)); + return f(component, make_iterator_range(this->iter, this->end)); } /////////////////////////////////////////////////////////////////////// @@ -338,8 +382,6 @@ namespace boost { namespace spirit { namespace karma { namespace detail } F f; - mutable Iterator iter; - mutable Iterator end; private: // silence MSVC warning C4512: assignment operator could not be generated diff --git a/boost/spirit/home/karma/directive/columns.hpp b/boost/spirit/home/karma/directive/columns.hpp index 75c029d2d1..78010db14a 100644 --- a/boost/spirit/home/karma/directive/columns.hpp +++ b/boost/spirit/home/karma/directive/columns.hpp @@ -25,6 +25,7 @@ #include <boost/spirit/home/support/info.hpp> #include <boost/fusion/include/at.hpp> #include <boost/fusion/include/vector.hpp> +#include <boost/integer_traits.hpp> namespace boost { namespace spirit { diff --git a/boost/spirit/home/karma/directive/omit.hpp b/boost/spirit/home/karma/directive/omit.hpp index ca6d7131ec..d07769e0c5 100644 --- a/boost/spirit/home/karma/directive/omit.hpp +++ b/boost/spirit/home/karma/directive/omit.hpp @@ -77,7 +77,7 @@ namespace boost { namespace spirit { namespace karma if (Execute) { // wrap the given output iterator to avoid output detail::disable_output<OutputIterator> disable(sink); - subject.generate(sink, ctx, d, attr); + return subject.generate(sink, ctx, d, attr); } return true; } diff --git a/boost/spirit/home/karma/nonterminal/rule.hpp b/boost/spirit/home/karma/nonterminal/rule.hpp index 623f638d51..8660f442a8 100644 --- a/boost/spirit/home/karma/nonterminal/rule.hpp +++ b/boost/spirit/home/karma/nonterminal/rule.hpp @@ -240,7 +240,7 @@ namespace boost { namespace spirit { namespace karma return r; } -#if defined(BOOST_NO_RVALUE_REFERENCES) +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) // non-const version needed to suppress proto's %= kicking in template <typename Expr> friend rule& operator%=(rule& r, Expr& expr) diff --git a/boost/spirit/home/karma/numeric/bool.hpp b/boost/spirit/home/karma/numeric/bool.hpp index 82db0423fd..bb041802a4 100644 --- a/boost/spirit/home/karma/numeric/bool.hpp +++ b/boost/spirit/home/karma/numeric/bool.hpp @@ -171,7 +171,7 @@ namespace boost { namespace spirit { namespace karma // without providing any attribute, as the generator doesn't 'know' // what to output. The following assertion fires if this situation // is detected in your code. - BOOST_SPIRIT_ASSERT_MSG(false, bool_not_usable_without_attribute, ()); + BOOST_SPIRIT_ASSERT_FAIL(OutputIterator, bool_not_usable_without_attribute, ()); return false; } diff --git a/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp b/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp index e1332d2367..2ce7b743ad 100644 --- a/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp +++ b/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp @@ -1,6 +1,6 @@ // Copyright (c) 2001-2011 Hartmut Kaiser -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying +// +// 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_KARMA_NUMERIC_UTILS_FEB_23_2007_0841PM) @@ -25,11 +25,11 @@ /////////////////////////////////////////////////////////////////////////////// // -// The value BOOST_KARMA_NUMERICS_LOOP_UNROLL specifies, how to unroll the +// The value BOOST_KARMA_NUMERICS_LOOP_UNROLL specifies, how to unroll the // integer string generation loop (see below). // -// Set the value to some integer in between 0 (no unrolling) and the -// largest expected generated integer string length (complete unrolling). +// Set the value to some integer in between 0 (no unrolling) and the +// largest expected generated integer string length (complete unrolling). // If not specified, this value defaults to 6. // /////////////////////////////////////////////////////////////////////////////// @@ -37,15 +37,15 @@ #define BOOST_KARMA_NUMERICS_LOOP_UNROLL 6 #endif -#if BOOST_KARMA_NUMERICS_LOOP_UNROLL < 0 +#if BOOST_KARMA_NUMERICS_LOOP_UNROLL < 0 #error "Please set the BOOST_KARMA_NUMERICS_LOOP_UNROLL to a non-negative value!" #endif namespace boost { namespace spirit { namespace traits -{ +{ /////////////////////////////////////////////////////////////////////// // - // return the absolute value from a given number, avoiding over- and + // return the absolute value from a given number, avoiding over- and // underflow // /////////////////////////////////////////////////////////////////////// @@ -153,36 +153,36 @@ namespace boost { namespace spirit { namespace traits template <typename T, typename Enable/* = void*/> struct is_negative { - static bool call(T n) - { - return (n < 0) ? true : false; + static bool call(T n) + { + return (n < 0) ? true : false; } }; template <> struct is_negative<float> { - static bool call(float n) - { - return (spirit::detail::signbit)(n) ? true : false; + static bool call(float n) + { + return (spirit::detail::signbit)(n) ? true : false; } }; template <> struct is_negative<double> { - static bool call(double n) - { - return (spirit::detail::signbit)(n) ? true : false; + static bool call(double n) + { + return (spirit::detail::signbit)(n) ? true : false; } }; template <> struct is_negative<long double> { - static bool call(long double n) - { - return (spirit::detail::signbit)(n) ? true : false; + static bool call(long double n) + { + return (spirit::detail::signbit)(n) ? true : false; } }; @@ -196,36 +196,36 @@ namespace boost { namespace spirit { namespace traits template <typename T, typename Enable/* = void*/> struct is_zero { - static bool call(T n) - { - return (n == 0) ? true : false; + static bool call(T n) + { + return (n == 0) ? true : false; } }; template <> struct is_zero<float> { - static bool call(float n) - { - return (math::fpclassify)(n) == FP_ZERO; + static bool call(float n) + { + return (math::fpclassify)(n) == FP_ZERO; } }; template <> struct is_zero<double> { - static bool call(double n) - { - return (math::fpclassify)(n) == FP_ZERO; + static bool call(double n) + { + return (math::fpclassify)(n) == FP_ZERO; } }; template <> struct is_zero<long double> { - static bool call(long double n) - { - return (math::fpclassify)(n) == FP_ZERO; + static bool call(long double n) + { + return (math::fpclassify)(n) == FP_ZERO; } }; @@ -239,8 +239,8 @@ namespace boost { namespace spirit { namespace traits template <typename T, typename Enable/* = void*/> struct is_nan { - static bool call(T n) - { + static bool call(T n) + { // NaN numbers are not equal to anything return (n != n) ? true : false; } @@ -249,27 +249,27 @@ namespace boost { namespace spirit { namespace traits template <> struct is_nan<float> { - static bool call(float n) - { - return (math::fpclassify)(n) == FP_NAN; + static bool call(float n) + { + return (math::fpclassify)(n) == FP_NAN; } }; template <> struct is_nan<double> { - static bool call(double n) - { - return (math::fpclassify)(n) == FP_NAN; + static bool call(double n) + { + return (math::fpclassify)(n) == FP_NAN; } }; template <> struct is_nan<long double> { - static bool call(long double n) - { - return (math::fpclassify)(n) == FP_NAN; + static bool call(long double n) + { + return (math::fpclassify)(n) == FP_NAN; } }; @@ -283,36 +283,38 @@ namespace boost { namespace spirit { namespace traits template <typename T, typename Enable/* = void*/> struct is_infinite { - static bool call(T n) - { - return (n == std::numeric_limits<T>::infinity()) ? true : false; + static bool call(T n) + { + if (!std::numeric_limits<T>::has_infinity) + return false; + return (n == std::numeric_limits<T>::infinity()) ? true : false; } }; template <> struct is_infinite<float> { - static bool call(float n) - { - return (math::fpclassify)(n) == FP_INFINITE; + static bool call(float n) + { + return (math::fpclassify)(n) == FP_INFINITE; } }; template <> struct is_infinite<double> { - static bool call(double n) - { - return (math::fpclassify)(n) == FP_INFINITE; + static bool call(double n) + { + return (math::fpclassify)(n) == FP_INFINITE; } }; template <> struct is_infinite<long double> { - static bool call(long double n) - { - return (math::fpclassify)(n) == FP_INFINITE; + static bool call(long double n) + { + return (math::fpclassify)(n) == FP_INFINITE; } }; @@ -343,7 +345,7 @@ namespace boost { namespace spirit { namespace traits template <typename T> static long call(T n, mpl::false_) { - // allow for ADL to find the correct overload for floor and + // allow for ADL to find the correct overload for floor and // lround using namespace std; return lround(floor(n)); @@ -367,19 +369,19 @@ namespace boost { namespace spirit { namespace traits { static long call(float n, mpl::false_) { - return test_negative(n) ? static_cast<long>(std::ceil(n)) : + return test_negative(n) ? static_cast<long>(std::ceil(n)) : static_cast<long>(std::floor(n)); } static long call(double n, mpl::false_) { - return test_negative(n) ? static_cast<long>(std::ceil(n)) : + return test_negative(n) ? static_cast<long>(std::ceil(n)) : static_cast<long>(std::floor(n)); } static long call(long double n, mpl::false_) { - return test_negative(n) ? static_cast<long>(std::ceil(n)) : + return test_negative(n) ? static_cast<long>(std::ceil(n)) : static_cast<long>(std::floor(n)); } @@ -408,7 +410,7 @@ namespace boost { namespace spirit { namespace traits // // Traits class for radix specific number conversion // - // Convert a digit from binary representation to character + // Convert a digit from binary representation to character // representation: // // static int call(unsigned n); @@ -451,7 +453,7 @@ namespace boost { namespace spirit { namespace traits } template <unsigned Radix, typename CharEncoding, typename Tag> - struct convert_digit + struct convert_digit : detail::convert_digit<CharEncoding, Tag, (Radix <= 10) ? true : false> {}; @@ -469,7 +471,7 @@ namespace boost { namespace spirit { namespace traits static T call(T& n, mpl::false_) { // Allow ADL to find the correct overload for floor - using namespace std; + using namespace std; return floor(n / Radix); } @@ -500,7 +502,7 @@ namespace boost { namespace spirit { namespace traits static T call(T, T& num, int exp, mpl::false_) { // Allow ADL to find the correct overload for floor - using namespace std; + using namespace std; return floor(num / spirit::traits::pow10<T>(exp)); } @@ -524,7 +526,7 @@ namespace boost { namespace spirit { namespace traits template <typename T> static long call(T n, mpl::true_) { - // this cast is safe since we know the result is not larger + // this cast is safe since we know the result is not larger // than Radix return static_cast<long>(n % Radix); } @@ -533,7 +535,7 @@ namespace boost { namespace spirit { namespace traits static long call(T n, mpl::false_) { // Allow ADL to find the correct overload for fmod - using namespace std; + using namespace std; return cast_to_long::call(fmod(n, T(Radix))); } @@ -545,16 +547,16 @@ namespace boost { namespace spirit { namespace traits }; }}} -namespace boost { namespace spirit { namespace karma -{ +namespace boost { namespace spirit { namespace karma +{ /////////////////////////////////////////////////////////////////////////// // - // The int_inserter template takes care of the integer to string + // The int_inserter template takes care of the integer to string // conversion. If specified, the loop is unrolled for better performance. // - // Set the value BOOST_KARMA_NUMERICS_LOOP_UNROLL to some integer in - // between 0 (no unrolling) and the largest expected generated integer - // string length (complete unrolling). + // Set the value BOOST_KARMA_NUMERICS_LOOP_UNROLL to some integer in + // between 0 (no unrolling) and the largest expected generated integer + // string length (complete unrolling). // If not specified, this value defaults to 6. // /////////////////////////////////////////////////////////////////////////// @@ -591,7 +593,7 @@ namespace boost { namespace spirit { namespace karma BOOST_KARMA_NUMERICS_LOOP_UNROLL, BOOST_KARMA_NUMERICS_INNER_LOOP_PREFIX, _); - if (!traits::test_zero(n)) + if (!traits::test_zero(n)) call(sink, n, num, exp); BOOST_PP_REPEAT( @@ -627,9 +629,9 @@ namespace boost { namespace spirit { namespace karma } public: - // Specialization for doubles and floats, falling back to long integers + // Specialization for doubles and floats, falling back to long integers // for representable values. These specializations speed up formatting - // of floating point numbers considerably as all the required + // of floating point numbers considerably as all the required // arithmetics will be executed using integral data types. template <typename OutputIterator> static bool @@ -671,7 +673,7 @@ namespace boost { namespace spirit { namespace karma /////////////////////////////////////////////////////////////////////////// // - // The uint_inserter template takes care of the conversion of any integer + // The uint_inserter template takes care of the conversion of any integer // to a string, while interpreting the number as an unsigned type. // /////////////////////////////////////////////////////////////////////////// @@ -697,7 +699,7 @@ namespace boost { namespace spirit { namespace karma // // The sign_inserter template generates a sign for a given numeric value. // - // The parameter forcesign allows to generate a sign even for positive + // The parameter forcesign allows to generate a sign even for positive // numbers. // /////////////////////////////////////////////////////////////////////////// @@ -705,10 +707,11 @@ namespace boost { namespace spirit { namespace karma { template <typename OutputIterator> static bool - call_noforce(OutputIterator& sink, bool /*is_zero*/, bool is_negative) + call_noforce(OutputIterator& sink, bool is_zero, bool is_negative, + bool sign_if_zero) { // generate a sign for negative numbers only - if (is_negative) { + if (is_negative || (is_zero && sign_if_zero)) { *sink = '-'; ++sink; } @@ -717,12 +720,13 @@ namespace boost { namespace spirit { namespace karma template <typename OutputIterator> static bool - call_force(OutputIterator& sink, bool is_zero, bool is_negative) + call_force(OutputIterator& sink, bool is_zero, bool is_negative, + bool sign_if_zero) { // generate a sign for all numbers except zero - if (!is_zero) + if (!is_zero || sign_if_zero) *sink = is_negative ? '-' : '+'; - else + else *sink = ' '; ++sink; @@ -732,11 +736,11 @@ namespace boost { namespace spirit { namespace karma template <typename OutputIterator> static bool call(OutputIterator& sink, bool is_zero, bool is_negative - , bool forcesign) + , bool forcesign, bool sign_if_zero = false) { return forcesign ? - call_force(sink, is_zero, is_negative) : - call_noforce(sink, is_zero, is_negative); + call_force(sink, is_zero, is_negative, sign_if_zero) : + call_noforce(sink, is_zero, is_negative, sign_if_zero); } }; diff --git a/boost/spirit/home/karma/numeric/detail/real_utils.hpp b/boost/spirit/home/karma/numeric/detail/real_utils.hpp index 493cf3b1a7..6acaf87707 100644 --- a/boost/spirit/home/karma/numeric/detail/real_utils.hpp +++ b/boost/spirit/home/karma/numeric/detail/real_utils.hpp @@ -46,11 +46,11 @@ namespace boost { namespace spirit { namespace karma call (OutputIterator& sink, U n, Policies const& p = Policies()) { if (traits::test_nan(n)) { - return Policies::template nan<CharEncoding, Tag>( + return p.template nan<CharEncoding, Tag>( sink, n, p.force_sign(n)); } else if (traits::test_infinite(n)) { - return Policies::template inf<CharEncoding, Tag>( + return p.template inf<CharEncoding, Tag>( sink, n, p.force_sign(n)); } return p.template call<real_inserter>(sink, n, p); @@ -152,10 +152,12 @@ namespace boost { namespace spirit { namespace karma } // call the actual generating functions to output the different parts - if (sign_val && traits::test_zero(long_int_part) && + if ((force_sign || sign_val) && + traits::test_zero(long_int_part) && traits::test_zero(long_frac_part)) { sign_val = false; // result is zero, no sign please + force_sign = false; } // generate integer part diff --git a/boost/spirit/home/karma/numeric/int.hpp b/boost/spirit/home/karma/numeric/int.hpp index 59d380497c..39878e1f97 100644 --- a/boost/spirit/home/karma/numeric/int.hpp +++ b/boost/spirit/home/karma/numeric/int.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2001-2011 Hartmut Kaiser +// Copyright (c) 2001-2012 Hartmut Kaiser // // 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) @@ -41,7 +41,7 @@ namespace boost { namespace spirit namespace tag { template <typename T, unsigned Radix, bool force_sign> - struct int_generator + struct int_generator { BOOST_SPIRIT_IS_TAG() }; @@ -252,7 +252,7 @@ namespace boost { namespace spirit { namespace karma // without providing any attribute, as the generator doesn't 'know' // what to output. The following assertion fires if this situation // is detected in your code. - BOOST_SPIRIT_ASSERT_MSG(false, int_not_usable_without_attribute, ()); + BOOST_SPIRIT_ASSERT_FAIL(OutputIterator, int_not_usable_without_attribute, ()); return false; } diff --git a/boost/spirit/home/karma/numeric/real.hpp b/boost/spirit/home/karma/numeric/real.hpp index cd1066a2f5..597ec4e46f 100644 --- a/boost/spirit/home/karma/numeric/real.hpp +++ b/boost/spirit/home/karma/numeric/real.hpp @@ -203,7 +203,8 @@ namespace boost { namespace spirit { namespace karma // without providing any attribute, as the generator doesn't 'know' // what to output. The following assertion fires if this situation // is detected in your code. - BOOST_SPIRIT_ASSERT_MSG(false, real_not_usable_without_attribute, ()); return false; + BOOST_SPIRIT_ASSERT_FAIL(OutputIterator, real_not_usable_without_attribute, ()); + return false; } template <typename Context> diff --git a/boost/spirit/home/karma/numeric/real_policies.hpp b/boost/spirit/home/karma/numeric/real_policies.hpp index 8fb560eea3..19843bb00c 100644 --- a/boost/spirit/home/karma/numeric/real_policies.hpp +++ b/boost/spirit/home/karma/numeric/real_policies.hpp @@ -175,19 +175,20 @@ namespace boost { namespace spirit { namespace karma // Generate the integer part of the number. // // sink The output iterator to use for generation - // n The absolute value of the integer part of the floating - // point number to convert (always non-negative). - // sign The sign of the overall floating point number to + // n The absolute value of the integer part of the floating + // point number to convert (always non-negative). + // sign The sign of the overall floating point number to // convert. - // force_sign Whether a sign has to be generated even for - // non-negative numbers + // force_sign Whether a sign has to be generated even for + // non-negative numbers. Note, that force_sign will be + // set to false for zero floating point values. /////////////////////////////////////////////////////////////////////// template <typename OutputIterator> static bool integer_part (OutputIterator& sink, T n, bool sign , bool force_sign) { return sign_inserter::call( - sink, traits::test_zero(n), sign, force_sign) && + sink, traits::test_zero(n), sign, force_sign, force_sign) && int_inserter<10>::call(sink, n); } diff --git a/boost/spirit/home/karma/numeric/uint.hpp b/boost/spirit/home/karma/numeric/uint.hpp index 35ae1951e5..1a34b8d18b 100644 --- a/boost/spirit/home/karma/numeric/uint.hpp +++ b/boost/spirit/home/karma/numeric/uint.hpp @@ -287,7 +287,7 @@ namespace boost { namespace spirit { namespace karma // without providing any attribute, as the generator doesn't 'know' // what to output. The following assertion fires if this situation // is detected in your code. - BOOST_SPIRIT_ASSERT_MSG(false, uint_not_usable_without_attribute, ()); + BOOST_SPIRIT_ASSERT_FAIL(OutputIterator, uint_not_usable_without_attribute, ()); return false; } diff --git a/boost/spirit/home/karma/operator/alternative.hpp b/boost/spirit/home/karma/operator/alternative.hpp index 0f709fbd76..6883ee204e 100644 --- a/boost/spirit/home/karma/operator/alternative.hpp +++ b/boost/spirit/home/karma/operator/alternative.hpp @@ -62,7 +62,7 @@ namespace boost { namespace spirit { namespace traits }; // never called, but needed for decltype-based result_of (C++0x) -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template <typename Element> typename result<element_properties(Element)>::type operator()(Element&&) const; diff --git a/boost/spirit/home/karma/operator/list.hpp b/boost/spirit/home/karma/operator/list.hpp index 45798746d9..e64a9bf730 100644 --- a/boost/spirit/home/karma/operator/list.hpp +++ b/boost/spirit/home/karma/operator/list.hpp @@ -47,12 +47,12 @@ namespace boost { namespace spirit { namespace karma template <typename F, typename Attribute> bool generate_left(F f, Attribute const&, mpl::false_) const { - // Failing subject generators are just skipped. This allows to + // Failing subject generators are just skipped. This allows to // selectively generate items in the provided attribute. while (!f.is_at_end()) { bool r = !f(left); - if (r) + if (r) return true; if (!f.is_at_end()) f.next(); @@ -66,7 +66,7 @@ namespace boost { namespace spirit { namespace karma return !f(left); } - // There is no way to distinguish a failed generator from a + // There is no way to distinguish a failed generator from a // generator to be skipped. We assume the user takes responsibility // for ending the loop if no attribute is specified. template <typename F> @@ -80,9 +80,9 @@ namespace boost { namespace spirit { namespace karma typedef Right right_type; typedef mpl::int_< - left_type::properties::value - | right_type::properties::value - | generator_properties::buffering + left_type::properties::value + | right_type::properties::value + | generator_properties::buffering | generator_properties::counting > properties; @@ -96,7 +96,7 @@ namespace boost { namespace spirit { namespace karma {}; base_list(Left const& left, Right const& right) - : left(left), right(right) + : left(left), right(right) {} template < @@ -113,8 +113,8 @@ namespace boost { namespace spirit { namespace karma typename add_const<Attribute>::type >::type iterator_type; - typedef - typename traits::make_indirect_iterator<iterator_type>::type + typedef + typename traits::make_indirect_iterator<iterator_type>::type indirect_iterator_type; typedef detail::pass_container< fail_function, Attribute, indirect_iterator_type, mpl::false_> @@ -123,7 +123,7 @@ namespace boost { namespace spirit { namespace karma iterator_type it = traits::begin(attr); iterator_type end = traits::end(attr); - pass_container pass(fail_function(sink, ctx, d), + pass_container pass(fail_function(sink, ctx, d), indirect_iterator_type(it), indirect_iterator_type(end)); if (generate_left(pass, attr, Strict())) @@ -160,7 +160,7 @@ namespace boost { namespace spirit { namespace karma }; template <typename Left, typename Right> - struct list + struct list : base_list<Left, Right, mpl::false_, list<Left, Right> > { typedef base_list<Left, Right, mpl::false_, list> base_list_; @@ -170,7 +170,7 @@ namespace boost { namespace spirit { namespace karma }; template <typename Left, typename Right> - struct strict_list + struct strict_list : base_list<Left, Right, mpl::true_, strict_list<Left, Right> > { typedef base_list<Left, Right, mpl::true_, strict_list> base_list_; @@ -185,12 +185,12 @@ namespace boost { namespace spirit { namespace karma namespace detail { template <typename Subject, bool strict_mode = false> - struct make_list + struct make_list : make_binary_composite<Subject, list> {}; template <typename Subject> - struct make_list<Subject, true> + struct make_list<Subject, true> : make_binary_composite<Subject, strict_list> {}; } @@ -216,13 +216,13 @@ namespace boost { namespace spirit { namespace traits template <typename Left, typename Right, typename Attribute , typename Context, typename Iterator> struct handles_container<karma::list<Left, Right>, Attribute - , Context, Iterator> + , Context, Iterator> : mpl::true_ {}; template <typename Left, typename Right, typename Attribute , typename Context, typename Iterator> struct handles_container<karma::strict_list<Left, Right>, Attribute - , Context, Iterator> + , Context, Iterator> : mpl::true_ {}; }}} diff --git a/boost/spirit/home/karma/operator/sequence.hpp b/boost/spirit/home/karma/operator/sequence.hpp index c9acc6e3c3..d7ee806d54 100644 --- a/boost/spirit/home/karma/operator/sequence.hpp +++ b/boost/spirit/home/karma/operator/sequence.hpp @@ -73,7 +73,7 @@ namespace boost { namespace spirit { namespace traits }; // never called, but needed for decltype-based result_of (C++0x) -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template <typename Element> typename result<element_properties(Element)>::type operator()(Element&&) const; diff --git a/boost/spirit/home/karma/stream/stream.hpp b/boost/spirit/home/karma/stream/stream.hpp index d1cd45638e..1b679a8aab 100644 --- a/boost/spirit/home/karma/stream/stream.hpp +++ b/boost/spirit/home/karma/stream/stream.hpp @@ -142,12 +142,15 @@ namespace boost { namespace spirit { namespace karma // use existing operator<<() typedef typename attribute<Context>::type attribute_type; - boost::iostreams::stream<sink_device> ostr(sink); - ostr << traits::extract_from<attribute_type>(attr, context) << std::flush; + { + boost::iostreams::stream<sink_device> ostr(sink); + ostr << traits::extract_from<attribute_type>(attr, context) << std::flush; - if (ostr.good()) - return karma::delimit_out(sink, d); // always do post-delimiting - return false; + if (!ostr.good()) + return false; + } + + return karma::delimit_out(sink, d); // always do post-delimiting } // this is a special overload to detect if the output iterator has been @@ -175,14 +178,16 @@ namespace boost { namespace spirit { namespace karma // use existing operator<<() typedef typename attribute<Context>::type attribute_type; - boost::iostreams::stream<sink_device> ostr(sink); - ostr.imbue(sink.get_ostream().getloc()); - ostr << traits::extract_from<attribute_type>(attr, context) - << std::flush; + { + boost::iostreams::stream<sink_device> ostr(sink); + ostr.imbue(sink.get_ostream().getloc()); + ostr << traits::extract_from<attribute_type>(attr, context) + << std::flush; + if (!ostr.good()) + return false; + } - if (ostr.good()) - return karma::delimit_out(sink, d); // always do post-delimiting - return false; + return karma::delimit_out(sink, d); // always do post-delimiting } // this any_stream has no parameter attached, it needs to have been @@ -192,11 +197,11 @@ namespace boost { namespace spirit { namespace karma static bool generate(OutputIterator&, Context&, Delimiter const&, unused_type) { - // It is not possible (doesn't make sense) to use stream generators - // without providing any attribute, as the generator doesn't 'know' + // It is not possible (doesn't make sense) to use stream generators + // without providing any attribute, as the generator doesn't 'know' // what to output. The following assertion fires if this situation // is detected in your code. - BOOST_SPIRIT_ASSERT_MSG(false, stream_not_usable_without_attribute, ()); + BOOST_SPIRIT_ASSERT_FAIL(OutputIterator, stream_not_usable_without_attribute, ()); return false; } @@ -260,13 +265,16 @@ namespace boost { namespace spirit { namespace karma output_iterator, Char, CharEncoding, Tag > sink_device; - boost::iostreams::stream<sink_device> ostr(sink); - ostr.imbue(sink.get_ostream().getloc()); - ostr << t_ << std::flush; // use existing operator<<() + { + boost::iostreams::stream<sink_device> ostr(sink); + ostr.imbue(sink.get_ostream().getloc()); + ostr << t_ << std::flush; // use existing operator<<() - if (ostr.good()) - return karma::delimit_out(sink, d); // always do post-delimiting - return false; + if (!ostr.good()) + return false; + } + + return karma::delimit_out(sink, d); // always do post-delimiting } template <typename Context> diff --git a/boost/spirit/home/karma/string/lit.hpp b/boost/spirit/home/karma/string/lit.hpp index 831063b598..0b9a6414ce 100644 --- a/boost/spirit/home/karma/string/lit.hpp +++ b/boost/spirit/home/karma/string/lit.hpp @@ -127,7 +127,7 @@ namespace boost { namespace spirit { namespace karma // providing any attribute, as the generator doesn't 'know' what // character to output. The following assertion fires if this // situation is detected in your code. - BOOST_SPIRIT_ASSERT_MSG(false, string_not_usable_without_attribute, ()); + BOOST_SPIRIT_ASSERT_FAIL(OutputIterator, string_not_usable_without_attribute, ()); return false; } diff --git a/boost/spirit/home/karma/string/symbols.hpp b/boost/spirit/home/karma/string/symbols.hpp index 185a280a50..72c82d1115 100644 --- a/boost/spirit/home/karma/string/symbols.hpp +++ b/boost/spirit/home/karma/string/symbols.hpp @@ -298,7 +298,7 @@ namespace boost { namespace spirit { namespace karma return sym.remove(attr); } -#if defined(BOOST_NO_RVALUE_REFERENCES) +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) // non-const version needed to suppress proto's += kicking in template <typename Attr, typename T_> friend adder const& diff --git a/boost/spirit/home/lex/argument.hpp b/boost/spirit/home/lex/argument.hpp index edfee0be32..fbac3c1da5 100644 --- a/boost/spirit/home/lex/argument.hpp +++ b/boost/spirit/home/lex/argument.hpp @@ -110,12 +110,6 @@ namespace boost { namespace spirit { namespace lex state_setter(Actor const& actor) : actor_(actor) {} - // see explanation for this constructor at the end of this file -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 - state_setter(phoenix::actor<state_getter>, Actor const& actor) - : actor_(actor) {} -#endif - Actor actor_; }; @@ -190,12 +184,6 @@ namespace boost { namespace spirit { namespace lex value_setter(Actor const& actor) : actor_(actor) {} -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 - // see explanation for this constructor at the end of this file - value_setter(phoenix::actor<value_getter>, Actor const& actor) - : actor_(actor) {} -#endif - Actor actor_; }; @@ -281,81 +269,6 @@ namespace boost { namespace spirit { namespace lex #endif }}} -/////////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -namespace boost { namespace phoenix -{ - /////////////////////////////////////////////////////////////////////////// - // The specialization of as_actor_base<> below is needed to convert all - // occurrences of _state in places where it's used as a rvalue into the - // proper Phoenix actor (spirit::state_getter) accessing the lexer state. - template<> - struct as_actor_base<actor<spirit::lex::state_context> > - { - typedef spirit::lex::state_getter type; - - static spirit::lex::state_getter - convert(actor<spirit::lex::state_context>) - { - return spirit::lex::state_getter(); - } - }; - - /////////////////////////////////////////////////////////////////////////// - // The specialization of as_composite<> below is needed to convert all - // assignments to _state (places where it's used as a lvalue) into the - // proper Phoenix actor (spirit::state_setter) allowing to change the - // lexer state. - template <typename RHS> - struct as_composite<assign_eval, actor<spirit::lex::state_context>, RHS> - { - // For an assignment to _state (a spirit::state_context actor), this - // specialization makes Phoenix's compose() function construct a - // spirit::state_setter actor from 1. the LHS, a spirit::state_getter - // actor (due to the specialization of as_actor_base<> above), - // and 2. the RHS actor. - // This is why spirit::state_setter needs a constructor which takes - // a dummy spirit::state_getter as its first argument in addition - // to its real, second argument (the RHS actor). - typedef spirit::lex::state_setter<typename as_actor<RHS>::type> type; - }; - - /////////////////////////////////////////////////////////////////////////// - // The specialization of as_actor_base<> below is needed to convert all - // occurrences of _val in places where it's used as a rvalue into the - // proper Phoenix actor (spirit::value_getter) accessing the token value. - template<> - struct as_actor_base<actor<spirit::lex::value_context> > - { - typedef spirit::lex::value_getter type; - - static spirit::lex::value_getter - convert(actor<spirit::lex::value_context>) - { - return spirit::lex::value_getter(); - } - }; - - /////////////////////////////////////////////////////////////////////////// - // The specialization of as_composite<> below is needed to convert all - // assignments to _val (places where it's used as a lvalue) into the - // proper Phoenix actor (spirit::value_setter) allowing to change the - // token value. - template <typename RHS> - struct as_composite<assign_eval, actor<spirit::lex::value_context>, RHS> - { - // For an assignment to _val (a spirit::value_context actor), this - // specialization makes Phoenix's compose() function construct a - // spirit::value_setter actor from 1. the LHS, a spirit::value_getter - // actor (due to the specialization of as_actor_base<> above), - // and 2. the RHS actor. - // This is why spirit::value_setter needs a constructor which takes - // a dummy spirit::value_getter as its first argument in addition - // to its real, second argument (the RHS actor). - typedef spirit::lex::value_setter<typename as_actor<RHS>::type> type; - }; -}} -#endif #undef SPIRIT_DECLARE_ARG #endif diff --git a/boost/spirit/home/lex/argument_phoenix.hpp b/boost/spirit/home/lex/argument_phoenix.hpp index da24503c2a..7989b01999 100644 --- a/boost/spirit/home/lex/argument_phoenix.hpp +++ b/boost/spirit/home/lex/argument_phoenix.hpp @@ -82,7 +82,6 @@ namespace boost { namespace spirit { namespace lex }}} /////////////////////////////////////////////////////////////////////////////// -#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 BOOST_PHOENIX_DEFINE_EXPRESSION( (boost)(spirit)(lex)(value_setter) @@ -246,6 +245,4 @@ namespace boost { namespace phoenix {}; }} -#endif // BOOST_SPIRIT_USE_PHOENIX_V3 - #endif diff --git a/boost/spirit/home/lex/lexer/lexer.hpp b/boost/spirit/home/lex/lexer/lexer.hpp index 93412ce8ff..e733533a41 100644 --- a/boost/spirit/home/lex/lexer/lexer.hpp +++ b/boost/spirit/home/lex/lexer/lexer.hpp @@ -285,7 +285,7 @@ namespace boost { namespace spirit { namespace lex lexer_def_& operator= (lexer_def_ const&); }; -#if defined(BOOST_NO_RVALUE_REFERENCES) +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) // allow to assign a token definition expression template <typename LexerDef, typename Expr> inline lexer_def_<LexerDef>& diff --git a/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp b/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp index 207b374772..dfad49b67a 100644 --- a/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp +++ b/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp @@ -300,7 +300,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl data (IterData const& data_, Iterator& first, Iterator const& last) : base_type(data_, first, last) , actions_(data_.actions_), hold_() - , value_(iterator_range<Iterator>(first, last)) + , value_(iterator_range<Iterator>(last, last)) , has_value_(false), has_hold_(false) {} // invoke attached semantic actions, if defined diff --git a/boost/spirit/home/lex/lexer/lexertl/generate_static.hpp b/boost/spirit/home/lex/lexer/lexertl/generate_static.hpp index ea9799cc79..72b8014611 100644 --- a/boost/spirit/home/lex/lexer/lexertl/generate_static.hpp +++ b/boost/spirit/home/lex/lexer/lexertl/generate_static.hpp @@ -20,6 +20,7 @@ #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> /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace lex { namespace lexertl @@ -50,7 +51,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl { using namespace std; // some systems have size_t in ns std size_t len = strlen(source); - std::auto_ptr<wchar_t> result (new wchar_t[len+1]); + boost::scoped_array<wchar_t> result (new wchar_t[len+1]); result.get()[len] = '\0'; // working with wide character streams is supported only if the diff --git a/boost/spirit/home/lex/lexer/lexertl/iterator.hpp b/boost/spirit/home/lex/lexer/lexertl/iterator.hpp index f2793ba802..1b057203c4 100644 --- a/boost/spirit/home/lex/lexer/lexertl/iterator.hpp +++ b/boost/spirit/home/lex/lexer/lexertl/iterator.hpp @@ -10,6 +10,7 @@ #pragma once #endif +#include <boost/spirit/home/support/multi_pass_wrapper.hpp> #if defined(BOOST_SPIRIT_DEBUG) #include <boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp> #else @@ -115,7 +116,34 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl : 0; } }; +}} -}}}} +namespace traits +{ + template <typename Functor> + struct is_multi_pass<spirit::lex::lexertl::iterator<Functor> > + : mpl::true_ {}; + + template <typename Functor> + void clear_queue(spirit::lex::lexertl::iterator<Functor> & mp + , BOOST_SCOPED_ENUM(traits::clear_mode) mode) + { + mp.clear_queue(mode); + } + + template <typename Functor> + void inhibit_clear_queue(spirit::lex::lexertl::iterator<Functor>& mp, bool flag) + { + mp.inhibit_clear_queue(flag); + } + + template <typename Functor> + bool inhibit_clear_queue(spirit::lex::lexertl::iterator<Functor>& mp) + { + return mp.inhibit_clear_queue(); + } +} + +}} #endif diff --git a/boost/spirit/home/lex/lexer/lexertl/position_token.hpp b/boost/spirit/home/lex/lexer/lexertl/position_token.hpp index 025cf55d6a..7bf13db12f 100644 --- a/boost/spirit/home/lex/lexer/lexertl/position_token.hpp +++ b/boost/spirit/home/lex/lexer/lexertl/position_token.hpp @@ -35,9 +35,7 @@ #include <boost/mpl/or.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/range/iterator_range.hpp> -#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) #include <boost/static_assert.hpp> -#endif #if defined(BOOST_SPIRIT_DEBUG) #include <iosfwd> @@ -387,7 +385,7 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl token_value_type& value() { return value_; } token_value_type const& value() const { return value_; } - bool has_value() const { return value_; } + bool has_value() const { return !!value_; } #if BOOST_WORKAROUND(BOOST_MSVC, == 1600) // workaround for MSVC10 which has problems copying a default @@ -529,15 +527,13 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl : position_token<Iterator, lex::omit, HasState, Idtype> { private: // precondition assertions -#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) BOOST_STATIC_ASSERT((mpl::is_sequence<AttributeTypes>::value || is_same<AttributeTypes, lex::omit>::value)); -#endif typedef position_token<Iterator, lex::omit, HasState, Idtype> base_type; protected: - // If no additional token value types are given, the the token will + // If no additional token value types are given, the token will // hold no token value at all as the base class already has the // iterator pair of the matched range in the underlying input sequence. // Otherwise the token value is stored as a variant and will diff --git a/boost/spirit/home/lex/lexer/lexertl/token.hpp b/boost/spirit/home/lex/lexer/lexertl/token.hpp index 90961af156..9f4bdb3872 100644 --- a/boost/spirit/home/lex/lexer/lexertl/token.hpp +++ b/boost/spirit/home/lex/lexer/lexertl/token.hpp @@ -35,9 +35,7 @@ #include <boost/mpl/or.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/range/iterator_range.hpp> -#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) #include <boost/static_assert.hpp> -#endif #if defined(BOOST_SPIRIT_DEBUG) #include <iosfwd> @@ -330,14 +328,12 @@ namespace boost { namespace spirit { namespace lex { namespace lexertl struct token : token<Iterator, lex::omit, HasState, Idtype> { private: // precondition assertions -#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) BOOST_STATIC_ASSERT((mpl::is_sequence<AttributeTypes>::value || is_same<AttributeTypes, lex::omit>::value)); -#endif typedef token<Iterator, lex::omit, HasState, Idtype> base_type; protected: - // If no additional token value types are given, the the token will + // If no additional token value types are given, the token will // hold the plain pair of iterators pointing to the matched range // in the underlying input sequence. Otherwise the token value is // stored as a variant and will again hold the pair of iterators but diff --git a/boost/spirit/home/lex/lexer/support_functions.hpp b/boost/spirit/home/lex/lexer/support_functions.hpp index f3987c636a..8467560f67 100644 --- a/boost/spirit/home/lex/lexer/support_functions.hpp +++ b/boost/spirit/home/lex/lexer/support_functions.hpp @@ -47,11 +47,11 @@ namespace boost { namespace spirit { namespace lex template <typename Env> struct result { - typedef typename - remove_const< + typedef typename remove_reference< + typename remove_const< typename mpl::at_c<typename Env::args_type, 4>::type >::type - context_type; + >::type context_type; typedef typename context_type::base_iterator_type type; }; diff --git a/boost/spirit/home/lex/lexer/support_functions_expression.hpp b/boost/spirit/home/lex/lexer/support_functions_expression.hpp index 613a4a4704..3c7572d8d6 100644 --- a/boost/spirit/home/lex/lexer/support_functions_expression.hpp +++ b/boost/spirit/home/lex/lexer/support_functions_expression.hpp @@ -21,37 +21,6 @@ namespace boost { namespace spirit { namespace lex }}} /////////////////////////////////////////////////////////////////////////////// -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 - -namespace boost { namespace spirit { namespace lex -{ - namespace expression - { - template <typename Eval> - struct less - { - typedef phoenix::actor<lex::less_type<Eval> > type; - - static type make(Eval const & eval) - { - return lex::less_type<Eval>(eval); - } - }; - - template <typename IdType, typename State> - struct lookahead - { - typedef phoenix::actor<lex::lookahead_type<IdType, State> > type; - - static type make(IdType const & id_type, State const & state) - { - return lex::lookahead_type<IdType, State>(id_type, state); - } - }; - } -}}} - -#else // BOOST_SPIRIT_USE_PHOENIX_V3 BOOST_PHOENIX_DEFINE_EXPRESSION( (boost)(spirit)(lex)(less) @@ -130,6 +99,4 @@ namespace boost { namespace phoenix {}; }} -#endif // BOOST_SPIRIT_USE_PHOENIX_V3 - #endif diff --git a/boost/spirit/home/phoenix.hpp b/boost/spirit/home/phoenix.hpp deleted file mode 100644 index b14ea5dc89..0000000000 --- a/boost/spirit/home/phoenix.hpp +++ /dev/null @@ -1,23 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2008 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_PHOENIX_APRIL_11_2008_0850AM) -#define BOOST_SPIRIT_PHOENIX_APRIL_11_2008_0850AM - -#include <boost/spirit/home/phoenix/algorithm.hpp> -#include <boost/spirit/home/phoenix/bind.hpp> -#include <boost/spirit/home/phoenix/container.hpp> -#include <boost/spirit/home/phoenix/core.hpp> -#include <boost/spirit/home/phoenix/function.hpp> -#include <boost/spirit/home/phoenix/fusion.hpp> -#include <boost/spirit/home/phoenix/object.hpp> -#include <boost/spirit/home/phoenix/operator.hpp> -#include <boost/spirit/home/phoenix/scope.hpp> -#include <boost/spirit/home/phoenix/statement.hpp> -#include <boost/spirit/home/phoenix/stl.hpp> -#include <boost/spirit/home/phoenix/version.hpp> - -#endif diff --git a/boost/spirit/home/phoenix/algorithm.hpp b/boost/spirit/home/phoenix/algorithm.hpp deleted file mode 100644 index c3f7600830..0000000000 --- a/boost/spirit/home/phoenix/algorithm.hpp +++ /dev/null @@ -1,14 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_ALGORITHM_HPP -#define PHOENIX_ALGORITHM_HPP - -#include <boost/spirit/home/phoenix/stl/algorithm/iteration.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/querying.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/transformation.hpp> - -#endif diff --git a/boost/spirit/home/phoenix/bind.hpp b/boost/spirit/home/phoenix/bind.hpp deleted file mode 100644 index 5a90d44aab..0000000000 --- a/boost/spirit/home/phoenix/bind.hpp +++ /dev/null @@ -1,16 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_BIND_HPP -#define PHOENIX_BIND_HPP - -#include <boost/spirit/home/phoenix/version.hpp> -#include <boost/spirit/home/phoenix/bind/bind_function.hpp> -#include <boost/spirit/home/phoenix/bind/bind_function_object.hpp> -#include <boost/spirit/home/phoenix/bind/bind_member_function.hpp> -#include <boost/spirit/home/phoenix/bind/bind_member_variable.hpp> - -#endif diff --git a/boost/spirit/home/phoenix/bind/bind_function.hpp b/boost/spirit/home/phoenix/bind/bind_function.hpp deleted file mode 100644 index 9121fdc8cf..0000000000 --- a/boost/spirit/home/phoenix/bind/bind_function.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_BIND_BIND_FUNCTION_HPP -#define PHOENIX_BIND_BIND_FUNCTION_HPP - -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/core/detail/function_eval.hpp> -#include <boost/spirit/home/phoenix/bind/detail/function_ptr.hpp> - -namespace boost { namespace phoenix -{ - template <typename RT> - inline actor< - typename as_composite< - detail::function_eval<0> - , detail::function_ptr<0, RT, RT(*)()> - >::type> - bind(RT(*f)()) - { - typedef detail::function_ptr<0, RT, RT(*)()> fp_type; - return compose<detail::function_eval<0> >(fp_type(f)); - } - - template <typename RT, typename T0, typename A0> - inline actor< - typename as_composite< - detail::function_eval<1> - , detail::function_ptr<1, RT, RT(*)(T0)> - , A0 - >::type> - bind(RT(*f)(T0), A0 const& _0) - { - typedef detail::function_ptr<1, RT, RT(*)(T0)> fp_type; - return compose<detail::function_eval<1> >(fp_type(f), _0); - } - - template <typename RT, typename T0, typename T1, typename A0, typename A1> - inline actor< - typename as_composite< - detail::function_eval<2> - , detail::function_ptr<2, RT, RT(*)(T0, T1)> - , A0, A1 - >::type> - bind(RT(*f)(T0, T1), A0 const& _0, A1 const& _1) - { - typedef detail::function_ptr<2, RT, RT(*)(T0, T1)> fp_type; - return compose<detail::function_eval<2> >(fp_type(f), _0, _1); - } - - // Bring in the rest of the function binders - #include <boost/spirit/home/phoenix/bind/detail/bind_function.hpp> -}} - -#endif diff --git a/boost/spirit/home/phoenix/bind/bind_function_object.hpp b/boost/spirit/home/phoenix/bind/bind_function_object.hpp deleted file mode 100644 index 752ae3109f..0000000000 --- a/boost/spirit/home/phoenix/bind/bind_function_object.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_BIND_BIND_FUNCTION_OBJECT_HPP -#define PHOENIX_BIND_BIND_FUNCTION_OBJECT_HPP - -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/core/detail/function_eval.hpp> - -namespace boost { namespace phoenix -{ - template <typename F> - inline actor<typename as_composite<detail::function_eval<0>, F>::type> - bind(F const& f) - { - return compose<detail::function_eval<0> >(f); - } - - template <typename F, typename A0> - inline actor<typename as_composite<detail::function_eval<1>, F, A0>::type> - bind(F const& f, A0 const& _0) - { - return compose<detail::function_eval<1> >(f, _0); - } - - template <typename F, typename A0, typename A1> - inline actor<typename as_composite<detail::function_eval<2>, F, A0, A1>::type> - bind(F const& f, A0 const& _0, A1 const& _1) - { - return compose<detail::function_eval<2> >(f, _0, _1); - } - - // Bring in the rest of the function object binders - #include <boost/spirit/home/phoenix/bind/detail/bind_function_object.hpp> -}} - -#endif diff --git a/boost/spirit/home/phoenix/bind/bind_member_function.hpp b/boost/spirit/home/phoenix/bind/bind_member_function.hpp deleted file mode 100644 index 9d31a38490..0000000000 --- a/boost/spirit/home/phoenix/bind/bind_member_function.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_BIND_BIND_MEMBER_FUNCTION_HPP -#define PHOENIX_BIND_BIND_MEMBER_FUNCTION_HPP - -#include <boost/spirit/home/phoenix/core/reference.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/core/detail/function_eval.hpp> -#include <boost/spirit/home/phoenix/bind/detail/member_function_ptr.hpp> - -namespace boost { namespace phoenix -{ - template <typename RT, typename ClassT, typename ClassA> - inline actor< - typename as_composite< - detail::function_eval<1> - , detail::member_function_ptr<0, RT, RT(ClassT::*)()> - , ClassA - >::type> - bind(RT(ClassT::*f)(), ClassA const& obj) - { - typedef detail::member_function_ptr<0, RT, RT(ClassT::*)()> fp_type; - return compose<detail::function_eval<1> >(fp_type(f), obj); - } - - template <typename RT, typename ClassT, typename ClassA> - inline actor< - typename as_composite< - detail::function_eval<1> - , detail::member_function_ptr<0, RT, RT(ClassT::*)() const> - , ClassA - >::type> - bind(RT(ClassT::*f)() const, ClassA const& obj) - { - typedef detail::member_function_ptr<0, RT, RT(ClassT::*)() const> fp_type; - return compose<detail::function_eval<1> >(fp_type(f), obj); - } - - template <typename RT, typename ClassT> - inline actor< - typename as_composite< - detail::function_eval<1> - , detail::member_function_ptr<0, RT, RT(ClassT::*)()> - , actor<reference<ClassT> > - >::type> - bind(RT(ClassT::*f)(), ClassT& obj) - { - typedef detail::member_function_ptr<0, RT, RT(ClassT::*)()> fp_type; - return compose<detail::function_eval<1> >( - fp_type(f) - , actor<reference<ClassT> >(reference<ClassT>(obj))); - } - - template <typename RT, typename ClassT> - inline actor< - typename as_composite< - detail::function_eval<1> - , detail::member_function_ptr<0, RT, RT(ClassT::*)() const> - , actor<reference<ClassT> > - >::type> - bind(RT(ClassT::*f)() const, ClassT& obj) - { - typedef detail::member_function_ptr<0, RT, RT(ClassT::*)() const> fp_type; - return compose<detail::function_eval<1> >( - fp_type(f) - , actor<reference<ClassT> >(reference<ClassT>(obj))); - } - - // Bring in the rest of the function binders - #include <boost/spirit/home/phoenix/bind/detail/bind_member_function.hpp> -}} - -#endif diff --git a/boost/spirit/home/phoenix/bind/bind_member_variable.hpp b/boost/spirit/home/phoenix/bind/bind_member_variable.hpp deleted file mode 100644 index 3d11351828..0000000000 --- a/boost/spirit/home/phoenix/bind/bind_member_variable.hpp +++ /dev/null @@ -1,105 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_BIND_BIND_MEMBER_VARIABLE_HPP -#define PHOENIX_BIND_BIND_MEMBER_VARIABLE_HPP - -#include <boost/mpl/if.hpp> -#include <boost/type_traits/is_const.hpp> -#include <boost/type_traits/remove_pointer.hpp> -#include <boost/type_traits/remove_reference.hpp> - -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/core/reference.hpp> -#include <boost/spirit/home/phoenix/core/detail/function_eval.hpp> -#include <boost/mpl/if.hpp> -#include <boost/type_traits/is_const.hpp> -#include <boost/type_traits/remove_pointer.hpp> -#include <boost/type_traits/remove_reference.hpp> - -namespace boost { namespace phoenix -{ - namespace detail - { - template <typename RT, typename MP> - struct member_variable - { - template <typename Class> - struct result - { - typedef typename boost::mpl::if_< - boost::is_const< - typename boost::remove_pointer< - typename boost::remove_reference<Class>::type - >::type - > - , const RT& - , RT& - >::type type; - }; - - member_variable(MP mp) - : mp(mp) {} - - template <typename Class> - RT& operator()(Class& obj) const - { - return obj.*mp; - } - - template <typename Class> - RT& operator()(Class* obj) const - { - return obj->*mp; - } - - template <typename Class> - RT const& operator()(Class const& obj) const - { - return obj.*mp; - } - - template <typename Class> - RT const& operator()(Class const* obj) const - { - return obj->*mp; - } - - MP mp; - }; - } - - template <typename RT, typename ClassT, typename ClassA> - inline actor< - typename as_composite< - detail::function_eval<1> - , detail::member_variable<RT, RT ClassT::*> - , ClassA - >::type> - bind(RT ClassT::*mp, ClassA const& obj) - { - typedef detail::member_variable<RT, RT ClassT::*> mp_type; - return compose<detail::function_eval<1> >(mp_type(mp), obj); - } - - template <typename RT, typename ClassT> - inline actor< - typename as_composite< - detail::function_eval<1> - , detail::member_variable<RT, RT ClassT::*> - , actor<reference<ClassT> > - >::type> - bind(RT ClassT::*mp, ClassT& obj) - { - typedef detail::member_variable<RT, RT ClassT::*> mp_type; - return compose<detail::function_eval<1> >( - mp_type(mp) - , actor<reference<ClassT> >(reference<ClassT>(obj))); - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/bind/detail/bind_function.hpp b/boost/spirit/home/phoenix/bind/detail/bind_function.hpp deleted file mode 100644 index 8d6340d0da..0000000000 --- a/boost/spirit/home/phoenix/bind/detail/bind_function.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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_PP_IS_ITERATING) -#if !defined(PHOENIX_BIND_DETAIL_BIND_FUNCTION_HPP) -#define PHOENIX_BIND_DETAIL_BIND_FUNCTION_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/dec.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (3, BOOST_PP_DEC(PHOENIX_COMPOSITE_LIMIT), \ - "boost/spirit/home/phoenix/bind/detail/bind_function.hpp")) -#include BOOST_PP_ITERATE() - -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <typename RT - , BOOST_PP_ENUM_PARAMS(N, typename T) - , BOOST_PP_ENUM_PARAMS(N, typename A)> - inline actor< - typename as_composite< - detail::function_eval<N> - , detail::function_ptr<N, RT, RT(*)(BOOST_PP_ENUM_PARAMS(N, T))> - , BOOST_PP_ENUM_PARAMS(N, A) - >::type> - bind(RT(*f)(BOOST_PP_ENUM_PARAMS(N, T)) - , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& _)) - { - typedef detail::function_ptr< - N, RT, RT(*)(BOOST_PP_ENUM_PARAMS(N, T))> fp_type; - return compose<detail::function_eval<N> >( - fp_type(f), BOOST_PP_ENUM_PARAMS(N, _)); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/bind/detail/bind_function_object.hpp b/boost/spirit/home/phoenix/bind/detail/bind_function_object.hpp deleted file mode 100644 index 4e4984d61e..0000000000 --- a/boost/spirit/home/phoenix/bind/detail/bind_function_object.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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_PP_IS_ITERATING) -#if !defined(PHOENIX_BIND_DETAIL_BIND_FUNCTION_OBJECT_HPP) -#define PHOENIX_BIND_DETAIL_BIND_FUNCTION_OBJECT_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/dec.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (3, BOOST_PP_DEC(PHOENIX_COMPOSITE_LIMIT), \ - "boost/spirit/home/phoenix/bind/detail/bind_function_object.hpp")) -#include BOOST_PP_ITERATE() - -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <typename F, BOOST_PP_ENUM_PARAMS(N, typename A)> - inline actor<typename as_composite<detail::function_eval<N>, F - , BOOST_PP_ENUM_PARAMS(N, A)>::type> - bind(F const& f, BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& _)) - { - return compose<detail::function_eval<N> >(f, BOOST_PP_ENUM_PARAMS(N, _)); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/bind/detail/bind_member_function.hpp b/boost/spirit/home/phoenix/bind/detail/bind_member_function.hpp deleted file mode 100644 index 315f56fc98..0000000000 --- a/boost/spirit/home/phoenix/bind/detail/bind_member_function.hpp +++ /dev/null @@ -1,132 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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_PP_IS_ITERATING) -#if !defined(PHOENIX_BIND_DETAIL_BIND_MEMBER_FUNCTION_HPP) -#define PHOENIX_BIND_DETAIL_BIND_MEMBER_FUNCTION_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/dec.hpp> -#include <boost/preprocessor/inc.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (1, BOOST_PP_DEC(BOOST_PP_DEC(PHOENIX_COMPOSITE_LIMIT)), \ - "boost/spirit/home/phoenix/bind/detail/bind_member_function.hpp")) -#include BOOST_PP_ITERATE() - -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <typename RT - , typename ClassT - , BOOST_PP_ENUM_PARAMS(N, typename T) - , typename ClassA - , BOOST_PP_ENUM_PARAMS(N, typename A)> - inline actor< - typename as_composite< - detail::function_eval<BOOST_PP_INC(N)> - , detail::member_function_ptr<N, - RT, RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(N, T))> - , ClassA, BOOST_PP_ENUM_PARAMS(N, A) - >::type> - bind( - RT(ClassT::*f)(BOOST_PP_ENUM_PARAMS(N, T)) - , ClassA const& obj - , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& _)) - { - typedef detail::member_function_ptr< - N, RT, RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(N, T))> fp_type; - return compose<detail::function_eval<BOOST_PP_INC(N)> >( - fp_type(f), obj, BOOST_PP_ENUM_PARAMS(N, _)); - } - - template <typename RT - , typename ClassT - , BOOST_PP_ENUM_PARAMS(N, typename T) - , typename ClassA - , BOOST_PP_ENUM_PARAMS(N, typename A)> - inline actor< - typename as_composite< - detail::function_eval<BOOST_PP_INC(N)> - , detail::member_function_ptr<N, - RT, RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(N, T)) const> - , ClassA, BOOST_PP_ENUM_PARAMS(N, A) - >::type> - bind( - RT(ClassT::*f)(BOOST_PP_ENUM_PARAMS(N, T)) const - , ClassA const& obj - , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& _)) - { - typedef detail::member_function_ptr< - N, RT, RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(N, T)) const> fp_type; - return compose<detail::function_eval<BOOST_PP_INC(N)> >( - fp_type(f), obj, BOOST_PP_ENUM_PARAMS(N, _)); - } - - template <typename RT - , typename ClassT - , BOOST_PP_ENUM_PARAMS(N, typename T) - , BOOST_PP_ENUM_PARAMS(N, typename A)> - inline actor< - typename as_composite< - detail::function_eval<BOOST_PP_INC(N)> - , detail::member_function_ptr<N, - RT, RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(N, T))> - , actor<reference<ClassT> > - , BOOST_PP_ENUM_PARAMS(N, A) - >::type> - bind( - RT(ClassT::*f)(BOOST_PP_ENUM_PARAMS(N, T)) - , ClassT& obj - , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& _)) - { - typedef detail::member_function_ptr< - N, RT, RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(N, T))> fp_type; - return compose<detail::function_eval<BOOST_PP_INC(N)> >( - fp_type(f) - , actor<reference<ClassT> >(reference<ClassT>(obj)) - , BOOST_PP_ENUM_PARAMS(N, _)); - } - - template <typename RT - , typename ClassT - , BOOST_PP_ENUM_PARAMS(N, typename T) - , BOOST_PP_ENUM_PARAMS(N, typename A)> - inline actor< - typename as_composite< - detail::function_eval<BOOST_PP_INC(N)> - , detail::member_function_ptr<N, - RT, RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(N, T)) const> - , actor<reference<ClassT> > - , BOOST_PP_ENUM_PARAMS(N, A) - >::type> - bind( - RT(ClassT::*f)(BOOST_PP_ENUM_PARAMS(N, T)) const - , ClassT& obj - , BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& _)) - { - typedef detail::member_function_ptr< - N, RT, RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(N, T)) const> fp_type; - return compose<detail::function_eval<BOOST_PP_INC(N)> >( - fp_type(f) - , actor<reference<ClassT> >(reference<ClassT>(obj)) - , BOOST_PP_ENUM_PARAMS(N, _)); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/bind/detail/function_ptr.hpp b/boost/spirit/home/phoenix/bind/detail/function_ptr.hpp deleted file mode 100644 index a2352cd7e5..0000000000 --- a/boost/spirit/home/phoenix/bind/detail/function_ptr.hpp +++ /dev/null @@ -1,99 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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_PP_IS_ITERATING) -#if !defined(PHOENIX_BIND_DETAIL_FUNCTION_PTR_HPP) -#define PHOENIX_BIND_DETAIL_FUNCTION_PTR_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> -#include <boost/preprocessor/dec.hpp> - -namespace boost { namespace phoenix { namespace detail -{ - template <int N> - struct function_ptr_impl - { - template <typename RT, typename FP> - struct impl; - }; - - template <int N, typename RT, typename FP> - struct function_ptr : function_ptr_impl<N>::template impl<RT, FP> - { - typedef typename function_ptr_impl<N>::template impl<RT, FP> base; - function_ptr(FP fp) - : base(fp) {} - }; - - template <> - struct function_ptr_impl<0> - { - template <typename RT, typename FP> - struct impl - { - typedef RT result_type; - - impl(FP fp) - : fp(fp) {} - - RT operator()() const - { - return fp(); - } - - FP fp; - }; - }; - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (1, PHOENIX_COMPOSITE_LIMIT, \ - "boost/spirit/home/phoenix/bind/detail/function_ptr.hpp")) -#include BOOST_PP_ITERATE() - -}}} // namespace boost::phoenix::detail - -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <> - struct function_ptr_impl<N> - { - template <typename RT, typename FP> - struct impl - { - template <BOOST_PP_ENUM_PARAMS(N, typename T)> - struct result - { - typedef RT type; - }; - - impl(FP fp) - : fp(fp) {} - - template <BOOST_PP_ENUM_PARAMS(N, typename A)> - RT operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, & _)) const - { - return fp(BOOST_PP_ENUM_PARAMS(N, _)); - } - - FP fp; - }; - }; - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/bind/detail/member_function_ptr.hpp b/boost/spirit/home/phoenix/bind/detail/member_function_ptr.hpp deleted file mode 100644 index 2c11510cee..0000000000 --- a/boost/spirit/home/phoenix/bind/detail/member_function_ptr.hpp +++ /dev/null @@ -1,119 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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_PP_IS_ITERATING) -#if !defined(PHOENIX_BIND_DETAIL_MEMBER_FUNCTION_PTR_HPP) -#define PHOENIX_BIND_DETAIL_MEMBER_FUNCTION_PTR_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> -#include <boost/preprocessor/dec.hpp> -#include <boost/utility/addressof.hpp> - -namespace boost { namespace phoenix { namespace detail -{ - template <int N> - struct member_function_ptr_impl - { - template <typename RT, typename FP> - struct impl; - }; - - template <int N, typename RT, typename FP> - struct member_function_ptr - : member_function_ptr_impl<N>::template impl<RT, FP> - { - typedef typename member_function_ptr_impl<N>:: - template impl<RT, FP> base; - member_function_ptr(FP fp) - : base(fp) {} - }; - - template <> - struct member_function_ptr_impl<0> - { - template <typename RT, typename FP> - struct impl - { - template <typename Class> - struct result - { - typedef RT type; - }; - - impl(FP fp) - : fp(fp) {} - - template <typename Class> - RT operator()(Class& obj) const - { - return (obj.*fp)(); - } - - template <typename Class> - RT operator()(Class* obj) const - { - return (obj->*fp)(); - } - - FP fp; - }; - }; - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (1, PHOENIX_COMPOSITE_LIMIT, \ - "boost/spirit/home/phoenix/bind/detail/member_function_ptr.hpp")) -#include BOOST_PP_ITERATE() - -}}} // namespace boost::phoenix::detail - -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <> - struct member_function_ptr_impl<N> - { - template <typename RT, typename FP> - struct impl - { - template <typename Class, BOOST_PP_ENUM_PARAMS(N, typename T)> - struct result - { - typedef RT type; - }; - - impl(FP fp) - : fp(fp) {} - - template <typename Class, BOOST_PP_ENUM_PARAMS(N, typename A)> - RT operator()(Class& obj, BOOST_PP_ENUM_BINARY_PARAMS(N, A, & _)) const - { - return (obj.*fp)(BOOST_PP_ENUM_PARAMS(N, _)); - } - - template <typename Class, BOOST_PP_ENUM_PARAMS(N, typename A)> - RT operator()(Class* obj, BOOST_PP_ENUM_BINARY_PARAMS(N, A, & _)) const - { - return (obj->*fp)(BOOST_PP_ENUM_PARAMS(N, _)); - } - - FP fp; - }; - }; - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/core.hpp b/boost/spirit/home/phoenix/core.hpp deleted file mode 100644 index 7dfefb3d1c..0000000000 --- a/boost/spirit/home/phoenix/core.hpp +++ /dev/null @@ -1,23 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_CORE_HPP -#define PHOENIX_CORE_HPP - -#include <boost/spirit/home/phoenix/version.hpp> -#include <boost/spirit/home/phoenix/core/limits.hpp> -#include <boost/spirit/home/phoenix/core/basic_environment.hpp> -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/spirit/home/phoenix/core/as_actor.hpp> -#include <boost/spirit/home/phoenix/core/is_actor.hpp> -#include <boost/spirit/home/phoenix/core/argument.hpp> -#include <boost/spirit/home/phoenix/core/value.hpp> -#include <boost/spirit/home/phoenix/core/reference.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/nothing.hpp> - -#endif diff --git a/boost/spirit/home/phoenix/core/actor.hpp b/boost/spirit/home/phoenix/core/actor.hpp deleted file mode 100644 index 6ff48e9e7f..0000000000 --- a/boost/spirit/home/phoenix/core/actor.hpp +++ /dev/null @@ -1,194 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_CORE_ACTOR_HPP -#define PHOENIX_CORE_ACTOR_HPP - -#include <boost/spirit/home/phoenix/core/limits.hpp> - -#if !defined(BOOST_RESULT_OF_NUM_ARGS) -# define BOOST_RESULT_OF_NUM_ARGS PHOENIX_ACTOR_LIMIT -#elif (BOOST_RESULT_OF_NUM_ARGS < PHOENIX_ACTOR_LIMIT) -# error "BOOST_RESULT_OF_NUM_ARGS < PHOENIX_ACTOR_LIMIT" -#endif - -#include <boost/spirit/home/phoenix/core/basic_environment.hpp> -#include <boost/mpl/min.hpp> -#include <boost/mpl/identity.hpp> -#include <boost/type_traits/add_const.hpp> -#include <boost/type_traits/remove_reference.hpp> -#include <boost/utility/result_of.hpp> - -namespace boost { namespace phoenix -{ - // phoenix::void_ is the same as fusion::void_ - typedef fusion::void_ void_; - - namespace detail - { - // Forward declarations. These will come in when we get to the - // operator module, yet, the actor's assignment operator and index - // operator are required to be members. - - template <typename T0, typename T1> - struct make_assign_composite; - - template <typename T0, typename T1> - struct make_index_composite; - - template <typename BaseT0, typename BaseT1> - struct comma_result; - - // error no arguments supplied - struct error_expecting_arguments - { - template <typename T> - error_expecting_arguments(T const&) {} - }; - } - - template <typename Eval, typename Env> - struct eval_result - { - typedef typename Eval::template result<Env>::type type; - }; - -#if defined(BOOST_MSVC) -# pragma warning(push) -# pragma warning(disable: 4522) // multiple assignment operators specified warning -#endif - - template <typename Eval> - struct actor : Eval - { - typedef actor<Eval> self_type; - typedef Eval eval_type; - - template <class Sig> struct result {}; - - actor() - : Eval() {} - - actor(Eval const& base) - : Eval(base) {} - - template <typename T0> - explicit actor(T0 const& _0) - : Eval(_0) {} - - template <typename T0, typename T1> - actor(T0 const& _0, T1 const& _1) - : Eval(_0, _1) {} - - typedef typename - mpl::eval_if< - typename Eval::no_nullary // avoid calling eval_result when this is true - , mpl::identity<detail::error_expecting_arguments> - , eval_result<eval_type, basic_environment<> > - >::type - nullary_result; - - actor& operator=(actor const& rhs) - { - Eval::operator=(rhs); - return *this; - } - - actor& operator=(actor& rhs) - { - Eval::operator=(rhs); - return *this; - } - - nullary_result - operator()() const - { - return eval_type::eval(basic_environment<>()); - } - - template <class F, class A0> - struct result<F(A0)> - : eval_result< - eval_type - , basic_environment< - typename remove_reference<A0>::type - > - > - {}; - - template <typename T0> - typename result<actor(T0&)>::type - operator()(T0& _0) const - { - return eval_type::eval(basic_environment<T0>(_0)); - } - - template <class F, class A0, class A1> - struct result<F(A0,A1)> - : eval_result< - eval_type - , basic_environment< - typename remove_reference<A0>::type - , typename remove_reference<A1>::type - > - > - {}; - - template <typename T0, typename T1> - typename result<actor(T0&,T1&)>::type - operator()(T0& _0, T1& _1) const - { - return eval_type::eval(basic_environment<T0, T1>(_0, _1)); - } - - template <typename T1> - typename detail::make_assign_composite<self_type, T1>::type - operator=(T1 const& a1) const; - - template <typename T1> - typename detail::make_index_composite<self_type, T1>::type - operator[](T1 const& a1) const; - - // Bring in the rest of the constructors and function call operators - #include <boost/spirit/home/phoenix/core/detail/actor.hpp> - }; - -#if defined(BOOST_MSVC) -# pragma warning(pop) -#endif - - // Forward declaration: The intent to overload the comma must be - // stated early on to avoid the subtle problem that arises when - // the header file where the comma operator overload is defined, - // is not included by the client and the client attempts to use - // the comma anyway. - - namespace detail - { - template <typename BaseT0, typename BaseT1> - struct comma_result; - } - - template <typename BaseT0, typename BaseT1> - typename detail::comma_result<BaseT0, BaseT1>::type - operator,(actor<BaseT0> const& a0, actor<BaseT1> const& a1); -}} - -namespace boost -{ - template <typename Eval> - struct result_of<phoenix::actor<Eval>()> - { - typedef typename phoenix::actor<Eval>::nullary_result type; - }; - - template <typename Eval> - struct result_of<phoenix::actor<Eval> const()> - : result_of<phoenix::actor<Eval>()> - {}; -} - -#endif diff --git a/boost/spirit/home/phoenix/core/argument.hpp b/boost/spirit/home/phoenix/core/argument.hpp deleted file mode 100644 index 1679cb2b38..0000000000 --- a/boost/spirit/home/phoenix/core/argument.hpp +++ /dev/null @@ -1,99 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_CORE_ARGUMENT_HPP -#define PHOENIX_CORE_ARGUMENT_HPP - -#include <boost/preprocessor/repetition/repeat_from_to.hpp> -#include <boost/preprocessor/inc.hpp> -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/fusion/include/at.hpp> -#include <boost/mpl/if.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/identity.hpp> -#include <boost/mpl/less.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/mpl/int.hpp> -#include <boost/mpl/at.hpp> -#include <boost/mpl/size.hpp> -#include <boost/type_traits/add_reference.hpp> - -#define PHOENIX_DECLARE_ARG(z, n, data) \ - typedef actor<argument<n> > \ - BOOST_PP_CAT(BOOST_PP_CAT(arg, BOOST_PP_INC(n)), _type); \ - actor<argument<n> > const \ - BOOST_PP_CAT(arg, BOOST_PP_INC(n)) = argument<n>(); \ - typedef actor<argument<n> > \ - BOOST_PP_CAT(BOOST_PP_CAT(_, BOOST_PP_INC(n)), _type); \ - actor<argument<n> > const \ - BOOST_PP_CAT(_, BOOST_PP_INC(n)) = argument<n>(); - -namespace boost { namespace phoenix -{ - namespace detail - { - template <typename Arg> - struct error_argument_not_found {}; - inline void test_invalid_argument(int) {} - } - - template <int N> - struct argument - { - typedef mpl::true_ no_nullary; - - template <typename Env> - struct result - { - typedef typename - fusion::result_of::at<typename Env::tie_type, mpl::int_<N> >::type - type; - }; - - template <typename Env> - typename result<Env>::type - eval(Env const& env) const - { - typedef typename - mpl::if_< - mpl::less<mpl::int_<N>, mpl::size<typename Env::args_type> > - , int - , detail::error_argument_not_found<argument<N> > - >::type - check_out_of_bounds; - - detail::test_invalid_argument(check_out_of_bounds()); - return fusion::at_c<N>(env.args()); - } - }; - - namespace arg_names - { - // Phoenix style names - typedef actor<argument<0> > arg1_type; - actor<argument<0> > const arg1 = argument<0>(); - typedef actor<argument<1> > arg2_type; - actor<argument<1> > const arg2 = argument<1>(); - typedef actor<argument<2> > arg3_type; - actor<argument<2> > const arg3 = argument<2>(); - - // BLL style names - typedef actor<argument<0> > _1_type; - actor<argument<0> > const _1 = argument<0>(); - typedef actor<argument<1> > _2_type; - actor<argument<1> > const _2 = argument<1>(); - typedef actor<argument<2> > _3_type; - actor<argument<2> > const _3 = argument<2>(); - - // Bring in the rest or the Phoenix style arguments (arg4 .. argN+1) - // and BLL style arguments (_4 .. _N+1), using PP - BOOST_PP_REPEAT_FROM_TO( - 3, PHOENIX_ARG_LIMIT, PHOENIX_DECLARE_ARG, _) - } -}} - -#undef PHOENIX_DECLARE_ARG -#endif diff --git a/boost/spirit/home/phoenix/core/as_actor.hpp b/boost/spirit/home/phoenix/core/as_actor.hpp deleted file mode 100644 index 36f0aacb69..0000000000 --- a/boost/spirit/home/phoenix/core/as_actor.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_CORE_AS_ACTOR_HPP -#define PHOENIX_CORE_AS_ACTOR_HPP - -#include <boost/spirit/home/phoenix/core/actor.hpp> - -namespace boost { namespace phoenix -{ - template <typename T> - struct as_actor_base; // defined in value.hpp - - template <typename Base> - struct as_actor_base<actor<Base> > - { - typedef Base type; - - static Base const& - convert(actor<Base> const& x) - { - return x; - } - }; - - template <> - struct as_actor_base<fusion::void_> - { - typedef fusion::void_ type; - struct error_attempting_to_convert_void_type_to_an_actor {}; - - static void - convert(error_attempting_to_convert_void_type_to_an_actor); - }; - - template <> - struct as_actor_base<void> - { - typedef void type; - struct error_attempting_to_convert_void_type_to_an_actor {}; - - static void - convert(error_attempting_to_convert_void_type_to_an_actor); - }; - - template <typename T> - struct as_actor - { - typedef actor<typename as_actor_base<T>::type> type; - - static type - convert(T const& x) - { - return as_actor_base<T>::convert(x); - } - }; -}} - -#endif diff --git a/boost/spirit/home/phoenix/core/basic_environment.hpp b/boost/spirit/home/phoenix/core/basic_environment.hpp deleted file mode 100644 index 5ef82234cd..0000000000 --- a/boost/spirit/home/phoenix/core/basic_environment.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_CORE_BASIC_ENVIRONMENT_HPP -#define PHOENIX_CORE_BASIC_ENVIRONMENT_HPP - -#include <boost/spirit/home/phoenix/core/limits.hpp> -#include <boost/mpl/remove.hpp> -#include <boost/mpl/transform.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> -#include <boost/type_traits/add_reference.hpp> -#include <boost/fusion/include/as_vector.hpp> -#include <boost/fusion/include/mpl.hpp> - -namespace boost { namespace phoenix -{ - template < - BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( - PHOENIX_ARG_LIMIT, typename T, fusion::void_)> - class basic_environment - { - typedef - mpl::BOOST_PP_CAT(vector, PHOENIX_ARG_LIMIT)< - BOOST_PP_ENUM_PARAMS(PHOENIX_ARG_LIMIT, T)> - args_with_void_type; - - public: - - // args_type: the list of types in an mpl::sequence - typedef typename - mpl::remove<args_with_void_type, fusion::void_>::type - args_type; - - // tie_type: a fusion::tuple of references - typedef typename - fusion::result_of::as_vector< - typename mpl::transform< - args_type, boost::add_reference<mpl::_1> - >::type - >::type - tie_type; - - basic_environment() - : args_() {} - - template <typename U0> - explicit basic_environment(U0& _0) - : args_(_0) {} - - template <typename U0, typename U1> - basic_environment(U0& _0, U1& _1) - : args_(_0, _1) {} - - // Bring in the rest of the constructors - #include <boost/spirit/home/phoenix/core/detail/basic_environment.hpp> - - tie_type const& - args() const - { - return args_; - } - - tie_type& - args() - { - return args_; - } - - private: - - tie_type args_; - }; -}} - -#endif - diff --git a/boost/spirit/home/phoenix/core/compose.hpp b/boost/spirit/home/phoenix/core/compose.hpp deleted file mode 100644 index d536113764..0000000000 --- a/boost/spirit/home/phoenix/core/compose.hpp +++ /dev/null @@ -1,118 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_CORE_COMPOSE_HPP -#define PHOENIX_CORE_COMPOSE_HPP - -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/identity.hpp> -#include <boost/type_traits/is_same.hpp> -#include <boost/preprocessor/repetition/enum.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/value.hpp> -#include <boost/spirit/home/phoenix/core/as_actor.hpp> - -#define PHOENIX_AS_ACTOR(z, n, data) \ - typename mpl::eval_if< \ - is_same<BOOST_PP_CAT(T, n), fusion::void_> \ - , mpl::identity<fusion::void_> \ - , as_actor_base<BOOST_PP_CAT(T, n)> \ - >::type - -namespace boost { namespace phoenix -{ - -/////////////////////////////////////////////////////////////////////////////// -// -// as_composite<EvalPolicy, T0,... TN> metafunction -// -// Create a composite given an EvalPolicy and types T0..TN. -// The types are converted to an actor through the as_actor -// metafunction (see as_actor.hpp). -// -/////////////////////////////////////////////////////////////////////////////// - template < - typename EvalPolicy - , BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( - PHOENIX_COMPOSITE_LIMIT, typename T, fusion::void_)> - struct as_composite - { - typedef composite< - EvalPolicy - , fusion::vector< - BOOST_PP_ENUM(PHOENIX_COMPOSITE_LIMIT, PHOENIX_AS_ACTOR, _)> - > - type; - }; - -/////////////////////////////////////////////////////////////////////////////// -// -// compose functions -// -// Usage: -// -// compose<EvalPolicy>(_0, _1,... _N) -// -// Returns a composite given an EvalPolicy and arguments _0.._N. -// The arguments are converted to an actor through the as_actor -// metafunction (see as_actor.hpp). -// -/////////////////////////////////////////////////////////////////////////////// - template <typename EvalPolicy> - inline actor<typename as_composite<EvalPolicy>::type> - compose() - { - return actor<typename as_composite<EvalPolicy>::type>(); - } - - template <typename EvalPolicy, typename T0> - inline actor<typename as_composite<EvalPolicy, T0>::type> - compose(T0 const& _0) - { - return actor<typename as_composite<EvalPolicy, T0>::type>( - as_actor<T0>::convert(_0) - ); - } - - template <typename EvalPolicy, typename T0, typename T1> - inline actor<typename as_composite<EvalPolicy, T0, T1>::type> - compose(T0 const& _0, T1 const& _1) - { - return actor<typename as_composite<EvalPolicy, T0, T1>::type>( - as_actor<T0>::convert(_0) - , as_actor<T1>::convert(_1) - ); - } - - // Bring in the the rest of the compose overloads - #include <boost/spirit/home/phoenix/core/detail/compose.hpp> - -/////////////////////////////////////////////////////////////////////////////// -// -// re_curry<EvalPolicy, T0,...TN> -// -// returns the result of re currying T0..TN using EvalPolicy. -// -/////////////////////////////////////////////////////////////////////////////// - template < - typename EvalPolicy - , BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( - PHOENIX_COMPOSITE_LIMIT, typename T, fusion::void_)> - struct re_curry - { - typedef actor< - typename as_composite< - EvalPolicy - , BOOST_PP_ENUM_PARAMS(PHOENIX_COMPOSITE_LIMIT, T)>::type - > - type; - }; -}} - -#undef PHOENIX_AS_ACTOR -#endif diff --git a/boost/spirit/home/phoenix/core/composite.hpp b/boost/spirit/home/phoenix/core/composite.hpp deleted file mode 100644 index 283bdc24f3..0000000000 --- a/boost/spirit/home/phoenix/core/composite.hpp +++ /dev/null @@ -1,96 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_CORE_COMPOSITE_HPP -#define PHOENIX_CORE_COMPOSITE_HPP - -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/spirit/home/phoenix/core/is_actor.hpp> -#include <boost/fusion/include/vector.hpp> -#include <boost/fusion/include/at.hpp> -#include <boost/fusion/include/size.hpp> -#include <boost/fusion/include/mpl.hpp> -#include <boost/mpl/fold.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/mpl/or.hpp> - -namespace boost { namespace phoenix -{ - namespace detail - { - template <int N> - struct composite_eval; - - struct compute_no_nullary - { - template <typename State, typename T> - struct apply - { - typedef typename - mpl::or_<typename T::no_nullary, State>::type - type; - }; - }; - } - - template <typename EvalPolicy, typename EvalTuple> - struct composite : EvalTuple - { - typedef EvalTuple base_type; - typedef composite<EvalPolicy, EvalTuple> self_type; - typedef EvalPolicy eval_policy_type; - - typedef typename - mpl::fold< - EvalTuple - , mpl::false_ - , detail::compute_no_nullary - >::type - no_nullary; - - template <typename Env> - struct result - { - typedef - typename detail::composite_eval< - fusion::result_of::size<base_type>::value>:: - template result<self_type, Env>::type - type; - }; - - composite() - : base_type() {} - - composite(base_type const& base) - : base_type(base) {} - - template <typename U0> - composite(U0& _0) - : base_type(_0) {} - - template <typename U0, typename U1> - composite(U0& _0, U1& _1) - : base_type(_0, _1) {} - - template <typename Env> - typename result<Env>::type - eval(Env const& env) const - { - typedef typename result<Env>::type return_type; - return detail:: - composite_eval<fusion::result_of::size<base_type>::value>::template - call<return_type>(*this, env); - } - - // Bring in the rest of the constructors - #include <boost/spirit/home/phoenix/core/detail/composite.hpp> - }; - - // Bring in the detail::composite_eval<0..N> definitions - #include <boost/spirit/home/phoenix/core/detail/composite_eval.hpp> -}} - -#endif diff --git a/boost/spirit/home/phoenix/core/detail/actor.hpp b/boost/spirit/home/phoenix/core/detail/actor.hpp deleted file mode 100644 index 66666c5474..0000000000 --- a/boost/spirit/home/phoenix/core/detail/actor.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_CORE_DETAIL_ACTOR_HPP -#define PHOENIX_CORE_DETAIL_ACTOR_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> -#include <boost/preprocessor/facilities/intercept.hpp> - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (3, PHOENIX_ACTOR_LIMIT, \ - "boost/spirit/home/phoenix/core/detail/actor.hpp")) -#include BOOST_PP_ITERATE() - -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <BOOST_PP_ENUM_PARAMS(N, typename T)> - actor(BOOST_PP_ENUM_BINARY_PARAMS(N, T, const& _)) - : Eval(BOOST_PP_ENUM_PARAMS(N, _)) {} - - template <typename F, BOOST_PP_ENUM_PARAMS(N, typename A)> - struct result<F(BOOST_PP_ENUM_PARAMS(N, A))> - : eval_result< - eval_type - , basic_environment< - BOOST_PP_ENUM_BINARY_PARAMS( - N - , typename remove_reference<A - , >::type BOOST_PP_INTERCEPT - ) - > - > - {}; - - template <BOOST_PP_ENUM_PARAMS(N, typename T)> - typename result< - actor(BOOST_PP_ENUM_BINARY_PARAMS(N, T, & BOOST_PP_INTERCEPT)) - >::type - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, T, & _)) const - { - return eval_type::eval( - basic_environment<BOOST_PP_ENUM_PARAMS(N, T)>( - BOOST_PP_ENUM_PARAMS(N, _)) - ); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/core/detail/basic_environment.hpp b/boost/spirit/home/phoenix/core/detail/basic_environment.hpp deleted file mode 100644 index 986ecf2b33..0000000000 --- a/boost/spirit/home/phoenix/core/detail/basic_environment.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_CORE_DETAIL_BASIC_ENVIRONMENT_HPP -#define PHOENIX_CORE_DETAIL_BASIC_ENVIRONMENT_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (3, PHOENIX_ARG_LIMIT, \ - "boost/spirit/home/phoenix/core/detail/basic_environment.hpp")) -#include BOOST_PP_ITERATE() - -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <BOOST_PP_ENUM_PARAMS(N, typename U)> - basic_environment(BOOST_PP_ENUM_BINARY_PARAMS(N, U, & _)) - : args_(BOOST_PP_ENUM_PARAMS(N, _)) {} - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/core/detail/compose.hpp b/boost/spirit/home/phoenix/core/detail/compose.hpp deleted file mode 100644 index 945a3d3f19..0000000000 --- a/boost/spirit/home/phoenix/core/detail/compose.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_CORE_DETAIL_COMPOSE_DETAIL_HPP -#define PHOENIX_CORE_DETAIL_COMPOSE_DETAIL_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/repetition/enum.hpp> - -#define PHOENIX_AS_ACTOR_CONVERT(z, n, data) \ - as_actor<BOOST_PP_CAT(T, n)>::convert(BOOST_PP_CAT(_, n)) - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (3, PHOENIX_COMPOSITE_LIMIT, \ - "boost/spirit/home/phoenix/core/detail/compose.hpp")) -#include BOOST_PP_ITERATE() - -#undef PHOENIX_AS_ACTOR_CONVERT -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <typename EvalPolicy, BOOST_PP_ENUM_PARAMS(N, typename T)> - inline actor< - typename as_composite<EvalPolicy, BOOST_PP_ENUM_PARAMS(N, T)>::type> - compose(BOOST_PP_ENUM_BINARY_PARAMS(N, T, const& _)) - { - return actor< - typename as_composite<EvalPolicy, BOOST_PP_ENUM_PARAMS(N, T)>::type>( - BOOST_PP_ENUM(N, PHOENIX_AS_ACTOR_CONVERT, _)); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/core/detail/composite.hpp b/boost/spirit/home/phoenix/core/detail/composite.hpp deleted file mode 100644 index 6970f7c96e..0000000000 --- a/boost/spirit/home/phoenix/core/detail/composite.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_CORE_DETAIL_COMPOSITE_HPP -#define PHOENIX_CORE_DETAIL_COMPOSITE_HPP - -#include <boost/preprocessor/iterate.hpp> - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (3, PHOENIX_COMPOSITE_LIMIT, \ - "boost/spirit/home/phoenix/core/detail/composite.hpp")) -#include BOOST_PP_ITERATE() - -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <BOOST_PP_ENUM_PARAMS(N, typename U)> - composite(BOOST_PP_ENUM_BINARY_PARAMS(N, U, & _)) - : base_type(BOOST_PP_ENUM_PARAMS(N, _)) {} - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/core/detail/composite_eval.hpp b/boost/spirit/home/phoenix/core/detail/composite_eval.hpp deleted file mode 100644 index 14f12afbc1..0000000000 --- a/boost/spirit/home/phoenix/core/detail/composite_eval.hpp +++ /dev/null @@ -1,106 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_CORE_DETAIL_COMPOSITE_EVAL_HPP -#define PHOENIX_CORE_DETAIL_COMPOSITE_EVAL_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/repetition/enum.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> - - namespace detail - { - template <int N> - struct composite_eval; - - template <> - struct composite_eval<0> - { - template <typename Composite, typename Env> - struct result - { - typedef typename Composite::eval_policy_type:: - template result<Env>::type - type; - }; - - template <typename RT, typename Composite, typename Env> - static RT - call(Composite const& /*composite*/, Env const& env) - { - typedef typename Composite::eval_policy_type eval_policy_type; - return eval_policy_type::template eval<RT>(env); - } - }; - - template <typename Actor, typename Env> - struct eval_is_actor - : is_actor<typename Actor::template result<Env>::type> {}; - - template <typename Actor, typename Env> - struct eval_is_void - : is_same<typename Actor::template result<Env>::type, fusion::void_> {}; - } - -#define PHOENIX_GET_ACTOR_TYPE(z, n, data) \ - typedef \ - typename fusion::result_of::value_at_c<Composite, n>::type \ - BOOST_PP_CAT(actor, n); - -#define PHOENIX_GET_ACTOR(z, n, data) \ - fusion::at_c<n>(composite) - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (1, PHOENIX_COMPOSITE_LIMIT, \ - "boost/spirit/home/phoenix/core/detail/composite_eval.hpp")) -#include BOOST_PP_ITERATE() - -#undef PHOENIX_GET_ACTOR -#undef PHOENIX_GET_ACTOR_TYPE -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - namespace detail - { - template <> - struct composite_eval<N> - { - template <typename Composite, typename Env> - struct result - { - BOOST_PP_REPEAT(N, PHOENIX_GET_ACTOR_TYPE, _) - - typedef typename - Composite::eval_policy_type::template result< - Env, BOOST_PP_ENUM_PARAMS(N, actor) - >::type - type; - }; - - template <typename RT, typename Composite, typename Env> - static RT - call(Composite const& composite, Env const& env) - { - typedef typename Composite::eval_policy_type eval_policy_type; - return eval_policy_type::template eval<RT>( - env, BOOST_PP_ENUM(N, PHOENIX_GET_ACTOR, _)); - } - }; - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/core/detail/composite_info.hpp b/boost/spirit/home/phoenix/core/detail/composite_info.hpp deleted file mode 100644 index 48cebea88a..0000000000 --- a/boost/spirit/home/phoenix/core/detail/composite_info.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_CORE_DETAIL_COMPOSITE_INFO_HPP -#define PHOENIX_CORE_DETAIL_COMPOSITE_INFO_HPP - -#include <boost/mpl/if.hpp> -#include <boost/mpl/greater.hpp> -#include <boost/mpl/int.hpp> -#include <boost/spirit/home/fusion/algorithm/fold.hpp> - -namespace boost { namespace phoenix { namespace detail -{ - struct max_nesting - { - template <typename T, typename State> - struct result : - mpl::if_< - mpl::greater<typename T::nesting, State> - , typename T::nesting - , State - > - {}; - }; - - template <typename ActorTuple> - struct compute_nesting - { - typedef typename - fusion::meta::fold<ActorTuple, mpl::int_<0>, max_nesting>::type - type; - }; - -}}} - -#endif - diff --git a/boost/spirit/home/phoenix/core/detail/function_eval.hpp b/boost/spirit/home/phoenix/core/detail/function_eval.hpp deleted file mode 100644 index 711b32c4b1..0000000000 --- a/boost/spirit/home/phoenix/core/detail/function_eval.hpp +++ /dev/null @@ -1,142 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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_PP_IS_ITERATING) -#if !defined(PHOENIX_CORE_DETAIL_FUNCTION_EVAL_HPP) -#define PHOENIX_CORE_DETAIL_FUNCTION_EVAL_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/enum.hpp> -#include <boost/preprocessor/repeat.hpp> -#include <boost/preprocessor/dec.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/find.hpp> -#include <boost/mpl/identity.hpp> -#include <boost/type_traits/is_same.hpp> -#include <boost/type_traits/remove_reference.hpp> - -// we assume that mpl::vectorN, where N = PHOENIX_COMPOSITE_LIMIT -// is included already. - -namespace boost { namespace phoenix { namespace detail -{ - template <int N> - struct function_eval; - - template <> - struct function_eval<0> - { - template <typename Env, typename F> - struct result - { - typedef typename - remove_reference< - typename F::template result<Env>::type - >::type - fn; - typedef typename fn::result_type type; - }; - - template <typename RT, typename Env, typename F> - static RT - eval(Env const& env, F const& f) - { - return f.eval(env)(); - } - }; - - template <typename T> - T& help_rvalue_deduction(T& x) - { - return x; - } - - template <typename T> - T const& help_rvalue_deduction(T const& x) - { - return x; - } - -// When we call f(_0, _1...) we remove the reference when deducing f's -// return type. $$$ Explain why $$$ - -#define PHOENIX_GET_ARG(z, n, data) \ - typedef typename \ - remove_reference< \ - typename BOOST_PP_CAT(A, n)::template result<Env>::type \ - >::type \ - BOOST_PP_CAT(a, n); - -#define PHOENIX_EVAL_ARG(z, n, data) \ - help_rvalue_deduction(BOOST_PP_CAT(_, n).eval(env)) - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (1, BOOST_PP_DEC(PHOENIX_COMPOSITE_LIMIT), \ - "boost/spirit/home/phoenix/core/detail/function_eval.hpp")) -#include BOOST_PP_ITERATE() - -}}} // namespace boost::phoenix::detail - -#undef PHOENIX_GET_ARG -#undef PHOENIX_EVAL_ARG -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <> - struct function_eval<N> - { - template <typename Env, typename F - , BOOST_PP_ENUM_PARAMS(N, typename A)> - struct result - { - typedef typename - remove_reference< - typename F::template result<Env>::type - >::type - fn; - BOOST_PP_REPEAT(N, PHOENIX_GET_ARG, _) - - typedef BOOST_PP_CAT(mpl::vector, N) - <BOOST_PP_ENUM_PARAMS(N, a)> - args; - - typedef typename - fn::template result<BOOST_PP_ENUM_PARAMS(N, a)> - function_apply; - - typedef typename - mpl::eval_if< - is_same< - typename mpl::find<args, fusion::void_>::type - , typename mpl::end<args>::type> - , function_apply - , mpl::identity<fusion::void_> - >::type - type; - }; - - template <typename RT, typename Env, typename F - , BOOST_PP_ENUM_PARAMS(N, typename A)> - static RT - eval(Env const& env, F const& f - , BOOST_PP_ENUM_BINARY_PARAMS(N, A, & _)) - { - return f.eval(env)(BOOST_PP_ENUM(N, PHOENIX_EVAL_ARG, _)); - } - }; - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/core/is_actor.hpp b/boost/spirit/home/phoenix/core/is_actor.hpp deleted file mode 100644 index ba0e77cbfc..0000000000 --- a/boost/spirit/home/phoenix/core/is_actor.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_CORE_IS_ACTOR_HPP -#define PHOENIX_CORE_IS_ACTOR_HPP - -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/mpl/bool.hpp> - -namespace boost { namespace phoenix -{ -/////////////////////////////////////////////////////////////////////////////// -// -// is_actor<T> -// -// Tests if T is an actor. Evaluates to mpl::true_ or mpl::false_ -// -/////////////////////////////////////////////////////////////////////////////// - template <typename T> - struct is_actor : mpl::false_ {}; - - template <typename Base> - struct is_actor<actor<Base> > : mpl::true_ {}; -}} - -#endif diff --git a/boost/spirit/home/phoenix/core/limits.hpp b/boost/spirit/home/phoenix/core/limits.hpp deleted file mode 100644 index 50c7573246..0000000000 --- a/boost/spirit/home/phoenix/core/limits.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_CORE_LIMITS_HPP -#define PHOENIX_CORE_LIMITS_HPP - -#include <boost/preprocessor/dec.hpp> - -#if !defined(PHOENIX_LIMIT) -# define PHOENIX_LIMIT 10 -#elif (PHOENIX_LIMIT < 5) -# error "PHOENIX_LIMIT is set too low" -#endif - -#if !defined(PHOENIX_ARG_LIMIT) -# define PHOENIX_ARG_LIMIT PHOENIX_LIMIT -#elif (PHOENIX_ARG_LIMIT < 5) -# error "PHOENIX_ARG_LIMIT is set too low" -#endif - -#if !defined(PHOENIX_ACTOR_LIMIT) -# define PHOENIX_ACTOR_LIMIT PHOENIX_LIMIT -#elif (PHOENIX_ACTOR_LIMIT > PHOENIX_ARG_LIMIT) -# error "PHOENIX_ACTOR_LIMIT > PHOENIX_ARG_LIMIT" -#elif (PHOENIX_ACTOR_LIMIT < 3) -# error "PHOENIX_ACTOR_LIMIT is set too low" -#endif - -#if !defined(PHOENIX_COMPOSITE_LIMIT) -# define PHOENIX_COMPOSITE_LIMIT PHOENIX_LIMIT -#elif (PHOENIX_COMPOSITE_LIMIT < 5) -# error "PHOENIX_COMPOSITE_LIMIT is set too low" -#endif - -#if !defined(PHOENIX_MEMBER_LIMIT) -# define PHOENIX_MEMBER_LIMIT BOOST_PP_DEC(BOOST_PP_DEC(PHOENIX_COMPOSITE_LIMIT)) -#elif (PHOENIX_MEMBER_LIMIT > PHOENIX_COMPOSITE_LIMIT) -# error "PHOENIX_MEMBER_LIMIT > PHOENIX_COMPOSITE_LIMIT" -#elif (PHOENIX_MEMBER_LIMIT < 3) -# error "PHOENIX_MEMBER_LIMIT is set too low" -#endif - -#if !defined(PHOENIX_CATCH_LIMIT) -# define PHOENIX_CATCH_LIMIT BOOST_PP_DEC(PHOENIX_COMPOSITE_LIMIT) -#elif (PHOENIX_CATCH_LIMIT < 1) -# error "PHOENIX_CATCH_LIMIT is set too low" -#endif - -#if !defined(PHOENIX_DYNAMIC_LIMIT) -# define PHOENIX_DYNAMIC_LIMIT PHOENIX_LIMIT -#elif (PHOENIX_DYNAMIC_LIMIT < 1) -# error "PHOENIX_DYNAMIC_LIMIT is set too low" -#endif - -#if !defined(PHOENIX_LOCAL_LIMIT) -# define PHOENIX_LOCAL_LIMIT PHOENIX_LIMIT -#elif (PHOENIX_LOCAL_LIMIT < 3) -# error "PHOENIX_LOCAL_LIMIT is set too low" -#endif - - -#if !defined(FUSION_MAX_VECTOR_SIZE) -# define FUSION_MAX_VECTOR_SIZE PHOENIX_LIMIT -#elif (FUSION_MAX_VECTOR_SIZE < PHOENIX_LIMIT) -# error "FUSION_MAX_VECTOR_SIZE < PHOENIX_LIMIT" -#endif - -// this include will bring in mpl::vectorN and -// fusion::vectorN where N is PHOENIX_LIMIT -#include <boost/fusion/include/vector.hpp> - -// for some reason, this must be included now to make -// detail/type_deduction.hpp compile. $$$ TODO: Investigate further $$$ -#include <boost/mpl/vector/vector20.hpp> - -#endif diff --git a/boost/spirit/home/phoenix/core/nothing.hpp b/boost/spirit/home/phoenix/core/nothing.hpp deleted file mode 100644 index 029fbbfdf9..0000000000 --- a/boost/spirit/home/phoenix/core/nothing.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_CORE_NOTHING_HPP -#define PHOENIX_CORE_NOTHING_HPP - -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/mpl/bool.hpp> - -namespace boost { namespace phoenix -{ -/////////////////////////////////////////////////////////////////////////////// -// -// null_actor -// -// A actor that does nothing (a "bum", if you will :-). -// -/////////////////////////////////////////////////////////////////////////////// - struct null_actor - { - typedef mpl::false_ no_nullary; - - template <typename Env> - struct result - { - typedef void type; - }; - - template <typename Env> - void - eval(Env const&) const - { - } - }; - - actor<null_actor> const nothing = null_actor(); -}} - -#endif diff --git a/boost/spirit/home/phoenix/core/reference.hpp b/boost/spirit/home/phoenix/core/reference.hpp deleted file mode 100644 index 2e1f588cbc..0000000000 --- a/boost/spirit/home/phoenix/core/reference.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_CORE_REFERENCE_HPP -#define PHOENIX_CORE_REFERENCE_HPP - -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/static_assert.hpp> -#include <boost/type_traits/is_reference.hpp> -#include <boost/mpl/bool.hpp> - -namespace boost { namespace phoenix -{ - template <typename T> - struct reference - { - // $$$ TODO: a better (user friendly) static assert - BOOST_STATIC_ASSERT( - mpl::not_<is_reference<T> >::value != 0); - - typedef mpl::false_ no_nullary; - - template <typename Env> - struct result - { - typedef T& type; - }; - - reference(T& arg) - : ref(arg) {} - - template <typename Env> - T& eval(Env const&) const - { - return ref; - } - - T& ref; - - private: - // silence MSVC warning C4512: assignment operator could not be generated - reference& operator= (reference const&); - }; - - template <typename T> - inline actor<reference<T> > const - ref(T& v) - { - return reference<T>(v); - } - - template <typename T> - inline actor<reference<T const> > const - cref(T const& v) - { - return reference<T const>(v); - } - - namespace detail - { - struct error_attempting_to_convert_an_actor_to_a_reference {}; - } - - template <typename Base> - void - ref(actor<Base> const& v - , detail::error_attempting_to_convert_an_actor_to_a_reference - = detail::error_attempting_to_convert_an_actor_to_a_reference()); - - template <typename Base> - void - cref(actor<Base> const& v - , detail::error_attempting_to_convert_an_actor_to_a_reference - = detail::error_attempting_to_convert_an_actor_to_a_reference()); -}} - -#endif diff --git a/boost/spirit/home/phoenix/core/value.hpp b/boost/spirit/home/phoenix/core/value.hpp deleted file mode 100644 index a275a7d221..0000000000 --- a/boost/spirit/home/phoenix/core/value.hpp +++ /dev/null @@ -1,158 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_CORE_VALUE_HPP -#define PHOENIX_CORE_VALUE_HPP - -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/spirit/home/phoenix/core/as_actor.hpp> -#include <boost/static_assert.hpp> - -#include <boost/type_traits/is_reference.hpp> -#include <boost/type_traits/remove_reference.hpp> -#include <boost/type_traits/is_pointer.hpp> -#include <boost/type_traits/add_const.hpp> -#include <boost/type_traits/add_reference.hpp> -#include <boost/type_traits/remove_pointer.hpp> -#include <boost/type_traits/is_function.hpp> - -#include <boost/mpl/bool.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/identity.hpp> - -namespace boost { namespace phoenix -{ - namespace meta - { - template<typename T> - struct const_ref - : add_reference<typename add_const<T>::type> - {}; - - template<typename T> - struct argument_type - : mpl::eval_if< - is_function<typename remove_pointer<T>::type>, - mpl::identity<T>, - const_ref<T> > - { - typedef T type; - }; - } - - template <typename T> - struct value - { - BOOST_STATIC_ASSERT( - mpl::not_<is_reference<T> >::value != 0); - - typedef mpl::false_ no_nullary; - - template <typename Env> - struct result - { - typedef T type; - }; - - value() - : val() {} - - value(T const& arg) - : val(arg) {} - - template <typename Env> - T const& - eval(Env const&) const - { - return val; - } - - T val; - }; - - template <typename Actor> - struct actor_value - { - typedef typename Actor::no_nullary no_nullary; - - template <typename Env> - struct result - { - typedef typename - remove_reference< - typename eval_result<Actor, Env>::type - >::type - type; - }; - - actor_value(Actor const& actor) - : actor(actor) {} - - template <typename Env> - typename result<Env>::type - eval(Env const& env) const - { - return actor.eval(env); - } - - Actor actor; - }; - - template <typename T> - inline typename as_actor<T>::type - val(T const& v) - { - return as_actor<T>::convert(v); - } - - template <typename Derived> - inline actor<actor_value<Derived> > - val(actor<Derived> const& actor) - { - return actor_value<Derived>(actor); - } - - template <typename T> - struct as_actor_base - { - typedef value<T> type; - - static value<T> - convert(typename meta::argument_type<T>::type x) - { - return value<T>(x); - } - }; - - // Sometimes it is necessary to auto-convert references to - // a value<T>. This happens when we are re-currying. This - // cannot happen through the standard public actor interfaces. - template <typename T> - struct as_actor_base<T&> - { - typedef value<T> type; - - static value<T> - convert(T& x) - { - return value<T>(x); - } - }; - - template <typename T, int N> - struct as_actor_base<T[N]> - { - typedef value<T const*> type; - - static value<T const*> - convert(T const x[N]) - { - return value<T const*>(x); - } - }; -}} - -#endif diff --git a/boost/spirit/home/phoenix/detail/local_reference.hpp b/boost/spirit/home/phoenix/detail/local_reference.hpp deleted file mode 100644 index ad1fdb4ab8..0000000000 --- a/boost/spirit/home/phoenix/detail/local_reference.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/*============================================================================= - Copyright (c) 2005-2007 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) -==============================================================================*/ -#ifndef PHOENIX_DETAIL_LOCAL_REFERENCE_HPP -#define PHOENIX_DETAIL_LOCAL_REFERENCE_HPP - -#include <boost/utility/addressof.hpp> - -namespace boost { namespace phoenix { namespace detail -{ - template <typename T> - struct local_reference - { - typedef T type; - - explicit local_reference(T& t): t_(boost::addressof(t)) {} - operator T& () const { return *t_; } - local_reference& operator=(T const& x) { *t_ = x; return *this; } - local_reference const& operator=(T const& x) const { *t_ = x; return *this; } - T& get() const { return *t_; } - T* get_pointer() const { return t_; } - - private: - - T* t_; - }; - - template <typename T> - struct unwrap_local_reference - { - typedef T type; // T should be a reference - }; - - template <typename T> - struct unwrap_local_reference<local_reference<T> > - { - typedef T type; // unwrap the reference; T is a value - }; -}}} - -#endif diff --git a/boost/spirit/home/phoenix/detail/type_deduction.hpp b/boost/spirit/home/phoenix/detail/type_deduction.hpp deleted file mode 100644 index b99ea1e86c..0000000000 --- a/boost/spirit/home/phoenix/detail/type_deduction.hpp +++ /dev/null @@ -1,497 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_DETAIL_TYPE_DEDUCTION_HPP -#define PHOENIX_DETAIL_TYPE_DEDUCTION_HPP - -/*============================================================================= - - Return Type Deduction - [JDG Sept. 15, 2003] - - Before C++ adopts the typeof, there is currently no way to deduce the - result type of an expression such as x + y. This deficiency is a major - problem with template metaprogramming; for example, when writing - forwarding functions that attempt to capture the essence of an - expression inside a function. Consider the std::plus<T>: - - template <typename T> - struct plus : public binary_function<T, T, T> - { - T operator()(T const& x, T const& y) const - { - return x + y; - } - }; - - What's wrong with this? Well, this functor does not accurately capture - the behavior of the plus operator. 1) It does not handle the case where - x and y are of different types (e.g. x is short and y is int). 2) It - assumes that the arguments and return type are the same (i.e. when - adding a short and an int, the return type ought to be an int). Due to - these shortcomings, std::plus<T>(x, y) is a poor substitute for x + y. - - The case where x is short and y is int does not really expose the - problem. We can simply use std::plus<int> and be happy that the - operands x and y will simply be converted to an int. The problem - becomes evident when an operand is a user defined type such as bigint. - Here, the conversion to bigint is simply not acceptable. Even if the - unnecessary conversion is tolerable, in generic code, it is not always - possible to choose the right T type that can accomodate both x and y - operands. - - To truly model the plus operator, what we need is a polymorphic functor - that can take arbitrary x and y operands. Here's a rough schematic: - - struct plus - { - template <typename X, typename Y> - unspecified-type - operator()(X const& x, Y const& y) const - { - return x + y; - } - }; - - Now, we can handle the case where X and Y are arbitrary types. We've - solved the first problem. To solve the second problem, we need some - form of return type deduction mechanism. If we had the typeof, it would - be something like: - - template <typename X, typename Y> - typeof(X() + Y()) - operator()(X const& x, Y const& y) const - { - return x + y; - } - - Without the typeof facility, it is only possible to wrap an expression - such as x + y in a function or functor if we are given a hint that - tells us what the actual result type of such an expression is. Such a - hint can be in the form of a metaprogram, that, given the types of the - arguments, will return the result type. Example: - - template <typename X, typename Y> - struct result_of_plus - { - typedef unspecified-type type; - }; - - Given a result_of_plus metaprogram, we can complete our polymorphic - plus functor: - - struct plus - { - template <typename X, typename Y> - typename result_of_plus<X, Y>::type - operator()(X const& x, Y const& y) const - { - return x + y; - } - }; - - The process is not automatic. We have to specialize the metaprogram for - specific argument types. Examples: - - template <> - struct result_of_plus<short, int> - { - typedef int type; - }; - - template <typename T> - struct result_of_plus<std::complex<T>, std::complex<T> > - { - typedef std::complex<T> type; - }; - - To make it easier for the user, specializations are provided for common - types such as primitive c++ types (e.g. int, char, double, etc.), and - standard types (e.g. std::complex, iostream, std containers and - iterators). - - To further improve the ease of use, for user defined classes, we can - supply a few more basic specializations through metaprogramming using - heuristics based on canonical operator rules (Such heuristics can be - found in the LL and Phoenix, for example). For example, it is rather - common that the result of x += y is X& or the result of x || y is a - bool. The client is out of luck if her classes do not follow the - canonical rules. She'll then have to supply her own specialization. - - The type deduction mechanism demostrated below approaches the problem - not through specialization and heuristics, but through a limited form - of typeof mechanism. The code does not use heuristics, hence, no - guessing games. The code takes advantage of the fact that, in general, - the result type of an expression is related to one its arguments' type. - For example, x + y, where x has type int and y has type double, has the - result type double (the second operand type). Another example, x[y] - where x is a vector<T> and y is a std::size_t, has the result type - vector<T>::reference (the vector<T>'s reference type type). - - The limited form of type deduction presented can detect common - relations if the result of a binary or unary operation, given arguments - x and y with types X and Y (respectively), is X, Y, X&, Y&, X*, Y*, X - const*, Y const*, bool, int, unsigned, double, container and iterator - elements (e.g the T, where X is: T[N], T*, vector<T>, map<T>, - vector<T>::iterator). More arguments/return type relationships can be - established if needed. - - A set of overloaded test(T) functions capture these argument related - types. Each test(T) function returns a distinct type that can be used - to determine the exact type of an expression. - - Consider: - - template <typename X, typename Y> - x_value_type - test(X const&); - - template <typename X, typename Y> - y_value_type - test(Y const&); - - Given an expression x + y, where x is int and y is double, the call to: - - test<int, double>(x + y) - - will return a y_value_type. - - Now, if we rig x_value_type and y_value_type such that both have unique - sizes, we can use sizeof(test<X, Y>(x + y)) to determine if the result - type is either X or Y. - - For example, if: - - sizeof(test<X, Y>(x + y)) == sizeof(y_value_type) - - then, we know for sure that the result of x + y has type Y. - - The same basic scheme can be used to detect more argument-dependent - return types where the sizeof the test(T) return type is used to index - through a boost::mpl vector which holds each of the corresponding - result types. - -==============================================================================*/ -#include <boost/mpl/vector/vector20.hpp> -#include <boost/mpl/at.hpp> -#include <boost/mpl/not.hpp> -#include <boost/mpl/or.hpp> -#include <boost/mpl/and.hpp> -#include <boost/mpl/identity.hpp> -#include <boost/type_traits/remove_reference.hpp> -#include <boost/type_traits/add_reference.hpp> -#include <boost/type_traits/remove_cv.hpp> -#include <boost/type_traits/is_const.hpp> -#include <boost/type_traits/is_reference.hpp> -#include <boost/type_traits/is_same.hpp> -#include <boost/type_traits/is_array.hpp> -#include <boost/type_traits/is_pointer.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/static_assert.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/spirit/home/phoenix/detail/local_reference.hpp> - -namespace boost -{ - struct error_cant_deduce_type {}; -} - -namespace boost { namespace type_deduction_detail -{ - typedef char(&bool_value_type)[1]; - typedef char(&int_value_type)[2]; - typedef char(&uint_value_type)[3]; - typedef char(&double_value_type)[4]; - - typedef char(&bool_reference_type)[5]; - typedef char(&int_reference_type)[6]; - typedef char(&uint_reference_type)[7]; - typedef char(&double_reference_type)[8]; - - typedef char(&x_value_type)[9]; - typedef char(&x_reference_type)[10]; - typedef char(&x_const_pointer_type)[11]; - typedef char(&x_pointer_type)[12]; - - typedef char(&y_value_type)[13]; - typedef char(&y_reference_type)[14]; - typedef char(&y_const_pointer_type)[15]; - typedef char(&y_pointer_type)[16]; - - typedef char(&container_reference_type)[17]; - typedef char(&container_const_reference_type)[18]; - typedef char(&container_mapped_type)[19]; - - typedef char(&cant_deduce_type)[20]; - - template <typename T, typename Plain = typename remove_cv<T>::type> - struct is_basic - : mpl::or_< - is_same<Plain, bool> - , is_same<Plain, int> - , is_same<Plain, unsigned> - , is_same<Plain, double> - > {}; - - template <typename C> - struct reference_type - { - typedef typename C::reference type; - }; - - template <typename T> - struct reference_type<T const> - : reference_type<T> {}; - - template <typename T, std::size_t N> - struct reference_type<T[N]> - { - typedef T& type; - }; - - template <typename T> - struct reference_type<T*> - { - typedef T& type; - }; - - template <typename T> - struct reference_type<T* const> - { - typedef T const& type; - }; - - template <typename C> - struct const_reference_type - { - typedef typename C::const_reference type; - }; - - template <typename C> - struct mapped_type - { - typedef typename C::mapped_type type; - }; - - struct asymmetric; - - template <typename X, typename Y> - cant_deduce_type - test(...); // The black hole !!! - - template <typename X, typename Y> - bool_value_type - test(bool const&); - - template <typename X, typename Y> - int_value_type - test(int const&); - - template <typename X, typename Y> - uint_value_type - test(unsigned const&); - - template <typename X, typename Y> - double_value_type - test(double const&); - - template <typename X, typename Y> - bool_reference_type - test(bool&); - - template <typename X, typename Y> - int_reference_type - test(int&); - - template <typename X, typename Y> - uint_reference_type - test(unsigned&); - - template <typename X, typename Y> - double_reference_type - test(double&); - - template <typename X, typename Y> - typename disable_if< - mpl::or_<is_basic<X>, is_const<X> > - , x_value_type - >::type - test(X const&); - - template <typename X, typename Y> - typename disable_if< - is_basic<X> - , x_reference_type - >::type - test(X&); - - template <typename X, typename Y> - typename disable_if< - mpl::or_< - is_basic<X> - , is_const<X> - > - , x_const_pointer_type - >::type - test(X const*); - - template <typename X, typename Y> - x_pointer_type - test(X*); - - template <typename X, typename Y> - typename disable_if< - mpl::or_< - is_basic<Y> - , is_same<Y, asymmetric> - , is_const<Y> - , is_same<X, Y> - > - , y_value_type - >::type - test(Y const&); - - template <typename X, typename Y> - typename disable_if< - mpl::or_< - is_basic<Y> - , is_same<Y, asymmetric> - , is_same<X, Y> - > - , y_reference_type - >::type - test(Y&); - - template <typename X, typename Y> - typename disable_if< - mpl::or_< - is_same<Y, asymmetric> - , is_const<Y> - , is_same<X, Y> - > - , y_const_pointer_type - >::type - test(Y const*); - - template <typename X, typename Y> - typename disable_if< - mpl::or_< - is_same<Y, asymmetric> - , is_same<X, Y> - > - , y_pointer_type - >::type - test(Y*); - - template <typename X, typename Y> - typename disable_if< - mpl::or_< - is_basic<typename X::value_type> - , is_same<typename add_reference<X>::type, typename X::reference> - > - , container_reference_type - >::type - test(typename X::reference); - - template <typename X, typename Y, typename Z> - typename enable_if< - mpl::and_< - mpl::or_<is_array<X>, is_pointer<X> > - , mpl::not_<is_basic<Z> > - , mpl::not_<is_same<X, Z> > - > - , container_reference_type - >::type - test(Z&); - - template <typename X, typename Y> - typename disable_if< - mpl::or_< - is_basic<typename X::value_type> - , is_same<typename add_reference<X>::type, typename X::const_reference> - > - , container_const_reference_type - >::type - test(typename X::const_reference); - - template <typename X, typename Y> - typename disable_if< - is_basic<typename X::mapped_type> - , container_mapped_type - >::type - test(typename X::mapped_type); - - template <typename X, typename Y> - struct base_result_of - { - typedef typename phoenix::detail::unwrap_local_reference<X>::type x_type_; - typedef typename phoenix::detail::unwrap_local_reference<Y>::type y_type_; - typedef typename remove_reference<x_type_>::type x_type; - typedef typename remove_reference<y_type_>::type y_type; - - typedef mpl::vector20< - mpl::identity<bool> - , mpl::identity<int> - , mpl::identity<unsigned> - , mpl::identity<double> - , mpl::identity<bool&> - , mpl::identity<int&> - , mpl::identity<unsigned&> - , mpl::identity<double&> - , mpl::identity<x_type> - , mpl::identity<x_type&> - , mpl::identity<x_type const*> - , mpl::identity<x_type*> - , mpl::identity<y_type> - , mpl::identity<y_type&> - , mpl::identity<y_type const*> - , mpl::identity<y_type*> - , reference_type<x_type> - , const_reference_type<x_type> - , mapped_type<x_type> - , mpl::identity<error_cant_deduce_type> - > - types; - }; - -}} // namespace boost::type_deduction_detail - -#define BOOST_RESULT_OF_COMMON(expr, name, Y, SYMMETRY) \ - struct name \ - { \ - typedef type_deduction_detail::base_result_of<X, Y> base_type; \ - static typename base_type::x_type x; \ - static typename base_type::y_type y; \ - \ - BOOST_STATIC_CONSTANT(int, \ - size = sizeof( \ - type_deduction_detail::test< \ - typename base_type::x_type \ - , SYMMETRY \ - >(expr) \ - )); \ - \ - BOOST_STATIC_CONSTANT(int, index = (size / sizeof(char)) - 1); \ - \ - typedef typename mpl::at_c< \ - typename base_type::types, index>::type id; \ - typedef typename id::type type; \ - }; - -#define BOOST_UNARY_RESULT_OF(expr, name) \ - template <typename X> \ - BOOST_RESULT_OF_COMMON(expr, name, \ - type_deduction_detail::asymmetric, type_deduction_detail::asymmetric) - -#define BOOST_BINARY_RESULT_OF(expr, name) \ - template <typename X, typename Y> \ - BOOST_RESULT_OF_COMMON(expr, name, Y, typename base_type::y_type) - -#define BOOST_ASYMMETRIC_BINARY_RESULT_OF(expr, name) \ - template <typename X, typename Y> \ - BOOST_RESULT_OF_COMMON(expr, name, Y, type_deduction_detail::asymmetric) - -#endif diff --git a/boost/spirit/home/phoenix/function/detail/function_call.hpp b/boost/spirit/home/phoenix/function/detail/function_call.hpp deleted file mode 100644 index 622f118a19..0000000000 --- a/boost/spirit/home/phoenix/function/detail/function_call.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_FUNCTION_DETAIL_FUNCTION_CALL_HPP -#define PHOENIX_FUNCTION_DETAIL_FUNCTION_CALL_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (3, BOOST_PP_DEC(PHOENIX_COMPOSITE_LIMIT), \ - "boost/spirit/home/phoenix/function/detail/function_call.hpp")) -#include BOOST_PP_ITERATE() - -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <BOOST_PP_ENUM_PARAMS(N, typename A)> - actor<typename as_composite<detail::function_eval<N>, F - , BOOST_PP_ENUM_PARAMS(N, A)>::type> - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& _)) const - { - return compose<detail::function_eval<N> >(f, BOOST_PP_ENUM_PARAMS(N, _)); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/function/function.hpp b/boost/spirit/home/phoenix/function/function.hpp deleted file mode 100644 index 1cf470111b..0000000000 --- a/boost/spirit/home/phoenix/function/function.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_FUNCTION_FUNCTION_HPP -#define PHOENIX_FUNCTION_FUNCTION_HPP - -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/core/detail/function_eval.hpp> - -namespace boost { namespace phoenix -{ - template <typename F> - struct function - { - function() : f() {} - function(F const& f) : f(f) {} - - actor<typename as_composite<detail::function_eval<0>, F>::type> - operator()() const - { - return compose<detail::function_eval<0> >(f); - } - - template <typename A0> - actor<typename as_composite<detail::function_eval<1>, F, A0>::type> - operator()(A0 const& _0) const - { - return compose<detail::function_eval<1> >(f, _0); - } - - template <typename A0, typename A1> - actor<typename as_composite<detail::function_eval<2>, F, A0, A1>::type> - operator()(A0 const& _0, A1 const& _1) const - { - return compose<detail::function_eval<2> >(f, _0, _1); - } - - // Bring in the rest of the function call operators - #include <boost/spirit/home/phoenix/function/detail/function_call.hpp> - - F f; - }; -}} - -#endif diff --git a/boost/spirit/home/phoenix/fusion/at.hpp b/boost/spirit/home/phoenix/fusion/at.hpp deleted file mode 100644 index 579658d195..0000000000 --- a/boost/spirit/home/phoenix/fusion/at.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/*============================================================================= - Copyright (c) 2005-2008 Hartmut Kaiser - Copyright (c) 2005-2007 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) -==============================================================================*/ -#ifndef PHOENIX_SEQUENCE_AT_HPP -#define PHOENIX_SEQUENCE_AT_HPP - -#include <boost/fusion/include/at.hpp> -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/type_traits/remove_reference.hpp> - -namespace boost { namespace phoenix -{ - template <int N> - struct at_eval - { - template <typename Env, typename Tuple> - struct result - { - typedef typename Tuple::template result<Env>::type tuple; - typedef typename - fusion::result_of::at_c< - typename remove_reference<tuple>::type, N - >::type - type; - }; - - template <typename RT, typename Env, typename Tuple> - static RT - eval(Env const& env, Tuple const& t) - { - return fusion::at_c<N>(t.eval(env)); - } - }; - - template <int N, typename Tuple> - inline actor<typename as_composite<at_eval<N>, Tuple>::type> - at_c(Tuple const& tup) - { - return compose<at_eval<N> >(tup); - } - -}} - -#endif diff --git a/boost/spirit/home/phoenix/object.hpp b/boost/spirit/home/phoenix/object.hpp deleted file mode 100644 index 5eecb96f9f..0000000000 --- a/boost/spirit/home/phoenix/object.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OBJECT_HPP -#define PHOENIX_OBJECT_HPP - -#include <boost/spirit/home/phoenix/version.hpp> -#include <boost/spirit/home/phoenix/object/new.hpp> -#include <boost/spirit/home/phoenix/object/construct.hpp> -#include <boost/spirit/home/phoenix/object/delete.hpp> -#include <boost/spirit/home/phoenix/object/static_cast.hpp> -#include <boost/spirit/home/phoenix/object/const_cast.hpp> -#include <boost/spirit/home/phoenix/object/dynamic_cast.hpp> -#include <boost/spirit/home/phoenix/object/reinterpret_cast.hpp> - -#endif diff --git a/boost/spirit/home/phoenix/object/const_cast.hpp b/boost/spirit/home/phoenix/object/const_cast.hpp deleted file mode 100644 index 77f24999c0..0000000000 --- a/boost/spirit/home/phoenix/object/const_cast.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OBJECT_CONST_CAST_HPP -#define PHOENIX_OBJECT_CONST_CAST_HPP - -#include <boost/spirit/home/phoenix/core/compose.hpp> - -namespace boost { namespace phoenix -{ - namespace impl - { - template <typename T> - struct const_cast_eval - { - template <typename Env, typename U> - struct result - { - typedef T type; - }; - - template <typename RT, typename Env, typename U> - static RT - eval(Env const& env, U& obj) - { - return const_cast<RT>(obj.eval(env)); - } - }; - } - - template <typename T, typename U> - inline actor<typename as_composite<impl::const_cast_eval<T>, U>::type> - const_cast_(U const& obj) - { - return compose<impl::const_cast_eval<T> >(obj); - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/object/construct.hpp b/boost/spirit/home/phoenix/object/construct.hpp deleted file mode 100644 index d26d6a4fce..0000000000 --- a/boost/spirit/home/phoenix/object/construct.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OBJECT_CONSTRUCT_HPP -#define PHOENIX_OBJECT_CONSTRUCT_HPP - -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> - -namespace boost { namespace phoenix -{ - namespace detail - { - template <typename T> - struct construct_eval - { - template <typename Env, - BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( - PHOENIX_COMPOSITE_LIMIT, typename T, fusion::void_)> - struct result - { - typedef T type; - }; - - template <typename RT, typename Env> - static RT - eval(Env const& env) - { - return RT(); - } - - template <typename RT, typename Env, typename A0> - static RT - eval(Env const& env, A0& _0) - { - return RT(_0.eval(env)); - } - - template <typename RT - , typename Env, typename A0, typename A1> - static RT - eval(Env const& env, A0& _0, A1& _1) - { - return RT(_0.eval(env), _1.eval(env)); - } - - // Bring in the rest of the evals - #include <boost/spirit/home/phoenix/object/detail/construct_eval.hpp> - }; - } - - template <typename T> - inline actor<typename as_composite<detail::construct_eval<T> >::type> - construct() - { - return compose<detail::construct_eval<T> >(); - } - - template <typename T, typename A0> - inline actor<typename as_composite<detail::construct_eval<T>, A0>::type> - construct(A0 const& _0) - { - return compose<detail::construct_eval<T> >(_0); - } - - template <typename T, typename A0, typename A1> - inline actor<typename as_composite<detail::construct_eval<T>, A0, A1>::type> - construct(A0 const& _0, A1 const& _1) - { - return compose<detail::construct_eval<T> >(_0, _1); - } - - // Bring in the rest of the new_ functions - #include <boost/spirit/home/phoenix/object/detail/construct.hpp> -}} - -#endif diff --git a/boost/spirit/home/phoenix/object/delete.hpp b/boost/spirit/home/phoenix/object/delete.hpp deleted file mode 100644 index 1b2328ca6e..0000000000 --- a/boost/spirit/home/phoenix/object/delete.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OBJECT_DELETE_HPP -#define PHOENIX_OBJECT_DELETE_HPP - -#include <boost/spirit/home/phoenix/core/compose.hpp> - -namespace boost { namespace phoenix -{ - namespace impl - { - struct delete_eval - { - template <typename Env, typename P> - struct result - { - typedef void type; - }; - - template <typename Args, typename Env, typename P> - static void - eval(Env const& env, P& p) - { - delete p.eval(env); - } - }; - } - - template <typename P> - inline actor<typename as_composite<impl::delete_eval, P>::type> - delete_(P const& p) - { - return compose<impl::delete_eval>(p); - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/object/detail/construct.hpp b/boost/spirit/home/phoenix/object/detail/construct.hpp deleted file mode 100644 index d474f960f3..0000000000 --- a/boost/spirit/home/phoenix/object/detail/construct.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_OBJECT_DETAIL_CONSTRUCT_HPP -#define PHOENIX_OBJECT_DETAIL_CONSTRUCT_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (3, PHOENIX_COMPOSITE_LIMIT, \ - "boost/spirit/home/phoenix/object/detail/construct.hpp")) -#include BOOST_PP_ITERATE() - -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <typename T, BOOST_PP_ENUM_PARAMS(N, typename A)> - inline actor<typename as_composite<detail::construct_eval<T> - , BOOST_PP_ENUM_PARAMS(N, A)>::type> - construct(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& _)) - { - return compose<detail::construct_eval<T> >(BOOST_PP_ENUM_PARAMS(N, _)); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/object/detail/construct_eval.hpp b/boost/spirit/home/phoenix/object/detail/construct_eval.hpp deleted file mode 100644 index aad710f230..0000000000 --- a/boost/spirit/home/phoenix/object/detail/construct_eval.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_OBJECT_DETAIL_CONSTRUCT_EVAL_HPP -#define PHOENIX_OBJECT_DETAIL_CONSTRUCT_EVAL_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> - -#define PHOENIX_EVAL_ARG(z, n, data) \ - BOOST_PP_CAT(_, n).eval(env) - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (3, PHOENIX_COMPOSITE_LIMIT, \ - "boost/spirit/home/phoenix/object/detail/construct_eval.hpp")) -#include BOOST_PP_ITERATE() - -#undef PHOENIX_EVAL_ARG -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <typename RT, typename Env, BOOST_PP_ENUM_PARAMS(N, typename A)> - static RT - eval(Env const& env, BOOST_PP_ENUM_BINARY_PARAMS(N, A, & _)) - { - return RT(BOOST_PP_ENUM(N, PHOENIX_EVAL_ARG, _)); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/object/detail/new.hpp b/boost/spirit/home/phoenix/object/detail/new.hpp deleted file mode 100644 index 7767c718db..0000000000 --- a/boost/spirit/home/phoenix/object/detail/new.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_OBJECT_DETAIL_NEW_HPP -#define PHOENIX_OBJECT_DETAIL_NEW_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (3, PHOENIX_COMPOSITE_LIMIT, \ - "boost/spirit/home/phoenix/object/detail/new.hpp")) -#include BOOST_PP_ITERATE() - -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <typename T, BOOST_PP_ENUM_PARAMS(N, typename A)> - inline actor<typename as_composite<detail::new_eval<T> - , BOOST_PP_ENUM_PARAMS(N, A)>::type> - new_(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& _)) - { - return compose<detail::new_eval<T> >(BOOST_PP_ENUM_PARAMS(N, _)); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/object/detail/new_eval.hpp b/boost/spirit/home/phoenix/object/detail/new_eval.hpp deleted file mode 100644 index dbaa79191d..0000000000 --- a/boost/spirit/home/phoenix/object/detail/new_eval.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_OBJECT_DETAIL_NEW_EVAL_HPP -#define PHOENIX_OBJECT_DETAIL_NEW_EVAL_HPP - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/preprocessor/repetition/enum.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> - -#define PHOENIX_EVAL_ARG(z, n, data) \ - BOOST_PP_CAT(_, n).eval(env) - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (3, PHOENIX_COMPOSITE_LIMIT, \ - "boost/spirit/home/phoenix/object/detail/new_eval.hpp")) -#include BOOST_PP_ITERATE() - -#undef PHOENIX_EVAL_ARG -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <typename RT, typename Env, BOOST_PP_ENUM_PARAMS(N, typename A)> - static RT - eval(Env const& env, BOOST_PP_ENUM_BINARY_PARAMS(N, A, & _)) - { - return new T(BOOST_PP_ENUM(N, PHOENIX_EVAL_ARG, _)); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/object/dynamic_cast.hpp b/boost/spirit/home/phoenix/object/dynamic_cast.hpp deleted file mode 100644 index 02b7c22934..0000000000 --- a/boost/spirit/home/phoenix/object/dynamic_cast.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OBJECT_DYNAMIC_CAST_HPP -#define PHOENIX_OBJECT_DYNAMIC_CAST_HPP - -#include <boost/spirit/home/phoenix/core/compose.hpp> - -namespace boost { namespace phoenix -{ - namespace impl - { - template <typename T> - struct dynamic_cast_eval - { - template <typename Env, typename U> - struct result - { - typedef T type; - }; - - template <typename RT, typename Env, typename U> - static RT - eval(Env const& env, U& obj) - { - return dynamic_cast<RT>(obj.eval(env)); - } - }; - } - - template <typename T, typename U> - inline actor<typename as_composite<impl::dynamic_cast_eval<T>, U>::type> - dynamic_cast_(U const& obj) - { - return compose<impl::dynamic_cast_eval<T> >(obj); - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/object/new.hpp b/boost/spirit/home/phoenix/object/new.hpp deleted file mode 100644 index 58bb64dfc4..0000000000 --- a/boost/spirit/home/phoenix/object/new.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OBJECT_NEW_HPP -#define PHOENIX_OBJECT_NEW_HPP - -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> - -namespace boost { namespace phoenix -{ - namespace detail - { - template <typename T> - struct new_eval - { - template <typename Env, - BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( - PHOENIX_COMPOSITE_LIMIT, typename T, fusion::void_)> - struct result - { - typedef T* type; - }; - - template <typename RT, typename Env> - static RT - eval(Env const& /*env*/) - { - return new T; - } - - template <typename RT, typename Env, typename A0> - static RT - eval(Env const& env, A0& _0) - { - return new T(_0.eval(env)); - } - - template <typename RT, typename Env - , typename A0, typename A1> - static RT - eval(Env const& env, A0& _0, A1& _1) - { - return new T(_0.eval(env), _1.eval(env)); - } - - // Bring in the rest of the evals - #include <boost/spirit/home/phoenix/object/detail/new_eval.hpp> - }; - } - - template <typename T> - inline actor<typename as_composite<detail::new_eval<T> >::type> - new_() - { - return compose<detail::new_eval<T> >(); - } - - template <typename T, typename A0> - inline actor<typename as_composite<detail::new_eval<T>, A0>::type> - new_(A0 const& _0) - { - return compose<detail::new_eval<T> >(_0); - } - - template <typename T, typename A0, typename A1> - inline actor<typename as_composite<detail::new_eval<T>, A0, A1>::type> - new_(A0 const& _0, A1 const& _1) - { - return compose<detail::new_eval<T> >(_0, _1); - } - - // Bring in the rest of the new_ functions - #include <boost/spirit/home/phoenix/object/detail/new.hpp> -}} - -#endif diff --git a/boost/spirit/home/phoenix/object/reinterpret_cast.hpp b/boost/spirit/home/phoenix/object/reinterpret_cast.hpp deleted file mode 100644 index 9e255d820d..0000000000 --- a/boost/spirit/home/phoenix/object/reinterpret_cast.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OBJECT_REINTERPRET_CAST_HPP -#define PHOENIX_OBJECT_REINTERPRET_CAST_HPP - -#include <boost/spirit/home/phoenix/core/compose.hpp> - -namespace boost { namespace phoenix -{ - namespace impl - { - template <typename T> - struct reinterpret_cast_eval - { - template <typename Env, typename U> - struct result - { - typedef T type; - }; - - template <typename RT, typename Env, typename U> - static RT - eval(Env const& env, U& obj) - { - return reinterpret_cast<RT>(obj.eval(env)); - } - }; - } - - template <typename T, typename U> - inline actor<typename as_composite<impl::reinterpret_cast_eval<T>, U>::type> - reinterpret_cast_(U const& obj) - { - return compose<impl::reinterpret_cast_eval<T> >(obj); - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/object/static_cast.hpp b/boost/spirit/home/phoenix/object/static_cast.hpp deleted file mode 100644 index 508d1b077d..0000000000 --- a/boost/spirit/home/phoenix/object/static_cast.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OBJECT_STATIC_CAST_HPP -#define PHOENIX_OBJECT_STATIC_CAST_HPP - -#include <boost/spirit/home/phoenix/core/compose.hpp> - -namespace boost { namespace phoenix -{ - namespace impl - { - template <typename T> - struct static_cast_eval - { - template <typename Env, typename U> - struct result - { - typedef T type; - }; - - template <typename RT, typename Env, typename U> - static RT - eval(Env const& env, U& obj) - { - return static_cast<RT>(obj.eval(env)); - } - }; - } - - template <typename T, typename U> - inline actor<typename as_composite<impl::static_cast_eval<T>, U>::type> - static_cast_(U const& obj) - { - return compose<impl::static_cast_eval<T> >(obj); - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/operator.hpp b/boost/spirit/home/phoenix/operator.hpp deleted file mode 100644 index 2d8ee6c5cf..0000000000 --- a/boost/spirit/home/phoenix/operator.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OPERATOR_HPP -#define PHOENIX_OPERATOR_HPP - -#include <boost/spirit/home/phoenix/version.hpp> -#include <boost/spirit/home/phoenix/operator/arithmetic.hpp> -#include <boost/spirit/home/phoenix/operator/bitwise.hpp> -#include <boost/spirit/home/phoenix/operator/comparison.hpp> -#include <boost/spirit/home/phoenix/operator/if_else.hpp> -#include <boost/spirit/home/phoenix/operator/logical.hpp> -#include <boost/spirit/home/phoenix/operator/self.hpp> -#include <boost/spirit/home/phoenix/operator/io.hpp> -#include <boost/spirit/home/phoenix/operator/member.hpp> - -#endif diff --git a/boost/spirit/home/phoenix/operator/arithmetic.hpp b/boost/spirit/home/phoenix/operator/arithmetic.hpp deleted file mode 100644 index e51b23e14a..0000000000 --- a/boost/spirit/home/phoenix/operator/arithmetic.hpp +++ /dev/null @@ -1,115 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OPERATOR_ARITHMETIC_HPP -#define PHOENIX_OPERATOR_ARITHMETIC_HPP - -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/detail/type_deduction.hpp> -#include <boost/spirit/home/phoenix/operator/detail/unary_eval.hpp> -#include <boost/spirit/home/phoenix/operator/detail/unary_compose.hpp> -#include <boost/spirit/home/phoenix/operator/detail/binary_eval.hpp> -#include <boost/spirit/home/phoenix/operator/detail/binary_compose.hpp> - -namespace boost { namespace phoenix -{ - struct negate_eval; - struct posit_eval; - struct pre_increment_eval; - struct pre_decrement_eval; - struct post_increment_eval; - struct post_decrement_eval; - - struct plus_assign_eval; - struct minus_assign_eval; - struct multiplies_assign_eval; - struct divides_assign_eval; - struct modulus_assign_eval; - - struct plus_eval; - struct minus_eval; - struct multiplies_eval; - struct divides_eval; - struct modulus_eval; - - BOOST_UNARY_RESULT_OF(-x, result_of_negate) - BOOST_UNARY_RESULT_OF(+x, result_of_posit) - BOOST_UNARY_RESULT_OF(++x, result_of_pre_increment) - BOOST_UNARY_RESULT_OF(--x, result_of_pre_decrement) - BOOST_UNARY_RESULT_OF(x++, result_of_post_increment) - BOOST_UNARY_RESULT_OF(x--, result_of_post_decrement) - - BOOST_BINARY_RESULT_OF(x += y, result_of_plus_assign) - BOOST_BINARY_RESULT_OF(x -= y, result_of_minus_assign) - BOOST_BINARY_RESULT_OF(x *= y, result_of_multiplies_assign) - BOOST_BINARY_RESULT_OF(x /= y, result_of_divides_assign) - BOOST_BINARY_RESULT_OF(x %= y, result_of_modulus_assign) - - BOOST_BINARY_RESULT_OF(x + y, result_of_plus) - BOOST_BINARY_RESULT_OF(x - y, result_of_minus) - BOOST_BINARY_RESULT_OF(x * y, result_of_multiplies) - BOOST_BINARY_RESULT_OF(x / y, result_of_divides) - BOOST_BINARY_RESULT_OF(x % y, result_of_modulus) - -#define x a0.eval(env) -#define y a1.eval(env) - - PHOENIX_UNARY_EVAL(negate_eval, result_of_negate, -x) - PHOENIX_UNARY_EVAL(posit_eval, result_of_posit, +x) - PHOENIX_UNARY_EVAL(pre_increment_eval, result_of_pre_increment, ++x) - PHOENIX_UNARY_EVAL(pre_decrement_eval, result_of_pre_decrement, --x) - PHOENIX_UNARY_EVAL(post_increment_eval, result_of_post_increment, x++) - PHOENIX_UNARY_EVAL(post_decrement_eval, result_of_post_decrement, x--) - - PHOENIX_BINARY_EVAL(plus_assign_eval, result_of_plus_assign, x += y) - PHOENIX_BINARY_EVAL(minus_assign_eval, result_of_minus_assign, x -= y) - PHOENIX_BINARY_EVAL(multiplies_assign_eval, result_of_multiplies_assign, x *= y) - PHOENIX_BINARY_EVAL(divides_assign_eval, result_of_divides_assign, x /= y) - PHOENIX_BINARY_EVAL(modulus_assign_eval, result_of_modulus_assign, x %= y) - - PHOENIX_BINARY_EVAL(plus_eval, result_of_plus, x + y) - PHOENIX_BINARY_EVAL(minus_eval, result_of_minus, x - y) - PHOENIX_BINARY_EVAL(multiplies_eval, result_of_multiplies, x * y) - PHOENIX_BINARY_EVAL(divides_eval, result_of_divides, x / y) - PHOENIX_BINARY_EVAL(modulus_eval, result_of_modulus, x % y) - - PHOENIX_UNARY_COMPOSE(negate_eval, -) - PHOENIX_UNARY_COMPOSE(posit_eval, +) - PHOENIX_UNARY_COMPOSE(pre_increment_eval, ++) - PHOENIX_UNARY_COMPOSE(pre_decrement_eval, --) - - template <typename T0> - inline actor<typename as_composite<post_increment_eval, actor<T0> >::type> - operator++(actor<T0> const& a0, int) // special case - { - return compose<post_increment_eval>(a0); - } - - template <typename T0> - inline actor<typename as_composite<post_decrement_eval, actor<T0> >::type> - operator--(actor<T0> const& a0, int) // special case - { - return compose<post_decrement_eval>(a0); - } - - PHOENIX_BINARY_COMPOSE(plus_assign_eval, +=) - PHOENIX_BINARY_COMPOSE(minus_assign_eval, -=) - PHOENIX_BINARY_COMPOSE(multiplies_assign_eval, *=) - PHOENIX_BINARY_COMPOSE(divides_assign_eval, /=) - PHOENIX_BINARY_COMPOSE(modulus_assign_eval, %=) - - PHOENIX_BINARY_COMPOSE(plus_eval, +) - PHOENIX_BINARY_COMPOSE(minus_eval, -) - PHOENIX_BINARY_COMPOSE(multiplies_eval, *) - PHOENIX_BINARY_COMPOSE(divides_eval, /) - PHOENIX_BINARY_COMPOSE(modulus_eval, %) - -#undef x -#undef y -}} - -#endif diff --git a/boost/spirit/home/phoenix/operator/bitwise.hpp b/boost/spirit/home/phoenix/operator/bitwise.hpp deleted file mode 100644 index 0450db46e9..0000000000 --- a/boost/spirit/home/phoenix/operator/bitwise.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OPERATOR_BITWISE_HPP -#define PHOENIX_OPERATOR_BITWISE_HPP - -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/detail/type_deduction.hpp> -#include <boost/spirit/home/phoenix/operator/detail/unary_eval.hpp> -#include <boost/spirit/home/phoenix/operator/detail/unary_compose.hpp> -#include <boost/spirit/home/phoenix/operator/detail/binary_eval.hpp> -#include <boost/spirit/home/phoenix/operator/detail/binary_compose.hpp> - -#ifdef BOOST_MSVC -# pragma warning(push) -# pragma warning(disable : 4800) -#endif - -namespace boost { namespace phoenix -{ - struct invert_eval; - - struct and_assign_eval; - struct or_assign_eval; - struct xor_assign_eval; - struct shift_left_assign_eval; - struct shift_right_assign_eval; - - struct and_eval; - struct or_eval; - struct xor_eval; - struct shift_left_eval; - struct shift_right_eval; - - BOOST_UNARY_RESULT_OF(~x, result_of_invert) - - BOOST_BINARY_RESULT_OF(x &= y, result_of_and_assign) - BOOST_BINARY_RESULT_OF(x |= y, result_of_or_assign) - BOOST_BINARY_RESULT_OF(x ^= y, result_of_xor_assign) - BOOST_BINARY_RESULT_OF(x <<= y, result_of_shift_left_assign) - BOOST_BINARY_RESULT_OF(x >>= y, result_of_shift_right_assign) - - BOOST_BINARY_RESULT_OF(x & y, result_of_and) - BOOST_BINARY_RESULT_OF(x | y, result_of_or) - BOOST_BINARY_RESULT_OF(x ^ y, result_of_xor) - BOOST_BINARY_RESULT_OF(x << y, result_of_shift_left) - BOOST_BINARY_RESULT_OF(x >> y, result_of_shift_right) - -#define x a0.eval(env) -#define y a1.eval(env) - - PHOENIX_UNARY_EVAL(invert_eval, result_of_invert, ~x) - PHOENIX_UNARY_COMPOSE(invert_eval, ~) - - PHOENIX_BINARY_EVAL(and_assign_eval, result_of_and_assign, x &= y) - PHOENIX_BINARY_EVAL(or_assign_eval, result_of_or_assign, x |= y) - PHOENIX_BINARY_EVAL(xor_assign_eval, result_of_xor_assign, x ^= y) - PHOENIX_BINARY_EVAL(shift_left_assign_eval, result_of_shift_left_assign, x <<= y) - PHOENIX_BINARY_EVAL(shift_right_assign_eval, result_of_shift_right_assign, x >>= y) - - PHOENIX_BINARY_EVAL(and_eval, result_of_and, x & y) - PHOENIX_BINARY_EVAL(or_eval, result_of_or, x | y) - PHOENIX_BINARY_EVAL(xor_eval, result_of_xor, x ^ y) - PHOENIX_BINARY_EVAL(shift_left_eval, result_of_shift_left, x << y) - PHOENIX_BINARY_EVAL(shift_right_eval, result_of_shift_right, x >> y) - - PHOENIX_BINARY_COMPOSE(and_assign_eval, &=) - PHOENIX_BINARY_COMPOSE(or_assign_eval, |=) - PHOENIX_BINARY_COMPOSE(xor_assign_eval, ^=) - PHOENIX_BINARY_COMPOSE(shift_left_assign_eval, <<=) - PHOENIX_BINARY_COMPOSE(shift_right_assign_eval, >>=) - - PHOENIX_BINARY_COMPOSE(and_eval, &) - PHOENIX_BINARY_COMPOSE(or_eval, |) - PHOENIX_BINARY_COMPOSE(xor_eval, ^) - PHOENIX_BINARY_COMPOSE(shift_left_eval, <<) - PHOENIX_BINARY_COMPOSE(shift_right_eval, >>) - -#undef x -#undef y -}} - -#if defined(BOOST_MSVC) -# pragma warning(pop) -#endif - -#endif diff --git a/boost/spirit/home/phoenix/operator/comparison.hpp b/boost/spirit/home/phoenix/operator/comparison.hpp deleted file mode 100644 index fe9298c834..0000000000 --- a/boost/spirit/home/phoenix/operator/comparison.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OPERATOR_COMPARISON_HPP -#define PHOENIX_OPERATOR_COMPARISON_HPP - -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/detail/type_deduction.hpp> -#include <boost/spirit/home/phoenix/operator/detail/unary_eval.hpp> -#include <boost/spirit/home/phoenix/operator/detail/unary_compose.hpp> -#include <boost/spirit/home/phoenix/operator/detail/binary_eval.hpp> -#include <boost/spirit/home/phoenix/operator/detail/binary_compose.hpp> - -namespace boost { namespace phoenix -{ - struct equal_to_eval; - struct not_equal_to_eval; - struct less_eval; - struct less_equal_eval; - struct greater_eval; - struct greater_equal_eval; - - BOOST_BINARY_RESULT_OF(x == y, result_of_equal_to) - BOOST_BINARY_RESULT_OF(x != y, result_of_not_equal_to) - BOOST_BINARY_RESULT_OF(x < y, result_of_less) - BOOST_BINARY_RESULT_OF(x <= y, result_of_less_equal) - BOOST_BINARY_RESULT_OF(x > y, result_of_greater) - BOOST_BINARY_RESULT_OF(x >= y, result_of_greater_equal) - -#define x a0.eval(env) -#define y a1.eval(env) - - PHOENIX_BINARY_EVAL(equal_to_eval, result_of_equal_to, x == y) - PHOENIX_BINARY_EVAL(not_equal_to_eval, result_of_not_equal_to, x != y) - PHOENIX_BINARY_EVAL(less_eval, result_of_less, x < y) - PHOENIX_BINARY_EVAL(less_equal_eval, result_of_less_equal, x <= y) - PHOENIX_BINARY_EVAL(greater_eval, result_of_greater, x > y) - PHOENIX_BINARY_EVAL(greater_equal_eval, result_of_greater_equal, x >= y) - - PHOENIX_BINARY_COMPOSE(equal_to_eval, ==) - PHOENIX_BINARY_COMPOSE(not_equal_to_eval, !=) - PHOENIX_BINARY_COMPOSE(less_eval, <) - PHOENIX_BINARY_COMPOSE(less_equal_eval, <=) - PHOENIX_BINARY_COMPOSE(greater_eval, >) - PHOENIX_BINARY_COMPOSE(greater_equal_eval, >=) - -#undef x -#undef y -}} - -#endif diff --git a/boost/spirit/home/phoenix/operator/detail/binary_compose.hpp b/boost/spirit/home/phoenix/operator/detail/binary_compose.hpp deleted file mode 100644 index 49335fda78..0000000000 --- a/boost/spirit/home/phoenix/operator/detail/binary_compose.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OPERATOR_DETAIL_BINARY_COMPOSE_HPP -#define PHOENIX_OPERATOR_DETAIL_BINARY_COMPOSE_HPP - -#define PHOENIX_BINARY_COMPOSE(eval_name, op) \ - template <typename T0, typename T1> \ - inline actor<typename as_composite<eval_name, actor<T0>, actor<T1> >::type> \ - operator op (actor<T0> const& a0, actor<T1> const& a1) \ - { \ - return compose<eval_name>(a0, a1); \ - } \ - \ - template <typename T0, typename T1> \ - inline actor<typename as_composite<eval_name, actor<T0>, T1>::type> \ - operator op (actor<T0> const& a0, T1 const& a1) \ - { \ - return compose<eval_name>(a0, a1); \ - } \ - \ - template <typename T0, typename T1> \ - inline actor<typename as_composite<eval_name, T0, actor<T1> >::type> \ - operator op (T0 const& a0, actor<T1> const& a1) \ - { \ - return compose<eval_name>(a0, a1); \ - } - -#endif diff --git a/boost/spirit/home/phoenix/operator/detail/binary_eval.hpp b/boost/spirit/home/phoenix/operator/detail/binary_eval.hpp deleted file mode 100644 index 1789882485..0000000000 --- a/boost/spirit/home/phoenix/operator/detail/binary_eval.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OPERATOR_DETAIL_BINARY_EVAL_HPP -#define PHOENIX_OPERATOR_DETAIL_BINARY_EVAL_HPP - -#include <boost/mpl/or.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/identity.hpp> -#include <boost/type_traits/is_same.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> - -#define PHOENIX_BINARY_EVAL(eval_name, op_result, expr) \ - struct eval_name \ - { \ - template <typename Env, typename A0, typename A1> \ - struct result \ - { \ - typedef typename A0::template result<Env>::type x_type; \ - typedef typename A1::template result<Env>::type y_type; \ - \ - typedef typename \ - mpl::eval_if< \ - mpl::or_<is_actor<x_type>, is_actor<y_type> > \ - , re_curry<eval_name, x_type, y_type> \ - , op_result<x_type, y_type> \ - >::type \ - type; \ - }; \ - \ - template <typename RT, typename Env, typename A0, typename A1> \ - static RT \ - eval(Env const& env, A0& a0, A1& a1) \ - { \ - return expr; \ - } \ - }; - -#undef x -#undef y -#endif diff --git a/boost/spirit/home/phoenix/operator/detail/io.hpp b/boost/spirit/home/phoenix/operator/detail/io.hpp deleted file mode 100644 index d82a153c32..0000000000 --- a/boost/spirit/home/phoenix/operator/detail/io.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OPERATOR_DETAIL_IO_HPP -#define PHOENIX_OPERATOR_DETAIL_IO_HPP - -#include <boost/spirit/home/phoenix/operator/bitwise.hpp> -#include <boost/spirit/home/phoenix/core/reference.hpp> -#include <boost/utility/addressof.hpp> -#include <boost/utility/enable_if.hpp> -#include <iostream> - -namespace boost { namespace phoenix { namespace detail -{ - typedef char(&no)[1]; - typedef char(&yes)[2]; - - template <typename CharType, typename CharTrait> - yes ostream_test(std::basic_ostream<CharType, CharTrait>*); - no ostream_test(...); - - template <typename CharType, typename CharTrait> - yes istream_test(std::basic_istream<CharType, CharTrait>*); - no istream_test(...); - - template <typename T> - struct is_ostream - { - static T x; - BOOST_STATIC_CONSTANT(bool, - value = sizeof(detail::ostream_test(boost::addressof(x))) == sizeof(yes)); - }; - - template <typename T> - struct is_istream - { - static T x; - BOOST_STATIC_CONSTANT(bool, - value = sizeof(detail::istream_test(boost::addressof(x))) == sizeof(yes)); - }; - - template <typename T0, typename T1> - struct enable_if_ostream : - enable_if< - detail::is_ostream<T0> - , actor< - typename as_composite< - shift_left_eval - , actor<reference<T0> > - , actor<T1> - >::type - > - > - {}; - - template <typename T0, typename T1> - struct enable_if_istream : - enable_if< - detail::is_istream<T0> - , actor< - typename as_composite< - shift_right_eval - , actor<reference<T0> > - , actor<T1> - >::type - > - > - {}; - - typedef std::ios_base& (*iomanip_type)(std::ios_base&); - typedef std::istream& (*imanip_type)(std::istream&); - typedef std::ostream& (*omanip_type)(std::ostream&); -}}} - -#endif diff --git a/boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_eval.hpp b/boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_eval.hpp deleted file mode 100644 index cb77613aea..0000000000 --- a/boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_eval.hpp +++ /dev/null @@ -1,76 +0,0 @@ -/*============================================================================= - Copyright (c) 2005-2007 Dan Marsden - Copyright (c) 2005-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_OPERATOR_DETAIL_MEM_FUN_PTR_EVAL_HPP -#define PHOENIX_OPERATOR_DETAIL_MEM_FUN_PTR_EVAL_HPP - -#include <boost/spirit/home/phoenix/core/limits.hpp> -#include <boost/spirit/home/phoenix/core/actor.hpp> - -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> -#include <boost/preprocessor/iteration/iterate.hpp> -#include <boost/preprocessor/arithmetic/sub.hpp> -#include <boost/preprocessor/arithmetic/dec.hpp> - -#include <boost/mpl/void.hpp> - -#include <boost/type_traits/function_traits.hpp> - -#include <boost/get_pointer.hpp> - -#include <boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_return.hpp> - -namespace boost { namespace phoenix { - - struct mem_fun_ptr_eval - { - template<typename Env, typename PtrActor, typename MemFunPtrActor, - BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_SUB(PHOENIX_MEMBER_LIMIT, 2), typename Arg, mpl::void_)> - - struct result - : detail::mem_fun_ptr_return<typename eval_result<MemFunPtrActor, Env>::type> { }; - - template<typename Rt, typename Env, typename PtrActor, typename MemFunPtrActor> - static typename result<Env,PtrActor,MemFunPtrActor>::type - eval(const Env& env, PtrActor& ptrActor, MemFunPtrActor& memFunPtrActor) - { - return (get_pointer(ptrActor.eval(env))->*memFunPtrActor.eval(env))(); - } - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (1, BOOST_PP_DEC(BOOST_PP_DEC(PHOENIX_MEMBER_LIMIT)), "boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_eval.hpp")) - -#include BOOST_PP_ITERATE() - - }; -}} - -#endif - -#else - -#define PHOENIX_ITERATION BOOST_PP_ITERATION() - -#define PHOENIX_EVAL_ARG(z,n,_) arg ## n.eval(env) - - template<typename Rt, typename Env, typename PtrActor, typename MemFunPtrActor, - BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, typename Arg)> - static typename result<Env,PtrActor,MemFunPtrActor, BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION,Arg)>::type - eval(const Env& env, PtrActor& ptrActor, MemFunPtrActor& memFunPtrActor, - BOOST_PP_ENUM_BINARY_PARAMS(PHOENIX_ITERATION, Arg, & arg)) - { - return (get_pointer(ptrActor.eval(env))->*memFunPtrActor.eval(env))( - BOOST_PP_ENUM(PHOENIX_ITERATION,PHOENIX_EVAL_ARG,_)); - } - -#undef PHOENIX_EVAL_ARG -#undef PHOENIX_ITERATION - -#endif diff --git a/boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_gen.hpp b/boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_gen.hpp deleted file mode 100644 index 31d5413035..0000000000 --- a/boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_gen.hpp +++ /dev/null @@ -1,69 +0,0 @@ -/*============================================================================= - Copyright (c) 2005-2007 Dan Marsden - Copyright (c) 2005-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_OPERATOR_DETAIL_MEM_FUN_PTR_GEN_HPP -#define PHOENIX_OPERATOR_DETAIL_MEM_FUN_PTR_GEN_HPP - -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/core/as_actor.hpp> -#include <boost/spirit/home/phoenix/core/limits.hpp> -#include <boost/spirit/home/phoenix/core/actor.hpp> - -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> -#include <boost/preprocessor/iteration/iterate.hpp> -#include <boost/preprocessor/arithmetic/dec.hpp> - -#include <boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_eval.hpp> - -namespace boost { namespace phoenix { - template<typename Actor, typename MemFunPtr> - struct mem_fun_ptr_gen - { - mem_fun_ptr_gen( - const Actor& actor, MemFunPtr memFunPtr) - : mActor(actor), mMemFunPtr(memFunPtr) { } - - actor<typename as_composite<mem_fun_ptr_eval, Actor, typename as_actor<MemFunPtr>::type>::type> - operator()() const - { - return compose<mem_fun_ptr_eval>( - mActor, as_actor<MemFunPtr>::convert(mMemFunPtr)); - } - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (1, BOOST_PP_DEC(BOOST_PP_DEC(PHOENIX_MEMBER_LIMIT)), "boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_gen.hpp")) - -#include BOOST_PP_ITERATE() - - Actor mActor; - MemFunPtr mMemFunPtr; - }; -}} - -#endif -#else - -#define PHOENIX_ITERATION BOOST_PP_ITERATION() - - template<BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, typename Arg)> - actor<typename as_composite< - mem_fun_ptr_eval, Actor, typename as_actor<MemFunPtr>::type, - BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, Arg)>::type> - operator()( - BOOST_PP_ENUM_BINARY_PARAMS(PHOENIX_ITERATION, const Arg, &arg)) const - { - return compose<mem_fun_ptr_eval>( - mActor, as_actor<MemFunPtr>::convert(mMemFunPtr), - BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, arg)); - } - -#undef PHOENIX_ITERATION - -#endif diff --git a/boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_return.hpp b/boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_return.hpp deleted file mode 100644 index 102f17f021..0000000000 --- a/boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_return.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/*============================================================================= - Copyright (c) 2005-2007 Dan Marsden - Copyright (c) 2005-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_OPERATOR_DETAIL_MEM_FUN_PTR_RETURN_HPP -#define PHOENIX_OPERATOR_DETAIL_MEM_FUN_PTR_RETURN_HPP - -#include <boost/spirit/home/phoenix/core/limits.hpp> - -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/iteration/iterate.hpp> - -namespace boost { namespace phoenix { -namespace detail -{ - template<typename MemFunPtr> - struct mem_fun_ptr_return; - - template<typename Ret, typename Class> - struct mem_fun_ptr_return<Ret (Class::*)()> - { - typedef Ret type; - }; - - template<typename Ret, typename Class> - struct mem_fun_ptr_return<Ret (Class::*)() const> - { - typedef Ret type; - }; - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (1, PHOENIX_MEMBER_LIMIT, "boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_return.hpp")) - -#include BOOST_PP_ITERATE() - -} -}} - -#endif - -#else - -#define PHOENIX_ITERATION BOOST_PP_ITERATION() - - template<typename Ret, typename Class, - BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, typename T)> - struct mem_fun_ptr_return<Ret (Class::*)(BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, T))> - { - typedef Ret type; - }; - - template<typename Ret, typename Class, - BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, typename T)> - struct mem_fun_ptr_return<Ret (Class::*)(BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, T)) const> - { - typedef Ret type; - }; - -#undef PHOENIX_ITERATION - -#endif diff --git a/boost/spirit/home/phoenix/operator/detail/unary_compose.hpp b/boost/spirit/home/phoenix/operator/detail/unary_compose.hpp deleted file mode 100644 index fd9a8c70fb..0000000000 --- a/boost/spirit/home/phoenix/operator/detail/unary_compose.hpp +++ /dev/null @@ -1,18 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OPERATOR_DETAIL_UNARY_COMPOSE_HPP -#define PHOENIX_OPERATOR_DETAIL_UNARY_COMPOSE_HPP - -#define PHOENIX_UNARY_COMPOSE(eval_name, op) \ - template <typename T0> \ - inline actor<typename as_composite<eval_name, actor<T0> >::type> \ - operator op (actor<T0> const& a0) \ - { \ - return compose<eval_name>(a0); \ - } - -#endif diff --git a/boost/spirit/home/phoenix/operator/detail/unary_eval.hpp b/boost/spirit/home/phoenix/operator/detail/unary_eval.hpp deleted file mode 100644 index 501f6df717..0000000000 --- a/boost/spirit/home/phoenix/operator/detail/unary_eval.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OPERATOR_DETAIL_UNARY_EVAL_HPP -#define PHOENIX_OPERATOR_DETAIL_UNARY_EVAL_HPP - -#include <boost/mpl/eval_if.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> - -#define PHOENIX_UNARY_EVAL(eval_name, op_result, expr) \ - struct eval_name \ - { \ - template <typename Env, typename A0> \ - struct result \ - { \ - typedef typename A0::template result<Env>::type x_type; \ - \ - typedef typename \ - mpl::eval_if< \ - is_actor<x_type> \ - , re_curry<eval_name, x_type> \ - , op_result<x_type> \ - >::type \ - type; \ - }; \ - \ - template <typename RT, typename Env, typename A0> \ - static RT \ - eval(Env const& env, A0& a0) \ - { \ - return expr; \ - } \ - }; - -#endif - - diff --git a/boost/spirit/home/phoenix/operator/if_else.hpp b/boost/spirit/home/phoenix/operator/if_else.hpp deleted file mode 100644 index 8492e90861..0000000000 --- a/boost/spirit/home/phoenix/operator/if_else.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OPERATOR_IF_ELSE_HPP -#define PHOENIX_OPERATOR_IF_ELSE_HPP - -#include <boost/mpl/and.hpp> -#include <boost/mpl/if.hpp> -#include <boost/type_traits/is_same.hpp> -#include <boost/type_traits/is_reference.hpp> -#include <boost/type_traits/remove_reference.hpp> -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/detail/type_deduction.hpp> - -namespace boost { namespace phoenix -{ - BOOST_BINARY_RESULT_OF(true ? x : y, result_of_if_else) - - struct if_else_op_eval - { - template < - typename Env - , typename Cond - , typename Then - , typename Else - > - struct result - { - typedef typename Then::template result<Env>::type then_type; - typedef typename Else::template result<Env>::type else_type; - - typedef typename - result_of_if_else<then_type, else_type>::type - ite_result; - - // Note: c ? x : y can return an lvalue! Allow if_else_op_eval - // to return an lvalue IFF then_type and else_type are both lvalues - // with the same type. - - typedef typename - mpl::if_< - mpl::and_< - is_same<then_type, else_type> - , is_reference<then_type> - > - , ite_result - , typename remove_reference<ite_result>::type - >::type - type; - }; - - template < - typename RT - , typename Env - , typename Cond - , typename Then - , typename Else - > - static RT - eval(Env const& env, Cond& cond, Then& then, Else& else_) - { - return cond.eval(env) ? then.eval(env) : else_.eval(env); - } - }; - - template <typename Cond, typename Then, typename Else> - inline actor<typename as_composite<if_else_op_eval, Cond, Then, Else>::type> - if_else(Cond const& cond, Then const& then, Else const& else_) - { - return compose<if_else_op_eval>(cond, then, else_); - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/operator/io.hpp b/boost/spirit/home/phoenix/operator/io.hpp deleted file mode 100644 index 360a46fbcc..0000000000 --- a/boost/spirit/home/phoenix/operator/io.hpp +++ /dev/null @@ -1,86 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OPERATOR_IO_HPP -#define PHOENIX_OPERATOR_IO_HPP - -#include <boost/spirit/home/phoenix/operator/detail/io.hpp> - -namespace boost { namespace phoenix -{ -/////////////////////////////////////////////////////////////////////////////// -// -// overloads for std::basic_ostream and std::basic_istream -// -/////////////////////////////////////////////////////////////////////////////// - template <typename T0, typename T1> - inline typename detail::enable_if_ostream<T0, T1>::type - operator<<(T0& a0, actor<T1> const& a1) - { - return compose<shift_left_eval>(phoenix::ref(a0), a1); - } - - template <typename T0, typename T1> - inline typename detail::enable_if_istream<T0, T1>::type - operator>>(T0& a0, actor<T1> const& a1) - { - return compose<shift_right_eval>(phoenix::ref(a0), a1); - } - - // resolve ambiguities with fusion. - template <typename T1> - inline typename detail::enable_if_ostream<std::ostream, T1>::type - operator<<(std::ostream& a0, actor<T1> const& a1) - { - return compose<shift_left_eval>(phoenix::ref(a0), a1); - } - - template <typename T1> - inline typename detail::enable_if_istream<std::istream, T1>::type - operator>>(std::istream& a0, actor<T1> const& a1) - { - return compose<shift_right_eval>(phoenix::ref(a0), a1); - } - -/////////////////////////////////////////////////////////////////////////////// -// -// overloads for I/O manipulators. -// -/////////////////////////////////////////////////////////////////////////////// - template <typename T0> - inline actor<typename as_composite< - shift_left_eval, actor<T0>, detail::omanip_type>::type> - operator<<(actor<T0> const& a0, detail::omanip_type a1) - { - return compose<shift_left_eval>(a0, a1); - } - - template <typename T0> - inline actor<typename as_composite< - shift_left_eval, actor<T0>, detail::iomanip_type>::type> - operator<<(actor<T0> const& a0, detail::iomanip_type a1) - { - return compose<shift_left_eval>(a0, a1); - } - - template <typename T0> - inline actor<typename as_composite< - shift_right_eval, actor<T0>, detail::imanip_type>::type> - operator>>(actor<T0> const& a0, detail::imanip_type a1) - { - return compose<shift_right_eval>(a0, a1); - } - - template <typename T0> - inline actor<typename as_composite< - shift_right_eval, actor<T0>, detail::iomanip_type>::type> - operator>>(actor<T0> const& a0, detail::iomanip_type a1) - { - return compose<shift_right_eval>(a0, a1); - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/operator/logical.hpp b/boost/spirit/home/phoenix/operator/logical.hpp deleted file mode 100644 index 84619aa460..0000000000 --- a/boost/spirit/home/phoenix/operator/logical.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OPERATOR_LOGICAL_HPP -#define PHOENIX_OPERATOR_LOGICAL_HPP - -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/detail/type_deduction.hpp> -#include <boost/spirit/home/phoenix/operator/detail/unary_eval.hpp> -#include <boost/spirit/home/phoenix/operator/detail/unary_compose.hpp> -#include <boost/spirit/home/phoenix/operator/detail/binary_eval.hpp> -#include <boost/spirit/home/phoenix/operator/detail/binary_compose.hpp> - -namespace boost { namespace phoenix -{ - struct logical_not_eval; - struct logical_and_eval; - struct logical_or_eval; - - BOOST_UNARY_RESULT_OF(!x, result_of_logical_not) - BOOST_BINARY_RESULT_OF(x && y, result_of_logical_and) - BOOST_BINARY_RESULT_OF(x || y, result_of_logical_or) - -#define x a0.eval(env) -#define y a1.eval(env) - - PHOENIX_UNARY_EVAL(logical_not_eval, result_of_logical_not, !x) - PHOENIX_BINARY_EVAL(logical_and_eval, result_of_logical_and, x && y) - PHOENIX_BINARY_EVAL(logical_or_eval, result_of_logical_or, x || y) - - PHOENIX_UNARY_COMPOSE(logical_not_eval, !) - PHOENIX_BINARY_COMPOSE(logical_and_eval, &&) - PHOENIX_BINARY_COMPOSE(logical_or_eval, ||) - -#undef x -#undef y -}} - -#endif diff --git a/boost/spirit/home/phoenix/operator/member.hpp b/boost/spirit/home/phoenix/operator/member.hpp deleted file mode 100644 index 27f3e8d1a8..0000000000 --- a/boost/spirit/home/phoenix/operator/member.hpp +++ /dev/null @@ -1,145 +0,0 @@ -/*============================================================================= - Copyright (c) 2005-2007 Dan Marsden - Copyright (c) 2005-2007 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) -==============================================================================*/ - -#ifndef PHOENIX_OPERATOR_MEMBER_HPP -#define PHOENIX_OPERATOR_MEMBER_HPP - -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> - -#include <boost/type_traits/add_reference.hpp> -#include <boost/type_traits/add_const.hpp> -#include <boost/type_traits/is_const.hpp> -#include <boost/type_traits/remove_reference.hpp> -#include <boost/type_traits/is_member_pointer.hpp> -#include <boost/type_traits/is_member_function_pointer.hpp> - -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/identity.hpp> -#include <boost/mpl/and.hpp> -#include <boost/mpl/not.hpp> - -#include <boost/utility/enable_if.hpp> - -#include <boost/get_pointer.hpp> - -#include <boost/spirit/home/phoenix/operator/detail/mem_fun_ptr_gen.hpp> - -#include <memory> - -namespace boost { - template<typename T> class shared_ptr; - template<typename T> class scoped_ptr; - -namespace phoenix { - namespace detail - { - template<typename T> - struct member_type; - - template<typename Class, typename MemberType> - struct member_type<MemberType (Class::*)> - { - typedef MemberType type; - }; - } - - namespace meta - { - template<typename T> - struct pointed_type; - - template<typename T> - struct pointed_type<T*> - { - typedef T type; - }; - - template<typename T> - struct pointed_type<shared_ptr<T> > - { - typedef T type; - }; - - template<typename T> - struct pointed_type<scoped_ptr<T> > - { - typedef T type; - }; - - template<typename T> - struct pointed_type<std::auto_ptr<T> > - { - typedef T type; - }; - } - - struct member_object_eval - { - template<typename Env, typename PtrActor, typename MemPtrActor> - struct result - { - typedef typename detail::member_type< - typename eval_result<MemPtrActor, Env>::type>::type member_type; - - typedef typename meta::pointed_type< - typename remove_reference< - typename eval_result<PtrActor, Env>::type>::type>::type object_type; - - typedef typename add_reference< - typename mpl::eval_if< - is_const<object_type>, - add_const<member_type>, - mpl::identity<member_type> >::type>::type type; - }; - - template<typename Rt, typename Env, typename PtrActor, typename MemPtrActor> - static typename result<Env,PtrActor,MemPtrActor>::type - eval(const Env& env, PtrActor& ptrActor, MemPtrActor& memPtrActor) - { - return get_pointer(ptrActor.eval(env))->*memPtrActor.eval(env); - } - }; - - namespace member_object - { - template<typename T0, typename MemObjPtr> - typename enable_if< - mpl::and_<is_member_pointer<MemObjPtr>, mpl::not_<is_member_function_pointer<MemObjPtr> > >, - actor<typename as_composite< - member_object_eval, actor<T0>, - typename as_actor<MemObjPtr>::type>::type> >::type - operator->*( - const actor<T0>& ptrActor, - MemObjPtr memObjPtr) - { - return compose<member_object_eval>( - ptrActor, - as_actor<MemObjPtr>::convert(memObjPtr)); - } - } - - namespace member_function - { - template<typename T0, typename MemFunPtr> - typename enable_if< - is_member_function_pointer<MemFunPtr>, - mem_fun_ptr_gen<actor<T0>, MemFunPtr> >::type - operator->*(const actor<T0>& ptrActor, MemFunPtr memFunPtr) - { - return mem_fun_ptr_gen<actor<T0>, MemFunPtr>( - ptrActor, memFunPtr); - } - } - - using member_object::operator->*; - using member_function::operator->*; -}} - -#endif diff --git a/boost/spirit/home/phoenix/operator/self.hpp b/boost/spirit/home/phoenix/operator/self.hpp deleted file mode 100644 index 294adf6b81..0000000000 --- a/boost/spirit/home/phoenix/operator/self.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_OPERATOR_SELF_HPP -#define PHOENIX_OPERATOR_SELF_HPP - -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/detail/type_deduction.hpp> -#include <boost/spirit/home/phoenix/operator/detail/unary_eval.hpp> -#include <boost/spirit/home/phoenix/operator/detail/unary_compose.hpp> -#include <boost/spirit/home/phoenix/operator/detail/binary_eval.hpp> -#include <boost/spirit/home/phoenix/operator/detail/binary_compose.hpp> - -namespace boost { namespace phoenix -{ - struct reference_eval; - struct dereference_eval; - struct assign_eval; - struct index_eval; - - BOOST_UNARY_RESULT_OF(&x, result_of_reference) - BOOST_UNARY_RESULT_OF(*x, result_of_dereference) - BOOST_BINARY_RESULT_OF(x = y, result_of_assign) - BOOST_ASYMMETRIC_BINARY_RESULT_OF(x[y], result_of_index) - - namespace detail - { - template <typename T0, typename T1> - struct make_assign_composite - { - typedef actor<typename as_composite<assign_eval, T0, T1>::type> type; - }; - - template <typename T0, typename T1> - struct make_index_composite - { - typedef actor<typename as_composite<index_eval, T0, T1>::type> type; - }; - } - - template <typename Base> - template <typename T1> - typename detail::make_assign_composite<actor<Base>, T1>::type - actor<Base>::operator=(T1 const& a1) const - { - return compose<assign_eval>(*this, a1); - } - - template <typename Base> - template <typename T1> - typename detail::make_index_composite<actor<Base>, T1>::type - actor<Base>::operator[](T1 const& a1) const - { - return compose<index_eval>(*this, a1); - } - -#define x a0.eval(env) -#define y a1.eval(env) - - PHOENIX_UNARY_EVAL(reference_eval, result_of_reference, &x) - PHOENIX_UNARY_EVAL(dereference_eval, result_of_dereference, *x) - PHOENIX_UNARY_COMPOSE(reference_eval, &) - PHOENIX_UNARY_COMPOSE(dereference_eval, *) - - PHOENIX_BINARY_EVAL(assign_eval, result_of_assign, x = y) - PHOENIX_BINARY_EVAL(index_eval, result_of_index, x[y]) -}} - -#undef x -#undef y -#endif diff --git a/boost/spirit/home/phoenix/scope.hpp b/boost/spirit/home/phoenix/scope.hpp deleted file mode 100644 index c1b9ae3192..0000000000 --- a/boost/spirit/home/phoenix/scope.hpp +++ /dev/null @@ -1,16 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_SCOPE_HPP -#define PHOENIX_SCOPE_HPP - -#include <boost/spirit/home/phoenix/version.hpp> -#include <boost/spirit/home/phoenix/scope/scoped_environment.hpp> -#include <boost/spirit/home/phoenix/scope/lambda.hpp> -#include <boost/spirit/home/phoenix/scope/let.hpp> -#include <boost/spirit/home/phoenix/scope/local_variable.hpp> - -#endif diff --git a/boost/spirit/home/phoenix/scope/detail/local_gen.hpp b/boost/spirit/home/phoenix/scope/detail/local_gen.hpp deleted file mode 100644 index 6a74df6b14..0000000000 --- a/boost/spirit/home/phoenix/scope/detail/local_gen.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -// Allow multiple inclusion. let.hpp and lambda.hpp will have the guards - -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/repetition/enum.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> - -#define PHOENIX_LOCAL_GEN_PARAM(z, n, data) \ - actor<composite<assign_eval \ - , fusion::vector<local_variable<K##n>, V##n> > > const& a##n - -#define PHOENIX_LOCAL_GEN_ACTOR(z, n, data) \ - fusion::at_c<1>(a##n) - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (3, PHOENIX_LOCAL_LIMIT, \ - "boost/spirit/home/phoenix/scope/detail/local_gen.hpp")) -#include BOOST_PP_ITERATE() - -#undef PHOENIX_LOCAL_GEN_PARAM -#undef PHOENIX_LOCAL_GEN_ACTOR - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template < - BOOST_PP_ENUM_PARAMS(N, typename K) - , BOOST_PP_ENUM_PARAMS(N, typename V) - > - PHOENIX_LOCAL_GEN_NAME< - fusion::vector<BOOST_PP_ENUM_PARAMS(N, V)> - , detail::map_local_index_to_tuple<BOOST_PP_ENUM_PARAMS(N, K)> - > - operator()( - BOOST_PP_ENUM(N, PHOENIX_LOCAL_GEN_PARAM, _) - ) const - { - return fusion::vector<BOOST_PP_ENUM_PARAMS(N, V)>( - BOOST_PP_ENUM(N, PHOENIX_LOCAL_GEN_ACTOR, _)); - } - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/scope/detail/local_variable.hpp b/boost/spirit/home/phoenix/scope/detail/local_variable.hpp deleted file mode 100644 index 1ad7932d86..0000000000 --- a/boost/spirit/home/phoenix/scope/detail/local_variable.hpp +++ /dev/null @@ -1,198 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - Copyright (c) 2004 Daniel Wallin - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#ifndef PHOENIX_SCOPE_DETAIL_LOCAL_VARIABLE_HPP -#define PHOENIX_SCOPE_DETAIL_LOCAL_VARIABLE_HPP - -#include <boost/mpl/int.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/equal_to.hpp> -#include <boost/mpl/identity.hpp> -#include <boost/mpl/less.hpp> -#include <boost/mpl/size.hpp> -#include <boost/fusion/include/at.hpp> -#include <boost/fusion/include/value_at.hpp> -#include <boost/preprocessor/enum.hpp> -#include <boost/preprocessor/repeat.hpp> -#include <boost/type_traits/remove_reference.hpp> -#include <boost/type_traits/is_reference.hpp> - -#define PHOENIX_MAP_LOCAL_TEMPLATE_PARAM(z, n, data) \ - typename T##n = unused<n> - -#define PHOENIX_MAP_LOCAL_DISPATCH(z, n, data) \ - typedef char(&result##n)[n+2]; \ - static result##n get(T##n*); - -namespace boost { namespace phoenix -{ - template <typename Env, typename OuterEnv, typename Locals, typename Map> - struct scoped_environment; - - namespace detail - { - template <typename Env> - struct initialize_local - { - template <class F> - struct result; - - template <class F, class Actor> - struct result<F(Actor)> - { - typedef typename remove_reference<Actor>::type actor_type; - typedef typename actor_type::template result<Env>::type type; - }; - - initialize_local(Env const& env) - : env(env) {} - - template <typename Actor> - typename result<initialize_local(Actor)>::type - operator()(Actor const& actor) const - { - return actor.eval(env); - } - - Env const& env; - - private: - // silence MSVC warning C4512: assignment operator could not be generated - initialize_local& operator= (initialize_local const&); - }; - - template <typename T> - struct is_scoped_environment : mpl::false_ {}; - - template <typename Env, typename OuterEnv, typename Locals, typename Map> - struct is_scoped_environment<scoped_environment<Env, OuterEnv, Locals, Map> > - : mpl::true_ {}; - - template <int N> - struct unused; - - template <BOOST_PP_ENUM( - PHOENIX_LOCAL_LIMIT, PHOENIX_MAP_LOCAL_TEMPLATE_PARAM, _)> - struct map_local_index_to_tuple - { - typedef char(¬_found)[1]; - static not_found get(...); - - BOOST_PP_REPEAT(PHOENIX_LOCAL_LIMIT, PHOENIX_MAP_LOCAL_DISPATCH, _) - }; - - template<typename T> - T* generate_pointer(); - - template <typename Map, typename Tag> - struct get_index - { - BOOST_STATIC_CONSTANT(int, - value = ( - static_cast<int>((sizeof(Map::get(generate_pointer<Tag>()))) / sizeof(char)) - 2 - )); - - // if value == -1, Tag is not found - typedef mpl::int_<value> type; - }; - - template <typename Local, typename Env> - struct apply_local; - - template <typename Local, typename Env> - struct outer_local - { - typedef typename - apply_local<Local, typename Env::outer_env_type>::type - type; - }; - - template <typename Locals, typename Index> - struct get_local_or_void - { - typedef typename - mpl::eval_if< - mpl::less<Index, mpl::size<Locals> > - , fusion::result_of::at<Locals, Index> - , mpl::identity<fusion::void_> - >::type - type; - }; - - template <typename Local, typename Env, typename Index> - struct get_local_from_index - { - typedef typename - mpl::eval_if< - mpl::equal_to<Index, mpl::int_<-1> > - , outer_local<Local, Env> - , get_local_or_void<typename Env::locals_type, Index> - >::type - type; - }; - - template <typename Local, typename Env> - struct get_local - { - typedef typename - get_index< - typename Env::map_type, typename Local::key_type>::type - index_type; - - typedef typename - get_local_from_index<Local, Env, index_type>::type - type; - }; - - template <typename Local, typename Env> - struct apply_local - { - // $$$ TODO: static assert that Env is a scoped_environment $$$ - typedef typename get_local<Local, Env>::type type; - }; - - template <typename Key> - struct eval_local - { - template <typename RT, typename Env, typename Index> - static RT - get(Env const& env, Index, mpl::false_) - { - return RT(fusion::at<Index>(env.locals)); - } - - template <typename RT, typename Env, typename Index> - static RT - get(Env const& env, Index index, mpl::true_) - { - typedef typename - get_index<typename Env::outer_env_type::map_type, Key>::type - index_type; - - return get<RT>( - env.outer_env - , index_type() - , mpl::equal_to<index_type, mpl::int_<-1> >()); - } - - template <typename RT, typename Env, typename Index> - static RT - get(Env const& env, Index index) - { - return get<RT>( - env - , index - , mpl::equal_to<Index, mpl::int_<-1> >()); - } - }; - } -}} - -#undef PHOENIX_MAP_LOCAL_TEMPLATE_PARAM -#undef PHOENIX_MAP_LOCAL_DISPATCH -#endif diff --git a/boost/spirit/home/phoenix/scope/dynamic.hpp b/boost/spirit/home/phoenix/scope/dynamic.hpp deleted file mode 100644 index c822bf7d07..0000000000 --- a/boost/spirit/home/phoenix/scope/dynamic.hpp +++ /dev/null @@ -1,193 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - Copyright (c) 2004 Daniel Wallin - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#ifndef PHOENIX_SCOPE_DYNAMIC_HPP -#define PHOENIX_SCOPE_DYNAMIC_HPP - -#include <boost/spirit/home/phoenix/core/limits.hpp> -#include <boost/fusion/include/at.hpp> -#include <boost/fusion/include/vector.hpp> -#include <boost/spirit/home/phoenix/core/actor.hpp> - -#include <boost/preprocessor/cat.hpp> -#include <boost/preprocessor/punctuation/comma_if.hpp> -#include <boost/preprocessor/seq/for_each_i.hpp> -#include <boost/preprocessor/tuple/elem.hpp> -#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/preprocessor/inc.hpp> - -#include <boost/noncopyable.hpp> -#include <boost/assert.hpp> - -#define PHOENIX_DYNAMIC_MEMBER(z, n, data) \ - typedef actor<dynamic_member<n, self_type> > \ - BOOST_PP_CAT(member, BOOST_PP_INC(n)); - -namespace boost { namespace phoenix -{ - template <typename DynamicScope> - struct dynamic_frame : noncopyable - { - typedef typename DynamicScope::tuple_type tuple_type; - - dynamic_frame(DynamicScope const& scope) - : tuple() - , save(scope.frame) - , scope(scope) - { - scope.frame = this; - } - - template <typename Tuple> - dynamic_frame(DynamicScope const& scope, Tuple const& init) - : tuple(init) - , save(scope.frame) - , scope(scope) - { - scope.frame = this; - } - - ~dynamic_frame() - { - scope.frame = save; - } - - tuple_type& data() { return tuple; } - tuple_type const& data() const { return tuple; } - - private: - - tuple_type tuple; - dynamic_frame* save; - DynamicScope const& scope; - }; - - template <int N, typename DynamicScope> - struct dynamic_member - { - typedef mpl::false_ no_nullary; - typedef typename DynamicScope::tuple_type tuple_type; - - dynamic_member(DynamicScope const& scope) - : scope(scope) {} - - template <typename Env> - struct result - { - typedef typename - fusion::result_of::at_c<tuple_type, N>::type - type; - }; - - template <typename Env> - typename result<Env>::type - eval(Env const& /*env*/) const - { - BOOST_ASSERT(scope.frame != 0); - return fusion::at_c<N>(scope.frame->data()); - } - - private: - - DynamicScope const& scope; - }; - - template <BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(PHOENIX_DYNAMIC_LIMIT, typename T, void_)> - struct dynamic : noncopyable - { - typedef fusion::vector<BOOST_PP_ENUM_PARAMS(PHOENIX_DYNAMIC_LIMIT, T)> tuple_type; - typedef dynamic<BOOST_PP_ENUM_PARAMS(PHOENIX_DYNAMIC_LIMIT, T)> self_type; - typedef dynamic_frame<self_type> dynamic_frame_type; - - dynamic() - : frame(0) {} - - BOOST_PP_REPEAT(PHOENIX_DYNAMIC_LIMIT, PHOENIX_DYNAMIC_MEMBER, _) - - private: - - template <int N, typename DynamicScope> - friend struct dynamic_member; - - template <typename DynamicScope> - friend struct dynamic_frame; - - mutable dynamic_frame_type* frame; - }; -}} - -#if defined(BOOST_MSVC) -# pragma warning(push) -# pragma warning(disable:4355) -#endif - -/* - PHOENIX_DYNAMIC macro(name, type-name sequence) - Example: - - PHOENIX_DYNAMIC( - my_dynamic, - (int, num) - (std::string, message) - (double, real) - ); - - which expands to: - - struct my_dynamic : ::boost::phoenix::dynamic<int, std::string, double> - { - my_dynamic() : num(*this), message(*this), real(*this) {} - - member1 num; - member2 message; - member3 real; - }; - - PHOENIX_DYNAMIC takes the input (containing a binary sequence) - and converts that sequence to a unary sequence of - binary tuples and passes it on to PHOENIX_DYNAMIC_I. - - Thanks to Paul Mensonides for the PP macro help -*/ - -#define PHOENIX_DYNAMIC(name, bseq) \ - PHOENIX_DYNAMIC_I(name, BOOST_PP_CAT(PHOENIX_DYNAMIC_X bseq, 0)) \ - -#define PHOENIX_DYNAMIC_X(x, y) ((x, y)) PHOENIX_DYNAMIC_Y -#define PHOENIX_DYNAMIC_Y(x, y) ((x, y)) PHOENIX_DYNAMIC_X -#define PHOENIX_DYNAMIC_X0 -#define PHOENIX_DYNAMIC_Y0 - -// PHOENIX_DYNAMIC_I generates the overarching structure and uses -// SEQ_FOR_EACH_I to generate the "linear" substructures. - -#define PHOENIX_DYNAMIC_I(name, seq) \ - struct name : \ - ::boost::phoenix::dynamic< \ - BOOST_PP_SEQ_FOR_EACH_I(PHOENIX_DYNAMIC_A, ~, seq)> { \ - name() : BOOST_PP_SEQ_FOR_EACH_I(PHOENIX_DYNAMIC_B, ~, seq) {} \ - BOOST_PP_SEQ_FOR_EACH_I(PHOENIX_DYNAMIC_C, ~, seq) \ - } \ - -#define PHOENIX_DYNAMIC_A(r, _, i, xy) \ - BOOST_PP_COMMA_IF(i) BOOST_PP_TUPLE_ELEM(2, 0, xy) \ - -#define PHOENIX_DYNAMIC_B(r, _, i, xy) \ - BOOST_PP_COMMA_IF(i) BOOST_PP_TUPLE_ELEM(2, 1, xy)(*this) \ - -#define PHOENIX_DYNAMIC_C(r, _, i, xy) \ - BOOST_PP_CAT(member, BOOST_PP_INC(i)) BOOST_PP_TUPLE_ELEM(2, 1, xy); \ - -#undef PHOENIX_DYNAMIC_MEMBER - -#if defined(BOOST_MSVC) -# pragma warning(pop) -#endif - -#endif diff --git a/boost/spirit/home/phoenix/scope/lambda.hpp b/boost/spirit/home/phoenix/scope/lambda.hpp deleted file mode 100644 index c4a7ce8314..0000000000 --- a/boost/spirit/home/phoenix/scope/lambda.hpp +++ /dev/null @@ -1,176 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - Copyright (c) 2004 Daniel Wallin - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#ifndef PHOENIX_SCOPE_LAMBDA_HPP -#define PHOENIX_SCOPE_LAMBDA_HPP - -#include <boost/spirit/home/phoenix/core/limits.hpp> -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/scope/scoped_environment.hpp> -#include <boost/spirit/home/phoenix/scope/detail/local_variable.hpp> -#include <boost/spirit/home/phoenix/detail/local_reference.hpp> -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/fusion/include/transform.hpp> -#include <boost/fusion/include/as_vector.hpp> - -namespace boost { namespace phoenix -{ - template <typename Base, typename OuterEnv, typename Locals, typename Map> - struct lambda_eval : Base - { - template <typename Env> - struct result - { - typedef typename Base::template - result<scoped_environment<Env, OuterEnv, Locals, Map> >::type - result_type; - - typedef typename - detail::unwrap_local_reference<result_type>::type - type; - }; - - lambda_eval( - Base const& base - , OuterEnv const& outer_env - , Locals const& locals) - : Base(base) - , outer_env(outer_env) - , locals(locals) {} - - template <typename Env> - typename result<Env>::type - eval(Env const& env) const - { - typedef typename result<Env>::type RT; - return RT(Base::eval( - scoped_environment<Env, OuterEnv, Locals, Map>( - env, outer_env, locals))); - } - - OuterEnv outer_env; - mutable Locals locals; - }; - - template <typename Base, typename Vars, typename Map> - struct lambda_actor - { - typedef typename - mpl::fold< - Vars - , mpl::false_ - , detail::compute_no_nullary - >::type - no_nullary; - - template <typename Env> - struct result - { - typedef typename - fusion::result_of::as_vector< - typename fusion::result_of::transform< - Vars - , detail::initialize_local<Env> - >::type - >::type - locals_type; - - typedef actor<lambda_eval<Base, Env, locals_type, Map> > type; - }; - - lambda_actor(Base const& f, Vars const& vars) - : f(f), vars(vars) {} - - template <typename Env> - typename result<Env>::type - eval(Env const& env) const - { - typedef typename result<Env>::type result_type; - - return result_type( - f, env, fusion::as_vector( - fusion::transform( - vars - , detail::initialize_local<Env>(env) - ))); - } - - Base f; - Vars vars; - }; - - template <typename Vars, typename Map> - struct lambda_actor_gen - { - template <typename Base> - actor<lambda_actor<Base, Vars, Map> > const - operator[](actor<Base> const& f) const - { - return lambda_actor<Base, Vars, Map>(f, vars); - } - - lambda_actor_gen(Vars const& vars) - : vars(vars) {} - - Vars vars; - }; - - template <typename Key> - struct local_variable; // forward - struct assign_eval; // forward - - struct lambda_gen - : lambda_actor_gen< - fusion::vector<> - , detail::map_local_index_to_tuple<> > - { - typedef - lambda_actor_gen< - fusion::vector<> - , detail::map_local_index_to_tuple<> > - base_type; - - lambda_gen() - : base_type(fusion::vector<>()) - { - } - - template <typename K0, typename V0> - lambda_actor_gen< - fusion::vector<V0> - , detail::map_local_index_to_tuple<K0> - > - operator()( - actor<composite<assign_eval, fusion::vector<local_variable<K0>, V0> > > const& a0 - ) const - { - return fusion::vector<V0>(fusion::at_c<1>(a0)); - } - - template <typename K0, typename K1, typename V0, typename V1> - lambda_actor_gen< - fusion::vector<V0, V1> - , detail::map_local_index_to_tuple<K0, K1> - > - operator()( - actor<composite<assign_eval, fusion::vector<local_variable<K0>, V0> > > const& a0 - , actor<composite<assign_eval, fusion::vector<local_variable<K1>, V1> > > const& a1 - ) const - { - return fusion::vector<V0, V1>(fusion::at_c<1>(a0), fusion::at_c<1>(a1)); - } - - // Bring in the rest... - #define PHOENIX_LOCAL_GEN_NAME lambda_actor_gen - #include <boost/spirit/home/phoenix/scope/detail/local_gen.hpp> - #undef PHOENIX_LOCAL_GEN_NAME - }; - - lambda_gen const lambda = lambda_gen(); -}} - -#endif diff --git a/boost/spirit/home/phoenix/scope/let.hpp b/boost/spirit/home/phoenix/scope/let.hpp deleted file mode 100644 index 40e951a49f..0000000000 --- a/boost/spirit/home/phoenix/scope/let.hpp +++ /dev/null @@ -1,145 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - Copyright (c) 2004 Daniel Wallin - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#ifndef PHOENIX_SCOPE_LET_HPP -#define PHOENIX_SCOPE_LET_HPP - -#include <boost/spirit/home/phoenix/core/limits.hpp> -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/scope/scoped_environment.hpp> -#include <boost/spirit/home/phoenix/scope/detail/local_variable.hpp> -#include <boost/spirit/home/phoenix/detail/local_reference.hpp> -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/fusion/include/transform.hpp> -#include <boost/fusion/include/as_vector.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/bool.hpp> - -namespace boost { namespace phoenix -{ - template <typename Base, typename Vars, typename Map> - struct let_actor : Base - { - typedef typename - mpl::fold< - Vars - , mpl::false_ - , detail::compute_no_nullary - >::type - no_nullary; - - template <typename Env> - struct result - { - typedef typename - fusion::result_of::as_vector< - typename fusion::result_of::transform< - Vars - , detail::initialize_local<Env> - >::type - >::type - locals_type; - - typedef typename Base::template - result<scoped_environment<Env, Env, locals_type, Map> >::type - result_type; - - typedef typename - detail::unwrap_local_reference<result_type>::type - type; - }; - - let_actor(Base const& base, Vars const& vars) - : Base(base), vars(vars) {} - - template <typename Env> - typename result<Env>::type - eval(Env const& env) const - { - typedef typename - fusion::result_of::as_vector< - typename fusion::result_of::transform< - Vars - , detail::initialize_local<Env> - >::type - >::type - locals_type; - - locals_type locals = - fusion::as_vector( - fusion::transform( - vars - , detail::initialize_local<Env>(env))); - - typedef typename result<Env>::type RT; - return RT(Base::eval( - scoped_environment<Env, Env, locals_type, Map>( - env - , env - , locals))); - } - - Vars vars; - }; - - template <typename Vars, typename Map> - struct let_actor_gen - { - template <typename Base> - actor<let_actor<Base, Vars, Map> > const - operator[](actor<Base> const& base) const - { - return let_actor<Base, Vars, Map>(base, vars); - } - - let_actor_gen(Vars const& vars) - : vars(vars) {} - - Vars vars; - }; - - template <typename Key> - struct local_variable; // forward - struct assign_eval; // forward - - struct let_gen - { - template <typename K0, typename V0> - let_actor_gen< - fusion::vector<V0> - , detail::map_local_index_to_tuple<K0> - > - operator()( - actor<composite<assign_eval, fusion::vector<local_variable<K0>, V0> > > const& a0 - ) const - { - return fusion::vector<V0>(fusion::at_c<1>(a0)); - } - - template <typename K0, typename K1, typename V0, typename V1> - let_actor_gen< - fusion::vector<V0, V1> - , detail::map_local_index_to_tuple<K0, K1> - > - operator()( - actor<composite<assign_eval, fusion::vector<local_variable<K0>, V0> > > const& a0 - , actor<composite<assign_eval, fusion::vector<local_variable<K1>, V1> > > const& a1 - ) const - { - return fusion::vector<V0, V1>(fusion::at_c<1>(a0), fusion::at_c<1>(a1)); - } - - // Bring in the rest... - #define PHOENIX_LOCAL_GEN_NAME let_actor_gen - #include <boost/spirit/home/phoenix/scope/detail/local_gen.hpp> - #undef PHOENIX_LOCAL_GEN_NAME - }; - - let_gen const let = let_gen(); -}} - -#endif diff --git a/boost/spirit/home/phoenix/scope/local_variable.hpp b/boost/spirit/home/phoenix/scope/local_variable.hpp deleted file mode 100644 index 5987ed441d..0000000000 --- a/boost/spirit/home/phoenix/scope/local_variable.hpp +++ /dev/null @@ -1,111 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - Copyright (c) 2004 Daniel Wallin - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#ifndef PHOENIX_SCOPE_LOCAL_VARIABLE_HPP -#define PHOENIX_SCOPE_LOCAL_VARIABLE_HPP - -#include <boost/spirit/home/phoenix/core/limits.hpp> -#include <boost/spirit/home/phoenix/detail/local_reference.hpp> -#include <boost/spirit/home/phoenix/scope/detail/local_variable.hpp> -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/mpl/bool.hpp> - -namespace boost { namespace phoenix -{ - template <typename Key> - struct local_variable - { - typedef Key key_type; - - // This will prevent actor::operator()() from kicking in. - // Actually, we do not need all actor::operator()s for - // all arities, but this will suffice. The nullary - // actor::operator() is particularly troublesome because - // it is always eagerly evaluated by the compiler. - typedef mpl::true_ no_nullary; - - template <typename Env> - struct result : detail::apply_local<local_variable<Key>, Env> {}; - - template <typename Env> - typename result<Env>::type - eval(Env const& env) const - { - typedef typename result<Env>::type return_type; - typedef typename - detail::get_index<typename Env::map_type, Key>::type - index_type; - typedef detail::eval_local<Key> eval_local; - - return eval_local::template get<return_type>( - env - , index_type()); - } - - private: - // silence MSVC warning C4512: assignment operator could not be generated - local_variable& operator= (local_variable const&); - }; - - namespace local_names - { - actor<local_variable<struct _a_key> > const _a - = local_variable<struct _a_key>(); - actor<local_variable<struct _b_key> > const _b - = local_variable<struct _b_key>(); - actor<local_variable<struct _c_key> > const _c - = local_variable<struct _c_key>(); - actor<local_variable<struct _d_key> > const _d - = local_variable<struct _d_key>(); - actor<local_variable<struct _e_key> > const _e - = local_variable<struct _e_key>(); - actor<local_variable<struct _f_key> > const _f - = local_variable<struct _f_key>(); - actor<local_variable<struct _g_key> > const _g - = local_variable<struct _g_key>(); - actor<local_variable<struct _h_key> > const _h - = local_variable<struct _h_key>(); - actor<local_variable<struct _i_key> > const _i - = local_variable<struct _i_key>(); - actor<local_variable<struct _j_key> > const _j - = local_variable<struct _j_key>(); - actor<local_variable<struct _k_key> > const _k - = local_variable<struct _k_key>(); - actor<local_variable<struct _l_key> > const _l - = local_variable<struct _l_key>(); - actor<local_variable<struct _m_key> > const _m - = local_variable<struct _m_key>(); - actor<local_variable<struct _n_key> > const _n - = local_variable<struct _n_key>(); - actor<local_variable<struct _o_key> > const _o - = local_variable<struct _o_key>(); - actor<local_variable<struct _p_key> > const _p - = local_variable<struct _p_key>(); - actor<local_variable<struct _q_key> > const _q - = local_variable<struct _q_key>(); - actor<local_variable<struct _r_key> > const _r - = local_variable<struct _r_key>(); - actor<local_variable<struct _s_key> > const _s - = local_variable<struct _s_key>(); - actor<local_variable<struct _t_key> > const _t - = local_variable<struct _t_key>(); - actor<local_variable<struct _u_key> > const _u - = local_variable<struct _u_key>(); - actor<local_variable<struct _v_key> > const _v - = local_variable<struct _v_key>(); - actor<local_variable<struct _w_key> > const _w - = local_variable<struct _w_key>(); - actor<local_variable<struct _x_key> > const _x - = local_variable<struct _x_key>(); - actor<local_variable<struct _y_key> > const _y - = local_variable<struct _y_key>(); - actor<local_variable<struct _z_key> > const _z - = local_variable<struct _z_key>(); - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/scope/scoped_environment.hpp b/boost/spirit/home/phoenix/scope/scoped_environment.hpp deleted file mode 100644 index b23f9eebc4..0000000000 --- a/boost/spirit/home/phoenix/scope/scoped_environment.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman - Copyright (c) 2004 Daniel Wallin - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#ifndef PHOENIX_SCOPE_SCOPED_ENVIRONMENT_HPP -#define PHOENIX_SCOPE_SCOPED_ENVIRONMENT_HPP - -namespace boost { namespace phoenix -{ - template <typename Env, typename OuterEnv, typename Locals, typename Map> - struct scoped_environment - { - typedef Env env_type; - typedef OuterEnv outer_env_type; - typedef Locals locals_type; - typedef Map map_type; - typedef typename Env::args_type args_type; - typedef typename Env::tie_type tie_type; - - scoped_environment( - Env const& env - , OuterEnv const& outer_env - , Locals& locals) - : env(env) - , outer_env(outer_env) - , locals(locals) {} - - tie_type const& - args() const - { - return env.args(); - } - - Env const& env; - OuterEnv const& outer_env; - Locals& locals; - - private: - // silence MSVC warning C4512: assignment operator could not be generated - scoped_environment& operator= (scoped_environment const&); - }; -}} - -#endif diff --git a/boost/spirit/home/phoenix/statement.hpp b/boost/spirit/home/phoenix/statement.hpp deleted file mode 100644 index 19e169ac71..0000000000 --- a/boost/spirit/home/phoenix/statement.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_STATEMENT_HPP -#define PHOENIX_STATEMENT_HPP - -#include <boost/spirit/home/phoenix/version.hpp> -#include <boost/spirit/home/phoenix/statement/do_while.hpp> -#include <boost/spirit/home/phoenix/statement/for.hpp> -#include <boost/spirit/home/phoenix/statement/if.hpp> -#include <boost/spirit/home/phoenix/statement/sequence.hpp> -#include <boost/spirit/home/phoenix/statement/switch.hpp> -#include <boost/spirit/home/phoenix/statement/while.hpp> -#include <boost/spirit/home/phoenix/statement/throw.hpp> -#include <boost/spirit/home/phoenix/statement/try_catch.hpp> - -#endif diff --git a/boost/spirit/home/phoenix/statement/detail/catch_all_eval.hpp b/boost/spirit/home/phoenix/statement/detail/catch_all_eval.hpp deleted file mode 100644 index 0609ad85a2..0000000000 --- a/boost/spirit/home/phoenix/statement/detail/catch_all_eval.hpp +++ /dev/null @@ -1,101 +0,0 @@ -/*============================================================================= - Copyright (c) 2005-2007 Dan Marsden - Copyright (c) 2005-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_STATEMENT_DETAIL_CATCH_ALL_EVAL_HPP -#define PHOENIX_STATEMENT_DETAIL_CATCH_ALL_EVAL_HPP - -#include <boost/spirit/home/phoenix/core/limits.hpp> -#include <boost/preprocessor/iteration/iterate.hpp> -#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> -#include <boost/preprocessor/repetition/enum_params_with_defaults.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> -#include <boost/preprocessor/repetition/repeat.hpp> -#include <boost/preprocessor/dec.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/mpl/void.hpp> - -namespace boost { namespace phoenix { - class catch_all_eval - { - public: - template<typename Env, typename TryBody, - BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(PHOENIX_CATCH_LIMIT, typename CatchBody, mpl::void_), - typename CatchAllBody = mpl::void_> - struct result - { - typedef void type; - }; - - template<typename Rt, typename Env, typename TryBody, - typename CatchAllBody> - static void eval( - const Env& env, TryBody& tryBody, CatchAllBody& catchAllBody) - { - try - { - tryBody.eval(env); - } - catch(...) - { - catchAllBody.eval(env); - } - } - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (1, PHOENIX_CATCH_LIMIT, "boost/spirit/home/phoenix/statement/detail/catch_all_eval.hpp")) - -#include BOOST_PP_ITERATE() - - }; -}} - -#endif - -#elif BOOST_PP_ITERATION_DEPTH() == 1 - -#define PHOENIX_ITERATION BOOST_PP_ITERATION() - - template<typename Rt, typename Env, typename TryBody, - BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, typename CatchBody), - typename CatchAllBody> - static void eval( - const Env& env, TryBody& tryBody, - BOOST_PP_ENUM_BINARY_PARAMS(PHOENIX_ITERATION, CatchBody, catchBody), - CatchAllBody& catchAllBody) - { - try - { - tryBody.eval(env); - } - -#define BOOST_PP_ITERATION_PARAMS_2 \ - (3, (0, BOOST_PP_DEC(PHOENIX_ITERATION), "boost/spirit/home/phoenix/statement/detail/catch_all_eval.hpp")) - -#include BOOST_PP_ITERATE() - - catch(...) - { - catchAllBody.eval(env); - } - } - -#undef PHOENIX_ITERATION - -#elif BOOST_PP_ITERATION_DEPTH() == 2 - -#define PHOENIX_ITERATION BOOST_PP_ITERATION() - - catch(typename BOOST_PP_CAT(CatchBody, PHOENIX_ITERATION)::exception_type&) - { - BOOST_PP_CAT(catchBody, PHOENIX_ITERATION).eval(env); - } - -#undef PHOENIX_ITERATION - -#endif diff --git a/boost/spirit/home/phoenix/statement/detail/catch_composite.hpp b/boost/spirit/home/phoenix/statement/detail/catch_composite.hpp deleted file mode 100644 index 1877310540..0000000000 --- a/boost/spirit/home/phoenix/statement/detail/catch_composite.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/*============================================================================= - Copyright (c) 2005-2007 Dan Marsden - Copyright (c) 2005-2007 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) -==============================================================================*/ - -#ifndef PHOENIX_STATEMENT_DETAIL_CATCH_COMPOSITE_HPP -#define PHOENIX_STATEMENT_DETAIL_CATCH_COMPOSITE_HPP - -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> - -namespace boost { namespace phoenix { -namespace detail -{ - struct catch_composite_eval - { - template<typename Env, typename Actor> - struct result : - eval_result<typename Actor::eval_type, Env> {}; - - template<typename Rt, typename Env, typename Actor> - static typename result<Env,Actor>::type - eval(const Env& env, Actor& actor) - { - return actor.eval(env); - } - }; - - template<typename Exception, typename Actor> - struct catch_composite : - composite<catch_composite_eval, fusion::vector<Actor> > - { - catch_composite(const Actor& actor) - : composite<catch_composite_eval, fusion::vector<Actor> >(actor) { } - - typedef Exception exception_type; - }; - - template<typename Exception, typename Actor> - struct as_catch_actor - { - typedef catch_composite< - Exception, - Actor> comp; - - typedef actor<comp> type; - }; - - template<typename Exception, typename Actor> - inline typename as_catch_actor<Exception, Actor>::type - catch_actor(const Actor& actor) - { - return catch_composite<Exception,Actor>(actor); - } -} -}} - -#endif diff --git a/boost/spirit/home/phoenix/statement/detail/catch_eval.hpp b/boost/spirit/home/phoenix/statement/detail/catch_eval.hpp deleted file mode 100644 index bc65e90af6..0000000000 --- a/boost/spirit/home/phoenix/statement/detail/catch_eval.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/*============================================================================= - Copyright (c) 2005-2007 Dan Marsden - Copyright (c) 2005-2007 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) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_STATEMENT_DETAIL_CATCH_EVAL_HPP -#define PHOENIX_STATEMENT_DETAIL_CATCH_EVAL_HPP - -#include <boost/spirit/home/phoenix/core/limits.hpp> -#include <boost/preprocessor/iteration/iterate.hpp> -#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> -#include <boost/preprocessor/repetition/enum_params_with_defaults.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> -#include <boost/preprocessor/repetition/repeat.hpp> -#include <boost/preprocessor/dec.hpp> -#include <boost/preprocessor/cat.hpp> -#include <boost/mpl/void.hpp> - -namespace boost { namespace phoenix { - class catch_eval - { - public: - template<typename Env, typename TryBody, - BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(PHOENIX_CATCH_LIMIT, typename CatchBody, mpl::void_)> - struct result - { - typedef void type; - }; - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (1, PHOENIX_CATCH_LIMIT, "boost/spirit/home/phoenix/statement/detail/catch_eval.hpp")) - -#include BOOST_PP_ITERATE() - - }; -}} - -#endif - -#elif BOOST_PP_ITERATION_DEPTH() == 1 - -#define PHOENIX_ITERATION BOOST_PP_ITERATION() - - template<typename Rt, typename Env, typename TryBody, - BOOST_PP_ENUM_PARAMS(PHOENIX_ITERATION, typename CatchBody)> - static void eval( - const Env& env, TryBody& tryBody, - BOOST_PP_ENUM_BINARY_PARAMS(PHOENIX_ITERATION, CatchBody, catchBody)) - { - try - { - tryBody.eval(env); - } - -#define BOOST_PP_ITERATION_PARAMS_2 \ - (3, (0, BOOST_PP_DEC(PHOENIX_ITERATION), "boost/spirit/home/phoenix/statement/detail/catch_eval.hpp")) - -#include BOOST_PP_ITERATE() - - } - -#undef PHOENIX_ITERATION - -#elif BOOST_PP_ITERATION_DEPTH() == 2 - -#define PHOENIX_ITERATION BOOST_PP_ITERATION() - - catch(typename BOOST_PP_CAT(CatchBody, PHOENIX_ITERATION)::exception_type&) - { - BOOST_PP_CAT(catchBody, PHOENIX_ITERATION).eval(env); - } - -#undef PHOENIX_ITERATION - -#endif diff --git a/boost/spirit/home/phoenix/statement/detail/switch.hpp b/boost/spirit/home/phoenix/statement/detail/switch.hpp deleted file mode 100644 index 537fcb1cec..0000000000 --- a/boost/spirit/home/phoenix/statement/detail/switch.hpp +++ /dev/null @@ -1,172 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_STATEMENT_DETAIL_SWITCH_HPP -#define PHOENIX_STATEMENT_DETAIL_SWITCH_HPP - -#include <boost/spirit/home/phoenix/core/nothing.hpp> -#include <boost/fusion/include/vector.hpp> -#include <boost/fusion/include/as_vector.hpp> -#include <boost/fusion/include/push_back.hpp> -#include <boost/fusion/include/push_front.hpp> -#include <boost/fusion/include/begin.hpp> -#include <boost/fusion/include/size.hpp> -#include <boost/fusion/include/value_of.hpp> -#include <boost/fusion/include/is_sequence.hpp> -#include <boost/mpl/identity.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/if.hpp> - -namespace boost { namespace phoenix -{ - - template <typename Actor, typename K, K Value> - struct switch_case; - - template <typename Actor> - struct default_case; - - namespace detail - { - template <typename T> - struct is_default_case : mpl::bool_<T::is_default> {}; - - template <typename A0, typename A1> - struct compose_case_a - { - // here, A0 and A1 are both switch cases - typedef typename - mpl::if_< - is_default_case<A1> - , fusion::vector<actor<A1>, actor<A0> > - , fusion::vector<actor<A0>, actor<A1> > - >::type - type; - - static type - eval(A0 const& _0, A1 const& _1, mpl::false_) - { - return type(_0, _1); - } - - static type - eval(A0 const& _0, A1 const& _1, mpl::true_) - { - return type(_1, _0); - } - - static type - eval(A0 const& _0, A1 const& _1) - { - return eval(_0, _1, is_default_case<A1>()); - } - }; - - template <typename Seq, typename Case> - struct compose_case_b - { - typedef typename fusion::result_of::as_vector< - typename mpl::eval_if< - is_default_case<Case> - , fusion::result_of::push_front<Seq const, actor<Case> > - , fusion::result_of::push_back<Seq const, actor<Case> > - >::type>::type - type; - - static type - eval(Seq const& seq, Case const& case_, mpl::false_) - { - return fusion::as_vector( - fusion::push_back(seq, actor<Case>(case_))); - } - - static type - eval(Seq const& seq, Case const& case_, mpl::true_) - { - return fusion::as_vector( - fusion::push_front(seq, actor<Case>(case_))); - } - - static type - eval(Seq const& seq, Case const& case_) - { - return eval(seq, case_, is_default_case<Case>()); - } - }; - - template <typename Cases> - struct ensure_default - { - typedef - is_default_case< - typename fusion::result_of::value_of< - typename fusion::result_of::begin<Cases>::type - >::type - > - is_default_case_; - - typedef typename - mpl::eval_if< - is_default_case_ - , mpl::identity<Cases> - , fusion::result_of::push_front< - Cases const, actor<default_case<actor<null_actor> > > > - >::type - type; - - static type - eval(Cases const& cases, mpl::false_); - - static type - eval(Cases const& cases, mpl::true_) - { - return cases; - } - - static type - eval(Cases const& cases) - { - return eval(cases, is_default_case_()); - } - }; - - template <typename Cond, typename Cases> - struct switch_composite - { - BOOST_STATIC_ASSERT(fusion::traits::is_sequence<Cases>::value); - typedef ensure_default<Cases> ensure_default_; - - typedef typename - fusion::result_of::as_vector< - typename fusion::result_of::push_front< - typename ensure_default_::type, Cond>::type - >::type - tuple_type; - - typedef - composite< - detail::switch_eval<fusion::result_of::size<tuple_type>::value-2> - , tuple_type> - type; - - static type - eval(Cond const& cond, Cases const& cases) - { - return fusion::as_vector( - fusion::push_front(ensure_default_::eval(cases), cond)); - } - }; - - template <typename Cond, typename Cases> - struct switch_composite_actor - { - typedef actor<typename switch_composite<Cond, Cases>::type> type; - }; - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/statement/detail/switch_eval.hpp b/boost/spirit/home/phoenix/statement/detail/switch_eval.hpp deleted file mode 100644 index 220745bab8..0000000000 --- a/boost/spirit/home/phoenix/statement/detail/switch_eval.hpp +++ /dev/null @@ -1,111 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_STATEMENT_DETAIL_SWITCH_EVAL_HPP -#define PHOENIX_STATEMENT_DETAIL_SWITCH_EVAL_HPP - -namespace boost { namespace phoenix { namespace detail -{ - template <int N> - struct switch_eval; - - template <> - struct switch_eval<0> - { - template < - typename Env, typename Cond, typename Default - > - struct result - { - typedef void type; - }; - - template < - typename RT, typename Env, typename Cond, typename Default - > - static void - eval( - Env const& env, Cond& cond, Default& default_ - ) - { - default_.eval(env); - } - }; - - template <> - struct switch_eval<1> - { - template < - typename Env, typename Cond, typename Default - , typename Case0 - > - struct result - { - typedef void type; - }; - - template < - typename RT, typename Env, typename Cond, typename Default - , typename Case0 - > - static void - eval( - Env const& env, Cond& cond, Default& default_ - , Case0& _0 - ) - { - switch (cond.eval(env)) - { - case Case0::value: - _0.eval(env); - break; - default: - default_.eval(env); - } - } - }; - - template <> - struct switch_eval<2> - { - template < - typename Env, typename Cond, typename Default - , typename Case0, typename Case1 - > - struct result - { - typedef void type; - }; - - template < - typename RT, typename Env, typename Cond, typename Default - , typename Case0, typename Case1 - > - static void - eval( - Env const& env, Cond& cond, Default& default_ - , Case0& _0, Case1& _1 - ) - { - switch (cond.eval(env)) - { - case Case0::value: - _0.eval(env); - break; - case Case1::value: - _1.eval(env); - break; - default: - default_.eval(env); - } - } - }; - - // Bring in the rest of the switch_evals - #include <boost/spirit/home/phoenix/statement/detail/switch_eval.ipp> -}}} - -#endif diff --git a/boost/spirit/home/phoenix/statement/detail/switch_eval.ipp b/boost/spirit/home/phoenix/statement/detail/switch_eval.ipp deleted file mode 100644 index ba4ae74618..0000000000 --- a/boost/spirit/home/phoenix/statement/detail/switch_eval.ipp +++ /dev/null @@ -1,74 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - - Use, modification and distribution is subject to the Boost Software - License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at - http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#ifndef BOOST_PP_IS_ITERATING -#ifndef PHOENIX_STATEMENT_DETAIL_SWITCH_EVAL_IPP -#define PHOENIX_STATEMENT_DETAIL_SWITCH_EVAL_IPP - -#include <boost/preprocessor/cat.hpp> -#include <boost/preprocessor/dec.hpp> -#include <boost/preprocessor/repeat.hpp> -#include <boost/preprocessor/iterate.hpp> -#include <boost/preprocessor/repetition/enum_params.hpp> -#include <boost/preprocessor/repetition/enum_binary_params.hpp> - -#define PHOENIX_CASE_ITEM(z, n, prefix) \ - case BOOST_PP_CAT(Case, n)::value: \ - BOOST_PP_CAT(_, n).eval(env); \ - break; - -#define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (3, BOOST_PP_DEC(BOOST_PP_DEC(PHOENIX_COMPOSITE_LIMIT)), \ - "boost/spirit/home/phoenix/statement/detail/switch_eval.ipp")) -#include BOOST_PP_ITERATE() - -#undef PHOENIX_CASE_ITEM -#endif - -/////////////////////////////////////////////////////////////////////////////// -// -// Preprocessor vertical repetition code -// -/////////////////////////////////////////////////////////////////////////////// -#else // defined(BOOST_PP_IS_ITERATING) - -#define N BOOST_PP_ITERATION() - - template <> - struct switch_eval<N> - { - template < - typename Env, typename Cond, typename Default - , BOOST_PP_ENUM_PARAMS(N, typename Case) - > - struct result - { - typedef void type; - }; - - template < - typename RT, typename Env, typename Cond, typename Default - , BOOST_PP_ENUM_PARAMS(N, typename Case) - > - static void - eval(Env const& env, Cond& cond, Default& default_ - , BOOST_PP_ENUM_BINARY_PARAMS(N, Case, & _) - ) - { - switch (cond.eval(env)) - { - BOOST_PP_REPEAT(N, PHOENIX_CASE_ITEM, _) - default: - default_.eval(env); - } - } - }; - -#undef N -#endif // defined(BOOST_PP_IS_ITERATING) - - diff --git a/boost/spirit/home/phoenix/statement/do_while.hpp b/boost/spirit/home/phoenix/statement/do_while.hpp deleted file mode 100644 index 8d634c94c4..0000000000 --- a/boost/spirit/home/phoenix/statement/do_while.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_STATEMENT_DO_WHILE_HPP -#define PHOENIX_STATEMENT_DO_WHILE_HPP - -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> - -namespace boost { namespace phoenix -{ - struct do_while_eval - { - template <typename Env, typename Cond, typename Do> - struct result - { - typedef void type; - }; - - template <typename RT, typename Env, typename Cond, typename Do> - static void - eval(Env const& env, Cond& cond, Do& do_) - { - do - do_.eval(env); - while (cond.eval(env)); - } - }; - - template <typename Do> - struct do_while_gen - { - do_while_gen(Do const& do_) - : do_(do_) {} - - template <typename Cond> - actor<typename as_composite<do_while_eval, Cond, Do>::type> - while_(Cond const& cond) const - { - return compose<do_while_eval>(cond, do_); - } - - Do do_; - }; - - struct do_gen - { - template <typename Do> - do_while_gen<Do> - operator[](Do const& do_) const - { - return do_while_gen<Do>(do_); - } - }; - - do_gen const do_ = do_gen(); -}} - -#endif diff --git a/boost/spirit/home/phoenix/statement/for.hpp b/boost/spirit/home/phoenix/statement/for.hpp deleted file mode 100644 index 35e091feb4..0000000000 --- a/boost/spirit/home/phoenix/statement/for.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_STATEMENT_FOR_HPP -#define PHOENIX_STATEMENT_FOR_HPP - -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> - -namespace boost { namespace phoenix -{ - struct for_eval - { - template < - typename Env - , typename Init, typename Cond, typename Step, typename Do> - struct result - { - typedef void type; - }; - - template < - typename RT, typename Env - , typename Init, typename Cond, typename Step, typename Do> - static void - eval( - Env const& env - , Init& init, Cond& cond, Step& step, Do& do_) - { - for (init.eval(env); cond.eval(env); step.eval(env)) - do_.eval(env); - } - }; - - template <typename Init, typename Cond, typename Step> - struct for_gen - { - for_gen(Init const& init, Cond const& cond, Step const& step) - : init(init), cond(cond), step(step) {} - - template <typename Do> - actor<typename as_composite<for_eval, Init, Cond, Step, Do>::type> - operator[](Do const& do_) const - { - return compose<for_eval>(init, cond, step, do_); - } - - Init init; - Cond cond; - Step step; - }; - - template <typename Init, typename Cond, typename Step> - inline for_gen<Init, Cond, Step> - for_(Init const& init, Cond const& cond, Step const& step) - { - return for_gen<Init, Cond, Step>(init, cond, step); - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/statement/if.hpp b/boost/spirit/home/phoenix/statement/if.hpp deleted file mode 100644 index 378fec0ca1..0000000000 --- a/boost/spirit/home/phoenix/statement/if.hpp +++ /dev/null @@ -1,130 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_STATEMENT_IF_HPP -#define PHOENIX_STATEMENT_IF_HPP - -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/as_actor.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> - -#if defined(BOOST_MSVC) -# pragma warning(push) -# pragma warning(disable:4355) -#endif - -namespace boost { namespace phoenix -{ - struct if_else_eval - { - template <typename Env, typename Cond, typename Then, typename Else> - struct result - { - typedef void type; - }; - - template < - typename RT, typename Env - , typename Cond, typename Then, typename Else> - static void - eval(Env const& env, Cond& cond, Then& then, Else& else_) - { - if (cond.eval(env)) - then.eval(env); - else - else_.eval(env); - } - }; - - struct if_eval - { - template <typename Env, typename Cond, typename Then> - struct result - { - typedef void type; - }; - - template <typename RT, typename Env, typename Cond, typename Then> - static void - eval(Env const& env, Cond& cond, Then& then) - { - if (cond.eval(env)) - then.eval(env); - } - }; - - template <typename Cond, typename Then> - struct if_composite; - - template <typename Cond, typename Then> - struct else_gen - { - else_gen(if_composite<Cond, Then> const& source) - : source(source) {} - - template <typename Else> - actor<typename as_composite<if_else_eval, Cond, Then, Else>::type> - operator[](Else const& else_) const - { - return compose<if_else_eval>( - fusion::at_c<0>(source) // cond - , fusion::at_c<1>(source) // then - , else_ // else - ); - } - - if_composite<Cond, Then> const& source; - - private: - // silence MSVC warning C4512: assignment operator could not be generated - else_gen& operator= (else_gen const&); - }; - - template <typename Cond, typename Then> - struct if_composite : composite<if_eval, fusion::vector<Cond, Then> > - { - if_composite(Cond const& cond, Then const& then) - : composite<if_eval, fusion::vector<Cond, Then> >(cond, then) - , else_(*this) {} - - else_gen<Cond, Then> else_; - - private: - // silence MSVC warning C4512: assignment operator could not be generated - if_composite& operator= (if_composite const&); - }; - - template <typename Cond> - struct if_gen - { - if_gen(Cond const& cond) - : cond(cond) {} - - template <typename Then> - actor<if_composite<Cond, typename as_actor<Then>::type> > - operator[](Then const& then) const - { - return actor<if_composite<Cond, typename as_actor<Then>::type> >( - cond, as_actor<Then>::convert(then)); - } - - Cond cond; - }; - - template <typename Cond> - inline if_gen<typename as_actor<Cond>::type> - if_(Cond const& cond) - { - return if_gen<typename as_actor<Cond>::type>( - as_actor<Cond>::convert(cond)); - } -}} - -#if defined(BOOST_MSVC) -# pragma warning(pop) -#endif - -#endif diff --git a/boost/spirit/home/phoenix/statement/sequence.hpp b/boost/spirit/home/phoenix/statement/sequence.hpp deleted file mode 100644 index 8a5f0c3e72..0000000000 --- a/boost/spirit/home/phoenix/statement/sequence.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_STATEMENT_SEQUENCE_HPP -#define PHOENIX_STATEMENT_SEQUENCE_HPP - -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> - -namespace boost { namespace phoenix -{ - struct sequence_eval - { - template <typename Env, typename A0, typename A1> - struct result - { - typedef void type; - }; - - template <typename RT, typename Env, typename A0, typename A1> - static void - eval(Env const& env, A0& a0, A1& a1) - { - a0.eval(env); - a1.eval(env); - } - }; - - namespace detail - { - template <typename BaseT0, typename BaseT1> - struct comma_result - { - typedef actor< - typename as_composite< - sequence_eval - , actor<BaseT0> - , actor<BaseT1> - >::type - > type; - }; - } - - template <typename BaseT0, typename BaseT1> - inline typename detail::comma_result<BaseT0, BaseT1>::type - operator,(actor<BaseT0> const& a0, actor<BaseT1> const& a1) - { - return compose<sequence_eval>(a0, a1); - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/statement/switch.hpp b/boost/spirit/home/phoenix/statement/switch.hpp deleted file mode 100644 index 1229994faf..0000000000 --- a/boost/spirit/home/phoenix/statement/switch.hpp +++ /dev/null @@ -1,164 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_STATEMENT_SWITCH_HPP -#define PHOENIX_STATEMENT_SWITCH_HPP - -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> -#include <boost/spirit/home/phoenix/core/nothing.hpp> -#include <boost/spirit/home/phoenix/statement/detail/switch_eval.hpp> -#include <boost/spirit/home/phoenix/statement/detail/switch.hpp> -#include <boost/utility/enable_if.hpp> -#include <boost/mpl/not.hpp> - -namespace boost { namespace phoenix -{ - template <typename Derived, typename Actor> - struct switch_case_base - { - typedef Derived derived_t; - typedef Actor actor_t; - typedef typename Actor::no_nullary no_nullary; - - template <typename Env> - struct result - { - typedef typename Actor::eval_type::template result<Env>::type type; - }; - - switch_case_base(Actor const& actor) - : actor(actor) {} - - template <typename Env> - typename result<Env>::type - eval(Env const& env) const - { - return actor.eval(env); - } - - Actor actor; - }; - - template <typename Actor, typename K, K Value> - struct switch_case : switch_case_base<switch_case<Actor, K, Value>, Actor> - { - typedef switch_case_base<switch_case<Actor, K, Value>, Actor> base_t; - static K const value = Value; - static bool const is_default = false; - - switch_case(Actor const& actor) - : base_t(actor) {} - }; - - template <typename Actor> - struct default_case : switch_case_base<default_case<Actor>, Actor> - { - typedef switch_case_base<default_case<Actor>, Actor> base_t; - static bool const is_default = true; - - default_case(Actor const& actor) - : base_t(actor) {} - }; - - template <typename Cond> - struct switch_gen - { - switch_gen(Cond const& cond) - : cond(cond) {} - - template <typename Cases> - typename lazy_enable_if< - fusion::traits::is_sequence<Cases> - , detail::switch_composite_actor<Cond, Cases> - >::type - operator[](Cases const& cases) const - { - typedef typename - detail::switch_composite<Cond, Cases> - switch_composite; - return switch_composite::eval(cond, cases); - } - - template <typename D, typename A> - actor<typename detail:: - switch_composite<Cond, fusion::vector<actor<D> > >::type> - operator[](switch_case_base<D, A> const& case_) const - { - typedef typename - detail::switch_composite<Cond, fusion::vector<actor<D> > > - switch_composite; - return switch_composite::eval(cond, - fusion::vector<actor<D> >(static_cast<D const&>(case_))); - } - - Cond cond; - }; - - template <typename Cond> - inline switch_gen<typename as_actor<Cond>::type> - switch_(Cond const& cond) - { - return switch_gen<typename as_actor<Cond>::type>( - as_actor<Cond>::convert(cond)); - } - - template <int N, typename A0> - switch_case<typename as_actor<A0>::type, int, N> - case_(A0 const& _0) - { - return switch_case<typename as_actor<A0>::type, int, N> - (as_actor<A0>::convert(_0)); - } - - template <typename A0> - default_case<typename as_actor<A0>::type> - default_(A0 const& _0) - { - return default_case<typename as_actor<A0>::type> - (as_actor<A0>::convert(_0)); - } - - template <typename D0, typename A0, typename D1, typename A1> - inline typename detail::compose_case_a<D0, D1>::type - operator,( - switch_case_base<D0, A0> const& _0 - , switch_case_base<D1, A1> const& _1 - ) - { - return detail::compose_case_a<D0, D1>::eval( - static_cast<D0 const&>(_0) - , static_cast<D1 const&>(_1) - ); - } - - template <typename Seq, typename D, typename A> - inline typename - lazy_enable_if< - fusion::traits::is_sequence<Seq> - , detail::compose_case_b<Seq, D> - >::type - operator,(Seq const& seq, switch_case_base<D, A> const& case_) - { - return detail::compose_case_b<Seq, D>::eval( - seq, static_cast<D const&>(case_)); - } - - // Implementation of routines in detail/switch.hpp that depend on - // the completeness of default_case. - namespace detail { - template <typename Cases> - typename ensure_default<Cases>::type - ensure_default<Cases>::eval(Cases const& cases, mpl::false_) - { - actor<default_case<actor<null_actor> > > default_ - = default_case<actor<null_actor> >(nothing); - return fusion::push_front(cases, default_); - } - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/statement/throw.hpp b/boost/spirit/home/phoenix/statement/throw.hpp deleted file mode 100644 index 87a087274d..0000000000 --- a/boost/spirit/home/phoenix/statement/throw.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/*============================================================================= - Copyright (c) 2005-2007 Dan Marsden - Copyright (c) 2005-2007 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) -==============================================================================*/ - -#ifndef PHOENIX_STATEMENT_THROW_HPP -#define PHOENIX_STATEMENT_THROW_HPP - -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> - -#include <boost/mpl/bool.hpp> - -namespace boost { namespace phoenix { - - struct throw_new_eval - { - template<typename Env, typename ThrowExpr> - struct result - { - typedef void type; - }; - - template<typename Rt, typename Env, typename ThrowExpr> - static void - eval(const Env& env, ThrowExpr& throwExpr) - { - throw throwExpr.eval(env); - } - }; - - struct throw_again_eval - { - typedef mpl::false_ no_nullary; - - template<typename Env> - struct result - { - typedef void type; - }; - - template<typename Env> - void eval(const Env&) const - { - throw; - } - }; - - inline actor<throw_again_eval> throw_() - { - return throw_again_eval(); - } - - template<typename Actor> - actor<typename as_composite<throw_new_eval, Actor>::type> - throw_(const Actor& a) - { - return compose<throw_new_eval>(a); - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/statement/try_catch.hpp b/boost/spirit/home/phoenix/statement/try_catch.hpp deleted file mode 100644 index dccfd425ac..0000000000 --- a/boost/spirit/home/phoenix/statement/try_catch.hpp +++ /dev/null @@ -1,188 +0,0 @@ -/*============================================================================= - Copyright (c) 2005-2007 Dan Marsden - Copyright (c) 2005-2007 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) -==============================================================================*/ - -#ifndef PHOENIX_STATEMENT_TRY_CATCH_HPP -#define PHOENIX_STATEMENT_TRY_CATCH_HPP - -#include <boost/spirit/home/phoenix/core/actor.hpp> -#include <boost/spirit/home/phoenix/core/composite.hpp> - -#include <boost/fusion/include/push_back.hpp> -#include <boost/fusion/include/as_vector.hpp> - -#include <boost/spirit/home/phoenix/statement/detail/catch_composite.hpp> -#include <boost/spirit/home/phoenix/statement/detail/catch_eval.hpp> -#include <boost/spirit/home/phoenix/statement/detail/catch_all_eval.hpp> - -#if defined(BOOST_MSVC) -# pragma warning(push) -# pragma warning(disable:4355) -#endif - -namespace boost { namespace phoenix { - - template<typename Tuple> struct try_catch_composite; - - namespace meta - { - template<typename Composite, typename Actor> - struct try_catch_composite_push_back - { - typedef typename Composite::base_type actor_tuple; - typedef try_catch_composite< - typename fusion::result_of::as_vector< - typename fusion::result_of::push_back< - actor_tuple, Actor>::type>::type> type; - }; - - template<typename Composite, typename Actor> - struct catch_all_composite_push_back - { - typedef typename Composite::base_type actor_tuple; - - typedef composite< - catch_all_eval, - typename fusion::result_of::as_vector< - typename fusion::result_of::push_back< - actor_tuple, Actor>::type>::type> type; - }; - } - - namespace detail - { - struct try_catch_composite_push_back - { - template<typename Composite, typename Actor> - struct result - : meta::try_catch_composite_push_back<Composite, Actor> - {}; - - template<typename Composite, typename Actor> - typename result<Composite, Actor>::type - operator()( - const Composite& composite, const Actor& actor) const - { - typedef typename result<Composite, Actor>::type result; - return result( - fusion::as_vector( - fusion::push_back(composite, actor))); - } - }; - - struct catch_all_composite_push_back - { - template<typename Composite, typename Actor> - struct result - : meta::catch_all_composite_push_back<Composite, Actor> - {}; - - template<typename Composite, typename Actor> - typename result<Composite, Actor>::type - operator()( - const Composite& composite, const Actor& actor) const - { - typedef typename result<Composite, Actor>::type result; - return result( - fusion::as_vector( - fusion::push_back(composite, actor))); - } - }; - - } - - detail::try_catch_composite_push_back const try_catch_composite_push_back - = detail::try_catch_composite_push_back(); - detail::catch_all_composite_push_back const catch_all_composite_push_back - = detail::catch_all_composite_push_back(); - - template<typename Exception, typename SourceComposite> - struct catch_gen - { - explicit catch_gen( - const SourceComposite& sourceComposite) - : mSourceComposite(sourceComposite) { } - - template<typename Actor> - actor<typename meta::try_catch_composite_push_back< - SourceComposite, - detail::catch_composite<Exception, Actor> >::type> - operator[](const Actor& actor) const - { - return try_catch_composite_push_back( - mSourceComposite, detail::catch_composite<Exception, Actor>(actor)); - } - - const SourceComposite& mSourceComposite; - }; - - template<typename SourceComposite> - struct catch_all_gen - { - explicit catch_all_gen( - const SourceComposite& sourceComposite) - : mSourceComposite(sourceComposite) { } - - template<typename Actor> - actor<typename meta::catch_all_composite_push_back<SourceComposite, Actor>::type> - operator[](const Actor& actor) const - { - return catch_all_composite_push_back( - mSourceComposite, actor); - } - - const SourceComposite& mSourceComposite; - }; - - template<typename Tuple> - struct try_catch_composite - : composite<catch_eval, Tuple> - { - explicit try_catch_composite( - const Tuple& t) - : - composite<catch_eval, Tuple>(t), - catch_all(*this) { } - - try_catch_composite( - const try_catch_composite& rhs) - : composite<catch_eval, Tuple>(rhs), - catch_all(*this) { } - - template<typename Exception> - catch_gen<Exception, try_catch_composite> catch_() const - { - return catch_gen<Exception, try_catch_composite>( - *this); - } - - const catch_all_gen<try_catch_composite> catch_all; - - private: - try_catch_composite& operator=(const try_catch_composite&); - }; - - struct try_gen - { - template<typename Try> - try_catch_composite<fusion::vector<Try> > operator[]( - const Try& try_) const - { - typedef fusion::vector<Try> tuple_type; - return try_catch_composite<tuple_type>( - tuple_type(try_)); - } - }; - - try_gen const try_ = try_gen(); -}} - -#if defined(BOOST_MSVC) -# pragma warning(pop) -#endif - -#endif diff --git a/boost/spirit/home/phoenix/statement/while.hpp b/boost/spirit/home/phoenix/statement/while.hpp deleted file mode 100644 index 96b988c291..0000000000 --- a/boost/spirit/home/phoenix/statement/while.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2007 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) -==============================================================================*/ -#ifndef PHOENIX_STATEMENT_WHILE_HPP -#define PHOENIX_STATEMENT_WHILE_HPP - -#include <boost/spirit/home/phoenix/core/composite.hpp> -#include <boost/spirit/home/phoenix/core/compose.hpp> - -namespace boost { namespace phoenix -{ - struct while_eval - { - template <typename Env, typename Cond, typename Do> - struct result - { - typedef void type; - }; - - template <typename RT, typename Env, typename Cond, typename Do> - static void - eval(Env const& env, Cond& cond, Do& do_) - { - while (cond.eval(env)) - do_.eval(env); - } - }; - - template <typename Cond> - struct while_gen - { - while_gen(Cond const& cond) - : cond(cond) {} - - template <typename Do> - actor<typename as_composite<while_eval, Cond, Do>::type> - operator[](Do const& do_) const - { - return compose<while_eval>(cond, do_); - } - - Cond cond; - }; - - template <typename Cond> - inline while_gen<Cond> - while_(Cond const& cond) - { - return while_gen<Cond>(cond); - } -}} - -#endif diff --git a/boost/spirit/home/phoenix/stl.hpp b/boost/spirit/home/phoenix/stl.hpp deleted file mode 100644 index 12832f7d9c..0000000000 --- a/boost/spirit/home/phoenix/stl.hpp +++ /dev/null @@ -1,15 +0,0 @@ -/*============================================================================= - Copyright (c) 2006 Daniel Wallin - Copyright (c) 2005 Dan Marsden - Copyright (c) 2007 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) -==============================================================================*/ -#ifndef PHOENIX_STL_HPP -#define PHOENIX_STL_HPP - -#include <boost/spirit/home/phoenix/stl/algorithm.hpp> -#include <boost/spirit/home/phoenix/stl/container.hpp> - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm.hpp b/boost/spirit/home/phoenix/stl/algorithm.hpp deleted file mode 100644 index 01f4f9d15e..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/*============================================================================= - Copyright (c) 2004 Angus Leeming - Copyright (c) 2006 Daniel Wallin - Copyright (c) 2005 Dan Marsden - Copyright (c) 2007 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) -==============================================================================*/ -#ifndef PHOENIX_STL_ALGORITHM_HPP -#define PHOENIX_STL_ALGORITHM_HPP - -#include <boost/spirit/home/phoenix/stl/algorithm/iteration.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/querying.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/transformation.hpp> - -#endif // PHOENIX_STL_ALGORITHM_HPP diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/begin.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/begin.hpp deleted file mode 100644 index 165aae87a3..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/begin.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler - -#ifndef PHOENIX_ALGORITHM_DETAIL_BEGIN_HPP -#define PHOENIX_ALGORITHM_DETAIL_BEGIN_HPP - -#include <boost/range/result_iterator.hpp> -#include <boost/range/begin.hpp> - -namespace boost { namespace phoenix { -namespace detail -{ - template<class R> - typename range_result_iterator<R>::type - begin_(R& r) - { - return boost::begin(r); - } -} -}} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/decay_array.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/decay_array.hpp deleted file mode 100644 index 1ea263d851..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/decay_array.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler - -#ifndef PHOENIX_ALGORITHM_DETAIL_DECAY_ARRAY_HPP -#define PHOENIX_ALGORITHM_DETAIL_DECAY_ARRAY_HPP - -namespace boost { namespace phoenix { -namespace detail -{ - template<typename T> - struct decay_array - { - typedef T type; - }; - - template<typename T, int N> - struct decay_array<T[N]> - { - typedef T* type; - }; -} -}} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/end.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/end.hpp deleted file mode 100644 index 4386d3a9da..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/end.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler - -#ifndef PHOENIX_ALGORITHM_DETAIL_END_HPP -#define PHOENIX_ALGORITHM_DETAIL_END_HPP - -#include <boost/range/result_iterator.hpp> -#include <boost/range/end.hpp> - -namespace boost { namespace phoenix { -namespace detail -{ - template<class R> - typename range_result_iterator<R>::type - end_(R& r) - { - return boost::end(r); - } -} -}} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/has_equal_range.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/has_equal_range.hpp deleted file mode 100644 index 1f7dcce252..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/has_equal_range.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// has_equal_range.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -#pragma once -#endif - -#ifndef HAS_EQUAL_RANGE_EN_14_12_2004 -#define HAS_EQUAL_RANGE_EN_14_12_2004 - -#include <boost/mpl/or.hpp> -#include "./is_std_map.hpp" -#include "./is_std_set.hpp" -#include "./is_std_hash_map.hpp" -#include "./is_std_hash_set.hpp" - -namespace boost -{ - // Specialize this for user-defined types - template<typename T> - struct has_equal_range - : boost::mpl::or_< - boost::mpl::or_< - is_std_map<T> - , is_std_multimap<T> - , is_std_set<T> - , is_std_multiset<T> - > - , boost::mpl::or_< - is_std_hash_map<T> - , is_std_hash_multimap<T> - , is_std_hash_set<T> - , is_std_hash_multiset<T> - > - > - { - }; -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/has_find.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/has_find.hpp deleted file mode 100644 index 3768dd5c43..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/has_find.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// has_find.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -#pragma once -#endif - -#ifndef HAS_FIND_EN_14_12_2004 -#define HAS_FIND_EN_14_12_2004 - -#include <boost/mpl/or.hpp> -#include "./is_std_map.hpp" -#include "./is_std_set.hpp" -#include "./is_std_hash_map.hpp" -#include "./is_std_hash_set.hpp" - -namespace boost -{ - // Specialize this for user-defined types - template<typename T> - struct has_find - : boost::mpl::or_< - boost::mpl::or_< - is_std_map<T> - , is_std_multimap<T> - , is_std_set<T> - , is_std_multiset<T> - > - , boost::mpl::or_< - is_std_hash_map<T> - , is_std_hash_multimap<T> - , is_std_hash_set<T> - , is_std_hash_multiset<T> - > - > - { - }; -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/has_lower_bound.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/has_lower_bound.hpp deleted file mode 100644 index c1d47e2927..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/has_lower_bound.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// has_lower_bound.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -#pragma once -#endif - -#ifndef HAS_LOWER_BOUND_EN_14_12_2004 -#define HAS_LOWER_BOUND_EN_14_12_2004 - -#include <boost/mpl/or.hpp> -#include "./is_std_map.hpp" -#include "./is_std_set.hpp" -#include "./is_std_hash_map.hpp" -#include "./is_std_hash_set.hpp" - -namespace boost -{ - // Specialize this for user-defined types - template<typename T> - struct has_lower_bound - : boost::mpl::or_< - boost::mpl::or_< - is_std_map<T> - , is_std_multimap<T> - , is_std_set<T> - , is_std_multiset<T> - > - , boost::mpl::or_< - is_std_hash_map<T> - , is_std_hash_multimap<T> - , is_std_hash_set<T> - , is_std_hash_multiset<T> - > - > - { - }; -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/has_remove.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/has_remove.hpp deleted file mode 100644 index e86c87c75e..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/has_remove.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// has_remove.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -#pragma once -#endif - -#ifndef HAS_REMOVE_EN_14_12_2004 -#define HAS_REMOVE_EN_14_12_2004 - -#include "./is_std_list.hpp" - -namespace boost -{ - // Specialize this for user-defined types - template<typename T> - struct has_remove - : is_std_list<T> - { - }; -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/has_remove_if.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/has_remove_if.hpp deleted file mode 100644 index 99ce7cd8aa..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/has_remove_if.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// has_remove_if.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -#pragma once -#endif - -#ifndef HAS_REMOVE_IF_EN_14_12_2004 -#define HAS_REMOVE_IF_EN_14_12_2004 - -#include "./is_std_list.hpp" - -namespace boost -{ - // Specialize this for user-defined types - template<typename T> - struct has_remove_if - : is_std_list<T> - { - }; -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/has_reverse.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/has_reverse.hpp deleted file mode 100644 index e74bcabf5a..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/has_reverse.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// has_reverse.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -#pragma once -#endif - -#ifndef HAS_REVERSE_EN_14_12_2004 -#define HAS_REVERSE_EN_14_12_2004 - -#include "./is_std_list.hpp" - -namespace boost -{ - // Specialize this for user-defined types - template<typename T> - struct has_reverse - : is_std_list<T> - { - }; -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/has_sort.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/has_sort.hpp deleted file mode 100644 index fa9edc923f..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/has_sort.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// has_sort.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -#pragma once -#endif - -#ifndef HAS_SORT_EN_14_12_2004 -#define HAS_SORT_EN_14_12_2004 - -#include "./is_std_list.hpp" - -namespace boost -{ - // Specialize this for user-defined types - template<typename T> - struct has_sort - : is_std_list<T> - { - }; -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/has_unique.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/has_unique.hpp deleted file mode 100644 index 35dcd3c96b..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/has_unique.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// has_unique.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -#pragma once -#endif - -#ifndef HAS_UNIQUE_EN_14_12_2004 -#define HAS_UNIQUE_EN_14_12_2004 - -#include "./is_std_list.hpp" - -namespace boost -{ - // Specialize this for user-defined types - template<typename T> - struct has_unique - : is_std_list<T> - { - }; -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/has_upper_bound.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/has_upper_bound.hpp deleted file mode 100644 index 995c28c01e..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/has_upper_bound.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// has_upper_bound.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -#pragma once -#endif - -#ifndef HAS_UPPER_BOUND_EN_14_12_2004 -#define HAS_UPPER_BOUND_EN_14_12_2004 - -#include <boost/mpl/or.hpp> -#include "./is_std_map.hpp" -#include "./is_std_set.hpp" -#include "./is_std_hash_map.hpp" -#include "./is_std_hash_set.hpp" - -namespace boost -{ - // Specialize this for user-defined types - template<typename T> - struct has_upper_bound - : boost::mpl::or_< - boost::mpl::or_< - is_std_map<T> - , is_std_multimap<T> - , is_std_set<T> - , is_std_multiset<T> - > - , boost::mpl::or_< - is_std_hash_map<T> - , is_std_hash_multimap<T> - , is_std_hash_set<T> - , is_std_hash_multiset<T> - > - > - { - }; -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_hash_map.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_hash_map.hpp deleted file mode 100644 index 9d4895c35d..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_hash_map.hpp +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// is_std_hash_map.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -# pragma once -#endif - -#ifndef IS_STD_HASH_MAP_EN_16_12_2004 -#define IS_STD_HASH_MAP_EN_16_12_2004 - -#include <boost/mpl/bool.hpp> -#include "./std_hash_map_fwd.hpp" - -namespace boost -{ - template<class T> - struct is_std_hash_map - : boost::mpl::false_ - {}; - - template<class T> - struct is_std_hash_multimap - : boost::mpl::false_ - {}; - -#ifdef BOOST_HAS_HASH - - template< - class Kty - , class Ty - , class Hash - , class Cmp - , class Alloc - > - struct is_std_hash_map< ::BOOST_STD_EXTENSION_NAMESPACE::hash_map<Kty,Ty,Hash,Cmp,Alloc> > - : boost::mpl::true_ - {}; - - template< - class Kty - , class Ty - , class Hash - , class Cmp - , class Alloc - > - struct is_std_hash_multimap< ::BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<Kty,Ty,Hash,Cmp,Alloc> > - : boost::mpl::true_ - {}; - -#elif defined(BOOST_DINKUMWARE_STDLIB) - - template< - class Kty - , class Ty - , class Tr - , class Alloc - > - struct is_std_hash_map< ::BOOST_STD_EXTENSION_NAMESPACE::hash_map<Kty,Ty,Tr,Alloc> > - : boost::mpl::true_ - {}; - - template< - class Kty - , class Ty - , class Tr - , class Alloc - > - struct is_std_hash_multimap< ::BOOST_STD_EXTENSION_NAMESPACE::hash_multimap<Kty,Ty,Tr,Alloc> > - : boost::mpl::true_ - {}; - -#endif - -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_hash_set.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_hash_set.hpp deleted file mode 100644 index ece3173152..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_hash_set.hpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// is_std_hash_set.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -# pragma once -#endif - -#ifndef IS_STD_HASH_SET_EN_16_12_2004 -#define IS_STD_HASH_SET_EN_16_12_2004 - -#include <boost/mpl/bool.hpp> -#include "./std_hash_set_fwd.hpp" - -namespace boost -{ - template<class T> - struct is_std_hash_set - : boost::mpl::false_ - {}; - - template<class T> - struct is_std_hash_multiset - : boost::mpl::false_ - {}; - -#if defined(BOOST_HAS_HASH) - - template< - class Kty - , class Hash - , class Cmp - , class Alloc - > - struct is_std_hash_set< ::BOOST_STD_EXTENSION_NAMESPACE::hash_set<Kty,Hash,Cmp,Alloc> > - : boost::mpl::true_ - {}; - - template< - class Kty - , class Hash - , class Cmp - , class Alloc - > - struct is_std_hash_multiset< ::BOOST_STD_EXTENSION_NAMESPACE::hash_multiset<Kty,Hash,Cmp,Alloc> > - : boost::mpl::true_ - {}; - -#elif defined(BOOST_DINKUMWARE_STDLIB) - - template< - class Kty - , class Tr - , class Alloc - > - struct is_std_hash_set< ::BOOST_STD_EXTENSION_NAMESPACE::hash_set<Kty,Tr,Alloc> > - : boost::mpl::true_ - {}; - - template< - class Kty - , class Tr - , class Alloc - > - struct is_std_hash_multiset< ::BOOST_STD_EXTENSION_NAMESPACE::hash_multiset<Kty,Tr,Alloc> > - : boost::mpl::true_ - {}; - -#endif - -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_list.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_list.hpp deleted file mode 100644 index 8317e51b9b..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_list.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// is_std_list.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -# pragma once -#endif - -#ifndef IS_STD_LIST_EN_16_12_2004 -#define IS_STD_LIST_EN_16_12_2004 - -#include <boost/mpl/bool.hpp> -#include <boost/detail/container_fwd.hpp> - -namespace boost -{ - template<class T> - struct is_std_list - : boost::mpl::false_ - {}; - - template< - class Ty - , class Alloc - > - struct is_std_list< ::std::list<Ty,Alloc> > - : boost::mpl::true_ - {}; -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_map.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_map.hpp deleted file mode 100644 index 2b0723114f..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_map.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// is_std_map.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -# pragma once -#endif - -#ifndef IS_STD_MAP_EN_16_12_2004 -#define IS_STD_MAP_EN_16_12_2004 - -#include <boost/mpl/bool.hpp> -#include <boost/detail/container_fwd.hpp> - -namespace boost -{ - template<class T> - struct is_std_map - : boost::mpl::false_ - {}; - - template< - class Kty - , class Ty - , class Pr - , class Alloc - > - struct is_std_map< ::std::map<Kty,Ty,Pr,Alloc> > - : boost::mpl::true_ - {}; - - template<class T> - struct is_std_multimap - : boost::mpl::false_ - {}; - - template< - class Kty - , class Ty - , class Pr - , class Alloc - > - struct is_std_multimap< ::std::multimap<Kty,Ty,Pr,Alloc> > - : boost::mpl::true_ - {}; -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_set.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_set.hpp deleted file mode 100644 index 43eb25892f..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/is_std_set.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// is_std_set.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -# pragma once -#endif - -#ifndef IS_STD_SET_EN_16_12_2004 -#define IS_STD_SET_EN_16_12_2004 - -#include <boost/mpl/bool.hpp> -#include <boost/detail/container_fwd.hpp> - -namespace boost -{ - template<class T> - struct is_std_set - : boost::mpl::false_ - {}; - - template< - class Kty - , class Pr - , class Alloc - > - struct is_std_set< ::std::set<Kty,Pr,Alloc> > - : boost::mpl::true_ - {}; - - template<class T> - struct is_std_multiset - : boost::mpl::false_ - {}; - - template< - class Kty - , class Pr - , class Alloc - > - struct is_std_multiset< ::std::multiset<Kty,Pr,Alloc> > - : boost::mpl::true_ - {}; -} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/std_hash_map_fwd.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/std_hash_map_fwd.hpp deleted file mode 100644 index 9e21c25d90..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/std_hash_map_fwd.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// std_hash_map_fwd.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -# pragma once -#endif - -#ifndef STD_HASH_MAP_FWD_EN_16_12_2004 -#define STD_HASH_MAP_FWD_EN_16_12_2004 - -#include <boost/config.hpp> - -#if defined(BOOST_HAS_HASH) - -namespace BOOST_STD_EXTENSION_NAMESPACE -{ - template< - class Kty - , class Ty - , class Hash - , class Cmp - , class Alloc - > - class hash_map; - - template< - class Kty - , class Ty - , class Hash - , class Cmp - , class Alloc - > - class hash_multimap; -} - -#elif defined(BOOST_DINKUMWARE_STDLIB) - -namespace BOOST_STD_EXTENSION_NAMESPACE -{ - template< - class Kty - , class Ty - , class Tr - , class Alloc - > - class hash_map; - - template< - class Kty - , class Ty - , class Tr - , class Alloc - > - class hash_multimap; -} - -#endif - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/detail/std_hash_set_fwd.hpp b/boost/spirit/home/phoenix/stl/algorithm/detail/std_hash_set_fwd.hpp deleted file mode 100644 index 76083f4db3..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/detail/std_hash_set_fwd.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler -/////////////////////////////////////////////////////////////////////////////// -// -// std_hash_set_fwd.hpp -// -///////////////////////////////////////////////////////////////////////////// - -#if defined(_MSC_VER) && _MSC_VER >= 1000 -# pragma once -#endif - -#ifndef STD_HASH_SET_FWD_EN_16_12_2004 -#define STD_HASH_SET_FWD_EN_16_12_2004 - -#include <boost/config.hpp> - -#if defined(BOOST_HAS_HASH) - -namespace BOOST_STD_EXTENSION_NAMESPACE -{ - template< - class Kty - , class Hash - , class Cmp - , class Alloc - > - class hash_set; - - template< - class Kty - , class Hash - , class Cmp - , class Alloc - > - class hash_multiset; -} - -#elif defined(BOOST_DINKUMWARE_STDLIB) - -namespace BOOST_STD_EXTENSION_NAMESPACE -{ - template< - class Kty - , class Tr - , class Alloc - > - class hash_set; - - template< - class Kty - , class Tr - , class Alloc - > - class hash_multiset; -} - -#endif - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/iteration.hpp b/boost/spirit/home/phoenix/stl/algorithm/iteration.hpp deleted file mode 100644 index c11905e738..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/iteration.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// Copyright 2005 Dan Marsden. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler - -#ifndef PHOENIX_ALGORITHM_ITERATION_HPP -#define PHOENIX_ALGORITHM_ITERATION_HPP - -#include <algorithm> -#include <numeric> - -#include <boost/spirit/home/phoenix/stl/algorithm/detail/begin.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/detail/end.hpp> - -#include <boost/spirit/home/phoenix/function/function.hpp> - -namespace boost { namespace phoenix { -namespace impl -{ - struct for_each - { - template<class R, class F> - struct result - { - typedef F type; - }; - - template<class R, class F> - F operator()(R& r, F fn) const - { - return std::for_each(detail::begin_(r), detail::end_(r), fn); - } - }; - - struct accumulate - { - template<class R, class I, class C = void> - struct result - { - typedef I type; - }; - - template<class R, class I> - typename result<R,I>::type - operator()(R& r, I i) const - { - return std::accumulate(detail::begin_(r), detail::end_(r), i); - } - - template<class R, class I, class C> - typename result<R,I,C>::type - operator()(R& r, I i, C c) const - { - return std::accumulate(detail::begin_(r), detail::end_(r), i, c); - } - }; -} - -function<impl::for_each> const for_each = impl::for_each(); -function<impl::accumulate> const accumulate = impl::accumulate(); - -}} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/querying.hpp b/boost/spirit/home/phoenix/stl/algorithm/querying.hpp deleted file mode 100644 index 87456fd7ff..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/querying.hpp +++ /dev/null @@ -1,502 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// Copyright 2005 Dan Marsden. -// Copyright 2008 Hartmut Kaiser. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler - -#ifndef PHOENIX_ALGORITHM_QUERYING_HPP -#define PHOENIX_ALGORITHM_QUERYING_HPP - -#include <algorithm> - -#include <boost/spirit/home/phoenix/stl/algorithm/detail/has_find.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/detail/has_lower_bound.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/detail/has_upper_bound.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/detail/has_equal_range.hpp> - -#include <boost/spirit/home/phoenix/stl/algorithm/detail/begin.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/detail/end.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/detail/decay_array.hpp> - -#include <boost/spirit/home/phoenix/function/function.hpp> - -#include <boost/range/result_iterator.hpp> -#include <boost/range/difference_type.hpp> - -namespace boost { namespace phoenix { -namespace impl -{ - struct find - { - template<class R, class T> - struct result : range_result_iterator<R> - {}; - - template<class R, class T> - typename result<R, T>::type execute(R& r, T const& x, mpl::true_) const - { - return r.find(x); - } - - template<class R, class T> - typename result<R, T>::type execute(R& r, T const& x, mpl::false_) const - { - return std::find(detail::begin_(r), detail::end_(r), x); - } - - template<class R, class T> - typename result<R, T>::type operator()(R& r, T const& x) const - { - return execute(r, x, has_find<R>()); - } - }; - - struct find_if - { - template<class R, class P> - struct result : range_result_iterator<R> - {}; - - template<class R, class P> - typename result<R, P>::type operator()(R& r, P p) const - { - return std::find_if(detail::begin_(r), detail::end_(r), p); - } - }; - - struct find_end - { - template<class R, class R2, class P = void> - struct result : range_result_iterator<R> - {}; - - template<class R, class R2> - typename result<R, R2>::type operator()(R& r, R2& r2) const - { - return std::find_end( - detail::begin_(r) - , detail::end_(r) - , detail::begin_(r2) - , detail::end_(r2) - ); - } - - template<class R, class R2, class P> - typename result<R, R2, P>::type operator()(R& r, R2& r2, P p) const - { - return std::find_end( - detail::begin_(r) - , detail::end_(r) - , detail::begin_(r2) - , detail::end_(r2) - , p - ); - } - }; - - struct find_first_of - { - template<class R, class R2, class P = void> - struct result : range_result_iterator<R> - {}; - - template<class R, class R2> - typename result<R, R2>::type operator()(R& r, R2& r2) const - { - return std::find_first_of( - detail::begin_(r) - , detail::end_(r) - , detail::begin_(r2) - , detail::end_(r2) - ); - } - - template<class R, class R2, class P> - typename result<R, R2, P>::type operator()(R& r, R2& r2, P p) const - { - return std::find_first_of( - detail::begin_(r) - , detail::end_(r) - , detail::begin_(r2) - , detail::end_(r2) - , p - ); - } - }; - - struct adjacent_find - { - template<class R, class P = void> - struct result : range_result_iterator<R> - {}; - - template<class R> - typename result<R>::type operator()(R& r) const - { - return std::adjacent_find(detail::begin_(r), detail::end_(r)); - } - - template<class R, class P> - typename result<R, P>::type operator()(R& r, P p) const - { - return std::adjacent_find(detail::begin_(r), detail::end_(r), p); - } - }; - - struct count - { - template<class R, class T> - struct result : range_difference<R> - {}; - - template<class R, class T> - typename result<R, T>::type operator()(R& r, T const& x) const - { - return std::count(detail::begin_(r), detail::end_(r), x); - } - }; - - struct count_if - { - template<class R, class P> - struct result : range_difference<R> - {}; - - template<class R, class P> - typename result<R, P>::type operator()(R& r, P p) const - { - return std::count_if(detail::begin_(r), detail::end_(r), p); - } - }; - - struct distance - { - template<class R> - struct result : range_difference<R> - {}; - - template<class R> - typename result<R>::type operator()(R& r) const - { - return std::distance(detail::begin_(r), detail::end_(r)); - } - }; - - struct equal - { - template<class R, class I, class P = void> - struct result - { - typedef bool type; - }; - - template<class R, class I> - bool operator()(R& r, I i) const - { - return std::equal(detail::begin_(r), detail::end_(r), i); - } - - template<class R, class I, class P> - bool operator()(R& r, I i, P p) const - { - return std::equal(detail::begin_(r), detail::end_(r), i, p); - } - }; - - struct search - { - template<class R, class R2, class P = void> - struct result : range_result_iterator<R> - {}; - - template<class R, class R2> - typename result<R, R2>::type operator()(R& r, R2& r2) const - { - return std::search( - detail::begin_(r) - , detail::end_(r) - , detail::begin_(r2) - , detail::end_(r2) - ); - } - - template<class R, class R2, class P> - typename result<R, R2, P>::type operator()(R& r, R2& r2, P p) const - { - return std::search( - detail::begin_(r) - , detail::end_(r) - , detail::begin_(r2) - , detail::end_(r2) - , p - ); - } - }; - - struct lower_bound - { - template<class R, class T, class C = void> - struct result : range_result_iterator<R> - {}; - - template<class R, class T> - typename result<R, T>::type execute(R& r, T const& val, mpl::true_) const - { - return r.lower_bound(val); - } - - template<class R, class T> - typename result<R, T>::type execute(R& r, T const& val, mpl::false_) const - { - return std::lower_bound(detail::begin_(r), detail::end_(r), val); - } - - template<class R, class T> - typename result<R, T>::type operator()(R& r, T const& val) const - { - return execute(r, val, has_lower_bound<R>()); - } - - template<class R, class T, class C> - typename result<R, T>::type operator()(R& r, T const& val, C c) const - { - return std::lower_bound(detail::begin_(r), detail::end_(r), val, c); - } - }; - - struct upper_bound - { - template<class R, class T, class C = void> - struct result : range_result_iterator<R> - {}; - - template<class R, class T> - typename result<R, T>::type execute(R& r, T const& val, mpl::true_) const - { - return r.upper_bound(val); - } - - template<class R, class T> - typename result<R, T>::type execute(R& r, T const& val, mpl::false_) const - { - return std::upper_bound(detail::begin_(r), detail::end_(r), val); - } - - template<class R, class T> - typename result<R, T>::type operator()(R& r, T const& val) const - { - return execute(r, val, has_upper_bound<R>()); - } - - template<class R, class T, class C> - typename result<R, T>::type operator()(R& r, T const& val, C c) const - { - return std::upper_bound(detail::begin_(r), detail::end_(r), val, c); - } - }; - - struct equal_range - { - template<class R, class T, class C = void> - struct result - { - typedef std::pair< - typename range_result_iterator<R>::type - , typename range_result_iterator<R>::type - > type; - }; - - template<class R, class T> - typename result<R, T>::type execute(R& r, T const& val, mpl::true_) const - { - return r.equal_range(val); - } - - template<class R, class T> - typename result<R, T>::type execute(R& r, T const& val, mpl::false_) const - { - return std::equal_range(detail::begin_(r), detail::end_(r), val); - } - - template<class R, class T> - typename result<R, T>::type operator()(R& r, T const& val) const - { - return execute(r, val, has_equal_range<R>()); - } - - template<class R, class T, class C> - typename result<R, T>::type operator()(R& r, T const& val, C c) const - { - return std::equal_range(detail::begin_(r), detail::end_(r), val, c); - } - }; - - struct mismatch - { - template<class R, class I, class P = void> - struct result - { - typedef std::pair< - typename range_result_iterator<R>::type - , typename detail::decay_array<I>::type - > type; - }; - - template<class R, class I> - typename result<R, I>::type operator()(R& r, I i) const - { - return std::mismatch(detail::begin_(r), detail::end_(r), i); - } - - template<class R, class I, class P> - typename result<R, I, P>::type operator()(R& r, I i, P p) const - { - return std::mismatch(detail::begin_(r), detail::end_(r), i, p); - } - }; - - struct binary_search - { - template<class R, class T, class C = void> - struct result - { - typedef bool type; - }; - - template<class R, class T> - bool operator()(R& r, T const& val) const - { - return std::binary_search(detail::begin_(r), detail::end_(r), val); - } - - template<class R, class T, class C> - bool operator()(R& r, T const& val, C c) const - { - return std::binary_search(detail::begin_(r), detail::end_(r), val, c); - } - }; - - struct includes - { - template<class R1, class R2, class C = void> - struct result - { - typedef bool type; - }; - - template<class R1, class R2> - bool operator()(R1& r1, R2& r2) const - { - return std::includes( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - ); - } - - template<class R1, class R2, class C> - bool operator()(R1& r1, R2& r2, C c) const - { - return std::includes( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - , c - ); - } - }; - - struct min_element - { - template<class R, class P = void> - struct result : range_result_iterator<R> - {}; - - template<class R> - typename result<R>::type operator()(R& r) const - { - return std::min_element(detail::begin_(r), detail::end_(r)); - } - - template<class R, class P> - typename result<R, P>::type operator()(R& r, P p) const - { - return std::min_element(detail::begin_(r), detail::end_(r), p); - } - }; - - struct max_element - { - template<class R, class P = void> - struct result : range_result_iterator<R> - {}; - - template<class R> - typename result<R>::type operator()(R& r) const - { - return std::max_element(detail::begin_(r), detail::end_(r)); - } - - template<class R, class P> - typename result<R, P>::type operator()(R& r, P p) const - { - return std::max_element(detail::begin_(r), detail::end_(r), p); - } - }; - - struct lexicographical_compare - { - template<class R1, class R2, class P = void> - struct result - { - typedef bool type; - }; - - template<class R1, class R2> - typename result<R1, R2>::type operator()(R1& r1, R2& r2) const - { - return std::lexicographical_compare( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - ); - } - - template<class R1, class R2, class P> - typename result<R1, R2>::type operator()(R1& r1, R2& r2, P p) const - { - return std::lexicographical_compare( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - , p - ); - } - }; - -} - -function<impl::find> const find = impl::find(); -function<impl::find_if> const find_if = impl::find_if(); -function<impl::find_end> const find_end = impl::find_end(); -function<impl::find_first_of> const find_first_of = impl::find_first_of(); -function<impl::adjacent_find> const adjacent_find = impl::adjacent_find(); -function<impl::count> const count = impl::count(); -function<impl::count_if> const count_if = impl::count_if(); -function<impl::distance> const distance = impl::distance(); -function<impl::equal> const equal = impl::equal(); -function<impl::search> const search = impl::search(); -function<impl::lower_bound> const lower_bound = impl::lower_bound(); -function<impl::upper_bound> const upper_bound = impl::upper_bound(); -function<impl::equal_range> const equal_range = impl::equal_range(); -function<impl::mismatch> const mismatch = impl::mismatch(); -function<impl::binary_search> const binary_search = impl::binary_search(); -function<impl::includes> const includes = impl::includes(); -function<impl::min_element> const min_element = impl::min_element(); -function<impl::max_element> const max_element = impl::max_element(); -function<impl::lexicographical_compare> const lexicographical_compare = impl::lexicographical_compare(); - -}} - -#endif diff --git a/boost/spirit/home/phoenix/stl/algorithm/transformation.hpp b/boost/spirit/home/phoenix/stl/algorithm/transformation.hpp deleted file mode 100644 index 7405be7885..0000000000 --- a/boost/spirit/home/phoenix/stl/algorithm/transformation.hpp +++ /dev/null @@ -1,1071 +0,0 @@ -// Copyright 2005 Daniel Wallin. -// Copyright 2005 Joel de Guzman. -// Copyright 2005 Dan Marsden. -// -// Use, modification and distribution is subject to 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) -// -// Modeled after range_ex, Copyright 2004 Eric Niebler - -#ifndef PHOENIX_ALGORITHM_TRANSFORMATION_HPP -#define PHOENIX_ALGORITHM_TRANSFORMATION_HPP - -#include <algorithm> -#include <numeric> - -#include <boost/spirit/home/phoenix/stl/algorithm/detail/has_sort.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/detail/has_remove.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/detail/has_remove_if.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/detail/has_unique.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/detail/has_reverse.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/detail/has_sort.hpp> - -#include <boost/spirit/home/phoenix/stl/algorithm/detail/begin.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/detail/end.hpp> -#include <boost/spirit/home/phoenix/stl/algorithm/detail/decay_array.hpp> - -#include <boost/spirit/home/phoenix/function/function.hpp> - -#include <boost/range/result_iterator.hpp> -#include <boost/range/difference_type.hpp> - -#include <boost/mpl/if.hpp> - -#include <boost/type_traits/is_void.hpp> - -namespace boost { namespace phoenix { namespace impl -{ - struct swap - { - template <class A, class B> - struct result - { - typedef void type; - }; - - template <class A, class B> - void operator()(A& a, B& b) const - { - using std::swap; - swap(a, b); - } - }; - - struct copy - { - template<class R, class I> - struct result - : detail::decay_array<I> - {}; - - template<class R, class I> - typename result<R,I>::type - operator()(R& r, I i) const - { - return std::copy(detail::begin_(r), detail::end_(r), i); - } - }; - - struct copy_backward - { - template<class R, class I> - struct result - { - typedef I type; - }; - - template<class R, class I> - I operator()(R& r, I i) const - { - return std::copy_backward(detail::begin_(r), detail::end_(r), i); - } - }; - - struct transform - { - template<class R, class OutorI1, class ForOut, class BinF = void> - struct result - : detail::decay_array< - typename mpl::if_<is_void<BinF>, OutorI1, ForOut>::type> - { - }; - - template<class R, class O, class F> - typename result<R,O,F>::type - operator()(R& r, O o, F f) const - { - return std::transform(detail::begin_(r), detail::end_(r), o, f); - } - - template<class R, class I, class O, class F> - typename result<R,I,O,F>::type - operator()(R& r, I i, O o, F f) const - { - return std::transform(detail::begin_(r), detail::end_(r), i, o, f); - } - }; - - struct replace - { - template<class R, class T, class T2> - struct result - { - typedef void type; - }; - - template<class R, class T> - void operator()(R& r, T const& what, T const& with) const - { - std::replace(detail::begin_(r), detail::end_(r), what, with); - } - }; - - struct replace_if - { - template<class R, class P, class T> - struct result - { - typedef void type; - }; - - template<class R, class P, class T> - void operator()(R& r, P p, T const& with) const - { - std::replace_if(detail::begin_(r), detail::end_(r), p, with); - } - }; - - struct replace_copy - { - template<class R, class O, class T, class T2> - struct result - : detail::decay_array<O> - {}; - - template<class R, class O, class T> - typename result<R,O,T,T>::type - operator()(R& r, O o, T const& what, T const& with) const - { - return std::replace_copy(detail::begin_(r), detail::end_(r), o, what, with); - } - }; - - struct replace_copy_if - { - template<class R, class O, class P, class T> - struct result - : detail::decay_array<O> - {}; - - template<class R, class O, class P, class T> - typename result<R,O,P,T>::type - operator()(R& r, O o, P p, T const& with) const - { - return std::replace_copy_if(detail::begin_(r), detail::end_(r), o, p, with); - } - }; - - struct fill - { - template<class R, class T> - struct result - { - typedef void type; - }; - - template<class R, class T> - void operator()(R& r, T const& x) const - { - std::fill(detail::begin_(r), detail::end_(r), x); - } - }; - - struct fill_n - { - template<class R, class N, class T> - struct result - { - typedef void type; - }; - - template<class R, class N, class T> - void operator()(R& r, N n, T const& x) const - { - std::fill_n(detail::begin_(r), n, x); - } - }; - - struct generate - { - template<class R, class G> - struct result - { - typedef void type; - }; - - template<class R, class G> - void operator()(R& r, G g) const - { - std::generate(detail::begin_(r), detail::end_(r), g); - } - }; - - struct generate_n - { - template<class R, class N, class G> - struct result - { - typedef void type; - }; - - template<class R, class N, class G> - void operator()(R& r, N n, G g) const - { - std::generate_n(detail::begin_(r), n, g); - } - }; - - struct remove - { - template<class R, class T> - struct result : range_result_iterator<R> - { - }; - - template<class R, class T> - typename result<R, T>::type execute(R& r, T const& x, mpl::true_) const - { - r.remove(x); - return detail::end_(r); - } - - template<class R, class T> - typename result<R, T>::type execute(R& r, T const& x, mpl::false_) const - { - return std::remove(detail::begin_(r), detail::end_(r), x); - } - - template<class R, class T> - typename result<R, T>::type operator()(R& r, T const& x) const - { - return execute(r, x, has_remove<R>()); - } - }; - - struct remove_if - { - template<class R, class P> - struct result : range_result_iterator<R> - { - }; - - template<class R, class P> - typename result<R, P>::type execute(R& r, P p, mpl::true_) const - { - r.remove_if(p); - return detail::end_(r); - } - - template<class R, class P> - typename result<R, P>::type execute(R& r, P p, mpl::false_) const - { - return std::remove_if(detail::begin_(r), detail::end_(r), p); - } - - template<class R, class P> - typename result<R, P>::type operator()(R& r, P p) const - { - return execute(r, p, has_remove_if<R>()); - } - }; - - struct remove_copy - { - template<class R, class O, class T> - struct result - : detail::decay_array<O> - {}; - - template<class R, class O, class T> - typename result<R,O,T>::type - operator()(R& r, O o, T const& x) const - { - return std::remove_copy(detail::begin_(r), detail::end_(r), o, x); - } - }; - - struct remove_copy_if - { - template<class R, class O, class P> - struct result - : detail::decay_array<O> - {}; - - template<class R, class O, class P> - typename result<R,O,P>::type - operator()(R& r, O o, P p) const - { - return std::remove_copy_if(detail::begin_(r), detail::end_(r), o, p); - } - }; - - struct unique - { - template<class R, class P = void> - struct result : range_result_iterator<R> - { - }; - - template<class R> - typename result<R>::type execute(R& r, mpl::true_) const - { - r.unique(); - return detail::end_(r); - } - - template<class R> - typename result<R>::type execute(R& r, mpl::false_) const - { - return std::unique(detail::begin_(r), detail::end_(r)); - } - - template<class R> - typename result<R>::type operator()(R& r) const - { - return execute(r, has_unique<R>()); - } - - - template<class R, class P> - typename result<R>::type execute(R& r, P p, mpl::true_) const - { - r.unique(p); - return detail::end_(r); - } - - template<class R, class P> - typename result<R, P>::type execute(R& r, P p, mpl::false_) const - { - return std::unique(detail::begin_(r), detail::end_(r), p); - } - - template<class R, class P> - typename result<R, P>::type operator()(R& r, P p) const - { - return execute(r, p, has_unique<R>()); - } - }; - - struct unique_copy - { - template<class R, class O, class P = void> - struct result - : detail::decay_array<O> - {}; - - template<class R, class O> - typename result<R, O>::type operator()(R& r, O o) const - { - return std::unique_copy( - detail::begin_(r) - , detail::end_(r) - , o - ); - } - - template<class R, class O, class P> - typename result<R, O, P>::type operator()(R& r, O o, P p) const - { - return std::unique_copy( - detail::begin_(r) - , detail::end_(r) - , o - , p - ); - } - }; - - struct reverse - { - template<class R> - struct result - { - typedef void type; - }; - - template<class R> - void execute(R& r, mpl::true_) const - { - r.reverse(); - } - - template<class R> - void execute(R& r, mpl::false_) const - { - std::reverse(detail::begin_(r), detail::end_(r)); - } - - template<class R> - void operator()(R& r) const - { - execute(r, has_reverse<R>()); - } - }; - - struct reverse_copy - { - template<class R, class O> - struct result - : detail::decay_array<O> - {}; - - template<class R, class O> - typename result<R, O>::type operator()(R& r, O o) const - { - return std::reverse_copy( - detail::begin_(r) - , detail::end_(r) - , o - ); - } - }; - - struct rotate - { - template<class R, class M> - struct result - { - typedef void type; - }; - - template<class R, class M> - void operator()(R& r, M m) const - { - std::rotate( - detail::begin_(r) - , m - , detail::end_(r) - ); - } - }; - - struct rotate_copy - { - template<class R, class M, class O> - struct result - : detail::decay_array<O> - {}; - - template<class R, class M, class O> - typename result<R, M, O>::type operator()(R& r, M m, O o) const - { - return std::rotate_copy( - detail::begin_(r) - , m - , detail::end_(r) - , o - ); - } - }; - - struct random_shuffle - { - template<class R, class G = void> - struct result - { - typedef void type; - }; - - template<class R> - void operator()(R& r) const - { - return std::random_shuffle(detail::begin_(r), detail::end_(r)); - } - - template<class R, class G> - void operator()(R& r, G g) const - { - return std::random_shuffle(detail::begin_(r), detail::end_(r), g); - } - }; - - struct partition - { - template<class R, class P> - struct result : range_result_iterator<R> - {}; - - template<class R, class P> - typename result<R, P>::type operator()(R& r, P p) const - { - return std::partition(detail::begin_(r), detail::end_(r), p); - } - }; - - struct stable_partition - { - template<class R, class P> - struct result : range_result_iterator<R> - {}; - - template<class R, class P> - typename result<R, P>::type operator()(R& r, P p) const - { - return std::stable_partition(detail::begin_(r), detail::end_(r), p); - } - }; - - struct sort - { - template<class R, class C = void> - struct result - { - typedef void type; - }; - - template<class R> - void execute(R& r, mpl::true_) const - { - r.sort(); - } - - template<class R> - void execute(R& r, mpl::false_) const - { - std::sort(detail::begin_(r), detail::end_(r)); - } - - template<class R> - void operator()(R& r) const - { - execute(r, has_sort<R>()); - } - - template<class R, class C> - void execute(R& r, C c, mpl::true_) const - { - r.sort(c); - } - - template<class R, class C> - void execute(R& r, C c, mpl::false_) const - { - std::sort(detail::begin_(r), detail::end_(r), c); - } - - template<class R, class C> - void operator()(R& r, C c) const - { - execute(r, c, has_sort<R>()); - } - }; - - struct stable_sort - { - template<class R, class C = void> - struct result - { - typedef void type; - }; - - template<class R> - void operator()(R& r) const - { - std::stable_sort(detail::begin_(r), detail::end_(r)); - } - - template<class R, class C> - void operator()(R& r, C c) const - { - std::stable_sort(detail::begin_(r), detail::end_(r), c); - } - }; - - struct partial_sort - { - template<class R, class M, class C = void> - struct result - { - typedef void type; - }; - - template<class R, class M> - void operator()(R& r, M m) const - { - std::partial_sort(detail::begin_(r), m, detail::end_(r)); - } - - template<class R, class M, class C> - void operator()(R& r, M m, C c) const - { - std::partial_sort(detail::begin_(r), m, detail::end_(r), c); - } - }; - - struct partial_sort_copy - { - template<class R1, class R2, class C = void> - struct result : range_result_iterator<R2> - {}; - - template<class R1, class R2> - typename result<R1, R2>::type operator()(R1& r1, R2& r2) const - { - return std::partial_sort_copy( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - ); - } - - template<class R1, class R2, class C> - typename result<R1, R2>::type operator()(R1& r1, R2& r2, C c) const - { - return std::partial_sort_copy( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - , c - ); - } - }; - - struct nth_element - { - template<class R, class N, class C = void> - struct result - { - typedef void type; - }; - - template<class R, class N> - void operator()(R& r, N n) const - { - return std::nth_element(detail::begin_(r), n, detail::end_(r)); - } - - template<class R, class N, class C> - void operator()(R& r, N n, C c) const - { - return std::nth_element(detail::begin_(r), n, detail::end_(r), c); - } - }; - - struct merge - { - template<class R1, class R2, class O, class C = void> - struct result - : detail::decay_array<O> - {}; - - template<class R1, class R2, class O> - typename result<R1, R2, O>::type operator()(R1& r1, R2& r2, O o) const - { - return std::merge( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - , o - ); - } - - template<class R1, class R2, class O, class C> - typename result<R1, R2, O, C>::type operator()(R1& r1, R2& r2, O o, C c) const - { - return std::merge( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - , o - , c - ); - } - }; - - struct inplace_merge - { - template<class R, class M, class C = void> - struct result - { - typedef void type; - }; - - template<class R, class M> - void operator()(R& r, M m) const - { - return std::inplace_merge(detail::begin_(r), m, detail::end_(r)); - } - - template<class R, class M, class C> - void operator()(R& r, M m, C c) const - { - return std::inplace_merge(detail::begin_(r), m, detail::end_(r), c); - } - }; - - struct next_permutation - { - template<class R, class C = void> - struct result - { - typedef bool type; - }; - - template<class R> - bool operator()(R& r) const - { - return std::next_permutation(detail::begin_(r), detail::end_(r)); - } - - template<class R, class C> - bool operator()(R& r, C c) const - { - return std::next_permutation(detail::begin_(r), detail::end_(r), c); - } - }; - - struct prev_permutation - { - template<class R, class C = void> - struct result - { - typedef bool type; - }; - - template<class R> - bool operator()(R& r) const - { - return std::prev_permutation(detail::begin_(r), detail::end_(r)); - } - - template<class R, class C> - bool operator()(R& r, C c) const - { - return std::prev_permutation(detail::begin_(r), detail::end_(r), c); - } - }; - - - struct inner_product - { - template<class R, class I, class T, class C1 = void, class C2 = void> - struct result - { - typedef T type; - }; - - template<class R, class I, class T> - typename result<R,I,T>::type - operator()(R& r, I i, T t) const - { - return std::inner_product( - detail::begin_(r), detail::end_(r), i, t); - } - - template<class R, class I, class T, class C1, class C2> - typename result<R,I,T,C1,C2>::type - operator()(R& r, I i, T t, C1 c1, C2 c2) const - { - return std::inner_product( - detail::begin_(r), detail::end_(r), i, - t, c1, c2); - } - }; - - struct partial_sum - { - template<class R, class I, class C = void> - struct result - : detail::decay_array<I> - {}; - - template<class R, class I> - typename result<R,I>::type - operator()(R& r, I i) const - { - return std::partial_sum( - detail::begin_(r), detail::end_(r), i); - } - - template<class R, class I, class C> - typename result<R,I,C>::type - operator()(R& r, I i, C c) const - { - return std::partial_sum( - detail::begin_(r), detail::end_(r), i, c); - } - }; - - struct adjacent_difference - { - template<class R, class I, class C = void> - struct result - : detail::decay_array<I> - {}; - - template<class R, class I> - typename result<R,I>::type - operator()(R& r, I i) const - { - return std::adjacent_difference( - detail::begin_(r), detail::end_(r), i); - } - - template<class R, class I, class C> - typename result<R,I,C>::type - operator()(R& r, I i, C c) const - { - return std::adjacent_difference( - detail::begin_(r), detail::end_(r), i, c); - } - }; - - struct push_heap - { - template<class R, class C = void> - struct result - { - typedef void type; - }; - - template<class R> - void operator()(R& r) const - { - std::push_heap(detail::begin_(r), detail::end_(r)); - } - - template<class R, class C> - void operator()(R& r, C c) const - { - std::push_heap(detail::begin_(r), detail::end_(r), c); - } - }; - - struct pop_heap - { - template<class R, class C = void> - struct result - { - typedef void type; - }; - - template<class R> - void operator()(R& r) const - { - std::pop_heap(detail::begin_(r), detail::end_(r)); - } - - template<class R, class C> - void operator()(R& r, C c) const - { - std::pop_heap(detail::begin_(r), detail::end_(r), c); - } - }; - - struct make_heap - { - template<class R, class C = void> - struct result - { - typedef void type; - }; - - template<class R> - void operator()(R& r) const - { - std::make_heap(detail::begin_(r), detail::end_(r)); - } - - template<class R, class C> - void operator()(R& r, C c) const - { - std::make_heap(detail::begin_(r), detail::end_(r), c); - } - }; - - struct sort_heap - { - template<class R, class C = void> - struct result - { - typedef void type; - }; - - template<class R> - void operator()(R& r) const - { - std::sort_heap(detail::begin_(r), detail::end_(r)); - } - - template<class R, class C> - void operator()(R& r, C c) const - { - std::sort_heap(detail::begin_(r), detail::end_(r), c); - } - }; - - struct set_union - { - template<class R1, class R2, class O, class C = void> - struct result - : detail::decay_array<O> - {}; - - template<class R1, class R2, class O> - typename result<R1, R2, O>::type operator()(R1& r1, R2& r2, O o) const - { - return std::set_union( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - , o - ); - } - - template<class R1, class R2, class O, class C> - typename result<R1, R2, O, C>::type operator()(R1& r1, R2& r2, O o, C c) const - { - return std::set_union( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - , o - , c - ); - } - }; - - struct set_intersection - { - template<class R1, class R2, class O, class C = void> - struct result - : detail::decay_array<O> - {}; - - template<class R1, class R2, class O> - typename result<R1, R2, O>::type operator()(R1& r1, R2& r2, O o) const - { - return std::set_intersection( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - , o - ); - } - - template<class R1, class R2, class O, class C> - typename result<R1, R2, O, C>::type operator()(R1& r1, R2& r2, O o, C c) const - { - return std::set_intersection( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - , o - , c - ); - } - }; - - struct set_difference - { - template<class R1, class R2, class O, class C = void> - struct result - : detail::decay_array<O> - {}; - - template<class R1, class R2, class O> - typename result<R1, R2, O>::type operator()(R1& r1, R2& r2, O o) const - { - return std::set_difference( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - , o - ); - } - - template<class R1, class R2, class O, class C> - typename result<R1, R2, O, C>::type operator()(R1& r1, R2& r2, O o, C c) const - { - return std::set_difference( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - , o - , c - ); - } - }; - - struct set_symmetric_difference - { - template<class R1, class R2, class O, class C = void> - struct result - : detail::decay_array<O> - {}; - - template<class R1, class R2, class O> - typename result<R1, R2, O>::type operator()(R1& r1, R2& r2, O o) const - { - return std::set_symmetric_difference( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - , o - ); - } - - template<class R1, class R2, class O, class C> - typename result<R1, R2, O, C>::type operator()(R1& r1, R2& r2, O o, C c) const - { - return std::set_symmetric_difference( - detail::begin_(r1), detail::end_(r1) - , detail::begin_(r2), detail::end_(r2) - , o - , c - ); - } - }; - -}}} // boost::phoenix::impl - -namespace boost { namespace phoenix -{ - function<impl::swap> const swap = impl::swap(); - function<impl::copy> const copy = impl::copy(); - function<impl::copy_backward> const copy_backward = impl::copy_backward(); - function<impl::transform> const transform = impl::transform(); - function<impl::replace> const replace = impl::replace(); - function<impl::replace_if> const replace_if = impl::replace_if(); - function<impl::replace_copy> const replace_copy = impl::replace_copy(); - function<impl::replace_copy_if> const replace_copy_if = impl::replace_copy_if(); - function<impl::fill> const fill = impl::fill(); - function<impl::fill_n> const fill_n = impl::fill_n(); - function<impl::generate> const generate = impl::generate(); - function<impl::generate_n> const generate_n = impl::generate_n(); - function<impl::remove> const remove = impl::remove(); - function<impl::remove_if> const remove_if = impl::remove_if(); - function<impl::remove_copy> const remove_copy = impl::remove_copy(); - function<impl::remove_copy_if> const remove_copy_if = impl::remove_copy_if(); - function<impl::unique> const unique = impl::unique(); - function<impl::unique_copy> const unique_copy = impl::unique_copy(); - function<impl::reverse> const reverse = impl::reverse(); - function<impl::reverse_copy> const reverse_copy = impl::reverse_copy(); - function<impl::rotate> const rotate = impl::rotate(); - function<impl::rotate_copy> const rotate_copy = impl::rotate_copy(); - function<impl::random_shuffle> const random_shuffle = impl::random_shuffle(); - function<impl::partition> const partition = impl::partition(); - function<impl::stable_partition> const stable_partition = impl::stable_partition(); - function<impl::sort> const sort = impl::sort(); - function<impl::stable_sort> const stable_sort = impl::stable_sort(); - function<impl::partial_sort> const partial_sort = impl::partial_sort(); - function<impl::partial_sort_copy> const partial_sort_copy = impl::partial_sort_copy(); - function<impl::nth_element> const nth_element = impl::nth_element(); - function<impl::merge> const merge = impl::merge(); - function<impl::inplace_merge> const inplace_merge = impl::inplace_merge(); - function<impl::next_permutation> const next_permutation = impl::next_permutation(); - function<impl::prev_permutation> const prev_permutation = impl::prev_permutation(); - function<impl::inner_product> const inner_product = impl::inner_product(); - function<impl::partial_sum> const partial_sum = impl::partial_sum(); - function<impl::adjacent_difference> const adjacent_difference = impl::adjacent_difference(); - function<impl::push_heap> const push_heap = impl::push_heap(); - function<impl::pop_heap> const pop_heap = impl::pop_heap(); - function<impl::make_heap> const make_heap = impl::make_heap(); - function<impl::sort_heap> const sort_heap = impl::sort_heap(); - function<impl::set_union> const set_union = impl::set_union(); - function<impl::set_intersection> const set_intersection = impl::set_intersection(); - function<impl::set_difference> const set_difference = impl::set_difference(); - function<impl::set_symmetric_difference> const set_symmetric_difference = impl::set_symmetric_difference(); -}} - -#endif diff --git a/boost/spirit/home/phoenix/stl/container.hpp b/boost/spirit/home/phoenix/stl/container.hpp deleted file mode 100644 index 6798fcb434..0000000000 --- a/boost/spirit/home/phoenix/stl/container.hpp +++ /dev/null @@ -1,13 +0,0 @@ -/*============================================================================= - Copyright (c) 2004 Angus Leeming - Copyright (c) 2007 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) -==============================================================================*/ -#ifndef PHOENIX_STL_CONTAINER_HPP -#define PHOENIX_STL_CONTAINER_HPP - -#include <boost/spirit/home/phoenix/stl/container/container.hpp> - -#endif // PHOENIX_STL_CONTAINER_HPP diff --git a/boost/spirit/home/phoenix/stl/container/container.hpp b/boost/spirit/home/phoenix/stl/container/container.hpp deleted file mode 100644 index 7e043d1d5d..0000000000 --- a/boost/spirit/home/phoenix/stl/container/container.hpp +++ /dev/null @@ -1,706 +0,0 @@ -/*============================================================================= - Copyright (c) 2004 Angus Leeming - Copyright (c) 2004 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) -==============================================================================*/ -#ifndef PHOENIX_STL_CONTAINER_CONTAINER_HPP -#define PHOENIX_STL_CONTAINER_CONTAINER_HPP - -#include <boost/spirit/home/phoenix/stl/container/detail/container.hpp> -#include <boost/spirit/home/phoenix/function/function.hpp> -#include <boost/mpl/and.hpp> -#include <boost/mpl/not.hpp> -#include <boost/mpl/or.hpp> -#include <boost/type_traits/is_const.hpp> - -namespace boost { namespace phoenix -{ -/////////////////////////////////////////////////////////////////////////////// -// -// STL container member functions -// -// Lazy functions for STL container member functions -// -// These functions provide a mechanism for the lazy evaluation of the -// public member functions of the STL containers. For an overview of -// what is meant by 'lazy evaluation', see the comments in operators.hpp -// and functions.hpp. -// -// Lazy functions are provided for all of the member functions of the -// following containers: -// -// deque - list - map - multimap - vector. -// -// Indeed, should *your* class have member functions with the same names -// and signatures as those listed below, then it will automatically be -// supported. To summarize, lazy functions are provided for member -// functions: -// -// assign - at - back - begin - capacity - clear - empty - end - -// erase - front - get_allocator - insert - key_comp - max_size - -// pop_back - pop_front - push_back - push_front - rbegin - rend - -// reserve - resize . size - splice - value_comp. -// -// The lazy functions' names are the same as the corresponding member -// function. Sample usage: -// -// "Normal" version "Lazy" version -// ---------------- -------------- -// my_vector.at(5) phoenix::at(arg1, 5) -// my_list.size() phoenix::size(arg1) -// my_vector1.swap(my_vector2) phoenix::swap(arg1, arg2) -// -// Notice that member functions with names that clash with a -// function in stl algorithms are absent. This will be provided -// in Phoenix's algorithm module. -// -// No support is provided here for lazy versions of operator+=, -// operator[] etc. Such operators are not specific to STL containers and -// lazy versions can therefore be found in operators.hpp. -// -/////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////// -// -// Lazy member function implementaions. -// -// The structs below provide the guts of the implementation. Thereafter, -// the corresponding lazy function itself is simply: -// -// function<stl::assign> const assign = stl::assign(); -// -// The structs provide a nested "result" class template whose -// "type" typedef enables the lazy function to ascertain the type -// to be returned when it is invoked. -// -// They also provide operator() member functions with signatures -// corresponding to those of the underlying member function of -// the STL container. -// -/////////////////////////////////////////////////////////////////////////////// - namespace stl - { - struct assign - { - template < - typename C - , typename Arg1 = fusion::void_ - , typename Arg2 = fusion::void_ - , typename Arg3 = fusion::void_ - > - struct result - { - typedef typename add_reference<C>::type type; - }; - - template <typename C, typename Arg1> - C& operator()(C& c, Arg1 const& arg1) const - { - c.assign(arg1); - return c; - } - - template <typename C, typename Arg1, typename Arg2> - C& operator()(C& c, Arg1 const& arg1, Arg2 const& arg2) const - { - c.assign(arg1, arg2); - return c; - } - - template <typename C, typename Arg1, typename Arg2, typename Arg3> - C& operator()( - C& c - , Arg1 const& arg1 - , Arg2 const& arg2 - , Arg3 const& arg3) const - { - return c.assign(arg1, arg2, arg3); - } - }; - - struct at - { - template <typename C, typename Index> - struct result - { - typedef typename const_qualified_reference_of<C>::type type; - }; - - template <typename C, typename Index> - typename result<C, Index>::type - operator()(C& c, Index const& i) const - { - return c.at(i); - } - }; - - struct back - { - template <typename C> - struct result - { - typedef - typename const_qualified_reference_of<C>::type - type; - }; - - template <typename C> - typename result<C>::type - operator()(C& c) const - { - return c.back(); - } - }; - - struct begin - { - template <typename C> - struct result - { - typedef typename const_qualified_iterator_of<C>::type type; - }; - - template <typename C> - typename result<C>::type - operator()(C& c) const - { - return c.begin(); - } - }; - - struct capacity - { - template <typename C> - struct result - { - typedef typename size_type_of<C>::type type; - }; - - template <typename C> - typename result<C>::type - operator()(C const& c) const - { - return c.capacity(); - } - }; - - struct clear - { - template <typename C> - struct result - { - typedef void type; - }; - - template <typename C> - void operator()(C& c) const - { - return c.clear(); - } - }; - - struct empty - { - template <typename C> - struct result - { - typedef bool type; - }; - - template <typename C> - bool operator()(C const& c) const - { - return c.empty(); - } - }; - - struct end - { - template <typename C> - struct result - { - typedef typename const_qualified_iterator_of<C>::type type; - }; - - template <typename C> - typename result<C>::type - operator()(C& c) const - { - return c.end(); - } - }; - - struct erase - { - // This mouthful can differentiate between the generic erase - // functions (Container == std::deque, std::list, std::vector) and - // that specific to the two map-types, std::map and std::multimap. - // - // where C is a std::deque, std::list, std::vector: - // - // 1) iterator C::erase(iterator where); - // 2) iterator C::erase(iterator first, iterator last); - // - // where M is a std::map or std::multimap: - // - // 3) size_type M::erase(const Key& keyval); - // 4) void M::erase(iterator where); - // 5) void M::erase(iterator first, iterator last); - - template <typename C, typename Arg1, typename Arg2 = fusion::void_> - struct result - { - // BOOST_MSVC #if branch here in map_erase_result non- - // standard behavior. The return type should be void but - // VC7.1 prefers to return iterator_of<C>. As a result, - // VC7.1 complains of error C2562: - // boost::phoenix::stl::erase::operator() 'void' function - // returning a value. Oh well... :* - - typedef - boost::mpl::eval_if< - boost::is_same<Arg1, typename iterator_of<C>::type> -#if defined(BOOST_MSVC) && (BOOST_MSVC <= 1500) - , iterator_of<C> -#else - , boost::mpl::identity<void> -#endif - , size_type_of<C> - > - map_erase_result; - - typedef typename - boost::mpl::eval_if< - has_mapped_type<C> - , map_erase_result - , iterator_of<C> - >::type - type; - }; - - template <typename C, typename Arg1> - typename result<C, Arg1>::type - operator()(C& c, Arg1 const& arg1) const - { - return c.erase(arg1); - } - - template <typename C, typename Arg1, typename Arg2> - typename result<C, Arg1, Arg2>::type - operator()(C& c, Arg1 const& arg1, Arg2 const& arg2) const - { - return c.erase(arg1, arg2); - } - }; - - struct front - { - template <typename C> - struct result - { - typedef typename const_qualified_reference_of<C>::type type; - }; - - template <typename C> - typename result<C>::type - operator()(C& c) const - { - return c.front(); - } - }; - - struct get_allocator - { - template <typename C> - struct result - { - typedef typename allocator_type_of<C>::type type; - }; - - template <typename C> - typename result<C>::type - operator()(C const& c) const - { - return c.get_allocator(); - } - }; - - struct insert - { - // This mouthful can differentiate between the generic insert - // functions (Container == deque, list, vector) and those - // specific to the two map-types, std::map and std::multimap. - // - // where C is a std::deque, std::list, std::vector: - // - // 1) iterator C::insert(iterator where, value_type value); - // 2) void C::insert( - // iterator where, size_type count, value_type value); - // 3) template <typename Iter> - // void C::insert(iterator where, Iter first, Iter last); - // - // where M is a std::map and MM is a std::multimap: - // - // 4) pair<iterator, bool> M::insert(value_type const&); - // 5) iterator MM::insert(value_type const&); - // - // where M is a std::map or std::multimap: - // - // 6) template <typename Iter> - // void M::insert(Iter first, Iter last); - - template < - typename C - , typename Arg1 - , typename Arg2 = fusion::void_ - , typename Arg3 = fusion::void_ - > - class result - { - struct pair_iterator_bool - { - typedef typename std::pair<typename C::iterator, bool> type; - }; - - typedef - boost::mpl::eval_if< - map_insert_returns_pair<C> - , pair_iterator_bool - , iterator_of<C> - > - choice_1; - - typedef - boost::mpl::eval_if< - boost::mpl::and_< - boost::is_same<Arg3, fusion::void_> - , boost::mpl::not_<boost::is_same<Arg1, Arg2> > > - , iterator_of<C> - , boost::mpl::identity<void> - > - choice_2; - - public: - - typedef typename - boost::mpl::eval_if< - boost::is_same<Arg2, fusion::void_> - , choice_1 - , choice_2 - >::type - type; - }; - - template <typename C, typename Arg1> - typename result<C, Arg1>::type - operator()(C& c, Arg1 const& arg1) const - { - return c.insert(arg1); - } - - template <typename C, typename Arg1, typename Arg2> - typename result<C, Arg1, Arg2>::type - operator()(C& c, Arg1 const& arg1, Arg2 const& arg2) const - { - return c.insert(arg1, arg2); - } - - template <typename C, typename Arg1, typename Arg2, typename Arg3> - typename result<C, Arg1, Arg2, Arg3>::type - operator()( - C& c, Arg1 const& arg1, Arg2 const& arg2, Arg3 const& arg3) const - { - return c.insert(arg1, arg2, arg3); - } - }; - - struct key_comp - { - template <typename C> - struct result - { - typedef typename key_compare_of<C>::type type; - }; - - template <typename C> - typename result<C>::type - operator()(C const& c) const - { - return c.key_comp(); - } - }; - - struct max_size - { - template <typename C> - struct result - { - typedef typename size_type_of<C>::type type; - }; - - template <typename C> - typename result<C>::type - operator()(C const& c) const - { - return c.max_size(); - } - }; - - struct pop_back - { - template <typename C> - struct result - { - typedef void type; - }; - - template <typename C> - void operator()(C& c) const - { - return c.pop_back(); - } - }; - - struct pop_front - { - template <typename C> - struct result - { - typedef void type; - }; - - template <typename C> - void operator()(C& c) const - { - return c.pop_front(); - } - }; - - struct push_back - { - template <typename C, typename Arg> - struct result - { - typedef void type; - }; - - template <typename C, typename Arg> - void operator()(C& c, Arg const& data) const - { - return c.push_back(data); - } - }; - - struct push_front - { - template <typename C, typename Arg> - struct result - { - typedef void type; - }; - - template <typename C, typename Arg> - void operator()(C& c, Arg const& data) const - { - return c.push_front(data); - } - }; - - struct rbegin - { - template <typename C> - struct result - { - typedef typename - const_qualified_reverse_iterator_of<C>::type - type; - }; - - template <typename C> - typename result<C>::type - operator()(C& c) const - { - return c.rbegin(); - } - }; - - struct rend - { - template <typename C> - struct result - { - typedef typename - const_qualified_reverse_iterator_of<C>::type - type; - }; - - template <typename C> - typename result<C>::type - operator()(C& c) const - { - return c.rend(); - } - }; - - struct reserve - { - - template <typename C, typename Arg> - struct result - { - typedef void type; - }; - - template <typename C, typename Arg> - void operator()(C& c, Arg const& count) const - { - return c.reserve(count); - } - }; - - struct resize - { - template <typename C, typename Arg1, typename Arg2 = fusion::void_> - struct result - { - typedef void type; - }; - - template <typename C, typename Arg1> - void operator()(C& c, Arg1 const& arg1) const - { - return c.resize(arg1); - } - - template <typename C, typename Arg1, typename Arg2> - void operator()(C& c, Arg1 const& arg1, Arg2 const& arg2) const - { - return c.resize(arg1, arg2); - } - }; - - struct size - { - template <typename C> - struct result - { - typedef typename size_type_of<C>::type type; - }; - - template <typename C> - typename result<C>::type - operator()(C const& c) const - { - return c.size(); - } - }; - - struct splice - { - template < - typename C - , typename Arg1 - , typename Arg2 - , typename Arg3 = fusion::void_ - , typename Arg4 = fusion::void_ - > - struct result - { - typedef void type; - }; - - template <typename C, typename Arg1, typename Arg2> - void operator()(C& c, Arg1 const& arg1, Arg2& arg2) const - { - c.splice(arg1, arg2); - } - - template < - typename C - , typename Arg1 - , typename Arg2 - , typename Arg3 - > - void operator()( - C& c - , Arg1 const& arg1 - , Arg2& arg2 - , Arg3 const& arg3 - ) const - { - c.splice(arg1, arg2, arg3); - } - - template < - typename C - , typename Arg1 - , typename Arg2 - , typename Arg3 - , typename Arg4 - > - void operator()( - C& c - , Arg1 const& arg1 - , Arg2& arg2 - , Arg3 const& arg3 - , Arg4 const& arg4 - ) const - { - c.splice(arg1, arg2, arg3, arg4); - } - }; - - struct value_comp - { - template <typename C> - struct result - { - typedef typename value_compare_of<C>::type type; - }; - - template <typename C> - typename result<C>::type - operator()(C const& c) const - { - return c.value_comp(); - } - }; - -} // namespace stl - -/////////////////////////////////////////////////////////////////////////////// -// -// The lazy functions themselves. -// -/////////////////////////////////////////////////////////////////////////////// -function<stl::assign> const assign = stl::assign(); -function<stl::at> const at = stl::at(); -function<stl::back> const back = stl::back(); -function<stl::begin> const begin = stl::begin(); -function<stl::capacity> const capacity = stl::capacity(); -function<stl::clear> const clear = stl::clear(); -function<stl::empty> const empty = stl::empty(); -function<stl::end> const end = stl::end(); -function<stl::erase> const erase = stl::erase(); -function<stl::front> const front = stl::front(); -function<stl::get_allocator> const get_allocator = stl::get_allocator(); -function<stl::insert> const insert = stl::insert(); -function<stl::key_comp> const key_comp = stl::key_comp(); -function<stl::max_size> const max_size = stl::max_size(); -function<stl::pop_back> const pop_back = stl::pop_back(); -function<stl::pop_front> const pop_front = stl::pop_front(); -function<stl::push_back> const push_back = stl::push_back(); -function<stl::push_front> const push_front = stl::push_front(); -function<stl::rbegin> const rbegin = stl::rbegin(); -function<stl::rend> const rend = stl::rend(); -function<stl::reserve> const reserve = stl::reserve(); -function<stl::resize> const resize = stl::resize(); -function<stl::size> const size = stl::size(); -function<stl::splice> const splice = stl::splice(); -function<stl::value_comp> const value_comp = stl::value_comp(); - -}} // namespace boost::phoenix - -#endif // PHOENIX_STL_CONTAINERS_HPP diff --git a/boost/spirit/home/phoenix/stl/container/detail/container.hpp b/boost/spirit/home/phoenix/stl/container/detail/container.hpp deleted file mode 100644 index eecf68dbaf..0000000000 --- a/boost/spirit/home/phoenix/stl/container/detail/container.hpp +++ /dev/null @@ -1,173 +0,0 @@ -/*============================================================================= - Copyright (c) 2004 Angus Leeming - Copyright (c) 2004 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) -==============================================================================*/ -#ifndef PHOENIX_CONTAINER_DETAIL_CONTAINER_HPP -#define PHOENIX_CONTAINER_DETAIL_CONTAINER_HPP - -#include <utility> -#include <boost/mpl/eval_if.hpp> -#include <boost/type_traits/is_same.hpp> -#include <boost/type_traits/is_const.hpp> - -namespace boost { namespace phoenix { namespace stl -{ -/////////////////////////////////////////////////////////////////////////////// -// -// Metafunctions "value_type_of", "key_type_of" etc. -// -// These metafunctions define a typedef "type" that returns the nested -// type if it exists. If not then the typedef returns void. -// -// For example, "value_type_of<std::vector<int> >::type" is "int" whilst -// "value_type_of<double>::type" is "void". -// -// I use a macro to define structs "value_type_of" etc simply to cut -// down on the amount of code. The macro is #undef-ed immediately after -// its final use. -// -/////////////////////////////////////////////////////////////////c////////////// -#define MEMBER_TYPE_OF(MEMBER_TYPE) \ - template <typename C> \ - struct BOOST_PP_CAT(MEMBER_TYPE, _of) \ - { \ - typedef typename C::MEMBER_TYPE type; \ - } - - MEMBER_TYPE_OF(allocator_type); - MEMBER_TYPE_OF(const_iterator); - MEMBER_TYPE_OF(const_reference); - MEMBER_TYPE_OF(const_reverse_iterator); - MEMBER_TYPE_OF(container_type); - MEMBER_TYPE_OF(data_type); - MEMBER_TYPE_OF(iterator); - MEMBER_TYPE_OF(key_compare); - MEMBER_TYPE_OF(key_type); - MEMBER_TYPE_OF(reference); - MEMBER_TYPE_OF(reverse_iterator); - MEMBER_TYPE_OF(size_type); - MEMBER_TYPE_OF(value_compare); - MEMBER_TYPE_OF(value_type); - -#undef MEMBER_TYPE_OF - -/////////////////////////////////////////////////////////////////////////////// -// -// Const-Qualified types. -// -// Many of the stl member functions have const and non-const -// overloaded versions that return distinct types. For example: -// -// iterator begin(); -// const_iterator begin() const; -// -// The three class templates defined below, -// const_qualified_reference_of, const_qualified_iterator_of -// and const_qualified_reverse_iterator_of provide a means to extract -// this return type automatically. -// -/////////////////////////////////////////////////////////////////////////////// - template <typename C> - struct const_qualified_reference_of - { - typedef typename - boost::mpl::eval_if< - boost::is_const<C> - , const_reference_of<C> - , reference_of<C> - >::type - type; - }; - - template <typename C> - struct const_qualified_iterator_of - { - typedef typename - boost::mpl::eval_if< - boost::is_const<C> - , const_iterator_of<C> - , iterator_of<C> - >::type - type; - }; - - template <typename C> - struct const_qualified_reverse_iterator_of - { - typedef typename - boost::mpl::eval_if< - boost::is_const<C> - , const_reverse_iterator_of<C> - , reverse_iterator_of<C> - >::type - type; - }; - -/////////////////////////////////////////////////////////////////////////////// -// -// has_mapped_type<C> -// -// Given a container C, determine if it is a map or multimap -// by checking if it has a member type named "mapped_type". -// -/////////////////////////////////////////////////////////////////////////////// - namespace stl_impl - { - struct one { char a[1]; }; - struct two { char a[2]; }; - - template <typename C> - one has_mapped_type(typename C::mapped_type(*)()); - - template <typename C> - two has_mapped_type(...); - } - - template <typename C> - struct has_mapped_type - : boost::mpl::bool_< - sizeof(stl_impl::has_mapped_type<C>(0)) == sizeof(stl_impl::one) - > - {}; - -/////////////////////////////////////////////////////////////////////////////// -// -// map_insert_returns_pair<C> -// -// Distinguish a map from a multimap by checking the return type -// of its "insert" member function. A map returns a pair while -// a multimap returns an iterator. -// -/////////////////////////////////////////////////////////////////////////////// - namespace stl_impl - { - // Cool implementation of map_insert_returns_pair by Daniel Wallin. - // Thanks Daniel!!! I owe you a Pizza! - - template<class A, class B> - one map_insert_returns_pair_check(std::pair<A,B> const&); - - template <typename T> - two map_insert_returns_pair_check(T const&); - - template <typename C> - struct map_insert_returns_pair - { - static typename C::value_type const& get; - BOOST_STATIC_CONSTANT(int, - value = sizeof( - map_insert_returns_pair_check(((C*)0)->insert(get)))); - typedef boost::mpl::bool_<value == sizeof(one)> type; - }; - } - - template <typename C> - struct map_insert_returns_pair - : stl_impl::map_insert_returns_pair<C>::type {}; - -}}} // namespace boost::phoenix::stl - -#endif // PHOENIX_STL_CONTAINER_TRAITS_HPP diff --git a/boost/spirit/home/phoenix/version.hpp b/boost/spirit/home/phoenix/version.hpp deleted file mode 100644 index c29baf8e47..0000000000 --- a/boost/spirit/home/phoenix/version.hpp +++ /dev/null @@ -1,18 +0,0 @@ -/*============================================================================= - Copyright (c) 2005-2008 Hartmut Kaiser - Copyright (c) 2005-2007 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) -==============================================================================*/ -#ifndef PHOENIX_VERSION_HPP -#define PHOENIX_VERSION_HPP - -/////////////////////////////////////////////////////////////////////////////// -// -// This is the version of the library -// -/////////////////////////////////////////////////////////////////////////////// -#define BOOST_PHOENIX_VERSION 0x2000 // 2.0.0 - -#endif diff --git a/boost/spirit/home/qi.hpp b/boost/spirit/home/qi.hpp index afdf1cb97c..e593d52e61 100644 --- a/boost/spirit/home/qi.hpp +++ b/boost/spirit/home/qi.hpp @@ -15,6 +15,7 @@ #include <boost/spirit/home/qi/auto.hpp> #include <boost/spirit/home/qi/auxiliary.hpp> #include <boost/spirit/home/qi/char.hpp> +#include <boost/spirit/home/qi/copy.hpp> #include <boost/spirit/home/qi/binary.hpp> #include <boost/spirit/home/qi/directive.hpp> #include <boost/spirit/home/qi/nonterminal.hpp> diff --git a/boost/spirit/home/qi/action/action.hpp b/boost/spirit/home/qi/action/action.hpp index 746dd84c1d..2bdf7d8f87 100644 --- a/boost/spirit/home/qi/action/action.hpp +++ b/boost/spirit/home/qi/action/action.hpp @@ -41,8 +41,8 @@ namespace boost { namespace spirit { namespace qi : traits::attribute_of<Subject, Context, Iterator> {}; - action(Subject const& subject, Action f) - : subject(subject), f(f) {} + action(Subject const& subject_, Action f_) + : subject(subject_), f(f_) {} #ifndef BOOST_SPIRIT_ACTIONS_ALLOW_ATTR_COMPAT template <typename Iterator, typename Context diff --git a/boost/spirit/home/qi/auxiliary/attr.hpp b/boost/spirit/home/qi/auxiliary/attr.hpp index 2778a685f1..fb018e7d73 100644 --- a/boost/spirit/home/qi/auxiliary/attr.hpp +++ b/boost/spirit/home/qi/auxiliary/attr.hpp @@ -59,9 +59,9 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& /*first*/, Iterator const& /*last*/ , Context& /*context*/, Skipper const& /*skipper*/ - , Attribute& attr) const + , Attribute& attr_) const { - spirit::traits::assign_to(value_, attr); + spirit::traits::assign_to(value_, attr_); return true; // never consume any input, succeed always } diff --git a/boost/spirit/home/qi/auxiliary/attr_cast.hpp b/boost/spirit/home/qi/auxiliary/attr_cast.hpp index a8fc6880e0..93d646c58d 100644 --- a/boost/spirit/home/qi/auxiliary/attr_cast.hpp +++ b/boost/spirit/home/qi/auxiliary/attr_cast.hpp @@ -50,11 +50,11 @@ namespace boost { namespace spirit { namespace qi typedef typename mpl::eval_if< traits::not_is_unused<Transformed> , mpl::identity<Transformed> - , traits::attribute_of<subject_type> >::type + , traits::attribute_of<subject_type> >::type transformed_attribute_type; - attr_cast_parser(Subject const& subject) - : subject(subject) + attr_cast_parser(Subject const& subject_) + : subject(subject_) { // If you got an error_invalid_expression error message here, // then the expression (Subject) is not a valid spirit qi @@ -75,7 +75,7 @@ namespace boost { namespace spirit { namespace qi , typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_param) const { // Find the real exposed attribute. If exposed is given, we use it // otherwise we assume the exposed attribute type to be the actual @@ -87,21 +87,21 @@ namespace boost { namespace spirit { namespace qi // do down-stream transformation, provides attribute for embedded // parser typedef traits::transform_attribute< - exposed_attribute_type, transformed_attribute_type, domain> + exposed_attribute_type, transformed_attribute_type, domain> transform; - typename transform::type attr_ = transform::pre(attr); + typename transform::type attr_ = transform::pre(attr_param); if (!compile<qi::domain>(subject). parse(first, last, context, skipper, attr_)) { - transform::fail(attr); + transform::fail(attr_param); return false; } // do up-stream transformation, this mainly integrates the results // back into the original attribute value, if appropriate - traits::post_transform(attr, attr_); + traits::post_transform(attr_param, attr_); return true; } diff --git a/boost/spirit/home/qi/auxiliary/eps.hpp b/boost/spirit/home/qi/auxiliary/eps.hpp index fe23935555..4ba6aa4cc4 100644 --- a/boost/spirit/home/qi/auxiliary/eps.hpp +++ b/boost/spirit/home/qi/auxiliary/eps.hpp @@ -80,8 +80,8 @@ namespace boost { namespace spirit { namespace qi typedef unused_type type; }; - semantic_predicate(bool predicate) - : predicate(predicate) {} + semantic_predicate(bool predicate_) + : predicate(predicate_) {} template <typename Iterator, typename Context , typename Skipper, typename Attribute> diff --git a/boost/spirit/home/qi/auxiliary/lazy.hpp b/boost/spirit/home/qi/auxiliary/lazy.hpp index b935261325..60b61d4ce4 100644 --- a/boost/spirit/home/qi/auxiliary/lazy.hpp +++ b/boost/spirit/home/qi/auxiliary/lazy.hpp @@ -60,7 +60,7 @@ namespace boost { namespace spirit { namespace qi bool lazy_parse_impl(Parser const& p , Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr, mpl::true_) + , Attribute& /*attr*/, mpl::true_) { // If DeducedAuto is false (semantic actions is present), the // component's attribute is unused. @@ -111,8 +111,8 @@ namespace boost { namespace spirit { namespace qi type; }; - lazy_parser(Function const& function, Modifiers const& modifiers) - : function(function), modifiers(modifiers) {} + lazy_parser(Function const& function_, Modifiers const& modifiers_) + : function(function_), modifiers(modifiers_) {} template <typename Iterator, typename Context , typename Skipper, typename Attribute> @@ -183,10 +183,10 @@ namespace boost { namespace spirit { namespace qi }; lazy_directive( - Function const& function - , Subject const& subject - , Modifiers const& modifiers) - : function(function), subject(subject), modifiers(modifiers) {} + Function const& function_ + , Subject const& subject_ + , Modifiers const& modifiers_) + : function(function_), subject(subject_), modifiers(modifiers_) {} template <typename Iterator, typename Context , typename Skipper, typename Attribute> diff --git a/boost/spirit/home/qi/binary/binary.hpp b/boost/spirit/home/qi/binary/binary.hpp index 7d47a6e2ee..a4e83f0ba5 100644 --- a/boost/spirit/home/qi/binary/binary.hpp +++ b/boost/spirit/home/qi/binary/binary.hpp @@ -241,7 +241,7 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_param) const { qi::skip_over(first, last, skipper); @@ -257,7 +257,7 @@ namespace boost { namespace spirit { namespace qi } first = it; - spirit::traits::assign_to(attr_, attr); + spirit::traits::assign_to(attr_, attr_param); return true; } @@ -280,14 +280,14 @@ namespace boost { namespace spirit { namespace qi typedef unused_type type; }; - binary_lit_parser(V n) - : n(n) {} + binary_lit_parser(V n_) + : n(n_) {} template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_param) const { qi::skip_over(first, last, skipper); @@ -317,7 +317,7 @@ namespace boost { namespace spirit { namespace qi } first = it; - spirit::traits::assign_to(attr_, attr); + spirit::traits::assign_to(attr_, attr_param); return true; } diff --git a/boost/spirit/home/qi/char/char.hpp b/boost/spirit/home/qi/char/char.hpp index 7269da4197..8c22aaa77d 100644 --- a/boost/spirit/home/qi/char/char.hpp +++ b/boost/spirit/home/qi/char/char.hpp @@ -123,8 +123,8 @@ namespace boost { namespace spirit { namespace qi typedef CharEncoding char_encoding; template <typename Char> - literal_char(Char ch) - : ch(static_cast<char_type>(ch)) {} + literal_char(Char ch_) + : ch(static_cast<char_type>(ch_)) {} template <typename Context, typename Iterator> struct attribute @@ -201,8 +201,8 @@ namespace boost { namespace spirit { namespace qi typedef typename CharEncoding::char_type char_type; typedef CharEncoding char_encoding; - char_range(char_type from, char_type to) - : from(from), to(to) {} + char_range(char_type from_, char_type to_) + : from(from_), to(to_) {} template <typename CharParam, typename Context> bool test(CharParam ch_, Context&) const diff --git a/boost/spirit/home/qi/char/char_parser.hpp b/boost/spirit/home/qi/char/char_parser.hpp index b896f73774..1d06d7cf8a 100644 --- a/boost/spirit/home/qi/char/char_parser.hpp +++ b/boost/spirit/home/qi/char/char_parser.hpp @@ -61,13 +61,13 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Context, typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper, Attribute& attr) const + , Context& context, Skipper const& skipper, Attribute& attr_) const { qi::skip_over(first, last, skipper); if (first != last && this->derived().test(*first, context)) { - spirit::traits::assign_to(*first, attr); + spirit::traits::assign_to(*first, attr_); ++first; return true; } @@ -87,8 +87,8 @@ namespace boost { namespace spirit { namespace qi struct negated_char_parser : char_parser<negated_char_parser<Positive>, typename Positive::char_type> { - negated_char_parser(Positive const& positive) - : positive(positive) {} + negated_char_parser(Positive const& positive_) + : positive(positive_) {} template <typename CharParam, typename Context> bool test(CharParam ch, Context& context) const diff --git a/boost/spirit/home/qi/copy.hpp b/boost/spirit/home/qi/copy.hpp new file mode 100644 index 0000000000..d9b843193d --- /dev/null +++ b/boost/spirit/home/qi/copy.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2001-2012 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_COPY_FEBRUARY_7_2012_0159PM) +#define BOOST_SPIRIT_COPY_FEBRUARY_7_2012_0159PM + +#include <boost/config.hpp> +#include <boost/proto/proto.hpp> + +#if defined(_MSC_VER) +#pragma once +#endif + +#if !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) + +namespace boost { namespace spirit { namespace qi +{ + template <typename Expr> + typename boost::proto::result_of::deep_copy<Expr>::type + copy(Expr const& expr) + { + BOOST_SPIRIT_ASSERT_MATCH(boost::spirit::qi::domain, Expr); + return boost::proto::deep_copy(expr); + } +}}} + +#endif +#endif diff --git a/boost/spirit/home/qi/detail/alternative_function.hpp b/boost/spirit/home/qi/detail/alternative_function.hpp index aad0c54866..0c400a90d4 100644 --- a/boost/spirit/home/qi/detail/alternative_function.hpp +++ b/boost/spirit/home/qi/detail/alternative_function.hpp @@ -56,10 +56,10 @@ namespace boost { namespace spirit { namespace qi { namespace detail struct alternative_function { alternative_function( - Iterator& first, Iterator const& last, Context& context, - Skipper const& skipper, Attribute& attr) - : first(first), last(last), context(context), skipper(skipper), - attr(attr) + Iterator& first_, Iterator const& last_, Context& context_, + Skipper const& skipper_, Attribute& attr_) + : first(first_), last(last_), context(context_), skipper(skipper_), + attr(attr_) { } @@ -185,14 +185,14 @@ namespace boost { namespace spirit { namespace qi { namespace detail struct alternative_function<Iterator, Context, Skipper, unused_type const> { alternative_function( - Iterator& first, Iterator const& last, Context& context, - Skipper const& skipper, unused_type) - : first(first), last(last), context(context), skipper(skipper) + Iterator& first_, Iterator const& last_, Context& context_, + Skipper const& skipper_, unused_type) + : first(first_), last(last_), context(context_), skipper(skipper_) { } template <typename Component> - bool operator()(Component const& component) + bool operator()(Component const& component) const { // return true if the parser succeeds return component.parse(first, last, context, skipper, diff --git a/boost/spirit/home/qi/detail/expect_function.hpp b/boost/spirit/home/qi/detail/expect_function.hpp index 34dd910744..920e30997b 100644 --- a/boost/spirit/home/qi/detail/expect_function.hpp +++ b/boost/spirit/home/qi/detail/expect_function.hpp @@ -26,12 +26,12 @@ namespace boost { namespace spirit { namespace qi { namespace detail typedef Context context_type; expect_function( - Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper) - : first(first) - , last(last) - , context(context) - , skipper(skipper) + Iterator& first_, Iterator const& last_ + , Context& context_, Skipper const& skipper_) + : first(first_) + , last(last_) + , context(context_) + , skipper(skipper_) , is_first(true) { } diff --git a/boost/spirit/home/qi/detail/fail_function.hpp b/boost/spirit/home/qi/detail/fail_function.hpp index fca03b33f9..7ab8d82a2b 100644 --- a/boost/spirit/home/qi/detail/fail_function.hpp +++ b/boost/spirit/home/qi/detail/fail_function.hpp @@ -22,12 +22,12 @@ namespace boost { namespace spirit { namespace qi { namespace detail typedef Context context_type; fail_function( - Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper) - : first(first) - , last(last) - , context(context) - , skipper(skipper) + Iterator& first_, Iterator const& last_ + , Context& context_, Skipper const& skipper_) + : first(first_) + , last(last_) + , context(context_) + , skipper(skipper_) { } diff --git a/boost/spirit/home/qi/detail/pass_container.hpp b/boost/spirit/home/qi/detail/pass_container.hpp index 82e153aa3a..f41f1e9bcc 100644 --- a/boost/spirit/home/qi/detail/pass_container.hpp +++ b/boost/spirit/home/qi/detail/pass_container.hpp @@ -33,17 +33,17 @@ namespace boost { namespace spirit { namespace qi { namespace detail Sequence , typename traits::is_weak_substitute<Attribute, ValueType>::type , typename mpl::not_< - traits::is_weak_substitute<Attribute, ValueType> + traits::is_weak_substitute<Attribute, ValueType> >::type> {}; - // pass_through_container: utility to check decide whether a provided - // container attribute needs to be passed through to the current component + // pass_through_container: utility to check decide whether a provided + // container attribute needs to be passed through to the current component // or of we need to split the container by passing along instances of its // value type - // if the expected attribute of the current component is neither a Fusion - // sequence nor a container, we will pass through the provided container + // if the expected attribute of the current component is neither a Fusion + // sequence nor a container, we will pass through the provided container // only if its value type is not compatible with the component template <typename Container, typename ValueType, typename Attribute , typename Sequence, typename Enable = void> @@ -53,9 +53,9 @@ namespace boost { namespace spirit { namespace qi { namespace detail // Specialization for fusion sequences, in this case we check whether all // the types in the sequence are convertible to the lhs attribute. - // + // // We return false if the rhs attribute itself is a fusion sequence, which - // is compatible with the LHS sequence (we want to pass through this + // is compatible with the LHS sequence (we want to pass through this // attribute without it being split apart). template <typename Container, typename ValueType, typename Attribute , typename Sequence = mpl::true_> @@ -66,7 +66,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail {}; // If the value type of the container is not a Fusion sequence, we pass - // through the container if each of the elements of the Attribute + // through the container if each of the elements of the Attribute // sequence is compatible with either the container or its value type. template <typename Container, typename ValueType, typename Attribute , typename Sequence @@ -82,7 +82,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail }; // If both, the Attribute and the value type of the provided container - // are Fusion sequences, we pass the container only if the two + // are Fusion sequences, we pass the container only if the two // sequences are not compatible. template <typename Container, typename ValueType, typename Attribute , typename Sequence> @@ -110,14 +110,14 @@ namespace boost { namespace spirit { namespace qi { namespace detail // Specialization for containers // // If the value type of the attribute of the current component is not - // a Fusion sequence, we have to pass through the provided container if + // a Fusion sequence, we have to pass through the provided container if // both are compatible. template <typename Container, typename ValueType, typename Attribute , typename Sequence, typename AttributeValueType , bool IsSequence = fusion::traits::is_sequence<AttributeValueType>::value> struct pass_through_container_container : mpl::or_< - traits::is_weak_substitute<Attribute, Container> + traits::is_weak_substitute<Attribute, Container> , traits::is_weak_substitute<AttributeValueType, Container> > {}; @@ -143,16 +143,16 @@ namespace boost { namespace spirit { namespace qi { namespace detail // Specialization for exposed optional attributes // - // If the type embedded in the exposed optional is not a Fusion + // If the type embedded in the exposed optional is not a Fusion // sequence we pass through the container attribute if it is compatible - // either to the optionals embedded type or to the containers value + // either to the optionals embedded type or to the containers value // type. template <typename Container, typename ValueType, typename Attribute , typename Sequence , bool IsSequence = fusion::traits::is_sequence<Attribute>::value> struct pass_through_container_optional : mpl::or_< - traits::is_weak_substitute<Attribute, Container> + traits::is_weak_substitute<Attribute, Container> , traits::is_weak_substitute<Attribute, ValueType> > {}; @@ -170,7 +170,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail template <typename Container, typename ValueType, typename Attribute , typename Sequence> struct pass_through_container - : pass_through_container_base<Container, ValueType, Attribute, Sequence> + : pass_through_container_base<Container, ValueType, Attribute, Sequence> {}; // Handle optional attributes @@ -179,25 +179,44 @@ namespace boost { namespace spirit { namespace qi { namespace detail struct pass_through_container< Container, ValueType, boost::optional<Attribute>, Sequence> : pass_through_container_optional< - Container, ValueType, Attribute, Sequence> + Container, ValueType, Attribute, Sequence> {}; // If both, the containers value type and the exposed attribute type are - // optionals we are allowed to pass through the the container only if the + // optionals we are allowed to pass through the container only if the // embedded types of those optionals are not compatible. template <typename Container, typename ValueType, typename Attribute , typename Sequence> struct pass_through_container< Container, boost::optional<ValueType>, boost::optional<Attribute> , Sequence> - : mpl::not_<traits::is_weak_substitute<Attribute, ValueType> > + : mpl::not_<traits::is_weak_substitute<Attribute, ValueType> > {}; // Specialization for exposed variant attributes - // - // We pass through the container attribute if at least one of the embedded + // + // We pass through the container attribute if at least one of the embedded // types in the variant requires to pass through the attribute +#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) + template <typename Container, typename ValueType, typename Sequence + , typename T> + struct pass_through_container<Container, ValueType, boost::variant<T> + , Sequence> + : pass_through_container<Container, ValueType, T, Sequence> + {}; + + template <typename Container, typename ValueType, typename Sequence + , typename T0, typename ...TN> + struct pass_through_container<Container, ValueType + , boost::variant<T0, TN...>, Sequence> + : mpl::bool_<pass_through_container< + Container, ValueType, T0, Sequence + >::type::value || pass_through_container< + Container, ValueType, boost::variant<TN...>, Sequence + >::type::value> + {}; +#else #define BOOST_SPIRIT_PASS_THROUGH_CONTAINER(z, N, _) \ pass_through_container<Container, ValueType, \ BOOST_PP_CAT(T, N), Sequence>::type::value || \ @@ -219,6 +238,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail {}; #undef BOOST_SPIRIT_PASS_THROUGH_CONTAINER +#endif }}}} /////////////////////////////////////////////////////////////////////////////// @@ -247,8 +267,8 @@ namespace boost { namespace spirit { namespace qi { namespace detail typedef typename F::context_type context_type; typedef typename F::iterator_type iterator_type; - pass_container(F const& f, Attr& attr) - : f(f), attr(attr) {} + pass_container(F const& f_, Attr& attr_) + : f(f_), attr(attr_) {} // this is for the case when the current element exposes an attribute // which is pushed back onto the container @@ -271,8 +291,8 @@ namespace boost { namespace spirit { namespace qi { namespace detail return r; } - // this is for the case when the current element is able to handle an - // attribute which is a container itself, this element will push its + // this is for the case when the current element is able to handle an + // attribute which is a container itself, this element will push its // data directly into the attribute container template <typename Component> bool dispatch_container(Component const& component, mpl::true_) const @@ -281,7 +301,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail } /////////////////////////////////////////////////////////////////////// - // this is for the case when the current element doesn't expect an + // this is for the case when the current element doesn't expect an // attribute template <typename Component> bool dispatch_attribute(Component const& component, mpl::false_) const @@ -298,12 +318,12 @@ namespace boost { namespace spirit { namespace qi { namespace detail Component, context_type, iterator_type>::type rhs_attribute; - // this predicate detects, whether the attribute of the current + // this predicate detects, whether the attribute of the current // element is a substitute for the value type of the container - // attribute + // attribute typedef mpl::and_< traits::handles_container< - Component, Attr, context_type, iterator_type> + Component, Attr, context_type, iterator_type> , traits::pass_through_container< Attr, value_type, rhs_attribute, Sequence, qi::domain> > predicate; @@ -340,7 +360,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail }; /////////////////////////////////////////////////////////////////////////// - // Utility function to make a pass_container for container components + // Utility function to make a pass_container for container components // (kleene, list, plus, repeat) template <typename F, typename Attr> inline pass_container<F, Attr, mpl::false_> diff --git a/boost/spirit/home/qi/detail/pass_function.hpp b/boost/spirit/home/qi/detail/pass_function.hpp index 2d9e6bab26..555adb8a49 100644 --- a/boost/spirit/home/qi/detail/pass_function.hpp +++ b/boost/spirit/home/qi/detail/pass_function.hpp @@ -20,12 +20,12 @@ namespace boost { namespace spirit { namespace qi { namespace detail struct pass_function { pass_function( - Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper) - : first(first) - , last(last) - , context(context) - , skipper(skipper) + Iterator& first_, Iterator const& last_ + , Context& context_, Skipper const& skipper_) + : first(first_) + , last(last_) + , context(context_) + , skipper(skipper_) { } diff --git a/boost/spirit/home/qi/detail/permute_function.hpp b/boost/spirit/home/qi/detail/permute_function.hpp index 13c1b8c123..8b1ed8a596 100644 --- a/boost/spirit/home/qi/detail/permute_function.hpp +++ b/boost/spirit/home/qi/detail/permute_function.hpp @@ -20,12 +20,12 @@ namespace boost { namespace spirit { namespace qi { namespace detail struct permute_function { permute_function( - Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper) - : first(first) - , last(last) - , context(context) - , skipper(skipper) + Iterator& first_, Iterator const& last_ + , Context& context_, Skipper const& skipper_) + : first(first_) + , last(last_) + , context(context_) + , skipper(skipper_) { } diff --git a/boost/spirit/home/qi/detail/unused_skipper.hpp b/boost/spirit/home/qi/detail/unused_skipper.hpp index c1405d67c7..b8a51f3224 100644 --- a/boost/spirit/home/qi/detail/unused_skipper.hpp +++ b/boost/spirit/home/qi/detail/unused_skipper.hpp @@ -11,14 +11,15 @@ #endif #include <boost/spirit/home/support/unused.hpp> +#include <boost/mpl/bool.hpp> namespace boost { namespace spirit { namespace qi { namespace detail { template <typename Skipper> struct unused_skipper : unused_type { - unused_skipper(Skipper const& skipper) - : skipper(skipper) {} + unused_skipper(Skipper const& skipper_) + : skipper(skipper_) {} Skipper const& skipper; private: @@ -26,12 +27,24 @@ namespace boost { namespace spirit { namespace qi { namespace detail unused_skipper& operator= (unused_skipper const&); }; + template <typename Skipper> + struct is_unused_skipper + : mpl::false_ {}; + + template <typename Skipper> + struct is_unused_skipper<unused_skipper<Skipper> > + : mpl::true_ {}; + + template <> + struct is_unused_skipper<unused_type> + : mpl::true_ {}; + // If a surrounding lexeme[] directive was specified, the current - // skipper is of the type unused_skipper. In this case we + // skipper is of the type unused_skipper. In this case we // re-activate the skipper which was active before the skip[] // directive. template <typename Skipper> - inline Skipper const& + inline Skipper const& get_skipper(unused_skipper<Skipper> const& u) { return u.skipper; @@ -39,7 +52,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail // If no surrounding lexeme[] directive was specified we keep what we got. template <typename Skipper> - inline Skipper const& + inline Skipper const& get_skipper(Skipper const& u) { return u; diff --git a/boost/spirit/home/qi/directive/as.hpp b/boost/spirit/home/qi/directive/as.hpp index 9ace587caf..e0376eb2ec 100644 --- a/boost/spirit/home/qi/directive/as.hpp +++ b/boost/spirit/home/qi/directive/as.hpp @@ -76,8 +76,8 @@ namespace boost { namespace spirit { namespace qi struct as_directive : unary_parser<as_directive<Subject, T> > { typedef Subject subject_type; - as_directive(Subject const& subject) - : subject(subject) {} + as_directive(Subject const& subject_) + : subject(subject_) {} template <typename Context, typename Iterator> struct attribute @@ -88,13 +88,13 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper, Attribute& attr) const + , Context& context, Skipper const& skipper, Attribute& attr_) const { Iterator i = first; T as_attr; if (subject.parse(i, last, context, skipper, as_attr)) { - spirit::traits::assign_to(as_attr, attr); + spirit::traits::assign_to(as_attr, attr_); first = i; return true; } @@ -103,10 +103,10 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Context, typename Skipper> bool parse(Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper, T& attr) const + , Context& context, Skipper const& skipper, T& attr_) const { Iterator i = first; - if (subject.parse(i, last, context, skipper, attr)) + if (subject.parse(i, last, context, skipper, attr_)) { first = i; return true; diff --git a/boost/spirit/home/qi/directive/hold.hpp b/boost/spirit/home/qi/directive/hold.hpp index d5b2ed5601..9cd905cf79 100644 --- a/boost/spirit/home/qi/directive/hold.hpp +++ b/boost/spirit/home/qi/directive/hold.hpp @@ -42,8 +42,8 @@ namespace boost { namespace spirit { namespace qi struct hold_directive : unary_parser<hold_directive<Subject> > { typedef Subject subject_type; - hold_directive(Subject const& subject) - : subject(subject) {} + hold_directive(Subject const& subject_) + : subject(subject_) {} template <typename Context, typename Iterator> struct attribute @@ -56,12 +56,12 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper, Attribute& attr) const + , Context& context, Skipper const& skipper, Attribute& attr_) const { - Attribute copy(attr); + Attribute copy(attr_); if (subject.parse(first, last, context, skipper, copy)) { - traits::swap_impl(copy, attr); + traits::swap_impl(copy, attr_); return true; } return false; diff --git a/boost/spirit/home/qi/directive/lexeme.hpp b/boost/spirit/home/qi/directive/lexeme.hpp index f0b83993ef..691d4fa52c 100644 --- a/boost/spirit/home/qi/directive/lexeme.hpp +++ b/boost/spirit/home/qi/directive/lexeme.hpp @@ -20,6 +20,7 @@ #include <boost/spirit/home/qi/detail/attributes.hpp> #include <boost/spirit/home/support/info.hpp> #include <boost/spirit/home/support/handles_container.hpp> +#include <boost/utility/enable_if.hpp> namespace boost { namespace spirit { @@ -42,8 +43,8 @@ namespace boost { namespace spirit { namespace qi struct lexeme_directive : unary_parser<lexeme_directive<Subject> > { typedef Subject subject_type; - lexeme_directive(Subject const& subject) - : subject(subject) {} + lexeme_directive(Subject const& subject_) + : subject(subject_) {} template <typename Context, typename Iterator> struct attribute @@ -55,13 +56,26 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Context , typename Skipper, typename Attribute> - bool parse(Iterator& first, Iterator const& last + typename disable_if<detail::is_unused_skipper<Skipper>, bool>::type + parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { qi::skip_over(first, last, skipper); return subject.parse(first, last, context - , detail::unused_skipper<Skipper>(skipper), attr); + , detail::unused_skipper<Skipper>(skipper), attr_); + } + template <typename Iterator, typename Context + , typename Skipper, typename Attribute> + typename enable_if<detail::is_unused_skipper<Skipper>, bool>::type + parse(Iterator& first, Iterator const& last + , Context& context, Skipper const& skipper + , Attribute& attr_) const + { + // no need to pre-skip if skipper is unused + //- qi::skip_over(first, last, skipper); + return subject.parse(first, last, context + , skipper, attr_); } template <typename Context> diff --git a/boost/spirit/home/qi/directive/matches.hpp b/boost/spirit/home/qi/directive/matches.hpp index b5349272d4..b6fecb994d 100644 --- a/boost/spirit/home/qi/directive/matches.hpp +++ b/boost/spirit/home/qi/directive/matches.hpp @@ -44,8 +44,8 @@ namespace boost { namespace spirit { namespace qi struct matches_directive : unary_parser<matches_directive<Subject> > { typedef Subject subject_type; - matches_directive(Subject const& subject) - : subject(subject) {} + matches_directive(Subject const& subject_) + : subject(subject_) {} template <typename Context, typename Iterator> struct attribute @@ -56,10 +56,10 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper, Attribute& attr) const + , Context& context, Skipper const& skipper, Attribute& attr_) const { bool result = subject.parse(first, last, context, skipper, unused); - spirit::traits::assign_to(result, attr); + spirit::traits::assign_to(result, attr_); return true; } diff --git a/boost/spirit/home/qi/directive/no_skip.hpp b/boost/spirit/home/qi/directive/no_skip.hpp index 9764d4a661..119b0c80c3 100644 --- a/boost/spirit/home/qi/directive/no_skip.hpp +++ b/boost/spirit/home/qi/directive/no_skip.hpp @@ -22,6 +22,7 @@ #include <boost/spirit/home/support/info.hpp> #include <boost/spirit/home/support/has_semantic_action.hpp> #include <boost/spirit/home/support/handles_container.hpp> +#include <boost/utility/enable_if.hpp> namespace boost { namespace spirit { @@ -45,8 +46,8 @@ namespace boost { namespace spirit { namespace qi struct no_skip_directive : unary_parser<no_skip_directive<Subject> > { typedef Subject subject_type; - no_skip_directive(Subject const& subject) - : subject(subject) {} + no_skip_directive(Subject const& subject_) + : subject(subject_) {} template <typename Context, typename Iterator> struct attribute @@ -58,12 +59,23 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Context , typename Skipper, typename Attribute> - bool parse(Iterator& first, Iterator const& last + typename disable_if<detail::is_unused_skipper<Skipper>, bool>::type + parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { return subject.parse(first, last, context - , detail::unused_skipper<Skipper>(skipper), attr); + , detail::unused_skipper<Skipper>(skipper), attr_); + } + template <typename Iterator, typename Context + , typename Skipper, typename Attribute> + typename enable_if<detail::is_unused_skipper<Skipper>, bool>::type + parse(Iterator& first, Iterator const& last + , Context& context, Skipper const& skipper + , Attribute& attr_) const + { + return subject.parse(first, last, context + , skipper, attr_); } template <typename Context> diff --git a/boost/spirit/home/qi/directive/omit.hpp b/boost/spirit/home/qi/directive/omit.hpp index b0ed86b0a7..05a6a76d75 100644 --- a/boost/spirit/home/qi/directive/omit.hpp +++ b/boost/spirit/home/qi/directive/omit.hpp @@ -45,8 +45,8 @@ namespace boost { namespace spirit { namespace qi struct omit_directive : unary_parser<omit_directive<Subject> > { typedef Subject subject_type; - omit_directive(Subject const& subject) - : subject(subject) {} + omit_directive(Subject const& subject_) + : subject(subject_) {} template <typename Context, typename Iterator> struct attribute @@ -57,9 +57,9 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper, Attribute& attr) const + , Context& context, Skipper const& skipper, Attribute& attr_) const { - return subject.parse(first, last, context, skipper, attr); + return subject.parse(first, last, context, skipper, attr_); } template <typename Context> diff --git a/boost/spirit/home/qi/directive/raw.hpp b/boost/spirit/home/qi/directive/raw.hpp index b88458ea28..e1d208e759 100644 --- a/boost/spirit/home/qi/directive/raw.hpp +++ b/boost/spirit/home/qi/directive/raw.hpp @@ -44,8 +44,8 @@ namespace boost { namespace spirit { namespace qi struct raw_directive : unary_parser<raw_directive<Subject> > { typedef Subject subject_type; - raw_directive(Subject const& subject) - : subject(subject) {} + raw_directive(Subject const& subject_) + : subject(subject_) {} template <typename Context, typename Iterator> struct attribute @@ -56,13 +56,13 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper, Attribute& attr) const + , Context& context, Skipper const& skipper, Attribute& attr_) const { qi::skip_over(first, last, skipper); Iterator i = first; if (subject.parse(i, last, context, skipper, unused)) { - spirit::traits::assign_to(first, i, attr); + spirit::traits::assign_to(first, i, attr_); first = i; return true; } diff --git a/boost/spirit/home/qi/directive/repeat.hpp b/boost/spirit/home/qi/directive/repeat.hpp index 252e18f743..72c3a998be 100644 --- a/boost/spirit/home/qi/directive/repeat.hpp +++ b/boost/spirit/home/qi/directive/repeat.hpp @@ -81,8 +81,8 @@ namespace boost { namespace spirit { namespace qi template <typename T> struct exact_iterator // handles repeat(exact)[p] { - exact_iterator(T const exact) - : exact(exact) {} + exact_iterator(T const exact_) + : exact(exact_) {} typedef T type; T start() const { return 0; } @@ -99,9 +99,9 @@ namespace boost { namespace spirit { namespace qi template <typename T> struct finite_iterator // handles repeat(min, max)[p] { - finite_iterator(T const min, T const max) - : min BOOST_PREVENT_MACRO_SUBSTITUTION (min) - , max BOOST_PREVENT_MACRO_SUBSTITUTION (max) {} + finite_iterator(T const min_, T const max_) + : min BOOST_PREVENT_MACRO_SUBSTITUTION (min_) + , max BOOST_PREVENT_MACRO_SUBSTITUTION (max_) {} typedef T type; T start() const { return 0; } @@ -119,8 +119,8 @@ namespace boost { namespace spirit { namespace qi template <typename T> struct infinite_iterator // handles repeat(min, inf)[p] { - infinite_iterator(T const min) - : min BOOST_PREVENT_MACRO_SUBSTITUTION (min) {} + infinite_iterator(T const min_) + : min BOOST_PREVENT_MACRO_SUBSTITUTION (min_) {} typedef T type; T start() const { return 0; } @@ -153,8 +153,8 @@ namespace boost { namespace spirit { namespace qi type; }; - repeat_parser(Subject const& subject, LoopIter const& iter) - : subject(subject), iter(iter) {} + repeat_parser(Subject const& subject_, LoopIter const& iter_) + : subject(subject_), iter(iter_) {} template <typename F> bool parse_container(F f) const @@ -183,17 +183,17 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { typedef detail::fail_function<Iterator, Context, Skipper> fail_function; // ensure the attribute is actually a container type - traits::make_container(attr); + traits::make_container(attr_); - Iterator iter = first; - fail_function f(iter, last, context, skipper); - if (!parse_container(detail::make_pass_container(f, attr))) + Iterator iter_local = first; + fail_function f(iter_local, last, context, skipper); + if (!parse_container(detail::make_pass_container(f, attr_))) return false; first = f.first; diff --git a/boost/spirit/home/qi/directive/skip.hpp b/boost/spirit/home/qi/directive/skip.hpp index 28539da3a0..6cc6f77454 100644 --- a/boost/spirit/home/qi/directive/skip.hpp +++ b/boost/spirit/home/qi/directive/skip.hpp @@ -26,6 +26,7 @@ #include <boost/spirit/home/support/handles_container.hpp> #include <boost/fusion/include/at.hpp> #include <boost/fusion/include/vector.hpp> +#include <boost/utility/enable_if.hpp> namespace boost { namespace spirit { @@ -70,17 +71,28 @@ namespace boost { namespace spirit { namespace qi type; }; - reskip_parser(Subject const& subject) - : subject(subject) {} + reskip_parser(Subject const& subject_) + : subject(subject_) {} template <typename Iterator, typename Context , typename Skipper, typename Attribute> - bool parse(Iterator& first, Iterator const& last + typename enable_if<detail::is_unused_skipper<Skipper>, bool>::type + parse(Iterator& first, Iterator const& last , Context& context, Skipper const& u // --> The skipper is reintroduced - , Attribute& attr) const + , Attribute& attr_) const + { + return subject.parse(first, last, context + , detail::get_skipper(u), attr_); + } + template <typename Iterator, typename Context + , typename Skipper, typename Attribute> + typename disable_if<detail::is_unused_skipper<Skipper>, bool>::type + parse(Iterator& first, Iterator const& last + , Context& context, Skipper const& skipper + , Attribute& attr_) const { return subject.parse(first, last, context - , detail::get_skipper(u), attr); + , skipper, attr_); } template <typename Context> @@ -106,16 +118,16 @@ namespace boost { namespace spirit { namespace qi type; }; - skip_parser(Subject const& subject, Skipper const& skipper) - : subject(subject), skipper(skipper) {} + skip_parser(Subject const& subject_, Skipper const& skipper_) + : subject(subject_), skipper(skipper_) {} template <typename Iterator, typename Context , typename Skipper_, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper_ const& //skipper --> bypass the supplied skipper - , Attribute& attr) const + , Attribute& attr_) const { - return subject.parse(first, last, context, skipper, attr); + return subject.parse(first, last, context, skipper, attr_); } template <typename Context> diff --git a/boost/spirit/home/qi/nonterminal/debug_handler.hpp b/boost/spirit/home/qi/nonterminal/debug_handler.hpp index 33287327cc..6a9f536699 100644 --- a/boost/spirit/home/qi/nonterminal/debug_handler.hpp +++ b/boost/spirit/home/qi/nonterminal/debug_handler.hpp @@ -36,12 +36,12 @@ namespace boost { namespace spirit { namespace qi function_type; debug_handler( - function_type subject - , F f - , std::string const& rule_name) - : subject(subject) - , f(f) - , rule_name(rule_name) + function_type subject_ + , F f_ + , std::string const& rule_name_) + : subject(subject_) + , f(f_) + , rule_name(rule_name_) { } diff --git a/boost/spirit/home/qi/nonterminal/detail/parameterized.hpp b/boost/spirit/home/qi/nonterminal/detail/parameterized.hpp index 0300a06b7e..825fa40732 100644 --- a/boost/spirit/home/qi/nonterminal/detail/parameterized.hpp +++ b/boost/spirit/home/qi/nonterminal/detail/parameterized.hpp @@ -27,8 +27,8 @@ namespace boost { namespace spirit { namespace qi struct parameterized_nonterminal : parser<parameterized_nonterminal<Subject, Params> > { - parameterized_nonterminal(Subject const& subject, Params const& params) - : ref(subject), params(params) + parameterized_nonterminal(Subject const& subject, Params const& params_) + : ref(subject), params(params_) { } @@ -41,11 +41,11 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { // Forward to subject, passing the additional // params argument to parse. - return ref.get().parse(first, last, context, skipper, attr, params); + return ref.get().parse(first, last, context, skipper, attr_, params); } template <typename Context> diff --git a/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp b/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp index 91bceba88e..87d8e84ec4 100644 --- a/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp +++ b/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp @@ -21,8 +21,8 @@ namespace boost { namespace spirit { namespace qi { namespace detail template <typename Parser, typename Auto> struct parser_binder { - parser_binder(Parser const& p) - : p(p) {} + parser_binder(Parser const& p_) + : p(p_) {} template <typename Iterator, typename Skipper, typename Context> bool call(Iterator& first, Iterator const& last @@ -60,8 +60,8 @@ namespace boost { namespace spirit { namespace qi { namespace detail template <typename Parser> struct parser_binder<Parser, mpl::true_> { - parser_binder(Parser const& p) - : p(p) {} + parser_binder(Parser const& p_) + : p(p_) {} template <typename Iterator, typename Skipper, typename Context> bool operator()( diff --git a/boost/spirit/home/qi/nonterminal/error_handler.hpp b/boost/spirit/home/qi/nonterminal/error_handler.hpp index 6dd4f08123..e8c4f8771a 100644 --- a/boost/spirit/home/qi/nonterminal/error_handler.hpp +++ b/boost/spirit/home/qi/nonterminal/error_handler.hpp @@ -76,9 +76,9 @@ namespace boost { namespace spirit { namespace qi )> function_type; - error_handler(function_type subject, F f) - : subject(subject) - , f(f) + error_handler(function_type subject_, F f_) + : subject(subject_) + , f(f_) { } diff --git a/boost/spirit/home/qi/nonterminal/grammar.hpp b/boost/spirit/home/qi/nonterminal/grammar.hpp index 982e49b91e..d41590cab9 100644 --- a/boost/spirit/home/qi/nonterminal/grammar.hpp +++ b/boost/spirit/home/qi/nonterminal/grammar.hpp @@ -56,9 +56,9 @@ namespace boost { namespace spirit { namespace qi grammar( start_type const& start - , std::string const& name_ = "unnamed-grammar") + , std::string const& name = "unnamed-grammar") : proto::extends<terminal, base_type>(terminal::make(reference_(start))) - , name_(name_) + , name_(name) {} // This constructor is used to catch if the start rule is not @@ -90,10 +90,10 @@ namespace boost { namespace spirit { namespace qi template <typename Context, typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { return this->proto_base().child0.parse( - first, last, context, skipper, attr); + first, last, context, skipper, attr_); } template <typename Context> diff --git a/boost/spirit/home/qi/nonterminal/rule.hpp b/boost/spirit/home/qi/nonterminal/rule.hpp index 23d25595a0..8dd42373b0 100644 --- a/boost/spirit/home/qi/nonterminal/rule.hpp +++ b/boost/spirit/home/qi/nonterminal/rule.hpp @@ -41,6 +41,7 @@ #if defined(BOOST_MSVC) # pragma warning(push) # pragma warning(disable: 4355) // 'this' : used in base member initializer list warning +# pragma warning(disable: 4127) // conditional expression is constant #endif namespace boost { namespace spirit { namespace qi @@ -154,9 +155,9 @@ namespace boost { namespace spirit { namespace qi >::type encoding_modifier_type; - explicit rule(std::string const& name_ = "unnamed-rule") + explicit rule(std::string const& name = "unnamed-rule") : base_type(terminal::make(reference_(*this))) - , name_(name_) + , name_(name) { } @@ -168,7 +169,7 @@ namespace boost { namespace spirit { namespace qi } 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, @@ -184,9 +185,9 @@ namespace boost { namespace spirit { namespace qi } template <typename Expr> - rule(Expr const& expr, std::string const& name_ = "unnamed-rule") + rule(Expr const& expr, std::string const& name = "unnamed-rule") : base_type(terminal::make(reference_(*this))) - , name_(name_) + , name_(name) { define<mpl::false_>(*this, expr, traits::matches<qi::domain, Expr>()); } @@ -231,7 +232,7 @@ namespace boost { namespace spirit { namespace qi return r; } -#if defined(BOOST_NO_RVALUE_REFERENCES) +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) // non-const version needed to suppress proto's %= kicking in template <typename Expr> friend rule& operator%=(rule& r, Expr& expr) @@ -272,7 +273,7 @@ namespace boost { namespace spirit { namespace qi template <typename Context, typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_param) const { if (f) { @@ -288,7 +289,7 @@ namespace boost { namespace spirit { namespace qi typename make_attribute::type, attr_type, domain> transform; - typename make_attribute::type made_attr = make_attribute::call(attr); + typename make_attribute::type made_attr = make_attribute::call(attr_param); typename transform::type attr_ = transform::pre(made_attr); // If you are seeing a compilation error here, you are probably @@ -304,12 +305,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, attr_); + traits::post_transform(attr_param, attr_); return true; } // inform attribute transformation of failed rhs - traits::fail_transform(attr, attr_); + traits::fail_transform(attr_param, attr_); } return false; } @@ -318,7 +319,7 @@ namespace boost { namespace spirit { namespace qi , typename Attribute, typename Params> bool parse(Iterator& first, Iterator const& last , Context& caller_context, Skipper const& skipper - , Attribute& attr, Params const& params) const + , Attribute& attr_param, Params const& params) const { if (f) { @@ -334,7 +335,7 @@ namespace boost { namespace spirit { namespace qi typename make_attribute::type, attr_type, domain> transform; - typename make_attribute::type made_attr = make_attribute::call(attr); + typename make_attribute::type made_attr = make_attribute::call(attr_param); typename transform::type attr_ = transform::pre(made_attr); // If you are seeing a compilation error here, you are probably @@ -350,12 +351,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, attr_); + traits::post_transform(attr_param, attr_); return true; } // inform attribute transformation of failed rhs - traits::fail_transform(attr, attr_); + traits::fail_transform(attr_param, attr_); } return false; } diff --git a/boost/spirit/home/qi/nonterminal/success_handler.hpp b/boost/spirit/home/qi/nonterminal/success_handler.hpp index 3b3133c7fb..5db83a2aa3 100644 --- a/boost/spirit/home/qi/nonterminal/success_handler.hpp +++ b/boost/spirit/home/qi/nonterminal/success_handler.hpp @@ -29,9 +29,9 @@ namespace boost { namespace spirit { namespace qi )> function_type; - success_handler(function_type subject, F f) - : subject(subject) - , f(f) + success_handler(function_type subject_, F f_) + : subject(subject_) + , f(f_) { } diff --git a/boost/spirit/home/qi/numeric/bool.hpp b/boost/spirit/home/qi/numeric/bool.hpp index 4041fc388d..74e1343918 100644 --- a/boost/spirit/home/qi/numeric/bool.hpp +++ b/boost/spirit/home/qi/numeric/bool.hpp @@ -153,11 +153,11 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { typedef detail::bool_impl<T, BoolPolicies> extract; qi::skip_over(first, last, skipper); - return extract::parse(first, last, attr, BoolPolicies()); + return extract::parse(first, last, attr_, BoolPolicies()); } template <typename Context> @@ -184,11 +184,11 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { typedef detail::bool_impl<T, BoolPolicies> extract; qi::skip_over(first, last, skipper); - return extract::parse(first, last, attr, BoolPolicies(), n_, n_); + return extract::parse(first, last, attr_, BoolPolicies(), n_, n_); } template <typename Context> diff --git a/boost/spirit/home/qi/numeric/bool_policies.hpp b/boost/spirit/home/qi/numeric/bool_policies.hpp index 1e7c6e5164..62641a6036 100644 --- a/boost/spirit/home/qi/numeric/bool_policies.hpp +++ b/boost/spirit/home/qi/numeric/bool_policies.hpp @@ -24,11 +24,11 @@ namespace boost { namespace spirit { namespace qi { template <typename Iterator, typename Attribute> static bool - parse_true(Iterator& first, Iterator const& last, Attribute& attr) + parse_true(Iterator& first, Iterator const& last, Attribute& attr_) { if (detail::string_parse("true", first, last, unused)) { - spirit::traits::assign_to(T(true), attr); // result is true + spirit::traits::assign_to(T(true), attr_); // result is true return true; } return false; @@ -36,11 +36,11 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Attribute> static bool - parse_false(Iterator& first, Iterator const& last, Attribute& attr) + parse_false(Iterator& first, Iterator const& last, Attribute& attr_) { if (detail::string_parse("false", first, last, unused)) { - spirit::traits::assign_to(T(false), attr); // result is false + spirit::traits::assign_to(T(false), attr_); // result is false return true; } return false; @@ -53,11 +53,11 @@ namespace boost { namespace spirit { namespace qi { template <typename Iterator, typename Attribute> static bool - parse_true(Iterator& first, Iterator const& last, Attribute& attr) + parse_true(Iterator& first, Iterator const& last, Attribute& attr_) { if (detail::string_parse("true", "TRUE", first, last, unused)) { - spirit::traits::assign_to(T(true), attr); // result is true + spirit::traits::assign_to(T(true), attr_); // result is true return true; } return false; @@ -65,11 +65,11 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Attribute> static bool - parse_false(Iterator& first, Iterator const& last, Attribute& attr) + parse_false(Iterator& first, Iterator const& last, Attribute& attr_) { if (detail::string_parse("false", "FALSE", first, last, unused)) { - spirit::traits::assign_to(T(false), attr); // result is false + spirit::traits::assign_to(T(false), attr_); // result is false return true; } return false; diff --git a/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp b/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp index f57c4d7214..5137f87f10 100644 --- a/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp +++ b/boost/spirit/home/qi/numeric/detail/numeric_utils.hpp @@ -19,6 +19,7 @@ #include <boost/spirit/home/support/unused.hpp> #include <boost/spirit/home/qi/detail/attributes.hpp> #include <boost/spirit/home/support/char_encoding/ascii.hpp> +#include <boost/spirit/home/support/numeric_traits.hpp> #include <boost/preprocessor/repetition/repeat.hpp> #include <boost/preprocessor/iteration/local.hpp> #include <boost/preprocessor/comparison/less.hpp> @@ -227,7 +228,7 @@ namespace boost { namespace spirit { namespace qi { namespace detail ( (MaxDigits < 0) || (MaxDigits > digits_traits<T, Radix>::value) ) - && std::numeric_limits<T>::is_modulo + && traits::check_overflow<T>::value >() ); } diff --git a/boost/spirit/home/qi/numeric/int.hpp b/boost/spirit/home/qi/numeric/int.hpp index a30bb3f15d..68e214cef7 100644 --- a/boost/spirit/home/qi/numeric/int.hpp +++ b/boost/spirit/home/qi/numeric/int.hpp @@ -19,6 +19,7 @@ #include <boost/spirit/home/qi/parser.hpp> #include <boost/spirit/home/support/common_terminals.hpp> #include <boost/spirit/home/support/info.hpp> +#include <boost/spirit/home/support/detail/is_spirit_tag.hpp> #include <boost/mpl/assert.hpp> #include <boost/type_traits/is_same.hpp> @@ -28,7 +29,10 @@ namespace boost { namespace spirit { template <typename T, unsigned Radix, unsigned MinDigits , int MaxDigits> - struct int_parser {}; + struct int_parser + { + BOOST_SPIRIT_IS_TAG() + }; } namespace qi @@ -198,11 +202,11 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { typedef extract_int<T, Radix, MinDigits, MaxDigits> extract; qi::skip_over(first, last, skipper); - return extract::call(first, last, attr); + return extract::call(first, last, attr_); } template <typename Context> @@ -236,7 +240,7 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_param) const { typedef extract_int<T, Radix, MinDigits, MaxDigits> extract; qi::skip_over(first, last, skipper); @@ -246,7 +250,7 @@ namespace boost { namespace spirit { namespace qi if (extract::call(first, last, attr_) && (attr_ == n_)) { - traits::assign_to(attr_, attr); + traits::assign_to(attr_, attr_param); return true; } diff --git a/boost/spirit/home/qi/numeric/numeric_utils.hpp b/boost/spirit/home/qi/numeric/numeric_utils.hpp index 72a54d8fd4..eebf40a0fa 100644 --- a/boost/spirit/home/qi/numeric/numeric_utils.hpp +++ b/boost/spirit/home/qi/numeric/numeric_utils.hpp @@ -53,7 +53,7 @@ namespace boost { namespace spirit { namespace qi not_supported_radix, ()); template <typename Iterator> - inline static bool call(Iterator& first, Iterator const& last, T& attr) + inline static bool call(Iterator& first, Iterator const& last, T& attr_) { if (first == last) return false; @@ -69,7 +69,7 @@ namespace boost { namespace spirit { namespace qi Iterator save = first; if (!extract_type::parse(first, last, - detail::cast_unsigned<T>::call(attr))) + detail::cast_unsigned<T>::call(attr_))) { first = save; return false; @@ -81,10 +81,10 @@ namespace boost { namespace spirit { namespace qi inline static bool call(Iterator& first, Iterator const& last, Attribute& attr_) { // this case is called when Attribute is not T - T attr; - if (call(first, last, attr)) + T attr_local; + if (call(first, last, attr_local)) { - traits::assign_to(attr, attr_); + traits::assign_to(attr_local, attr_); return true; } return false; @@ -103,7 +103,7 @@ namespace boost { namespace spirit { namespace qi not_supported_radix, ()); template <typename Iterator> - inline static bool call(Iterator& first, Iterator const& last, T& attr) + inline static bool call(Iterator& first, Iterator const& last, T& attr_) { if (first == last) return false; @@ -119,9 +119,9 @@ namespace boost { namespace spirit { namespace qi Iterator save = first; bool hit = extract_sign(first, last); if (hit) - hit = extract_neg_type::parse(first, last, attr); + hit = extract_neg_type::parse(first, last, attr_); else - hit = extract_pos_type::parse(first, last, attr); + hit = extract_pos_type::parse(first, last, attr_); if (!hit) { @@ -135,10 +135,10 @@ namespace boost { namespace spirit { namespace qi inline static bool call(Iterator& first, Iterator const& last, Attribute& attr_) { // this case is called when Attribute is not T - T attr; - if (call(first, last, attr)) + T attr_local; + if (call(first, last, attr_local)) { - traits::assign_to(attr, attr_); + traits::assign_to(attr_local, attr_); return true; } return false; diff --git a/boost/spirit/home/qi/numeric/real.hpp b/boost/spirit/home/qi/numeric/real.hpp index 325acd5ad7..27d48e50aa 100644 --- a/boost/spirit/home/qi/numeric/real.hpp +++ b/boost/spirit/home/qi/numeric/real.hpp @@ -161,24 +161,24 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Context, typename Skipper> bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper - , T& attr) const + , T& attr_) const { typedef detail::real_impl<T, RealPolicies> extract; qi::skip_over(first, last, skipper); - return extract::parse(first, last, attr, RealPolicies()); + return extract::parse(first, last, attr_, RealPolicies()); } template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_param) const { // this case is called when Attribute is not T T attr_; if (parse(first, last, context, skipper, attr_)) { - traits::assign_to(attr_, attr); + traits::assign_to(attr_, attr_param); return true; } return false; @@ -207,8 +207,8 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper - , Attribute& attr) const + , Context&, Skipper const& skipper + , Attribute& attr_param) const { typedef detail::real_impl<T, RealPolicies> extract; qi::skip_over(first, last, skipper); @@ -219,7 +219,7 @@ namespace boost { namespace spirit { namespace qi if (extract::parse(first, last, attr_, RealPolicies()) && (attr_ == n_)) { - traits::assign_to(attr_, attr); + traits::assign_to(attr_, attr_param); return true; } diff --git a/boost/spirit/home/qi/numeric/real_policies.hpp b/boost/spirit/home/qi/numeric/real_policies.hpp index 6512d6f3f7..d4f5654b5b 100644 --- a/boost/spirit/home/qi/numeric/real_policies.hpp +++ b/boost/spirit/home/qi/numeric/real_policies.hpp @@ -37,9 +37,9 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Attribute> static bool - parse_n(Iterator& first, Iterator const& last, Attribute& attr) + parse_n(Iterator& first, Iterator const& last, Attribute& attr_) { - return extract_uint<T, 10, 1, -1>::call(first, last, attr); + return extract_uint<T, 10, 1, -1>::call(first, last, attr_); } template <typename Iterator> @@ -54,9 +54,9 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Attribute> static bool - parse_frac_n(Iterator& first, Iterator const& last, Attribute& attr) + parse_frac_n(Iterator& first, Iterator const& last, Attribute& attr_) { - return extract_uint<T, 10, 1, -1, true>::call(first, last, attr); + return extract_uint<T, 10, 1, -1, true>::call(first, last, attr_); } template <typename Iterator> @@ -71,9 +71,9 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator> static bool - parse_exp_n(Iterator& first, Iterator const& last, int& attr) + parse_exp_n(Iterator& first, Iterator const& last, int& attr_) { - return extract_int<int, 10, 1, -1>::call(first, last, attr); + return extract_int<int, 10, 1, -1>::call(first, last, attr_); } /////////////////////////////////////////////////////////////////////// @@ -105,7 +105,7 @@ namespace boost { namespace spirit { namespace qi /////////////////////////////////////////////////////////////////////// template <typename Iterator, typename Attribute> static bool - parse_nan(Iterator& first, Iterator const& last, Attribute& attr) + parse_nan(Iterator& first, Iterator const& last, Attribute& attr_) { if (first == last) return false; // end of input reached @@ -116,7 +116,7 @@ namespace boost { namespace spirit { namespace qi // nan[(...)] ? if (detail::string_parse("nan", "NAN", first, last, unused)) { - if (*first == '(') + if (first != last && *first == '(') { // skip trailing (...) part Iterator i = first; @@ -128,7 +128,7 @@ namespace boost { namespace spirit { namespace qi first = ++i; } - attr = std::numeric_limits<T>::quiet_NaN(); + attr_ = std::numeric_limits<T>::quiet_NaN(); return true; } return false; @@ -136,7 +136,7 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Attribute> static bool - parse_inf(Iterator& first, Iterator const& last, Attribute& attr) + parse_inf(Iterator& first, Iterator const& last, Attribute& attr_) { if (first == last) return false; // end of input reached @@ -149,7 +149,7 @@ namespace boost { namespace spirit { namespace qi { // skip allowed 'inity' part of infinity detail::string_parse("inity", "INITY", first, last, unused); - attr = std::numeric_limits<T>::infinity(); + attr_ = std::numeric_limits<T>::infinity(); return true; } return false; diff --git a/boost/spirit/home/qi/numeric/uint.hpp b/boost/spirit/home/qi/numeric/uint.hpp index ea763d356c..f6d1efde37 100644 --- a/boost/spirit/home/qi/numeric/uint.hpp +++ b/boost/spirit/home/qi/numeric/uint.hpp @@ -235,11 +235,11 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { typedef extract_uint<T, Radix, MinDigits, MaxDigits> extract; qi::skip_over(first, last, skipper); - return extract::call(first, last, attr); + return extract::call(first, last, attr_); } template <typename Context> @@ -273,7 +273,7 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_param) const { typedef extract_uint<T, Radix, MinDigits, MaxDigits> extract; qi::skip_over(first, last, skipper); @@ -283,7 +283,7 @@ namespace boost { namespace spirit { namespace qi if (extract::call(first, last, attr_) && (attr_ == n_)) { - traits::assign_to(attr_, attr); + traits::assign_to(attr_, attr_param); return true; } diff --git a/boost/spirit/home/qi/operator/alternative.hpp b/boost/spirit/home/qi/operator/alternative.hpp index 9785d45101..22cfdeff56 100644 --- a/boost/spirit/home/qi/operator/alternative.hpp +++ b/boost/spirit/home/qi/operator/alternative.hpp @@ -63,17 +63,17 @@ namespace boost { namespace spirit { namespace qi type; }; - alternative(Elements const& elements) - : elements(elements) {} + alternative(Elements const& elements_) + : elements(elements_) {} template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { detail::alternative_function<Iterator, Context, Skipper, Attribute> - f(first, last, context, skipper, attr); + f(first, last, context, skipper, attr_); // return true if *any* of the parsers succeed return fusion::any(elements, f); diff --git a/boost/spirit/home/qi/operator/and_predicate.hpp b/boost/spirit/home/qi/operator/and_predicate.hpp index 031ce1df01..0554c10d6d 100644 --- a/boost/spirit/home/qi/operator/and_predicate.hpp +++ b/boost/spirit/home/qi/operator/and_predicate.hpp @@ -43,8 +43,8 @@ namespace boost { namespace spirit { namespace qi typedef unused_type type; }; - and_predicate(Subject const& subject) - : subject(subject) {} + and_predicate(Subject const& subject_) + : subject(subject_) {} template <typename Iterator, typename Context , typename Skipper, typename Attribute> diff --git a/boost/spirit/home/qi/operator/difference.hpp b/boost/spirit/home/qi/operator/difference.hpp index 5f8c4c90cc..f703d7f9e5 100644 --- a/boost/spirit/home/qi/operator/difference.hpp +++ b/boost/spirit/home/qi/operator/difference.hpp @@ -46,14 +46,14 @@ namespace boost { namespace spirit { namespace qi type; }; - difference(Left const& left, Right const& right) - : left(left), right(right) {} + difference(Left const& left_, Right const& right_) + : left(left_), right(right_) {} template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { // Unlike classic Spirit, with this version of difference, the rule // lit("policeman") - "police" will always fail to match. @@ -71,7 +71,7 @@ namespace boost { namespace spirit { namespace qi return false; } // RHS fails, now try LHS - return left.parse(first, last, context, skipper, attr); + return left.parse(first, last, context, skipper, attr_); } template <typename Context> diff --git a/boost/spirit/home/qi/operator/expect.hpp b/boost/spirit/home/qi/operator/expect.hpp index c42b2defc9..ff279fd5d1 100644 --- a/boost/spirit/home/qi/operator/expect.hpp +++ b/boost/spirit/home/qi/operator/expect.hpp @@ -39,9 +39,9 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator> struct expectation_failure : std::runtime_error { - expectation_failure(Iterator first, Iterator last, info const& what) + expectation_failure(Iterator first_, Iterator last_, info const& what) : std::runtime_error("boost::spirit::qi::expectation_failure") - , first(first), last(last), what_(what) + , first(first_), last(last_), what_(what) {} ~expectation_failure() throw() {} diff --git a/boost/spirit/home/qi/operator/kleene.hpp b/boost/spirit/home/qi/operator/kleene.hpp index ae778f0bf7..798e63d675 100644 --- a/boost/spirit/home/qi/operator/kleene.hpp +++ b/boost/spirit/home/qi/operator/kleene.hpp @@ -56,8 +56,8 @@ namespace boost { namespace spirit { namespace qi type; }; - kleene(Subject const& subject) - : subject(subject) {} + kleene(Subject const& subject_) + : subject(subject_) {} template <typename F> bool parse_container(F f) const @@ -71,17 +71,17 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { // ensure the attribute is actually a container type - traits::make_container(attr); + traits::make_container(attr_); typedef detail::fail_function<Iterator, Context, Skipper> fail_function; Iterator iter = first; fail_function f(iter, last, context, skipper); - parse_container(detail::make_pass_container(f, attr)); + parse_container(detail::make_pass_container(f, attr_)); first = f.first; return true; diff --git a/boost/spirit/home/qi/operator/list.hpp b/boost/spirit/home/qi/operator/list.hpp index cc067cd342..c5b3ef6cd3 100644 --- a/boost/spirit/home/qi/operator/list.hpp +++ b/boost/spirit/home/qi/operator/list.hpp @@ -55,8 +55,8 @@ namespace boost { namespace spirit { namespace qi type; }; - list(Left const& left, Right const& right) - : left(left), right(right) {} + list(Left const& left_, Right const& right_) + : left(left_), right(right_) {} template <typename F> bool parse_container(F f) const @@ -80,17 +80,17 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { typedef detail::fail_function<Iterator, Context, Skipper> fail_function; // ensure the attribute is actually a container type - traits::make_container(attr); + traits::make_container(attr_); Iterator iter = first; fail_function f(iter, last, context, skipper); - if (!parse_container(detail::make_pass_container(f, attr))) + if (!parse_container(detail::make_pass_container(f, attr_))) return false; first = f.first; diff --git a/boost/spirit/home/qi/operator/not_predicate.hpp b/boost/spirit/home/qi/operator/not_predicate.hpp index 57cbb0db4a..1fb81cd6e0 100644 --- a/boost/spirit/home/qi/operator/not_predicate.hpp +++ b/boost/spirit/home/qi/operator/not_predicate.hpp @@ -42,8 +42,8 @@ namespace boost { namespace spirit { namespace qi typedef unused_type type; }; - not_predicate(Subject const& subject) - : subject(subject) {} + not_predicate(Subject const& subject_) + : subject(subject_) {} template <typename Iterator, typename Context , typename Skipper, typename Attribute> diff --git a/boost/spirit/home/qi/operator/optional.hpp b/boost/spirit/home/qi/operator/optional.hpp index b183ad6f60..0f7698de72 100644 --- a/boost/spirit/home/qi/operator/optional.hpp +++ b/boost/spirit/home/qi/operator/optional.hpp @@ -55,23 +55,23 @@ namespace boost { namespace spirit { namespace qi type; }; - optional(Subject const& subject) - : subject(subject) {} + optional(Subject const& subject_) + : subject(subject_) {} template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse_impl(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr, mpl::false_) const + , Attribute& attr_, mpl::false_) const { // create a local value if Attribute is not unused_type - typename spirit::result_of::optional_value<Attribute>::type val = + typename spirit::result_of::optional_value<Attribute>::type val = typename spirit::result_of::optional_value<Attribute>::type(); if (subject.parse(first, last, context, skipper, val)) { // assign the parsed value into our attribute - spirit::traits::assign_to(val, attr); + spirit::traits::assign_to(val, attr_); } return true; } @@ -80,9 +80,9 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse_impl(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr, mpl::true_) const + , Attribute& attr_, mpl::true_) const { - subject.parse(first, last, context, skipper, attr); + subject.parse(first, last, context, skipper, attr_); return true; } @@ -90,12 +90,12 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { - typedef typename spirit::result_of::optional_value<Attribute>::type + typedef typename spirit::result_of::optional_value<Attribute>::type attribute_type; - return parse_impl(first, last, context, skipper, attr + return parse_impl(first, last, context, skipper, attr_ , traits::is_container<attribute_type>()); } diff --git a/boost/spirit/home/qi/operator/permutation.hpp b/boost/spirit/home/qi/operator/permutation.hpp index 1dcad89e10..cadfa24e77 100644 --- a/boost/spirit/home/qi/operator/permutation.hpp +++ b/boost/spirit/home/qi/operator/permutation.hpp @@ -62,8 +62,8 @@ namespace boost { namespace spirit { namespace qi type; }; - permutation(Elements const& elements) - : elements(elements) {} + permutation(Elements const& elements_) + : elements(elements_) {} template <typename Iterator, typename Context , typename Skipper, typename Attribute> @@ -82,7 +82,7 @@ namespace boost { namespace spirit { namespace qi } // wrap the attribute in a tuple if it is not a tuple - typename traits::wrap_if_not_tuple<Attribute>::type attr(attr_); + typename traits::wrap_if_not_tuple<Attribute>::type attr_local(attr_); // We have a bool array 'flags' with one flag for each parser. // permute_function sets the slot to true when the corresponding @@ -91,7 +91,7 @@ namespace boost { namespace spirit { namespace qi bool result = false; f.taken = flags.begin(); - while (spirit::any_if_ns(elements, attr, f, predicate())) + while (spirit::any_if_ns(elements, attr_local, f, predicate())) { f.taken = flags.begin(); result = true; diff --git a/boost/spirit/home/qi/operator/plus.hpp b/boost/spirit/home/qi/operator/plus.hpp index 780403a2ca..3c08d1fabe 100644 --- a/boost/spirit/home/qi/operator/plus.hpp +++ b/boost/spirit/home/qi/operator/plus.hpp @@ -53,8 +53,8 @@ namespace boost { namespace spirit { namespace qi type; }; - plus(Subject const& subject) - : subject(subject) {} + plus(Subject const& subject_) + : subject(subject_) {} template <typename F> bool parse_container(F f) const @@ -72,17 +72,17 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { typedef detail::fail_function<Iterator, Context, Skipper> fail_function; // ensure the attribute is actually a container type - traits::make_container(attr); + traits::make_container(attr_); Iterator iter = first; fail_function f(iter, last, context, skipper); - if (!parse_container(detail::make_pass_container(f, attr))) + if (!parse_container(detail::make_pass_container(f, attr_))) return false; first = f.first; diff --git a/boost/spirit/home/qi/operator/sequence_base.hpp b/boost/spirit/home/qi/operator/sequence_base.hpp index 35f45dfaa3..366468602e 100644 --- a/boost/spirit/home/qi/operator/sequence_base.hpp +++ b/boost/spirit/home/qi/operator/sequence_base.hpp @@ -60,8 +60,8 @@ namespace boost { namespace spirit { namespace qi type; }; - sequence_base(Elements const& elements) - : elements(elements) {} + sequence_base(Elements const& elements_) + : elements(elements_) {} // standard case. Attribute is a fusion tuple template <typename Iterator, typename Context @@ -80,11 +80,11 @@ namespace boost { namespace spirit { namespace qi , typename mpl::and_< traits::one_element_sequence<attr_type_> , mpl::not_<traits::one_element_sequence<Attribute> > - >::type - >::type attr(attr_); + >::type + >::type attr_local(attr_); // return false if *any* of the parsers fail - if (spirit::any_if(elements, attr + if (spirit::any_if(elements, attr_local , Derived::fail_function(iter, last, context, skipper), predicate())) return false; first = iter; @@ -118,9 +118,9 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { - return parse_impl(first, last, context, skipper, attr + return parse_impl(first, last, context, skipper, attr_ , traits::is_container<Attribute>()); } diff --git a/boost/spirit/home/qi/operator/sequential_or.hpp b/boost/spirit/home/qi/operator/sequential_or.hpp index 80b86f38e4..a4c9c0ceca 100644 --- a/boost/spirit/home/qi/operator/sequential_or.hpp +++ b/boost/spirit/home/qi/operator/sequential_or.hpp @@ -16,6 +16,7 @@ #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/handles_container.hpp> #include <boost/fusion/include/as_vector.hpp> #include <boost/fusion/include/for_each.hpp> @@ -57,8 +58,8 @@ namespace boost { namespace spirit { namespace qi type; }; - sequential_or(Elements const& elements) - : elements(elements) {} + sequential_or(Elements const& elements_) + : elements(elements_) {} template <typename Iterator, typename Context , typename Skipper, typename Attribute> @@ -71,12 +72,12 @@ namespace boost { namespace spirit { namespace qi f(first, last, context, skipper); // wrap the attribute in a tuple if it is not a tuple - typename traits::wrap_if_not_tuple<Attribute>::type attr(attr_); + 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, f, predicate()); + return spirit::any_if_ns(elements, attr_local, f, predicate()); } template <typename Context> diff --git a/boost/spirit/home/qi/parse_attr.hpp b/boost/spirit/home/qi/parse_attr.hpp index 1933ffb09c..6db33008f1 100644 --- a/boost/spirit/home/qi/parse_attr.hpp +++ b/boost/spirit/home/qi/parse_attr.hpp @@ -62,8 +62,8 @@ namespace boost { namespace spirit { namespace qi BOOST_PP_ENUM(N, BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE, A) > vector_type; - vector_type attr (BOOST_PP_ENUM_PARAMS(N, attr)); - return compile<qi::domain>(expr).parse(first, last, unused, unused, attr); + vector_type lattr (BOOST_PP_ENUM_PARAMS(N, attr)); + return compile<qi::domain>(expr).parse(first, last, unused, unused, lattr); } template <typename Iterator, typename Expr @@ -113,9 +113,9 @@ namespace boost { namespace spirit { namespace qi BOOST_PP_ENUM(N, BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE, A) > vector_type; - vector_type attr (BOOST_PP_ENUM_PARAMS(N, attr)); + vector_type lattr (BOOST_PP_ENUM_PARAMS(N, attr)); if (!compile<qi::domain>(expr).parse( - first, last, unused, skipper_, attr)) + first, last, unused, skipper_, lattr)) return false; if (post_skip == skip_flag::postskip) diff --git a/boost/spirit/home/qi/reference.hpp b/boost/spirit/home/qi/reference.hpp index f6fcabcee1..f1f5c67570 100644 --- a/boost/spirit/home/qi/reference.hpp +++ b/boost/spirit/home/qi/reference.hpp @@ -38,9 +38,9 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { - return ref.get().parse(first, last, context, skipper, attr); + return ref.get().parse(first, last, context, skipper, attr_); } template <typename Context> diff --git a/boost/spirit/home/qi/stream/detail/iterator_source.hpp b/boost/spirit/home/qi/stream/detail/iterator_source.hpp index 8a48eda76d..af53366c0b 100644 --- a/boost/spirit/home/qi/stream/detail/iterator_source.hpp +++ b/boost/spirit/home/qi/stream/detail/iterator_source.hpp @@ -50,17 +50,17 @@ namespace boost { namespace spirit { namespace qi { namespace detail return bytes_read; } - // Write is implemented only to satisfy the requirements of a + // Write is implemented only to satisfy the requirements of a // boost::iostreams::seekable_device. We need to have see support to - // be able to figure out how many characters have been actually + // be able to figure out how many characters have been actually // consumed by the stream. - std::streamsize write(const char*, std::streamsize) + std::streamsize write(const char_type*, std::streamsize) { BOOST_ASSERT(false); // not supported return -1; } - std::streampos seek(boost::iostreams::stream_offset, std::ios_base::seekdir way) + std::streampos seek(boost::iostreams::stream_offset, std::ios_base::seekdir way) { BOOST_ASSERT(way == std::ios_base::cur); // only support queries return pos; // return current position diff --git a/boost/spirit/home/qi/stream/stream.hpp b/boost/spirit/home/qi/stream/stream.hpp index 952f2f976d..83b417df64 100644 --- a/boost/spirit/home/qi/stream/stream.hpp +++ b/boost/spirit/home/qi/stream/stream.hpp @@ -58,23 +58,28 @@ namespace boost { namespace spirit { namespace qi , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper - , Attribute& attr) const + , Attribute& attr_) const { typedef qi::detail::iterator_source<Iterator> source_device; typedef boost::iostreams::stream<source_device> instream; qi::skip_over(first, last, skipper); - instream in(first, last); // copies 'first' - in >> attr; // use existing operator>>() + instream in(first, last); // copies 'first' + in >> attr_; // use existing operator>>() // advance the iterator if everything is ok - if (in.good()) { - std::streamsize pos = in.tellg(); - std::advance(first, pos); + if (in) { + if (!in.eof()) { + std::streamsize pos = in.tellg(); + std::advance(first, pos); + } else { + first = last; + } + return true; } - return in.good() || in.eof(); + return false; } template <typename Context> diff --git a/boost/spirit/home/qi/string/detail/tst.hpp b/boost/spirit/home/qi/string/detail/tst.hpp index 989477d27b..168e4cf03e 100644 --- a/boost/spirit/home/qi/string/detail/tst.hpp +++ b/boost/spirit/home/qi/string/detail/tst.hpp @@ -24,8 +24,8 @@ namespace boost { namespace spirit { namespace qi { namespace detail template <typename Char, typename T> struct tst_node { - tst_node(Char id) - : id(id), data(0), lt(0), eq(0), gt(0) + tst_node(Char id_) + : id(id_), data(0), lt(0), eq(0), gt(0) { } diff --git a/boost/spirit/home/qi/string/lit.hpp b/boost/spirit/home/qi/string/lit.hpp index 1b966c32b5..1e163619c9 100644 --- a/boost/spirit/home/qi/string/lit.hpp +++ b/boost/spirit/home/qi/string/lit.hpp @@ -89,8 +89,8 @@ namespace boost { namespace spirit { namespace qi char_type; typedef std::basic_string<char_type> string_type; - literal_string(typename add_reference<String>::type str) - : str(str) + literal_string(typename add_reference<String>::type str_) + : str(str_) {} template <typename Context, typename Iterator> @@ -104,10 +104,10 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last - , Context& /*context*/, Skipper const& skipper, Attribute& attr) const + , Context& /*context*/, Skipper const& skipper, Attribute& attr_) const { qi::skip_over(first, last, skipper); - return detail::string_parse(str, first, last, attr); + return detail::string_parse(str, first, last, attr_); } template <typename Context> @@ -163,10 +163,10 @@ namespace boost { namespace spirit { namespace qi template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last - , Context& /*context*/, Skipper const& skipper, Attribute& attr) const + , Context& /*context*/, Skipper const& skipper, Attribute& attr_) const { qi::skip_over(first, last, skipper); - return detail::string_parse(str_lo, str_hi, first, last, attr); + return detail::string_parse(str_lo, str_hi, first, last, attr_); } template <typename Context> diff --git a/boost/spirit/home/qi/string/symbols.hpp b/boost/spirit/home/qi/string/symbols.hpp index a9656f1827..081632438c 100644 --- a/boost/spirit/home/qi/string/symbols.hpp +++ b/boost/spirit/home/qi/string/symbols.hpp @@ -166,7 +166,7 @@ namespace boost { namespace spirit { namespace qi return sym.remove(str); } -#if defined(BOOST_NO_RVALUE_REFERENCES) +#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES) // non-const version needed to suppress proto's += kicking in template <typename Str> friend adder const& @@ -257,14 +257,14 @@ public: template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last - , Context& /*context*/, Skipper const& skipper, Attribute& attr) const + , Context& /*context*/, Skipper const& skipper, Attribute& attr_) const { qi::skip_over(first, last, skipper); if (value_type* val_ptr = lookup->find(first, last, Filter())) { - spirit::traits::assign_to(*val_ptr, attr); + spirit::traits::assign_to(*val_ptr, attr_); return true; } return false; @@ -290,8 +290,8 @@ public: template <typename, typename = unused_type, typename = unused_type> struct result { typedef adder const& type; }; - adder(symbols& sym) - : sym(sym) + adder(symbols& sym_) + : sym(sym_) { } @@ -333,8 +333,8 @@ public: template <typename, typename = unused_type, typename = unused_type> struct result { typedef remover const& type; }; - remover(symbols& sym) - : sym(sym) + remover(symbols& sym_) + : sym(sym_) { } diff --git a/boost/spirit/home/qi/string/tst_map.hpp b/boost/spirit/home/qi/string/tst_map.hpp index 0ea838c42e..a3208f2743 100644 --- a/boost/spirit/home/qi/string/tst_map.hpp +++ b/boost/spirit/home/qi/string/tst_map.hpp @@ -54,16 +54,20 @@ namespace boost { namespace spirit { namespace qi Iterator save = first; typename map_type::const_iterator i = map.find(filter(*first++)); - if (i == map.end()) - { - first = save; - return 0; - } - if (T* p = node::find(i->second.root, first, last, filter)) + + if (i != map.end()) { - return p; + if (T* p = node::find(i->second.root, first, last, filter)) + { + return p; + } + + if (i->second.data) + { + return i->second.data; + } } - return i->second.data; + first = save; } return 0; } diff --git a/boost/spirit/home/support/action_dispatch.hpp b/boost/spirit/home/support/action_dispatch.hpp index 7b9bccf097..c17f56dfb8 100644 --- a/boost/spirit/home/support/action_dispatch.hpp +++ b/boost/spirit/home/support/action_dispatch.hpp @@ -15,8 +15,8 @@ #include<boost/config.hpp> -#if !defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_NO_LAMBDAS) && \ - !defined(BOOST_NO_VARIADIC_TEMPLATES) && !defined(BOOST_NO_DECLTYPE) +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_LAMBDAS) && \ + !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_DECLTYPE) #include <utility> #include <type_traits> #endif @@ -30,8 +30,8 @@ namespace boost { namespace spirit { namespace traits template <typename Component> struct action_dispatch { -#if !defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_NO_LAMBDAS) && \ - !defined(BOOST_NO_VARIADIC_TEMPLATES) && !defined(BOOST_NO_DECLTYPE) +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_LAMBDAS) && \ + !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && !defined(BOOST_NO_CXX11_DECLTYPE) // omit function parameters without specializing for each possible // type of callable entity // many thanks to Eelis/##iso-c++ for this contribution diff --git a/boost/spirit/home/support/algorithm/any_if.hpp b/boost/spirit/home/support/algorithm/any_if.hpp index 0ce6d3ff30..c4671cb32c 100644 --- a/boost/spirit/home/support/algorithm/any_if.hpp +++ b/boost/spirit/home/support/algorithm/any_if.hpp @@ -181,7 +181,7 @@ namespace boost { namespace spirit , Last2 const& last2, F& f, mpl::false_) { typename result_of::attribute_value<First1, First2, Last2, Pred>::type - attribute = attribute_value<Pred, First1, Last2>(first2); + attribute = spirit::detail::attribute_value<Pred, First1, Last2>(first2); return f(*first1, attribute) || detail::any_if<Pred>( diff --git a/boost/spirit/home/support/algorithm/any_if_ns.hpp b/boost/spirit/home/support/algorithm/any_if_ns.hpp index 394f365b28..9af0261ed3 100644 --- a/boost/spirit/home/support/algorithm/any_if_ns.hpp +++ b/boost/spirit/home/support/algorithm/any_if_ns.hpp @@ -48,7 +48,7 @@ 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, attribute_value<Pred, First1, Last2>(first2)) | + return (0 != (f(*first1, spirit::detail::attribute_value<Pred, First1, Last2>(first2)) | detail::any_if_ns<Pred>( fusion::next(first1) , attribute_next<Pred, First1, Last2>(first2) diff --git a/boost/spirit/home/support/argument_expression.hpp b/boost/spirit/home/support/argument_expression.hpp index ff5d4cec53..ccf5021dd7 100644 --- a/boost/spirit/home/support/argument_expression.hpp +++ b/boost/spirit/home/support/argument_expression.hpp @@ -21,29 +21,6 @@ namespace boost { namespace spirit namespace expression { -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 - template <int N> - struct argument - { - typedef phoenix::actor<spirit::argument<N> > type; - - static type make() - { - return spirit::argument<N>(); - } - }; - - template <typename Dummy> - struct attribute_context - { - typedef phoenix::actor<spirit::attribute_context<Dummy> > type; - - static type make() - { - return spirit::attribute_context<Dummy>(); - } - }; -#else template <int N> struct argument : phoenix::expression::terminal<spirit::argument<N> > @@ -73,11 +50,9 @@ namespace boost { namespace spirit return e; } }; -#endif } }} -#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 namespace boost { namespace phoenix { namespace result_of @@ -127,6 +102,5 @@ namespace boost { namespace phoenix > {}; }} -#endif // BOOST_SPIRIT_USE_PHOENIX_V3 #endif diff --git a/boost/spirit/home/support/assert_msg.hpp b/boost/spirit/home/support/assert_msg.hpp index db36072917..f1433daac5 100644 --- a/boost/spirit/home/support/assert_msg.hpp +++ b/boost/spirit/home/support/assert_msg.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2001-2011 Hartmut Kaiser +// Copyright (c) 2001-2013 Hartmut Kaiser // // 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) @@ -10,12 +10,21 @@ #pragma once #endif -// Allow to work around the MPL problem in BOOST_MPL_ASSERT_MSG generating -// multiple definition linker errors for certain compilers (VC++) -#if BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG != 0 +#include <boost/config.hpp> + +// Work around the MPL problem in BOOST_MPL_ASSERT_MSG generating +// multiple definition linker errors for certain compilers (VC++ 8). +// BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG can also be defined by user. +#if !defined(BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG) +# if defined(BOOST_MSVC) && BOOST_MSVC < 1500 +# define BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG 1 +# endif +#endif + +#if !defined(BOOST_NO_CXX11_STATIC_ASSERT) || BOOST_SPIRIT_DONT_USE_MPL_ASSERT_MSG != 0 #include <boost/static_assert.hpp> #define BOOST_SPIRIT_ASSERT_MSG(Cond, Msg, Types) \ - BOOST_STATIC_ASSERT(Cond) + BOOST_STATIC_ASSERT_MSG(Cond, # Msg) #else #include <boost/mpl/assert.hpp> #define BOOST_SPIRIT_ASSERT_MSG(Cond, Msg, Types) \ @@ -24,8 +33,22 @@ #define BOOST_SPIRIT_ASSERT_MATCH(Domain, Expr) \ BOOST_SPIRIT_ASSERT_MSG(( \ - boost::spirit::traits::matches<Domain, Expr>::value \ + boost::spirit::traits::matches< Domain, Expr >::value \ ), error_invalid_expression, (Expr)) +// GCC 4.7 will overeagerly instantiate static_asserts in template functions, +// if the assert condition does not depend on template parameters +// (see https://svn.boost.org/trac/boost/ticket/8381). +// There are places where we want to use constant false as the condition in +// template functions to indicate that these function overloads should never +// be called. This allows to generate better error messages. To solve this +// problem we make the condition dependent on the template argument and use +// the following macro in such places. +#include <boost/type_traits/is_same.hpp> + +#define BOOST_SPIRIT_ASSERT_FAIL(TemplateParam, Msg, Types) \ + BOOST_SPIRIT_ASSERT_MSG((!boost::is_same< \ + TemplateParam, TemplateParam >::value), Msg, Types) + #endif diff --git a/boost/spirit/home/support/attributes.hpp b/boost/spirit/home/support/attributes.hpp index 48bff06085..163f11cfe2 100644 --- a/boost/spirit/home/support/attributes.hpp +++ b/boost/spirit/home/support/attributes.hpp @@ -1,6 +1,6 @@ /*============================================================================= Copyright (c) 2001-2011 Joel de Guzman - Copyright (c) 2001-2011 Hartmut Kaiser + Copyright (c) 2001-2012 Hartmut Kaiser 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) @@ -202,6 +202,19 @@ namespace boost { namespace spirit { namespace traits struct is_weak_substitute<T, optional<Expected> > : is_weak_substitute<T, Expected> {}; +#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) + template <typename T, typename Expected> + struct is_weak_substitute<boost::variant<T>, Expected> + : is_weak_substitute<T, Expected> + {}; + + template <typename T0, typename T1, typename ...TN, typename Expected> + struct is_weak_substitute<boost::variant<T0, T1, TN...>, + Expected> + : mpl::bool_<is_weak_substitute<T0, Expected>::type::value && + is_weak_substitute<boost::variant<T1, TN...>, Expected>::type::value> + {}; +#else #define BOOST_SPIRIT_IS_WEAK_SUBSTITUTE(z, N, _) \ is_weak_substitute<BOOST_PP_CAT(T, N), Expected>::type::value && \ /***/ @@ -220,6 +233,7 @@ namespace boost { namespace spirit { namespace traits {}; #undef BOOST_SPIRIT_IS_WEAK_SUBSTITUTE +#endif template <typename T> struct is_weak_substitute<T, T @@ -516,7 +530,30 @@ namespace boost { namespace spirit { namespace traits { if (!val) return 0; - return val.get(); + return traits::size(val.get()); + } + }; + + namespace detail + { + struct attribute_size_visitor : static_visitor<std::size_t> + { + template <typename T> + std::size_t operator()(T const& val) const + { + return spirit::traits::size(val); + } + }; + } + + template <BOOST_VARIANT_ENUM_PARAMS(typename T)> + struct attribute_size<variant<BOOST_VARIANT_ENUM_PARAMS(T)> > + { + typedef std::size_t type; + + static type call(variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& val) + { + return apply_visitor(detail::attribute_size_visitor(), val); } }; @@ -748,7 +785,7 @@ namespace boost { namespace spirit { namespace traits }; // never called, but needed for decltype-based result_of (C++0x) -#ifndef BOOST_NO_RVALUE_REFERENCES +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES template <typename Element> typename result<element_attribute(Element)>::type operator()(Element&&) const; @@ -1158,8 +1195,8 @@ namespace boost { namespace spirit { namespace traits template <typename Out> struct print_fusion_sequence { - print_fusion_sequence(Out& out) - : out(out), is_first(true) {} + print_fusion_sequence(Out& out_) + : out(out_), is_first(true) {} typedef void result_type; @@ -1181,7 +1218,7 @@ namespace boost { namespace spirit { namespace traits template <typename Out> struct print_visitor : static_visitor<> { - print_visitor(Out& out) : out(out) {} + print_visitor(Out& out_) : out(out_) {} template <typename T> void operator()(T const& val) const diff --git a/boost/spirit/home/support/auto.hpp b/boost/spirit/home/support/auto.hpp new file mode 100644 index 0000000000..69aa76094e --- /dev/null +++ b/boost/spirit/home/support/auto.hpp @@ -0,0 +1,35 @@ +/*============================================================================= + Copyright (c) 2001-2012 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_AUTO_FEBRUARY_7_2012_0159PM) +#define BOOST_SPIRIT_AUTO_FEBRUARY_7_2012_0159PM + +#include <boost/config.hpp> +#include <boost/typeof/typeof.hpp> + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/config.hpp> + +// Support for c++11 auto. See: +// http://boost-spirit.com/home/articles/qi-example/zero-to-60-mph-in-2-seconds/ +// for more info + +#if defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) + +#define BOOST_SPIRIT_AUTO(domain_, name, expr) \ + typedef boost::proto::result_of:: \ + deep_copy<BOOST_TYPEOF(expr)>::type name##_expr_type; \ + BOOST_SPIRIT_ASSERT_MATCH( \ + boost::spirit::domain_::domain, name##_expr_type); \ + BOOST_AUTO(name, boost::proto::deep_copy(expr)); \ + /****/ + +#endif + +#endif diff --git a/boost/spirit/home/support/char_encoding/ascii.hpp b/boost/spirit/home/support/char_encoding/ascii.hpp index 9b8a72fc38..8bd6c11350 100644 --- a/boost/spirit/home/support/char_encoding/ascii.hpp +++ b/boost/spirit/home/support/char_encoding/ascii.hpp @@ -188,7 +188,7 @@ namespace boost { namespace spirit { namespace char_encoding return isascii_(ch); } - static int + static bool isalnum(int ch) { BOOST_ASSERT(isascii_(ch)); @@ -196,78 +196,78 @@ namespace boost { namespace spirit { namespace char_encoding || (ascii_char_types[ch] & BOOST_CC_DIGIT); } - static int + static bool isalpha(int ch) { BOOST_ASSERT(isascii_(ch)); - return (ascii_char_types[ch] & BOOST_CC_ALPHA); + return (ascii_char_types[ch] & BOOST_CC_ALPHA) ? true : false; } - static int + static bool isdigit(int ch) { BOOST_ASSERT(isascii_(ch)); - return (ascii_char_types[ch] & BOOST_CC_DIGIT); + return (ascii_char_types[ch] & BOOST_CC_DIGIT) ? true : false; } - static int + static bool isxdigit(int ch) { BOOST_ASSERT(isascii_(ch)); - return (ascii_char_types[ch] & BOOST_CC_XDIGIT); + return (ascii_char_types[ch] & BOOST_CC_XDIGIT) ? true : false; } - static int + static bool iscntrl(int ch) { BOOST_ASSERT(isascii_(ch)); - return (ascii_char_types[ch] & BOOST_CC_CTRL); + return (ascii_char_types[ch] & BOOST_CC_CTRL) ? true : false; } - static int + static bool isgraph(int ch) { return ('\x21' <= ch && ch <= '\x7e'); } - static int + static bool islower(int ch) { BOOST_ASSERT(isascii_(ch)); - return (ascii_char_types[ch] & BOOST_CC_LOWER); + return (ascii_char_types[ch] & BOOST_CC_LOWER) ? true : false; } - static int + static bool isprint(int ch) { return ('\x20' <= ch && ch <= '\x7e'); } - static int + static bool ispunct(int ch) { BOOST_ASSERT(isascii_(ch)); - return (ascii_char_types[ch] & BOOST_CC_PUNCT); + return (ascii_char_types[ch] & BOOST_CC_PUNCT) ? true : false; } - static int + static bool isspace(int ch) { BOOST_ASSERT(isascii_(ch)); - return (ascii_char_types[ch] & BOOST_CC_SPACE); + return (ascii_char_types[ch] & BOOST_CC_SPACE) ? true : false; } - static int + static bool isblank BOOST_PREVENT_MACRO_SUBSTITUTION (int ch) { return ('\x09' == ch || '\x20' == ch); } - static int + static bool isupper(int ch) { BOOST_ASSERT(isascii_(ch)); - return (ascii_char_types[ch] & BOOST_CC_UPPER); + return (ascii_char_types[ch] & BOOST_CC_UPPER) ? true : false; } /////////////////////////////////////////////////////////////////////// diff --git a/boost/spirit/home/support/char_encoding/iso8859_1.hpp b/boost/spirit/home/support/char_encoding/iso8859_1.hpp index 37d2e6f98f..b2b5dd1d8a 100644 --- a/boost/spirit/home/support/char_encoding/iso8859_1.hpp +++ b/boost/spirit/home/support/char_encoding/iso8859_1.hpp @@ -584,7 +584,7 @@ namespace boost { namespace spirit { namespace char_encoding return (0 == (ch & ~0xff) || ~0 == (ch | 0xff)) ? true : false; } - static int + static bool isalnum(int ch) { BOOST_ASSERT(0 == (ch & ~UCHAR_MAX)); @@ -592,78 +592,78 @@ namespace boost { namespace spirit { namespace char_encoding || (iso8859_1_char_types[ch] & BOOST_CC_DIGIT); } - static int + static bool isalpha(int ch) { BOOST_ASSERT(0 == (ch & ~UCHAR_MAX)); - return (iso8859_1_char_types[ch] & BOOST_CC_ALPHA); + return (iso8859_1_char_types[ch] & BOOST_CC_ALPHA) ? true : false; } - static int + static bool isdigit(int ch) { BOOST_ASSERT(0 == (ch & ~UCHAR_MAX)); - return (iso8859_1_char_types[ch] & BOOST_CC_DIGIT); + return (iso8859_1_char_types[ch] & BOOST_CC_DIGIT) ? true : false; } - static int + static bool isxdigit(int ch) { BOOST_ASSERT(0 == (ch & ~UCHAR_MAX)); - return (iso8859_1_char_types[ch] & BOOST_CC_XDIGIT); + return (iso8859_1_char_types[ch] & BOOST_CC_XDIGIT) ? true : false; } - static int + static bool iscntrl(int ch) { BOOST_ASSERT(0 == (ch & ~UCHAR_MAX)); - return (iso8859_1_char_types[ch] & BOOST_CC_CTRL); + return (iso8859_1_char_types[ch] & BOOST_CC_CTRL) ? true : false; } - static int + static bool isgraph(int ch) { return ('\x21' <= ch && ch <= '\x7e') || ('\xa1' <= ch && ch <= '\xff'); } - static int + static bool islower(int ch) { BOOST_ASSERT(0 == (ch & ~UCHAR_MAX)); - return (iso8859_1_char_types[ch] & BOOST_CC_LOWER); + return (iso8859_1_char_types[ch] & BOOST_CC_LOWER) ? true : false; } - static int + static bool isprint(int ch) { return ('\x20' <= ch && ch <= '\x7e') || ('\xa0' <= ch && ch <= '\xff'); } - static int + static bool ispunct(int ch) { BOOST_ASSERT(0 == (ch & ~UCHAR_MAX)); - return (iso8859_1_char_types[ch] & BOOST_CC_PUNCT); + return (iso8859_1_char_types[ch] & BOOST_CC_PUNCT) ? true : false; } - static int + static bool isspace(int ch) { BOOST_ASSERT(0 == (ch & ~UCHAR_MAX)); - return (iso8859_1_char_types[ch] & BOOST_CC_SPACE); + return (iso8859_1_char_types[ch] & BOOST_CC_SPACE) ? true : false; } - static int + static bool isblank BOOST_PREVENT_MACRO_SUBSTITUTION (int ch) { return ('\x09' == ch || '\x20' == ch || '\xa0' == ch); } - static int + static bool isupper(int ch) { BOOST_ASSERT(0 == (ch & ~UCHAR_MAX)); - return (iso8859_1_char_types[ch] & BOOST_CC_UPPER); + return (iso8859_1_char_types[ch] & BOOST_CC_UPPER) ? true : false; } /////////////////////////////////////////////////////////////////////////// diff --git a/boost/spirit/home/support/char_encoding/standard.hpp b/boost/spirit/home/support/char_encoding/standard.hpp index c32a9e73d8..fb307ced45 100644 --- a/boost/spirit/home/support/char_encoding/standard.hpp +++ b/boost/spirit/home/support/char_encoding/standard.hpp @@ -38,81 +38,82 @@ namespace boost { namespace spirit { namespace char_encoding return (0 == (ch & ~0xff) || ~0 == (ch | 0xff)) ? true : false; } - static int + static bool isalnum(int ch) { - return std::isalnum(ch); + return std::isalnum(ch) ? true : false; } - static int + static bool isalpha(int ch) { - return std::isalpha(ch); + return std::isalpha(ch) ? true : false; } - static int + static bool isdigit(int ch) { - return std::isdigit(ch); + return std::isdigit(ch) ? true : false; } - static int + static bool isxdigit(int ch) { - return std::isxdigit(ch); + return std::isxdigit(ch) ? true : false; } - static int + static bool iscntrl(int ch) { - return std::iscntrl(ch); + return std::iscntrl(ch) ? true : false; } - static int + static bool isgraph(int ch) { - return std::isgraph(ch); + return std::isgraph(ch) ? true : false; } - static int + static bool islower(int ch) { - return std::islower(ch); + return std::islower(ch) ? true : false; } - static int + static bool isprint(int ch) { - return std::isprint(ch); + return std::isprint(ch) ? true : false; } - static int + static bool ispunct(int ch) { - return std::ispunct(ch); + return std::ispunct(ch) ? true : false; } - static int + static bool isspace(int ch) { - return std::isspace(ch); + return std::isspace(ch) ? true : false; } - static int + static bool isblank BOOST_PREVENT_MACRO_SUBSTITUTION (int ch) { return (ch == ' ' || ch == '\t'); } - static int + static bool isupper(int ch) { - return std::isupper(ch); + return std::isupper(ch) ? true : false; } /////////////////////////////////////////////////////////////////////////////// // Simple character conversions /////////////////////////////////////////////////////////////////////////////// + static int tolower(int ch) { diff --git a/boost/spirit/home/support/char_encoding/standard_wide.hpp b/boost/spirit/home/support/char_encoding/standard_wide.hpp index 99c918ce56..515a388136 100644 --- a/boost/spirit/home/support/char_encoding/standard_wide.hpp +++ b/boost/spirit/home/support/char_encoding/standard_wide.hpp @@ -154,6 +154,10 @@ namespace boost { namespace spirit { namespace char_encoding return (ch == L' ' || ch == L'\t'); } + /////////////////////////////////////////////////////////////////////// + // Simple character conversions + /////////////////////////////////////////////////////////////////////// + static wchar_t tolower(wchar_t ch) { diff --git a/boost/spirit/home/support/char_encoding/unicode.hpp b/boost/spirit/home/support/char_encoding/unicode.hpp index 9febf7e2a4..b5ec3e6f96 100644 --- a/boost/spirit/home/support/char_encoding/unicode.hpp +++ b/boost/spirit/home/support/char_encoding/unicode.hpp @@ -100,7 +100,7 @@ namespace boost { namespace spirit { namespace char_encoding return ucd::is_white_space(ch); } - static int + static bool isblank BOOST_PREVENT_MACRO_SUBSTITUTION (char_type ch) { return ucd::is_blank(ch); diff --git a/boost/spirit/home/support/char_encoding/unicode/create_tables.cpp b/boost/spirit/home/support/char_encoding/unicode/create_tables.cpp index aa36fb4d93..c4b82b33c8 100644 --- a/boost/spirit/home/support/char_encoding/unicode/create_tables.cpp +++ b/boost/spirit/home/support/char_encoding/unicode/create_tables.cpp @@ -16,6 +16,7 @@ #include <boost/range/iterator_range.hpp> #include <iostream> +#include <iomanip> #include <fstream> #include <vector> #include <algorithm> @@ -49,13 +50,13 @@ struct ucd_range { ucd_range(uint32_t start, uint32_t finish) : start(start), finish(finish) {} - - // we need this so we can use ucd_range as a multimap key + + // we need this so we can use ucd_range as a multimap key friend bool operator<(ucd_range const& a, ucd_range const& b) { return a.start < b.start; } - + uint32_t start; uint32_t finish; }; @@ -89,23 +90,23 @@ public: rule<iterator_type, std::string()> field = *(char_-(';'|endl)) >> (';'|&endl); rule<iterator_type, ucd_line()> line = +(field-endl) >> endl; rule<iterator_type, std::vector<ucd_line>()> file = +(endl | line[push_back(_val, _1)]); - + parse(f, l, file, info); } } - + template <typename Array> void collect(Array& data, int field, bool collect_properties = true) const { BOOST_ASSERT(!info.empty()); ucd_vector::const_iterator current = info.begin(); ucd_vector::const_iterator end = info.end(); - + while (current != end) { std::string range = (*current)[0]; boost::trim(range); - + std::string::const_iterator f = range.begin(); std::string::const_iterator l = range.end(); @@ -113,14 +114,14 @@ public: uint32_t start; uint32_t finish; parse(f, l, hex[ref(start) = ref(finish) = _1] >> -(".." >> hex[ref(finish) = _1])); - + // special case for UnicodeData.txt ranges: if ((*current)[1].find("First>") != std::string::npos) { ++current; BOOST_ASSERT(current != end); BOOST_ASSERT((*current)[1].find("Last>") != std::string::npos); - + std::string range = (*current)[0]; boost::trim(range); f = range.begin(); @@ -128,7 +129,7 @@ public: parse(f, l, hex[ref(finish) = _1]); } - + std::string code; if (field < int(current->size())) code = (*current)[field]; @@ -136,7 +137,7 @@ public: // Only collect properties we are interested in if (collect_properties) // code for properties { - if (!ignore_property(code)) + if (!ignore_property(code)) { for (uint32_t i = start; i <= finish; ++i) data[i] |= map_property(code); @@ -161,7 +162,7 @@ public: ++current; } } - + private: static bool ignore_property(std::string const& p) @@ -169,7 +170,7 @@ private: // We don't handle all properties std::map<std::string, int>& pm = get_property_map(); std::map<std::string, int>::iterator i = pm.find(p); - return i == pm.end(); + return i == pm.end(); } static int @@ -181,7 +182,7 @@ private: return i->second; } - static std::map<std::string, int>& + static std::map<std::string, int>& get_property_map() { // The properties we are interested in: @@ -194,25 +195,25 @@ private: map["Lt"] = 2; map["Lm"] = 3; map["Lo"] = 4; - + map["Mn"] = 8; map["Me"] = 9; map["Mc"] = 10; - + map["Nd"] = 16; map["Nl"] = 17; map["No"] = 18; - + map["Zs"] = 24; map["Zl"] = 25; map["Zp"] = 26; - + map["Cc"] = 32; map["Cf"] = 33; map["Co"] = 34; map["Cs"] = 35; map["Cn"] = 36; - + map["Pd"] = 40; map["Ps"] = 41; map["Pe"] = 42; @@ -220,12 +221,12 @@ private: map["Po"] = 44; map["Pi"] = 45; map["Pf"] = 46; - + map["Sm"] = 48; map["Sc"] = 49; map["Sk"] = 50; map["So"] = 51; - + // Derived Properties. map["Alphabetic"] = 64; map["Uppercase"] = 128; @@ -351,24 +352,24 @@ public: for (uint32_t i = 0; i < full_span; ++i) p[i] = 0; } - + void collect(char const* filename, int field, bool collect_properties = true) { std::cout << "collecting " << filename << std::endl; ucd_info info(filename); info.collect(p, field, collect_properties); } - + void build(std::vector<uint8_t>& stage1, std::vector<T const*>& stage2) - { + { std::cout << "building tables" << std::endl; std::map<block_ptr, std::vector<T const*> > blocks; for (T const* i = p.get(); i < (p.get() + full_span); i += block_size) blocks[block_ptr(i)].push_back(i); - + // Not enough bits to store the block indices. BOOST_ASSERT(blocks.size() < (1 << (sizeof(uint8_t) * 8))); - + typedef std::pair<block_ptr, std::vector<T const*> > blocks_value_type; std::map<T const*, std::vector<T const*> > sorted_blocks; BOOST_FOREACH(blocks_value_type const& val, blocks) @@ -392,9 +393,9 @@ public: } } } - + private: - + struct block_ptr { block_ptr(T const* p) : p(p) {} @@ -404,7 +405,7 @@ private: return std::lexicographical_compare( a.p, a.p + block_size, b.p, b.p + block_size); } - + T const* p; }; @@ -422,7 +423,7 @@ template <typename Out, typename C> void print_table(Out& out, C const& c, bool trailing_comma, int width = 4, int group = 16) { int const tab = 4; - C::size_type size = c.size(); + typename C::size_type size = c.size(); BOOST_ASSERT(size > 1); print_tab(out, tab); out << std::setw(width) << int(c[0]); @@ -436,7 +437,7 @@ void print_table(Out& out, C const& c, bool trailing_comma, int width = 4, int g } out << std::setw(width) << int(c[i]); } - + if (trailing_comma) out << ", " << std::endl; } @@ -444,7 +445,7 @@ void print_table(Out& out, C const& c, bool trailing_comma, int width = 4, int g template <typename Out> void print_head(Out& out) { - out + out << "/*=============================================================================\n" << " Copyright (c) 2001-2011 Joel de Guzman\n" << "\n" @@ -463,7 +464,7 @@ void print_head(Out& out) template <typename Out> void print_tail(Out& out) { - out + out << "\n" << "}}}} // namespace boost::spirit::unicode::detail\n" ; @@ -489,13 +490,13 @@ void print_file(Out& out, Builder& builder, int field_width, char const* name) uint32_t const block_size = Builder::block_size; typedef typename Builder::value_type value_type; print_head(out); - + std::vector<uint8_t> stage1; std::vector<value_type const*> stage2; builder.build(stage1, stage2); std::cout << "Block Size: " << block_size << std::endl; - std::cout << "Total Bytes: " - << stage1.size()+(stage2.size()*block_size*sizeof(value_type)) + std::cout << "Total Bytes: " + << stage1.size()+(stage2.size()*block_size*sizeof(value_type)) << std::endl; out @@ -503,11 +504,11 @@ void print_file(Out& out, Builder& builder, int field_width, char const* name) << " static const ::boost::uint8_t " << name << "_stage1[] = {\n" << "\n" ; - + print_table(out, stage1, false, 3); char const* int_name = get_int_type_name(sizeof(value_type)); - out + out << "\n" << " };" << "\n" @@ -521,17 +522,17 @@ void print_file(Out& out, Builder& builder, int field_width, char const* name) value_type const* p = stage2[i]; bool last = (i+1 == stage2.size()); out << "\n\n // block " << block_n++ << std::endl; - print_table(out, + print_table(out, boost::iterator_range<value_type const*>(p, p+block_size), !last, field_width); } - out + out << "\n" << " };" << "\n" ; - - out + + out << "\n" << " inline " << int_name << ' ' << name << "_lookup(::boost::uint32_t ch)\n" << " {\n" @@ -539,7 +540,7 @@ void print_file(Out& out, Builder& builder, int field_width, char const* name) << " return " << name << "_stage2[block_offset + ch % " << block_size << "];\n" << " }\n" ; - + print_tail(out); } @@ -554,7 +555,7 @@ int main() builder.collect("PropList.txt", 1); print_file(out, builder, 4, "category"); } - + // The script tables { std::ofstream out("script_table.hpp"); @@ -562,7 +563,7 @@ int main() builder.collect("Scripts.txt", 1); print_file(out, builder, 3, "script"); } - + // The lowercase tables { std::ofstream out("lowercase_table.hpp"); @@ -570,7 +571,7 @@ int main() builder.collect("UnicodeData.txt", 13, false); print_file(out, builder, 6, "lowercase"); } - + // The uppercase tables { std::ofstream out("uppercase_table.hpp"); diff --git a/boost/spirit/home/support/char_encoding/unicode/query.hpp b/boost/spirit/home/support/char_encoding/unicode/query.hpp index 3a0526cd75..370ab67d2e 100644 --- a/boost/spirit/home/support/char_encoding/unicode/query.hpp +++ b/boost/spirit/home/support/char_encoding/unicode/query.hpp @@ -284,7 +284,7 @@ namespace boost { namespace spirit { namespace ucd inline properties::script get_script(::boost::uint32_t ch) { - return static_cast<properties::script>(detail::script_lookup(ch) & 0x3F); + return static_cast<properties::script>(detail::script_lookup(ch) & 0x7F); } inline ::boost::uint32_t to_lowercase(::boost::uint32_t ch) diff --git a/boost/spirit/home/support/char_set/range.hpp b/boost/spirit/home/support/char_set/range.hpp index 6d1f661996..1973889645 100644 --- a/boost/spirit/home/support/char_set/range.hpp +++ b/boost/spirit/home/support/char_set/range.hpp @@ -22,7 +22,7 @@ namespace boost { namespace spirit { namespace support { namespace detail typedef T value_type; range() : first(), last() {} - range(T first, T last) : first(first), last(last) {} + range(T first_, T last_) : first(first_), last(last_) {} T first; T last; diff --git a/boost/spirit/home/support/char_set/range_run_impl.hpp b/boost/spirit/home/support/char_set/range_run_impl.hpp index fe91ad8f0d..9dd206454c 100644 --- a/boost/spirit/home/support/char_set/range_run_impl.hpp +++ b/boost/spirit/home/support/char_set/range_run_impl.hpp @@ -13,7 +13,6 @@ #include <boost/spirit/home/support/char_set/range_functions.hpp> #include <boost/assert.hpp> -#include <boost/integer_traits.hpp> #include <algorithm> namespace boost { namespace spirit { namespace support { namespace detail @@ -25,9 +24,6 @@ namespace boost { namespace spirit { namespace support { namespace detail // if *iter intersects with, or is adjacent to, 'range'... if (can_merge(*iter, range)) { - typedef typename Range::value_type value_type; - typedef integer_traits<value_type> integer_traits; - // merge range and *iter merge(*iter, range); diff --git a/boost/spirit/home/support/container.hpp b/boost/spirit/home/support/container.hpp index 7f491aa476..5e154cdb7b 100644 --- a/boost/spirit/home/support/container.hpp +++ b/boost/spirit/home/support/container.hpp @@ -59,6 +59,19 @@ namespace boost { namespace spirit { namespace traits : is_container<T> {}; +#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) + template<typename T> + struct is_container<boost::variant<T> > + : is_container<T> + {}; + + template<typename T0, typename T1, typename ...TN> + struct is_container<boost::variant<T0, T1, TN...> > + : mpl::bool_<is_container<T0>::value || + is_container<boost::variant<T1, TN...> >::value> + {}; + +#else #define BOOST_SPIRIT_IS_CONTAINER(z, N, data) \ is_container<BOOST_PP_CAT(T, N)>::value || \ /***/ @@ -76,6 +89,7 @@ namespace boost { namespace spirit { namespace traits {}; #undef BOOST_SPIRIT_IS_CONTAINER +#endif template <typename T, typename Enable/* = void*/> struct is_iterator_range @@ -238,7 +252,7 @@ namespace boost { namespace spirit { namespace traits static bool is_valid(boost::optional<T> const& val) { - return val; + return !!val; } }; diff --git a/boost/spirit/home/support/context.hpp b/boost/spirit/home/support/context.hpp index b728b4f10d..ada873aa72 100644 --- a/boost/spirit/home/support/context.hpp +++ b/boost/spirit/home/support/context.hpp @@ -98,7 +98,7 @@ namespace boost { namespace spirit typedef Locals locals_type; context(typename Attributes::car_type attribute) - : attributes(attribute, fusion::nil()), locals() {} + : attributes(attribute, fusion::nil_()), locals() {} template <typename Args, typename Context> context( @@ -116,8 +116,8 @@ namespace boost { namespace spirit ) , locals() {} - context(Attributes const& attributes) - : attributes(attributes), locals() {} + context(Attributes const& attributes_) + : attributes(attributes_), locals() {} Attributes attributes; // The attributes Locals locals; // Local variables diff --git a/boost/spirit/home/support/detail/as_variant.hpp b/boost/spirit/home/support/detail/as_variant.hpp index e2fe18d68e..9312042ed7 100644 --- a/boost/spirit/home/support/detail/as_variant.hpp +++ b/boost/spirit/home/support/detail/as_variant.hpp @@ -23,6 +23,7 @@ #include <boost/mpl/push_back.hpp> #include <boost/mpl/equal_to.hpp> #include <boost/mpl/contains.hpp> +#include <boost/mpl/limits/list.hpp> #include <boost/type_traits/is_same.hpp> namespace boost { namespace spirit { namespace detail @@ -30,6 +31,8 @@ namespace boost { namespace spirit { namespace detail template <int size> struct as_variant_impl; +#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) +#else template <> struct as_variant_impl<0> { @@ -39,6 +42,7 @@ namespace boost { namespace spirit { namespace detail typedef variant<> type; }; }; +#endif #define BOOST_FUSION_NEXT_ITERATOR(z, n, data) \ typedef typename fusion::result_of::next<BOOST_PP_CAT(I, n)>::type \ @@ -53,7 +57,13 @@ namespace boost { namespace spirit { namespace detail BOOST_PP_CAT(T, n); #define BOOST_PP_FILENAME_1 <boost/spirit/home/support/detail/as_variant.hpp> + +#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) +#define BOOST_PP_ITERATION_LIMITS (1, BOOST_MPL_LIMIT_LIST_SIZE) +#else #define BOOST_PP_ITERATION_LIMITS (1, BOOST_VARIANT_LIMIT_TYPES) +#endif + #include BOOST_PP_ITERATE() #undef BOOST_FUSION_NEXT_ITERATOR diff --git a/boost/spirit/home/support/detail/endian.hpp b/boost/spirit/home/support/detail/endian.hpp index 85f13dda55..489bb4ce32 100644 --- a/boost/spirit/home/support/detail/endian.hpp +++ b/boost/spirit/home/support/detail/endian.hpp @@ -18,6 +18,12 @@ #define BOOST_ENDIAN_FORCE_PODNESS 1 #endif +// If Boost has the endian library, use it, otherwise use an adapted version +// included with Spirit +// #if BOOST_VERSION >= 105100 +// #include <boost/endian/integers.hpp> +// #else #include <boost/spirit/home/support/detail/endian/endian.hpp> +// #endif #endif diff --git a/boost/spirit/home/support/detail/hold_any.hpp b/boost/spirit/home/support/detail/hold_any.hpp index 4332fa2c08..f9a3ff1bfa 100644 --- a/boost/spirit/home/support/detail/hold_any.hpp +++ b/boost/spirit/home/support/detail/hold_any.hpp @@ -98,7 +98,6 @@ namespace boost { namespace spirit } static void move(void* const* src, void** dest) { - reinterpret_cast<T*>(dest)->~T(); *reinterpret_cast<T*>(dest) = *reinterpret_cast<T const*>(src); } @@ -144,7 +143,6 @@ namespace boost { namespace spirit } static void move(void* const* src, void** dest) { - (*reinterpret_cast<T**>(dest))->~T(); **reinterpret_cast<T**>(dest) = **reinterpret_cast<T* const*>(src); } @@ -300,11 +298,25 @@ namespace boost { namespace spirit } // assignment operator +#ifdef BOOST_HAS_RVALUE_REFS + template <typename T> + basic_hold_any& operator=(T&& x) + { + return assign(std::forward<T>(x)); + } +#else + template <typename T> + basic_hold_any& operator=(T& x) + { + return assign(x); + } + template <typename T> basic_hold_any& operator=(T const& x) { return assign(x); } +#endif // utility functions basic_hold_any& swap(basic_hold_any& x) @@ -405,15 +417,6 @@ namespace boost { namespace spirit { typedef BOOST_DEDUCED_TYPENAME remove_reference<T>::type nonref; -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - // If 'nonref' is still reference type, it means the user has not - // specialized 'remove_reference'. - - // Please use BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION macro - // to generate specialization of remove_reference for your class - // See type traits library documentation for details - BOOST_STATIC_ASSERT(!is_reference<nonref>::value); -#endif nonref* result = any_cast<nonref>(&operand); if(!result) @@ -426,11 +429,6 @@ namespace boost { namespace spirit { typedef BOOST_DEDUCED_TYPENAME remove_reference<T>::type nonref; -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - // The comment in the above version of 'any_cast' explains when this - // assert is fired and what to do. - BOOST_STATIC_ASSERT(!is_reference<nonref>::value); -#endif return any_cast<nonref const&>(const_cast<basic_hold_any<Char> &>(operand)); } diff --git a/boost/spirit/home/support/detail/is_spirit_tag.hpp b/boost/spirit/home/support/detail/is_spirit_tag.hpp index 73269e22e1..e8f9f6dc2a 100644 --- a/boost/spirit/home/support/detail/is_spirit_tag.hpp +++ b/boost/spirit/home/support/detail/is_spirit_tag.hpp @@ -11,10 +11,6 @@ #pragma once #endif -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -#define BOOST_SPIRIT_IS_TAG() -#else #define BOOST_SPIRIT_IS_TAG() typedef void is_spirit_tag; -#endif #endif diff --git a/boost/spirit/home/support/detail/lexer/debug.hpp b/boost/spirit/home/support/detail/lexer/debug.hpp index 23cda87315..36ee1bb706 100644 --- a/boost/spirit/home/support/detail/lexer/debug.hpp +++ b/boost/spirit/home/support/detail/lexer/debug.hpp @@ -31,11 +31,7 @@ public: const CharT *ptr_ = in_.c_str (); std::size_t size_ = in_.size (); -#if defined _MSC_VER && _MSC_VER <= 1200 - out_.erase (); -#else out_.clear (); -#endif while (size_) { diff --git a/boost/spirit/home/support/detail/lexer/file_input.hpp b/boost/spirit/home/support/detail/lexer/file_input.hpp index bf7dba742f..fe5412e005 100644 --- a/boost/spirit/home/support/detail/lexer/file_input.hpp +++ b/boost/spirit/home/support/detail/lexer/file_input.hpp @@ -24,11 +24,7 @@ public: class iterator { public: -#if defined _MSC_VER && _MSC_VER <= 1200 - friend basic_file_input; -#else friend class basic_file_input; -#endif struct data { @@ -132,11 +128,7 @@ public: data _data; }; -#if defined _MSC_VER && _MSC_VER <= 1200 - friend iterator; -#else friend class iterator; -#endif // Make it explict that we are NOT taking a copy of state_machine_! basic_file_input (const basic_state_machine<CharT> *state_machine_, diff --git a/boost/spirit/home/support/detail/lexer/generate_re2c.hpp b/boost/spirit/home/support/detail/lexer/generate_re2c.hpp index dced1f9060..8e76fdbe69 100644 --- a/boost/spirit/home/support/detail/lexer/generate_re2c.hpp +++ b/boost/spirit/home/support/detail/lexer/generate_re2c.hpp @@ -331,11 +331,7 @@ void generate_re2c (const basic_state_machine<CharT> &state_machine_, string_token::escape_char (start_char_, temp_); os_ << "(ch_ >= '" << temp_; -#if defined _MSC_VER && _MSC_VER <= 1200 - temp_.erase (); -#else temp_.clear (); -#endif string_token::escape_char (curr_char_, temp_); os_ << "' && ch_ <= '" << temp_ << "')"; range_ = false; diff --git a/boost/spirit/home/support/detail/lexer/generator.hpp b/boost/spirit/home/support/detail/lexer/generator.hpp index 49bea2fe9c..daa06e7944 100644 --- a/boost/spirit/home/support/detail/lexer/generator.hpp +++ b/boost/spirit/home/support/detail/lexer/generator.hpp @@ -12,6 +12,7 @@ #include "partition/charset.hpp" #include "partition/equivset.hpp" #include <memory> +#include <limits> #include "parser/tree/node.hpp" #include "parser/parser.hpp" #include "containers/ptr_list.hpp" @@ -185,10 +186,10 @@ protected: while (regex_iter_ != regex_iter_end_) { // re-declare var, otherwise we perform an assignment..! - const typename rules::string ®ex_ = *regex_iter_; + const typename rules::string ®ex2_ = *regex_iter_; - root_ = parser::parse (regex_.c_str (), - regex_.c_str () + regex_.size (), *ids_iter_, + root_ = parser::parse (regex2_.c_str (), + regex2_.c_str () + regex2_.size (), *ids_iter_, *unique_ids_iter_, *states_iter_, rules_.flags (), rules_.locale (), node_ptr_vector_, macromap_, token_map_, internals_._seen_BOL_assertion, @@ -336,16 +337,16 @@ protected: equiv_end_ = equivset_->_index_vector.end (); equiv_iter_ != equiv_end_; ++equiv_iter_) { - const std::size_t index_ = *equiv_iter_; + const std::size_t equiv_index_ = *equiv_iter_; - if (index_ == bol_token) + if (equiv_index_ == bol_token) { if (ptr_[eol_index] == 0) { ptr_[bol_index] = transition_; } } - else if (index_ == eol_token) + else if (equiv_index_ == eol_token) { if (ptr_[bol_index] == 0) { @@ -354,7 +355,7 @@ protected: } else { - ptr_[index_ + dfa_offset] = transition_; + ptr_[equiv_index_ + dfa_offset] = transition_; } } } @@ -560,7 +561,12 @@ protected: if (token_._negated) { - CharT curr_char_ = sizeof (CharT) == 1 ? -128 : 0; + // $$$ FIXME JDG July 2014 $$$ + // this code is problematic on platforms where wchar_t is signed + // with min generating negative numbers. This crashes with BAD_ACCESS + // because of the vector index below: + // ptr_[static_cast<typename Traits::index_type>(curr_char_)] + CharT curr_char_ = 0; // (std::numeric_limits<CharT>::min)(); std::size_t i_ = 0; while (curr_ < chars_end_) diff --git a/boost/spirit/home/support/detail/lexer/input.hpp b/boost/spirit/home/support/detail/lexer/input.hpp index a575e6c8c8..e0a5ecc819 100644 --- a/boost/spirit/home/support/detail/lexer/input.hpp +++ b/boost/spirit/home/support/detail/lexer/input.hpp @@ -23,11 +23,7 @@ public: class iterator { public: -#if defined _MSC_VER && _MSC_VER <= 1200 - friend basic_input; -#else friend class basic_input; -#endif struct data { @@ -481,11 +477,7 @@ public: } }; -#if defined _MSC_VER && _MSC_VER <= 1200 - friend iterator; -#else friend class iterator; -#endif // Make it explict that we are NOT taking a copy of state_machine_! basic_input (const basic_state_machine<typename Traits::char_type> diff --git a/boost/spirit/home/support/detail/lexer/size_t.hpp b/boost/spirit/home/support/detail/lexer/size_t.hpp index 349aa6de09..449ff4d858 100644 --- a/boost/spirit/home/support/detail/lexer/size_t.hpp +++ b/boost/spirit/home/support/detail/lexer/size_t.hpp @@ -8,14 +8,6 @@ #include <stddef.h> // ptrdiff_t -#if defined _MSC_VER && _MSC_VER <= 1200 -namespace std -{ - using ::ptrdiff_t; - using ::size_t; -} -#else #include <string> -#endif #endif diff --git a/boost/spirit/home/support/detail/lexer/state_machine.hpp b/boost/spirit/home/support/detail/lexer/state_machine.hpp index e09e9914b9..46e50c9a0a 100644 --- a/boost/spirit/home/support/detail/lexer/state_machine.hpp +++ b/boost/spirit/home/support/detail/lexer/state_machine.hpp @@ -29,11 +29,7 @@ public: class iterator { public: -#if defined _MSC_VER && _MSC_VER <= 1200 - friend basic_state_machine; -#else friend class basic_state_machine; -#endif struct data { @@ -225,11 +221,7 @@ public: } }; -#if defined _MSC_VER && _MSC_VER <= 1200 - friend iterator; -#else friend class iterator; -#endif basic_state_machine () { @@ -365,7 +357,7 @@ private: { const std::size_t col_ = lu_->at (alpha_index_); - if (col_ != dead_state_index) + if (col_ != static_cast<std::size_t>(dead_state_index)) { chars_[col_ - dfa_offset] += static_cast<CharT> (alpha_index_); diff --git a/boost/spirit/home/support/detail/lexer/string_token.hpp b/boost/spirit/home/support/detail/lexer/string_token.hpp index 6bfa6ff1a5..dd58c986b5 100644 --- a/boost/spirit/home/support/detail/lexer/string_token.hpp +++ b/boost/spirit/home/support/detail/lexer/string_token.hpp @@ -10,6 +10,7 @@ #include "size_t.hpp" #include "consts.hpp" // num_chars, num_wchar_ts #include <string> +#include <limits> namespace boost { @@ -55,11 +56,7 @@ struct basic_string_token if (_charset.length () == max_chars_) { _negated = !_negated; -#if defined _MSC_VER && _MSC_VER <= 1200 - _charset.erase (); -#else _charset.clear (); -#endif } else if (_charset.length () > max_chars_ / 2) { @@ -71,7 +68,7 @@ struct basic_string_token { const std::size_t max_chars_ = sizeof (CharT) == 1 ? num_chars : num_wchar_ts; - CharT curr_char_ = sizeof (CharT) == 1 ? -128 : 0; + CharT curr_char_ = (std::numeric_limits<CharT>::min)(); string temp_; const CharT *curr_ = _charset.c_str (); const CharT *chars_end_ = curr_ + _charset.size (); @@ -126,11 +123,7 @@ struct basic_string_token void clear () { _negated = false; -#if defined _MSC_VER && _MSC_VER <= 1200 - _charset.erase (); -#else - _charset.clear (); -#endif + _charset.clear (); } void intersect (basic_string_token &rhs_, basic_string_token &overlap_) diff --git a/boost/spirit/home/support/detail/make_cons.hpp b/boost/spirit/home/support/detail/make_cons.hpp index cbbb73b445..0d6b0ae2c6 100644 --- a/boost/spirit/home/support/detail/make_cons.hpp +++ b/boost/spirit/home/support/detail/make_cons.hpp @@ -42,11 +42,10 @@ namespace boost { namespace spirit { namespace detail namespace result_of { - template <typename Car, typename Cdr = fusion::nil> + template <typename Car, typename Cdr = fusion::nil_> struct make_cons { - typedef typename as_meta_element<Car>::type car_type; - typedef typename fusion::cons<car_type, Cdr> type; + typedef typename as_meta_element<Car>::type car_type; typedef typename fusion::cons<car_type, Cdr> type; }; } diff --git a/boost/spirit/home/support/detail/scoped_enum_emulation.hpp b/boost/spirit/home/support/detail/scoped_enum_emulation.hpp index 70979a6d2d..1b35043f89 100644 --- a/boost/spirit/home/support/detail/scoped_enum_emulation.hpp +++ b/boost/spirit/home/support/detail/scoped_enum_emulation.hpp @@ -17,8 +17,8 @@ #if BOOST_VERSION >= 104000 # include <boost/detail/scoped_enum_emulation.hpp> #else -# if !defined(BOOST_NO_SCOPED_ENUMS) -# define BOOST_NO_SCOPED_ENUMS +# if !defined(BOOST_NO_CXX11_SCOPED_ENUMS) +# define BOOST_NO_CXX11_SCOPED_ENUMS # endif # define BOOST_SCOPED_ENUM_START(name) struct name { enum enum_type # define BOOST_SCOPED_ENUM_END }; diff --git a/boost/spirit/home/support/detail/what_function.hpp b/boost/spirit/home/support/detail/what_function.hpp index d9678ddca4..179807b1ac 100644 --- a/boost/spirit/home/support/detail/what_function.hpp +++ b/boost/spirit/home/support/detail/what_function.hpp @@ -20,8 +20,8 @@ namespace boost { namespace spirit { namespace detail template <typename Context> struct what_function { - what_function(info& what, Context& context) - : what(what), context(context) + what_function(info& what_, Context& context_) + : what(what_), context(context_) { what.value = std::list<info>(); } diff --git a/boost/spirit/home/support/extended_variant.hpp b/boost/spirit/home/support/extended_variant.hpp index 0a9613ba65..d23ca3d8b2 100644 --- a/boost/spirit/home/support/extended_variant.hpp +++ b/boost/spirit/home/support/extended_variant.hpp @@ -12,8 +12,20 @@ #endif #include <boost/variant.hpp> +#include <boost/mpl/limits/list.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> +#if !defined(BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES) +#define BOOST_SPIRIT_EXTENDED_VARIANT_LIMIT_TYPES BOOST_MPL_LIMIT_LIST_SIZE +#else +#define BOOST_SPIRIT_EXTENDED_VARIANT_LIMIT_TYPES BOOST_VARIANT_LIMIT_TYPES +#endif + +#define BOOST_SPIRIT_EXTENDED_VARIANT_ENUM_PARAMS(T) \ + BOOST_PP_ENUM_PARAMS(BOOST_SPIRIT_EXTENDED_VARIANT_LIMIT_TYPES, T) \ + /**/ + /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { @@ -31,11 +43,13 @@ namespace boost { namespace spirit struct adapted_variant_tag; typedef boost::variant< - BOOST_VARIANT_ENUM_PARAMS(T)> + BOOST_SPIRIT_EXTENDED_VARIANT_ENUM_PARAMS(T)> variant_type; typedef typename variant_type::types types; - typedef extended_variant<BOOST_VARIANT_ENUM_PARAMS(T)> base_type; + typedef extended_variant< + BOOST_SPIRIT_EXTENDED_VARIANT_ENUM_PARAMS(T) + > base_type; extended_variant() : var() {} @@ -43,6 +57,10 @@ namespace boost { namespace spirit extended_variant(T const& var) : var(var) {} + template <typename T> + extended_variant(T& var) + : var(var) {} + template <typename F> typename F::result_type apply_visitor(F const& v) { @@ -83,33 +101,40 @@ namespace boost { namespace spirit namespace boost { - template <typename T, BOOST_VARIANT_ENUM_PARAMS(typename T)> + template <typename T, BOOST_SPIRIT_EXTENDED_VARIANT_ENUM_PARAMS(typename T)> inline T const& - get(boost::spirit::extended_variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& x) + get(boost::spirit::extended_variant< + BOOST_SPIRIT_EXTENDED_VARIANT_ENUM_PARAMS(T)> const& x) { return boost::get<T>(x.get()); } - template <typename T, BOOST_VARIANT_ENUM_PARAMS(typename T)> + template <typename T, BOOST_SPIRIT_EXTENDED_VARIANT_ENUM_PARAMS(typename T)> inline T& - get(boost::spirit::extended_variant<BOOST_VARIANT_ENUM_PARAMS(T)>& x) + get(boost::spirit::extended_variant< + BOOST_SPIRIT_EXTENDED_VARIANT_ENUM_PARAMS(T)>& x) { return boost::get<T>(x.get()); } - template <typename T, BOOST_VARIANT_ENUM_PARAMS(typename T)> + template <typename T, BOOST_SPIRIT_EXTENDED_VARIANT_ENUM_PARAMS(typename T)> inline T const* - get(boost::spirit::extended_variant<BOOST_VARIANT_ENUM_PARAMS(T)> const* x) + get(boost::spirit::extended_variant< + BOOST_SPIRIT_EXTENDED_VARIANT_ENUM_PARAMS(T)> const* x) { return boost::get<T>(&x->get()); } - template <typename T, BOOST_VARIANT_ENUM_PARAMS(typename T)> + template <typename T, BOOST_SPIRIT_EXTENDED_VARIANT_ENUM_PARAMS(typename T)> inline T* - get(boost::spirit::extended_variant<BOOST_VARIANT_ENUM_PARAMS(T)>* x) + get(boost::spirit::extended_variant< + BOOST_SPIRIT_EXTENDED_VARIANT_ENUM_PARAMS(T)>* x) { return boost::get<T>(&x->get()); } } +#undef BOOST_SPIRIT_EXTENDED_VARIANT_ENUM_PARAMS +#undef BOOST_SPIRIT_EXTENDED_VARIANT_LIMIT_TYPES + #endif diff --git a/boost/spirit/home/support/info.hpp b/boost/spirit/home/support/info.hpp index 07018886b5..9b991ac882 100644 --- a/boost/spirit/home/support/info.hpp +++ b/boost/spirit/home/support/info.hpp @@ -28,42 +28,42 @@ namespace boost { namespace spirit // for uniformity. struct info { - struct nil {}; + struct nil_ {}; typedef boost::variant< - nil + nil_ , utf8_string , recursive_wrapper<info> , recursive_wrapper<std::pair<info, info> > - , std::list<info> + , recursive_wrapper<std::list<info> > > value_type; - explicit info(utf8_string const& tag) - : tag(tag), value(nil()) {} + explicit info(utf8_string const& tag_) + : tag(tag_), value(nil_()) {} template <typename T> - info(utf8_string const& tag, T const& value) - : tag(tag), value(value) {} + info(utf8_string const& tag_, T const& value_) + : tag(tag_), value(value_) {} - info(utf8_string const& tag, char value) - : tag(tag), value(utf8_string(1, value)) {} + info(utf8_string const& tag_, char value_) + : tag(tag_), value(utf8_string(1, value_)) {} - info(utf8_string const& tag, wchar_t value) - : tag(tag), value(to_utf8(value)) {} + info(utf8_string const& tag_, wchar_t value_) + : tag(tag_), value(to_utf8(value_)) {} - info(utf8_string const& tag, ucs4_char value) - : tag(tag), value(to_utf8(value)) {} + info(utf8_string const& tag_, ucs4_char value_) + : tag(tag_), value(to_utf8(value_)) {} template <typename Char> - info(utf8_string const& tag, Char const* str) - : tag(tag), value(to_utf8(str)) {} + info(utf8_string const& tag_, Char const* str) + : tag(tag_), value(to_utf8(str)) {} template <typename Char, typename Traits, typename Allocator> - info(utf8_string const& tag + info(utf8_string const& tag_ , std::basic_string<Char, Traits, Allocator> const& str) - : tag(tag), value(to_utf8(str)) {} + : tag(tag_), value(to_utf8(str)) {} utf8_string tag; value_type value; @@ -75,10 +75,10 @@ namespace boost { namespace spirit typedef void result_type; typedef basic_info_walker<Callback> this_type; - basic_info_walker(Callback& callback, utf8_string const& tag, int depth) - : callback(callback), tag(tag), depth(depth) {} + basic_info_walker(Callback& callback_, utf8_string const& tag_, int depth_) + : callback(callback_), tag(tag_), depth(depth_) {} - void operator()(info::nil) const + void operator()(info::nil_) const { callback.element(tag, "", depth); } @@ -128,8 +128,8 @@ namespace boost { namespace spirit { typedef utf8_string string; - simple_printer(Out& out) - : out(out) {} + simple_printer(Out& out_) + : out(out_) {} void element(string const& tag, string const& value, int /*depth*/) const { diff --git a/boost/spirit/home/support/iterators/detail/buffering_input_iterator_policy.hpp b/boost/spirit/home/support/iterators/detail/buffering_input_iterator_policy.hpp index e70af081bc..c5cc430817 100644 --- a/boost/spirit/home/support/iterators/detail/buffering_input_iterator_policy.hpp +++ b/boost/spirit/home/support/iterators/detail/buffering_input_iterator_policy.hpp @@ -48,9 +48,7 @@ namespace boost { namespace spirit { namespace iterator_policies typedef typename boost::detail::iterator_traits<T>::pointer pointer; - typedef - typename boost::detail::iterator_traits<T>::reference - reference; + typedef result_type& reference; typedef result_type value_type; protected: diff --git a/boost/spirit/home/support/iterators/detail/combine_policies.hpp b/boost/spirit/home/support/iterators/detail/combine_policies.hpp index cfac882084..06946b82f7 100644 --- a/boost/spirit/home/support/iterators/detail/combine_policies.hpp +++ b/boost/spirit/home/support/iterators/detail/combine_policies.hpp @@ -21,43 +21,6 @@ namespace boost { namespace spirit { namespace iterator_policies // single multi_pass_policy as required by the multi_pass template /////////////////////////////////////////////////////////////////////////// -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - // without partial template specialization there is nothing much to do in - // terms of empty base optimization anyways... - template <typename T, typename Ownership, typename Checking, - typename Input, typename Storage> - struct multi_pass_unique - : Ownership, Checking, Input, Storage - { - multi_pass_unique() {} - multi_pass_unique(T& x) : Input(x) {} - multi_pass_unique(T const& x) : Input(x) {} - - template <typename MultiPass> - static void destroy(MultiPass& mp) - { - Ownership::destroy(mp); - Checking::destroy(mp); - Input::destroy(mp); - Storage::destroy(mp); - } - - void swap(multi_pass_unique& x) - { - this->Ownership::swap(x); - this->Checking::swap(x); - this->Input::swap(x); - this->Storage::swap(x); - } - - template <typename MultiPass> - inline static void clear_queue(MultiPass& mp) - { - Checking::clear_queue(mp); - Storage::clear_queue(mp); - } - }; -#else /////////////////////////////////////////////////////////////////////////// // select the correct derived classes based on if a policy is empty template <typename T @@ -470,7 +433,6 @@ namespace boost { namespace spirit { namespace iterator_policies inline static bool is_unique(MultiPass const& mp) { return Ownership::is_unique(mp); } }; -#endif /////////////////////////////////////////////////////////////////////////// // the multi_pass_shared structure is used to combine the shared data items diff --git a/boost/spirit/home/support/iterators/detail/multi_pass.hpp b/boost/spirit/home/support/iterators/detail/multi_pass.hpp index 088b39ae42..8f8e6c71d3 100644 --- a/boost/spirit/home/support/iterators/detail/multi_pass.hpp +++ b/boost/spirit/home/support/iterators/detail/multi_pass.hpp @@ -17,29 +17,6 @@ /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace detail { -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - /////////////////////////////////////////////////////////////////////////// - // 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. - /////////////////////////////////////////////////////////////////////////// - template <typename T, typename InputPolicy> - struct iterator_base_creator - { - typedef typename InputPolicy::BOOST_NESTED_TEMPLATE unique<T> input_type; - - typedef boost::iterator < - std::forward_iterator_tag - , typename input_type::value_type - , typename input_type::difference_type - , typename input_type::pointer - , typename input_type::reference - > type; - }; -#endif /////////////////////////////////////////////////////////////////////////// // Default implementations of the different policies to be used with a diff --git a/boost/spirit/home/support/iterators/multi_pass.hpp b/boost/spirit/home/support/iterators/multi_pass.hpp index 2b355bfa6d..3fc244034f 100644 --- a/boost/spirit/home/support/iterators/multi_pass.hpp +++ b/boost/spirit/home/support/iterators/multi_pass.hpp @@ -26,9 +26,6 @@ namespace boost { namespace spirit : private boost::base_from_member< typename Policies::BOOST_NESTED_TEMPLATE shared<T>*> , public Policies::BOOST_NESTED_TEMPLATE unique<T> -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - , typename iterator_base_creator<T, typename Policies::input_policy>::type -#endif { private: // unique and shared data types @@ -41,11 +38,7 @@ namespace boost { namespace spirit // define the types the standard embedded iterator typedefs are taken // from -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - typedef typename iterator_base_creator<Input, T>::type iterator_type; -#else typedef typename policies_base_type::input_policy iterator_type; -#endif public: // standard iterator typedefs diff --git a/boost/spirit/home/support/limits.hpp b/boost/spirit/home/support/limits.hpp index ff53967f1c..8abb4f1400 100644 --- a/boost/spirit/home/support/limits.hpp +++ b/boost/spirit/home/support/limits.hpp @@ -12,17 +12,6 @@ #include <boost/spirit/include/phoenix_core.hpp> -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 - -#if !defined(SPIRIT_ARGUMENTS_LIMIT) -# define SPIRIT_ARGUMENTS_LIMIT PHOENIX_LIMIT -#endif -#if !defined(SPIRIT_ATTRIBUTES_LIMIT) -# define SPIRIT_ATTRIBUTES_LIMIT PHOENIX_LIMIT -#endif - -#else - #if !defined(SPIRIT_ARGUMENTS_LIMIT) # define SPIRIT_ARGUMENTS_LIMIT BOOST_PHOENIX_LIMIT #endif @@ -31,5 +20,3 @@ #endif #endif - -#endif diff --git a/boost/spirit/home/support/make_component.hpp b/boost/spirit/home/support/make_component.hpp index 04a743763d..3868475c6e 100644 --- a/boost/spirit/home/support/make_component.hpp +++ b/boost/spirit/home/support/make_component.hpp @@ -258,7 +258,7 @@ namespace boost { namespace spirit { namespace detail typedef typename proto::reverse_fold_tree< proto::_ - , proto::make<fusion::nil> + , proto::make<fusion::nil_> , make_binary_helper<Grammar> >::template impl<Expr, State, Data> reverse_fold_tree; @@ -362,13 +362,6 @@ namespace boost { namespace spirit { namespace detail )>::type lhs_component; -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 - typedef typename - proto::result_of::value< - typename proto::result_of::child_c<Expr, 1>::type - >::type - rhs_component; -#else typedef typename mpl::eval_if_c< phoenix::is_actor< @@ -380,7 +373,6 @@ namespace boost { namespace spirit { namespace detail > >::type rhs_component; -#endif typedef typename result_of::make_cons< @@ -396,24 +388,6 @@ namespace boost { namespace spirit { namespace detail result<make_component_(elements_type, Data)>::type result_type; -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 - result_type operator()( - typename impl::expr_param expr - , typename impl::state_param state - , typename impl::data_param data - ) const - { - elements_type elements = - detail::make_cons( - Grammar()( - proto::child_c<0>(expr), state, data) // LHS - , detail::make_cons( - proto::value(proto::child_c<1>(expr))) // RHS - ); - - return make_component_()(elements, data); - } -#else result_type operator()( typename impl::expr_param expr , typename impl::state_param state @@ -466,7 +440,6 @@ namespace boost { namespace spirit { namespace detail return make_component_()(elements, data); } -#endif }; }; }}} diff --git a/boost/spirit/home/support/nonterminal/expand_arg.hpp b/boost/spirit/home/support/nonterminal/expand_arg.hpp index f037acce24..f214096be1 100644 --- a/boost/spirit/home/support/nonterminal/expand_arg.hpp +++ b/boost/spirit/home/support/nonterminal/expand_arg.hpp @@ -50,8 +50,8 @@ namespace boost { namespace spirit { namespace detail struct result<F(A0&)> : result_type<A0> {}; - expand_arg(Context& context) - : context(context) + expand_arg(Context& context_) + : context(context_) { } diff --git a/boost/spirit/home/support/numeric_traits.hpp b/boost/spirit/home/support/numeric_traits.hpp index 3a5dce88ee..01771dd982 100644 --- a/boost/spirit/home/support/numeric_traits.hpp +++ b/boost/spirit/home/support/numeric_traits.hpp @@ -12,6 +12,8 @@ #include <boost/config.hpp> #include <boost/mpl/bool.hpp> +#include <boost/integer_traits.hpp> +#include <boost/utility/enable_if.hpp> namespace boost { namespace spirit { namespace traits { @@ -113,6 +115,13 @@ namespace boost { namespace spirit { namespace traits template <typename T, typename Enable = void> struct is_infinite; + + template <typename T, typename Enable = void> + struct check_overflow : mpl::false_ {}; + + template <typename T> + struct check_overflow<T, typename enable_if_c<integer_traits<T>::is_integral>::type> + : mpl::true_ {}; }}} #endif diff --git a/boost/spirit/home/support/terminal.hpp b/boost/spirit/home/support/terminal.hpp index d52fad2c3a..3ef8c83ae2 100644 --- a/boost/spirit/home/support/terminal.hpp +++ b/boost/spirit/home/support/terminal.hpp @@ -33,10 +33,10 @@ namespace boost { namespace spirit typedef Terminal terminal_type; typedef Args args_type; - terminal_ex(Args const& args) - : args(args) {} - terminal_ex(Args const& args, Terminal const& term) - : args(args), term(term) {} + terminal_ex(Args const& args_) + : args(args_) {} + terminal_ex(Args const& args_, Terminal const& term_) + : args(args_), term(term_) {} Args args; // Args is guaranteed to be a fusion::vectorN so you // can use that template for detection and specialization @@ -50,10 +50,10 @@ namespace boost { namespace spirit typedef Actor actor_type; static int const arity = Arity; - lazy_terminal(Actor const& actor) - : actor(actor) {} - lazy_terminal(Actor const& actor, Terminal const& term) - : actor(actor), term(term) {} + lazy_terminal(Actor const& actor_) + : actor(actor_) {} + lazy_terminal(Actor const& actor_, Terminal const& term_) + : actor(actor_), term(term_) {} Actor actor; Terminal term; @@ -104,11 +104,11 @@ namespace boost { namespace spirit typedef result_type type; result_type - operator()(F f, A0 const& _0) const + operator()(F f, A0 const& _0_) const { typedef typename result_type::proto_child0 child_type; return result_type::make(child_type( - phoenix::detail::expression::function_eval<F, A0>::make(f, _0) + phoenix::detail::expression::function_eval<F, A0>::make(f, _0_) , f.proto_base().child0 )); } @@ -129,11 +129,11 @@ namespace boost { namespace spirit typedef result_type type; result_type - operator()(F f, A0 const& _0, A1 const& _1) const + operator()(F f, A0 const& _0_, A1 const& _1_) const { typedef typename result_type::proto_child0 child_type; return result_type::make(child_type( - phoenix::detail::expression::function_eval<F, A0, A1>::make(f, _0, _1) + phoenix::detail::expression::function_eval<F, A0, A1>::make(f, _0_, _1_) , f.proto_base().child0 )); } @@ -154,11 +154,11 @@ namespace boost { namespace spirit typedef result_type type; result_type - operator()(F f, A0 const& _0, A1 const& _1, A2 const& _2) const + operator()(F f, A0 const& _0_, A1 const& _1_, A2 const& _2_) const { typedef typename result_type::proto_child0 child_type; return result_type::make(child_type( - phoenix::detail::expression::function_eval<F, A0, A1, A2>::make(f, _0, _1, _2) + phoenix::detail::expression::function_eval<F, A0, A1, A2>::make(f, _0_, _1_, _2_) , f.proto_base().child0 )); } @@ -368,42 +368,42 @@ namespace boost { namespace spirit template <typename A0> typename result<A0>::type - operator()(A0 const& _0 + operator()(A0 const& _0_ , typename detail::contains_actor<A0>::is_false = 0) const { typedef typename result<A0>::type result_type; typedef typename result_type::proto_child0 child_type; return result_type::make( child_type( - detail::make_vector(_0) + detail::make_vector(_0_) , this->proto_base().child0) ); } template <typename A0, typename A1> typename result<A0, A1>::type - operator()(A0 const& _0, A1 const& _1 + operator()(A0 const& _0_, A1 const& _1_ , typename detail::contains_actor<A0, A1>::is_false = 0) const { typedef typename result<A0, A1>::type result_type; typedef typename result_type::proto_child0 child_type; return result_type::make( child_type( - detail::make_vector(_0, _1) + detail::make_vector(_0_, _1_) , this->proto_base().child0) ); } template <typename A0, typename A1, typename A2> typename result<A0, A1, A2>::type - operator()(A0 const& _0, A1 const& _1, A2 const& _2 + operator()(A0 const& _0_, A1 const& _1_, A2 const& _2_ , typename detail::contains_actor<A0, A1, A2>::is_false = 0) const { typedef typename result<A0, A1, A2>::type result_type; typedef typename result_type::proto_child0 child_type; return result_type::make( child_type( - detail::make_vector(_0, _1, _2) + detail::make_vector(_0_, _1_, _2_) , this->proto_base().child0) ); } @@ -412,38 +412,38 @@ namespace boost { namespace spirit // least one arg is a Phoenix actor. template <typename A0> typename result<A0>::type - operator()(A0 const& _0 + operator()(A0 const& _0_ , typename detail::contains_actor<A0>::is_true = 0) const { return make_lazy<this_type , typename phoenix::as_actor<A0>::type>()(*this - , phoenix::as_actor<A0>::convert(_0)); + , phoenix::as_actor<A0>::convert(_0_)); } template <typename A0, typename A1> typename result<A0, A1>::type - operator()(A0 const& _0, A1 const& _1 + operator()(A0 const& _0_, A1 const& _1_ , typename detail::contains_actor<A0, A1>::is_true = 0) const { return make_lazy<this_type , typename phoenix::as_actor<A0>::type , typename phoenix::as_actor<A1>::type>()(*this - , phoenix::as_actor<A0>::convert(_0) - , phoenix::as_actor<A1>::convert(_1)); + , phoenix::as_actor<A0>::convert(_0_) + , phoenix::as_actor<A1>::convert(_1_)); } template <typename A0, typename A1, typename A2> typename result<A0, A1, A2>::type - operator()(A0 const& _0, A1 const& _1, A2 const& _2 + operator()(A0 const& _0_, A1 const& _1_, A2 const& _2_ , typename detail::contains_actor<A0, A1, A2>::is_true = 0) const { return make_lazy<this_type , typename phoenix::as_actor<A0>::type , typename phoenix::as_actor<A1>::type , typename phoenix::as_actor<A2>::type>()(*this - , phoenix::as_actor<A0>::convert(_0) - , phoenix::as_actor<A1>::convert(_1) - , phoenix::as_actor<A2>::convert(_2)); + , phoenix::as_actor<A0>::convert(_0_) + , phoenix::as_actor<A1>::convert(_1_) + , phoenix::as_actor<A2>::convert(_2_)); } private: @@ -547,7 +547,6 @@ namespace boost { namespace spirit }} -#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 namespace boost { namespace phoenix { template <typename Tag> @@ -558,6 +557,10 @@ namespace boost { namespace phoenix template <typename Tag> struct custom_terminal<Tag, typename Tag::is_spirit_tag> { +#ifndef BOOST_PHOENIX_NO_SPECIALIZE_CUSTOM_TERMINAL + typedef void _is_default_custom_terminal; // fix for #7730 +#endif + typedef spirit::terminal<Tag> result_type; template <typename Context> @@ -567,7 +570,6 @@ namespace boost { namespace phoenix } }; }} -#endif // Define a spirit terminal. This macro may be placed in any namespace. // Common placeholders are placed in the main boost::spirit namespace diff --git a/boost/spirit/home/support/terminal_expression.hpp b/boost/spirit/home/support/terminal_expression.hpp index cf6bc5de54..0d206bfd9f 100644 --- a/boost/spirit/home/support/terminal_expression.hpp +++ b/boost/spirit/home/support/terminal_expression.hpp @@ -9,67 +9,4 @@ #if !defined(BOOST_SPIRIT_TERMINAL_EXPRESSION_MARCH_24_2011_1210AM) #define BOOST_SPIRIT_TERMINAL_EXPRESSION_MARCH_24_2011_1210AM -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 - -namespace boost { namespace phoenix { namespace detail -{ - namespace expression - { - template < - typename F, typename A0 = void, typename A1 = void - , typename A2 = void, typename Dummy = void> - struct function_eval; - - template <typename F, typename A0> - struct function_eval<F, A0> - { - typedef phoenix::actor< - typename phoenix::as_composite< - phoenix::detail::function_eval<1>, F, A0 - >::type - > type; - - static type make(F f, A0 const & _0) - { - return phoenix::compose< - phoenix::detail::function_eval<1> >(f, _0); - } - }; - - template <typename F, typename A0, typename A1> - struct function_eval<F, A0, A1> - { - typedef phoenix::actor< - typename phoenix::as_composite< - phoenix::detail::function_eval<2>, F, A0, A1 - >::type - > type; - - static type make(F f, A0 const & _0, A1 const & _1) - { - return phoenix::compose< - phoenix::detail::function_eval<2> >(f, _0, _1); - } - }; - - template <typename F, typename A0, typename A1, typename A2> - struct function_eval<F, A0, A1, A2> - { - typedef phoenix::actor< - typename phoenix::as_composite< - phoenix::detail::function_eval<3>, F, A0, A1, A2 - >::type - > type; - - static type make(F f, A0 const & _0, A1 const & _1, A2 const & _2) - { - return phoenix::compose< - phoenix::detail::function_eval<3> >(f, _0, _1, _2); - } - }; - } -}}} - -#endif // !BOOST_SPIRIT_USE_PHOENIX_V3 - #endif diff --git a/boost/spirit/home/support/utree/detail/utree_detail2.hpp b/boost/spirit/home/support/utree/detail/utree_detail2.hpp index 789d99d482..d4be2c5bde 100644 --- a/boost/spirit/home/support/utree/detail/utree_detail2.hpp +++ b/boost/spirit/home/support/utree/detail/utree_detail2.hpp @@ -120,9 +120,9 @@ namespace boost { namespace spirit { namespace detail construct(other.str(), other.str() + other.size()); } - inline void fast_string::initialize() + inline void fast_string::initialize() { - for (std::size_t i = 0; i != buff_size / (sizeof(long)/sizeof(char)); ++i) + for (std::size_t i = 0; i != buff_size / (sizeof(long)/sizeof(char)); ++i) lbuff[i] = 0; } @@ -293,7 +293,7 @@ namespace boost { namespace spirit { namespace detail return; } - detail::list::node* new_node = + detail::list::node* new_node = new detail::list::node(val, pos.node, pos.node->prev); if (pos.node->prev) @@ -330,7 +330,7 @@ namespace boost { namespace spirit { namespace detail if (last == 0) push_front(val); else { - detail::list::node* new_node = + detail::list::node* new_node = new detail::list::node(val, last->next, last); last->next = new_node; last = new_node; @@ -402,7 +402,7 @@ namespace boost { namespace spirit { namespace detail /////////////////////////////////////////////////////////////////////////// // simple binder for binary visitation (we don't want to bring in the big guns) template <typename F, typename X> - struct bind_impl + struct bind_impl { typedef typename F::result_type result_type; X& x; // always by reference @@ -647,9 +647,9 @@ namespace boost { namespace spirit { return f(env); } - + template <typename F> - utree stored_function<F>::operator()(utree& env) const + utree stored_function<F>::operator()(utree& env) const { return f(env); } @@ -660,7 +660,7 @@ namespace boost { namespace spirit { return new stored_function<F>(f); } - + template <typename F> referenced_function<F>::referenced_function(F& f) : f(f) @@ -677,7 +677,7 @@ namespace boost { namespace spirit { return f(env); } - + template <typename F> utree referenced_function<F>::operator()(utree& env) const { @@ -702,8 +702,8 @@ namespace boost { namespace spirit s.initialize(); set_type(type::nil_type); } - - inline utree::utree(bool b_) + + inline utree::utree(bool b_) { s.initialize(); b = b_; @@ -718,21 +718,21 @@ namespace boost { namespace spirit set_type(type::string_type); } - inline utree::utree(unsigned int i_) + inline utree::utree(unsigned int i_) { s.initialize(); i = i_; set_type(type::int_type); } - inline utree::utree(int i_) + inline utree::utree(int i_) { s.initialize(); i = i_; set_type(type::int_type); } - inline utree::utree(double d_) + inline utree::utree(double d_) { s.initialize(); d = d_; @@ -789,14 +789,14 @@ namespace boost { namespace spirit pf = pf_.clone(); set_type(type::function_type); } - + inline utree::utree(function_base* pf_) { s.initialize(); pf = pf_; set_type(type::function_type); } - + template <typename Iter> inline utree::utree(boost::iterator_range<Iter> r) { @@ -930,7 +930,7 @@ namespace boost { namespace spirit set_type(type::reference_type); return *this; } - + inline utree& utree::operator=(any_ptr const& p) { free(); @@ -939,7 +939,7 @@ namespace boost { namespace spirit set_type(type::any_type); return *this; } - + inline utree& utree::operator=(function_base const& pf_) { free(); @@ -955,7 +955,7 @@ namespace boost { namespace spirit set_type(type::function_type); return *this; } - + template <typename Iter> inline utree& utree::operator=(boost::iterator_range<Iter> r) { @@ -1040,7 +1040,7 @@ namespace boost { namespace spirit return p->insert(pos, val); ensure_list_type("insert()"); - if (!pos.node) + if (!pos.node) { l.push_back(val); return utree::iterator(l.last, l.last->prev); @@ -1275,10 +1275,10 @@ namespace boost { namespace spirit if (t == type::symbol_type) return s.size(); - + if (t == type::binary_type) return s.size(); - + if (t == type::string_range_type) return sr.last - sr.first; @@ -1333,7 +1333,7 @@ namespace boost { namespace spirit } // otherwise... - if (get_type() != type::list_type) + if (get_type() != type::list_type) BOOST_THROW_EXCEPTION( bad_type_exception ("back() called on non-list utree type", get_type())); @@ -1381,7 +1381,7 @@ namespace boost { namespace spirit } // otherwise... - if (get_type() != type::list_type) + if (get_type() != type::list_type) BOOST_THROW_EXCEPTION( bad_type_exception ("back() called on non-list utree type", get_type())); @@ -1602,7 +1602,7 @@ namespace boost { namespace spirit "eval() called on non-function utree type", get_type())); return (*pf)(env); } - + inline utree utree::eval(utree& env) const { if (get_type() == type::reference_type) @@ -1614,12 +1614,12 @@ namespace boost { namespace spirit "eval() called on non-function utree type", get_type())); return (*pf)(env); } - + inline utree utree::operator() (utree const& env) const { return eval(env); } - + inline utree utree::operator() (utree& env) const { return eval(env); diff --git a/boost/spirit/home/x3.hpp b/boost/spirit/home/x3.hpp new file mode 100644 index 0000000000..9da6057b96 --- /dev/null +++ b/boost/spirit/home/x3.hpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2001-2013 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_X3_MARCH_04_2007_0852PM) +#define BOOST_SPIRIT_X3_MARCH_04_2007_0852PM + +#if defined(_MSC_VER) +#pragma once +#endif + +//~ #include <boost/spirit/home/x3/action.hpp> +//~ #include <boost/spirit/home/x3/auto.hpp> +#include <boost/spirit/home/x3/auxiliary.hpp> +#include <boost/spirit/home/x3/char.hpp> +//~ #include <boost/spirit/home/x3/binary.hpp> +#include <boost/spirit/home/x3/directive.hpp> +#include <boost/spirit/home/x3/nonterminal.hpp> +#include <boost/spirit/home/x3/numeric.hpp> +#include <boost/spirit/home/x3/operator.hpp> +#include <boost/spirit/home/x3/core.hpp> +#include <boost/spirit/home/x3/string.hpp> +//~ #include <boost/spirit/home/x3/stream.hpp> + +#endif diff --git a/boost/spirit/home/x3/auxiliary.hpp b/boost/spirit/home/x3/auxiliary.hpp new file mode 100644 index 0000000000..afa89b2883 --- /dev/null +++ b/boost/spirit/home/x3/auxiliary.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_X3_AUXILIARY_FEBRUARY_03_2007_0355PM) +#define BOOST_SPIRIT_X3_AUXILIARY_FEBRUARY_03_2007_0355PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/auxiliary/any_parser.hpp> +#include <boost/spirit/home/x3/auxiliary/eps.hpp> +#include <boost/spirit/home/x3/auxiliary/guard.hpp> +//~ #include <boost/spirit/home/x3/auxiliary/lazy.hpp> +#include <boost/spirit/home/x3/auxiliary/eol.hpp> +#include <boost/spirit/home/x3/auxiliary/eoi.hpp> +#include <boost/spirit/home/x3/auxiliary/attr.hpp> +//~ #include <boost/spirit/home/x3/auxiliary/attr_cast.hpp> + +#endif diff --git a/boost/spirit/home/x3/auxiliary/any_parser.hpp b/boost/spirit/home/x3/auxiliary/any_parser.hpp new file mode 100644 index 0000000000..0e257c04b1 --- /dev/null +++ b/boost/spirit/home/x3/auxiliary/any_parser.hpp @@ -0,0 +1,155 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2013-2014 Agustin Berge + + 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_X3_AUXILIARY_ANY_PARSER_APR_09_2014_1145PM) +#define BOOST_SPIRIT_X3_AUXILIARY_ANY_PARSER_APR_09_2014_1145PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/support/context.hpp> +#include <boost/spirit/home/x3/support/subcontext.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/support/traits/container_traits.hpp> +#include <boost/spirit/home/x3/support/traits/has_attribute.hpp> +#include <boost/spirit/home/x3/support/traits/move_to.hpp> +#include <boost/spirit/home/x3/support/traits/is_parser.hpp> +#include <memory> +#include <string> + +namespace boost { namespace spirit { namespace x3 +{ + template < + typename Iterator + , typename Attribute = unused_type + , typename Context = subcontext<>> + struct any_parser : parser<any_parser<Iterator, Attribute, Context>> + { + typedef Attribute attribute_type; + + static bool const has_attribute = + !is_same<unused_type, attribute_type>::value; + static bool const handles_container = + traits::is_container<Attribute>::value; + + public: + any_parser() + : _content(nullptr) {} + + template <typename Expr, + typename Enable = typename enable_if<traits::is_parser<Expr>>::type> + any_parser(Expr const& expr) + : _content(new holder<Expr>(expr)) {} + + any_parser(any_parser const& other) + : _content(other._content ? other._content->clone() : nullptr) {} + + any_parser(any_parser&& other) = default; + + any_parser& operator=(any_parser const& other) + { + _content.reset(other._content ? other._content->clone() : nullptr); + return *this; + } + + any_parser& operator=(any_parser&& other) = default; + + template <typename Iterator_, typename Context_> + bool parse(Iterator_& first, Iterator_ const& last + , Context_ const& context, unused_type, Attribute& attr) const + { + BOOST_STATIC_ASSERT_MSG( + (is_same<Iterator, Iterator_>::value) + , "Incompatible iterator used" + ); + + BOOST_ASSERT_MSG( + (_content != nullptr) + , "Invalid use of uninitialized any_parser" + ); + + return _content->parse(first, last, context, attr); + } + + template <typename Iterator_, typename Context_, typename Attribute_> + bool parse(Iterator_& first, Iterator_ const& last + , Context_ const& context, unused_type, Attribute_& attr_) const + { + Attribute attr; + if (parse(first, last, context, unused, attr)) + { + traits::move_to(attr, attr_); + return true; + } + return false; + } + + std::string get_info() const + { + return _content ? _content->get_info() : ""; + } + + private: + + struct placeholder + { + virtual placeholder* clone() const = 0; + + virtual bool parse(Iterator& first, Iterator const& last + , Context const& context, Attribute& attr) const = 0; + + virtual std::string get_info() const = 0; + + virtual ~placeholder() {} + }; + + template <typename Expr> + struct holder : placeholder + { + typedef typename extension::as_parser<Expr>::value_type parser_type; + + explicit holder(Expr const& p) + : _parser(as_parser(p)) {} + + holder* clone() const override + { + return new holder(*this); + } + + bool parse(Iterator& first, Iterator const& last + , Context const& context, Attribute& attr) const override + { + return _parser.parse(first, last, context, unused, attr); + } + + std::string get_info() const override + { + return x3::what(_parser); + } + + parser_type _parser; + }; + + private: + std::unique_ptr<placeholder> _content; + }; + + template <typename Iterator, typename Attribute, typename Context> + struct get_info<any_parser<Iterator, Attribute, Context>> + { + typedef std::string result_type; + std::string operator()( + any_parser<Iterator, Attribute, Context> const& p) const + { + return p.get_info(); + } + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/auxiliary/attr.hpp b/boost/spirit/home/x3/auxiliary/attr.hpp new file mode 100644 index 0000000000..364cca0bee --- /dev/null +++ b/boost/spirit/home/x3/auxiliary/attr.hpp @@ -0,0 +1,135 @@ +/*============================================================================= + Copyright (c) 2001-2011 Hartmut Kaiser + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2013 Agustin Berge + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef BOOST_SPIRIT_X3_ATTR_JUL_23_2008_0956AM +#define BOOST_SPIRIT_X3_ATTR_JUL_23_2008_0956AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/support/traits/container_traits.hpp> +#include <boost/spirit/home/x3/support/traits/move_to.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/remove_cv.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <algorithm> +#include <cstddef> +#include <string> +#include <utility> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Value> + struct attr_parser : parser<attr_parser<Value>> + { + typedef Value attribute_type; + + static bool const has_attribute = + !is_same<unused_type, attribute_type>::value; + static bool const handles_container = + traits::is_container<attribute_type>::value; + + attr_parser(Value const& value) + : value_(value) {} + attr_parser(Value&& value) + : value_(std::move(value)) {} + + template <typename Iterator, typename Context + , typename RuleContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RuleContext&, Attribute& attr_) const + { + // $$$ Change to copy_to once we have it $$$ + traits::move_to(value_, attr_); + return true; + } + + Value value_; + + private: + // silence MSVC warning C4512: assignment operator could not be generated + attr_parser& operator= (attr_parser const&); + }; + + template <typename Value, std::size_t N> + struct attr_parser<Value[N]> : parser<attr_parser<Value[N]>> + { + typedef Value attribute_type[N]; + + static bool const has_attribute = + !is_same<unused_type, attribute_type>::value; + static bool const handles_container = true; + + attr_parser(Value const (&value)[N]) + { + std::copy(value + 0, value + N, value_ + 0); + } + + attr_parser(Value (&&value)[N]) + { + std::move(value + 0, value + N, value_ + 0); + } + + template <typename Iterator, typename Context + , typename RuleContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RuleContext&, Attribute& attr_) const + { + // $$$ Change to copy_to once we have it $$$ + traits::move_to(value_ + 0, value_ + N, attr_); + return true; + } + + Value value_[N]; + + private: + // silence MSVC warning C4512: assignment operator could not be generated + attr_parser& operator= (attr_parser const&); + }; + + template <typename Value> + struct get_info<attr_parser<Value>> + { + typedef std::string result_type; + std::string operator()(attr_parser<Value> const& /*p*/) const + { + return "attr"; + } + }; + + struct attr_gen + { + template <typename Value> + attr_parser<typename remove_cv< + typename remove_reference<Value>::type>::type> + operator()(Value&& value) const + { + return {std::forward<Value>(value)}; + } + + template <typename Value, std::size_t N> + attr_parser<typename remove_cv<Value>::type[N]> + operator()(Value (&value)[N]) const + { + return {value}; + } + template <typename Value, std::size_t N> + attr_parser<typename remove_cv<Value>::type[N]> + operator()(Value (&&value)[N]) const + { + return {value}; + } + }; + + attr_gen const attr = attr_gen(); +}}} + +#endif diff --git a/boost/spirit/home/x3/auxiliary/eoi.hpp b/boost/spirit/home/x3/auxiliary/eoi.hpp new file mode 100644 index 0000000000..55bd51cfc4 --- /dev/null +++ b/boost/spirit/home/x3/auxiliary/eoi.hpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_X3_EOI_MARCH_23_2007_0454PM) +#define BOOST_SPIRIT_X3_EOI_MARCH_23_2007_0454PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + struct eoi_parser : parser<eoi_parser> + { + typedef unused_type attribute_type; + static bool const has_attribute = false; + + template <typename Iterator, typename Context, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, unused_type, Attribute&) const + { + x3::skip_over(first, last, context); + return first == last; + } + }; + + template<> + struct get_info<eoi_parser> + { + typedef std::string result_type; + result_type operator()(eoi_parser const &) const { return "eoi"; } + }; + + eoi_parser const eoi = eoi_parser(); +}}} + +#endif diff --git a/boost/spirit/home/x3/auxiliary/eol.hpp b/boost/spirit/home/x3/auxiliary/eol.hpp new file mode 100644 index 0000000000..3d191b4269 --- /dev/null +++ b/boost/spirit/home/x3/auxiliary/eol.hpp @@ -0,0 +1,59 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_X3_EOL_MARCH_23_2007_0454PM) +#define BOOST_SPIRIT_X3_EOL_MARCH_23_2007_0454PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + struct eol_parser : parser<eol_parser> + { + typedef unused_type attribute_type; + static bool const has_attribute = false; + + template <typename Iterator, typename Context, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, unused_type, Attribute& /*attr*/) const + { + x3::skip_over(first, last, context); + Iterator iter = first; + bool matched = false; + if (iter != last && *iter == '\r') // CR + { + matched = true; + ++iter; + } + if (iter != last && *iter == '\n') // LF + { + matched = true; + ++iter; + } + + if (matched) first = iter; + return matched; + } + }; + + template<> + struct get_info<eol_parser> + { + typedef std::string result_type; + result_type operator()(eol_parser const &) const { return "eol"; } + }; + + eol_parser const eol = eol_parser(); +}}} + +#endif diff --git a/boost/spirit/home/x3/auxiliary/eps.hpp b/boost/spirit/home/x3/auxiliary/eps.hpp new file mode 100644 index 0000000000..ab4d307931 --- /dev/null +++ b/boost/spirit/home/x3/auxiliary/eps.hpp @@ -0,0 +1,92 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_EPS_MARCH_23_2007_0454PM) +#define BOOST_SPIRIT_X3_EPS_MARCH_23_2007_0454PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + struct rule_context_tag; + + struct semantic_predicate : parser<semantic_predicate> + { + typedef unused_type attribute_type; + static bool const has_attribute = false; + + semantic_predicate(bool predicate) + : predicate(predicate) {} + + template <typename Iterator, typename Context, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, unused_type, Attribute&) const + { + x3::skip_over(first, last, context); + return predicate; + } + + bool predicate; + }; + + template <typename F> + struct lazy_semantic_predicate : parser<lazy_semantic_predicate<F>> + { + typedef unused_type attribute_type; + static bool const has_attribute = false; + + lazy_semantic_predicate(F f) + : f(f) {} + + template <typename Iterator, typename Context, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, unused_type, Attribute& attr) const + { + x3::skip_over(first, last, context); + return f(x3::get<rule_context_tag>(context)); + } + + F f; + }; + + struct eps_parser : parser<eps_parser> + { + typedef unused_type attribute_type; + static bool const has_attribute = false; + + template <typename Iterator, typename Context + , typename RuleContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RuleContext&, Attribute&) const + { + x3::skip_over(first, last, context); + return true; + } + + semantic_predicate + operator()(bool predicate) const + { + return semantic_predicate(predicate); + } + + template <typename F> + lazy_semantic_predicate<F> + operator()(F f) const + { + return lazy_semantic_predicate<F>(f); + } + }; + + eps_parser const eps = eps_parser(); +}}} + +#endif diff --git a/boost/spirit/home/x3/auxiliary/guard.hpp b/boost/spirit/home/x3/auxiliary/guard.hpp new file mode 100644 index 0000000000..6fd63c822c --- /dev/null +++ b/boost/spirit/home/x3/auxiliary/guard.hpp @@ -0,0 +1,73 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_GUARD_FERBRUARY_02_2013_0649PM) +#define BOOST_SPIRIT_X3_GUARD_FERBRUARY_02_2013_0649PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/context.hpp> +#include <boost/spirit/home/x3/directive/expect.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + enum class error_handler_result + { + fail + , retry + , accept + , rethrow + }; + + template <typename Subject, typename Handler> + struct guard : unary_parser<Subject, guard<Subject, Handler>> + { + typedef unary_parser<Subject, guard<Subject, Handler>> base_type; + static bool const is_pass_through_unary = true; + + guard(Subject const& subject, Handler handler) + : base_type(subject), handler(handler) {} + + template <typename Iterator, typename Context + , typename RuleContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RuleContext& rcontext, Attribute& attr) const + { + for (;;) + { + try + { + Iterator i = first; + bool r = this->subject.parse(i, last, context, rcontext, attr); + if (r) + first = i; + return r; + } + catch (expectation_failure<Iterator> const& x) + { + switch (handler(first, last, x, context)) + { + case error_handler_result::fail: + return false; + case error_handler_result::retry: + continue; + case error_handler_result::accept: + return true; + case error_handler_result::rethrow: + throw; + } + } + } + return false; + } + + Handler handler; + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/char.hpp b/boost/spirit/home/x3/char.hpp new file mode 100644 index 0000000000..19d26de3a2 --- /dev/null +++ b/boost/spirit/home/x3/char.hpp @@ -0,0 +1,23 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_CHAR_FEBRUARY_02_2007_0921AM) +#define BOOST_SPIRIT_X3_CHAR_FEBRUARY_02_2007_0921AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/char/char_parser.hpp> +#include <boost/spirit/home/x3/char/negated_char_parser.hpp> +#include <boost/spirit/home/x3/char/char.hpp> +#include <boost/spirit/home/x3/char/char_class.hpp> + +#if defined(BOOST_SPIRIT_X3_UNICODE) +#include <boost/spirit/home/x3/char/unicode.hpp> +#endif + +#endif diff --git a/boost/spirit/home/x3/char/any_char.hpp b/boost/spirit/home/x3/char/any_char.hpp new file mode 100644 index 0000000000..7ff769b8b2 --- /dev/null +++ b/boost/spirit/home/x3/char/any_char.hpp @@ -0,0 +1,41 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_ANY_CHAR_APRIL_16_2006_1051AM) +#define BOOST_SPIRIT_X3_ANY_CHAR_APRIL_16_2006_1051AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/char/literal_char.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Encoding> + struct any_char : char_parser<any_char<Encoding>> + { + typedef typename Encoding::char_type char_type; + typedef Encoding encoding; + typedef char_type attribute_type; + static bool const has_attribute = true; + + template <typename Char, typename Context> + bool test(Char ch_, Context const&) const + { + return ((sizeof(Char) <= sizeof(char_type)) || encoding::ischar(ch_)); + } + + template <typename Char> + literal_char<Encoding> + operator()(Char ch) const + { + return literal_char<Encoding>(ch); + } + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/char/char.hpp b/boost/spirit/home/x3/char/char.hpp new file mode 100644 index 0000000000..9452dcd86d --- /dev/null +++ b/boost/spirit/home/x3/char/char.hpp @@ -0,0 +1,88 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_CHAR_APRIL_16_2006_1051AM) +#define BOOST_SPIRIT_X3_CHAR_APRIL_16_2006_1051AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/char/any_char.hpp> +#include <boost/spirit/home/support/char_encoding/ascii.hpp> +#include <boost/spirit/home/support/char_encoding/standard.hpp> +#include <boost/spirit/home/support/char_encoding/standard_wide.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + namespace standard + { + typedef any_char<char_encoding::standard> char_type; + char_type const char_ = char_type(); + } + + using standard::char_type; + using standard::char_; + + namespace standard_wide + { + typedef any_char<char_encoding::standard_wide> char_type; + char_type const char_ = char_type(); + } + + namespace ascii + { + typedef any_char<char_encoding::ascii> char_type; + char_type const char_ = char_type(); + } + + namespace extension + { + template <> + struct as_parser<char> + { + typedef literal_char< + char_encoding::standard, unused_type> + type; + + typedef type value_type; + + static type call(char ch) + { + return type(ch); + } + }; + + template <> + struct as_parser<wchar_t> + { + typedef literal_char< + char_encoding::standard_wide, unused_type> + type; + + typedef type value_type; + + static type call(wchar_t ch) + { + return type(ch); + } + }; + } + + inline literal_char<char_encoding::standard, unused_type> + lit(char ch) + { + return literal_char<char_encoding::standard, unused_type>(ch); + } + + inline literal_char<char_encoding::standard_wide, unused_type> + lit(wchar_t ch) + { + return literal_char<char_encoding::standard_wide, unused_type>(ch); + } +}}} + +#endif diff --git a/boost/spirit/home/x3/char/char_class.hpp b/boost/spirit/home/x3/char/char_class.hpp new file mode 100644 index 0000000000..18b7131c0f --- /dev/null +++ b/boost/spirit/home/x3/char/char_class.hpp @@ -0,0 +1,148 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_CHAR_CLASS_APRIL_16_2006_1051AM) +#define BOOST_SPIRIT_X3_CHAR_CLASS_APRIL_16_2006_1051AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/char/char_parser.hpp> +#include <boost/spirit/home/x3/char/detail/cast_char.hpp> +#include <boost/spirit/home/support/char_encoding/standard.hpp> +#include <boost/spirit/home/support/char_encoding/standard_wide.hpp> +#include <boost/spirit/home/support/char_encoding/ascii.hpp> +#include <boost/spirit/home/support/char_encoding/iso8859_1.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + /////////////////////////////////////////////////////////////////////////// + struct char_tag {}; + struct alnum_tag {}; + struct alpha_tag {}; + struct blank_tag {}; + struct cntrl_tag {}; + struct digit_tag {}; + struct graph_tag {}; + struct print_tag {}; + struct punct_tag {}; + struct space_tag {}; + struct xdigit_tag {}; + struct lower_tag {}; + struct upper_tag {}; + + /////////////////////////////////////////////////////////////////////////// + template <typename Encoding> + struct char_class_base + { + typedef typename Encoding::char_type char_type; + +#define BOOST_SPIRIT_X3_CLASSIFY(name) \ + template <typename Char> \ + static bool \ + is(name##_tag, Char ch) \ + { \ + return Encoding::is##name \ + BOOST_PREVENT_MACRO_SUBSTITUTION \ + (detail::cast_char<char_type>(ch)); \ + } \ + /***/ + + BOOST_SPIRIT_X3_CLASSIFY(char) + BOOST_SPIRIT_X3_CLASSIFY(alnum) + BOOST_SPIRIT_X3_CLASSIFY(alpha) + BOOST_SPIRIT_X3_CLASSIFY(digit) + BOOST_SPIRIT_X3_CLASSIFY(xdigit) + BOOST_SPIRIT_X3_CLASSIFY(cntrl) + BOOST_SPIRIT_X3_CLASSIFY(graph) + BOOST_SPIRIT_X3_CLASSIFY(lower) + BOOST_SPIRIT_X3_CLASSIFY(print) + BOOST_SPIRIT_X3_CLASSIFY(punct) + BOOST_SPIRIT_X3_CLASSIFY(space) + BOOST_SPIRIT_X3_CLASSIFY(blank) + BOOST_SPIRIT_X3_CLASSIFY(upper) + +#undef BOOST_SPIRIT_X3_CLASSIFY + }; + + template <typename Encoding, typename Tag> + struct char_class + : char_parser<char_class<Encoding, Tag>> + { + typedef Encoding encoding; + typedef Tag tag; + typedef typename Encoding::char_type char_type; + typedef char_type attribute_type; + static bool const has_attribute = true; + + template <typename Char, typename Context> + bool test(Char ch, Context const&) const + { + return ((sizeof(Char) <= sizeof(char_type)) || encoding::ischar(ch)) + && char_class_base<Encoding>::is(tag(), ch); + } + }; + +#define BOOST_SPIRIT_X3_CHAR_CLASS(encoding, name) \ + typedef char_class<char_encoding::encoding, name##_tag> name##_type; \ + name##_type const name = name##_type(); \ + /***/ + +#define BOOST_SPIRIT_X3_CHAR_CLASSES(encoding) \ + namespace encoding \ + { \ + BOOST_SPIRIT_X3_CHAR_CLASS(encoding, alnum) \ + BOOST_SPIRIT_X3_CHAR_CLASS(encoding, alpha) \ + BOOST_SPIRIT_X3_CHAR_CLASS(encoding, digit) \ + BOOST_SPIRIT_X3_CHAR_CLASS(encoding, xdigit) \ + BOOST_SPIRIT_X3_CHAR_CLASS(encoding, cntrl) \ + BOOST_SPIRIT_X3_CHAR_CLASS(encoding, graph) \ + BOOST_SPIRIT_X3_CHAR_CLASS(encoding, lower) \ + BOOST_SPIRIT_X3_CHAR_CLASS(encoding, print) \ + BOOST_SPIRIT_X3_CHAR_CLASS(encoding, punct) \ + BOOST_SPIRIT_X3_CHAR_CLASS(encoding, space) \ + BOOST_SPIRIT_X3_CHAR_CLASS(encoding, blank) \ + BOOST_SPIRIT_X3_CHAR_CLASS(encoding, upper) \ + } \ + /***/ + + BOOST_SPIRIT_X3_CHAR_CLASSES(standard) + BOOST_SPIRIT_X3_CHAR_CLASSES(standard_wide) + BOOST_SPIRIT_X3_CHAR_CLASSES(ascii) + BOOST_SPIRIT_X3_CHAR_CLASSES(iso8859_1) + +#undef BOOST_SPIRIT_X3_CHAR_CLASS +#undef BOOST_SPIRIT_X3_CHAR_CLASSES + + using standard::alnum_type; + using standard::alpha_type; + using standard::digit_type; + using standard::xdigit_type; + using standard::cntrl_type; + using standard::graph_type; + using standard::lower_type; + using standard::print_type; + using standard::punct_type; + using standard::space_type; + using standard::blank_type; + using standard::upper_type; + + using standard::alnum; + using standard::alpha; + using standard::digit; + using standard::xdigit; + using standard::cntrl; + using standard::graph; + using standard::lower; + using standard::print; + using standard::punct; + using standard::space; + using standard::blank; + using standard::upper; +}}} + +#endif diff --git a/boost/spirit/home/x3/char/char_parser.hpp b/boost/spirit/home/x3/char/char_parser.hpp new file mode 100644 index 0000000000..6943804369 --- /dev/null +++ b/boost/spirit/home/x3/char/char_parser.hpp @@ -0,0 +1,44 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_CHAR_PARSER_APR_16_2006_0906AM) +#define BOOST_SPIRIT_X3_CHAR_PARSER_APR_16_2006_0906AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/support/traits/move_to.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + /////////////////////////////////////////////////////////////////////////// + // The base char_parser + /////////////////////////////////////////////////////////////////////////// + template <typename Derived> + struct char_parser : parser<Derived> + { + template <typename Iterator, typename Context, typename Attribute> + bool parse( + Iterator& first, Iterator const& last + , Context const& context, unused_type, Attribute& attr) const + { + x3::skip_over(first, last, context); + + if (first != last && this->derived().test(*first, context)) + { + x3::traits::move_to(*first, attr); + ++first; + return true; + } + return false; + } + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/char/detail/cast_char.hpp b/boost/spirit/home/x3/char/detail/cast_char.hpp new file mode 100644 index 0000000000..03bda27a29 --- /dev/null +++ b/boost/spirit/home/x3/char/detail/cast_char.hpp @@ -0,0 +1,58 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_X3_CAST_CHAR_NOVEMBER_10_2006_0907AM) +#define BOOST_SPIRIT_X3_CAST_CHAR_NOVEMBER_10_2006_0907AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/type_traits/is_signed.hpp> +#include <boost/type_traits/make_unsigned.hpp> +#include <boost/type_traits/make_signed.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace detail +{ + // Here's the thing... typical encodings (except ASCII) deal with unsigned + // integers > 127 (ASCII uses only 127). Yet, most char and wchar_t are signed. + // Thus, a char with value > 127 is negative (e.g. char 233 is -23). When you + // cast this to an unsigned int with 32 bits, you get 4294967273! + // + // The trick is to cast to an unsigned version of the source char first + // before casting to the target. {P.S. Don't worry about the code, the + // optimizer will optimize the if-else branches} + + template <typename TargetChar, typename SourceChar> + TargetChar cast_char(SourceChar ch) + { + if (is_signed<TargetChar>::value != is_signed<SourceChar>::value) + { + if (is_signed<SourceChar>::value) + { + // source is signed, target is unsigned + typedef typename make_unsigned<SourceChar>::type USourceChar; + return TargetChar(USourceChar(ch)); + } + else + { + // source is unsigned, target is signed + typedef typename make_signed<SourceChar>::type SSourceChar; + return TargetChar(SSourceChar(ch)); + } + } + else + { + // source and target has same signedness + return TargetChar(ch); // just cast + } + } +}}}} + +#endif + + diff --git a/boost/spirit/home/x3/char/literal_char.hpp b/boost/spirit/home/x3/char/literal_char.hpp new file mode 100644 index 0000000000..94b2a239a6 --- /dev/null +++ b/boost/spirit/home/x3/char/literal_char.hpp @@ -0,0 +1,54 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_LITERAL_CHAR_APRIL_16_2006_1051AM) +#define BOOST_SPIRIT_X3_LITERAL_CHAR_APRIL_16_2006_1051AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/char/char_parser.hpp> +#include <boost/spirit/home/x3/support/utility/utf8.hpp> +#include <boost/type_traits/is_same.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Encoding, typename Attribute = typename Encoding::char_type> + struct literal_char : char_parser<literal_char<Encoding, Attribute>> + { + typedef typename Encoding::char_type char_type; + typedef Encoding encoding; + typedef Attribute attribute_type; + static bool const has_attribute = + !is_same<unused_type, attribute_type>::value; + + template <typename Char> + literal_char(Char ch) + : ch(static_cast<char_type>(ch)) {} + + template <typename Char, typename Context> + bool test(Char ch_, Context const&) const + { + return ((sizeof(Char) <= sizeof(char_type)) || encoding::ischar(ch_)) + && ch == char_type(ch_); + } + + char_type ch; + }; + + template <typename Encoding, typename Attribute> + struct get_info<literal_char<Encoding, Attribute>> + { + typedef std::string result_type; + std::string operator()(literal_char<Encoding, Attribute> const& p) const + { + return '\'' + to_utf8(Encoding::toucs4(p.ch)) + '\''; + } + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/char/negated_char_parser.hpp b/boost/spirit/home/x3/char/negated_char_parser.hpp new file mode 100644 index 0000000000..392d712759 --- /dev/null +++ b/boost/spirit/home/x3/char/negated_char_parser.hpp @@ -0,0 +1,65 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_NEGATED_CHAR_PARSER_APR_16_2006_0906AM) +#define BOOST_SPIRIT_X3_NEGATED_CHAR_PARSER_APR_16_2006_0906AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/traits/attribute_of.hpp> +#include <boost/spirit/home/x3/support/traits/has_attribute.hpp> +#include <boost/spirit/home/x3/char/char_parser.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + /////////////////////////////////////////////////////////////////////////// + // negated_char_parser handles ~cp expressions (cp is a char_parser) + /////////////////////////////////////////////////////////////////////////// + template <typename Positive> + struct negated_char_parser : + char_parser<negated_char_parser<Positive>> + { + negated_char_parser(Positive const& positive) + : positive(positive) {} + + template <typename CharParam, typename Context> + bool test(CharParam ch, Context const& context) const + { + return !positive.test(ch, context); + } + + Positive positive; + }; + + template <typename Positive> + inline negated_char_parser<Positive> + operator~(char_parser<Positive> const& cp) + { + return negated_char_parser<Positive>(cp.derived()); + } + + template <typename Positive> + inline Positive const& + operator~(negated_char_parser<Positive> const& cp) + { + return cp.positive; + } +}}} + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Positive, typename Context> + struct attribute_of<x3::negated_char_parser<Positive>, Context> + : attribute_of<Positive, Context> {}; + + template <typename Positive, typename Context> + struct has_attribute<x3::negated_char_parser<Positive>, Context> + : has_attribute<Positive, Context> {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/char/unicode.hpp b/boost/spirit/home/x3/char/unicode.hpp new file mode 100644 index 0000000000..6954c40e40 --- /dev/null +++ b/boost/spirit/home/x3/char/unicode.hpp @@ -0,0 +1,617 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_UNICODE_JAN_20_2012_1218AM) +#define BOOST_SPIRIT_X3_UNICODE_JAN_20_2012_1218AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/char/char_parser.hpp> +#include <boost/spirit/home/x3/char/char.hpp> +#include <boost/spirit/home/x3/char/detail/cast_char.hpp> +#include <boost/spirit/home/support/char_encoding/unicode.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + /////////////////////////////////////////////////////////////////////////// + // Unicode Major Categories + /////////////////////////////////////////////////////////////////////////// + struct char_tag; + struct alnum_tag; + struct alpha_tag; + struct blank_tag; + struct cntrl_tag; + struct digit_tag; + struct graph_tag; + struct print_tag; + struct punct_tag; + struct space_tag; + struct xdigit_tag; + struct lower_tag; + struct upper_tag; + + /////////////////////////////////////////////////////////////////////////// + // Unicode Major Categories + /////////////////////////////////////////////////////////////////////////// + struct letter_tag {}; + struct mark_tag {}; + struct number_tag {}; + struct separator_tag {}; + struct other_tag {}; + struct punctuation_tag {}; + struct symbol_tag {}; + + /////////////////////////////////////////////////////////////////////////// + // Unicode General Categories + /////////////////////////////////////////////////////////////////////////// + struct uppercase_letter_tag {}; + struct lowercase_letter_tag {}; + struct titlecase_letter_tag {}; + struct modifier_letter_tag {}; + struct other_letter_tag {}; + + struct nonspacing_mark_tag {}; + struct enclosing_mark_tag {}; + struct spacing_mark_tag {}; + + struct decimal_number_tag {}; + struct letter_number_tag {}; + struct other_number_tag {}; + + struct space_separator_tag {}; + struct line_separator_tag {}; + struct paragraph_separator_tag {}; + + struct control_tag {}; + struct format_tag {}; + struct private_use_tag {}; + struct surrogate_tag {}; + struct unassigned_tag {}; + + struct dash_punctuation_tag {}; + struct open_punctuation_tag {}; + struct close_punctuation_tag {}; + struct connector_punctuation_tag {}; + struct other_punctuation_tag {}; + struct initial_punctuation_tag {}; + struct final_punctuation_tag {}; + + struct math_symbol_tag {}; + struct currency_symbol_tag {}; + struct modifier_symbol_tag {}; + struct other_symbol_tag {}; + + /////////////////////////////////////////////////////////////////////////// + // Unicode Derived Categories + /////////////////////////////////////////////////////////////////////////// + struct alphabetic_tag {}; + struct uppercase_tag {}; + struct lowercase_tag {}; + struct white_space_tag {}; + struct hex_digit_tag {}; + struct noncharacter_code_point_tag {}; + struct default_ignorable_code_point_tag {}; + + /////////////////////////////////////////////////////////////////////////// + // Unicode Scripts + /////////////////////////////////////////////////////////////////////////// + struct arabic_tag {}; + struct imperial_aramaic_tag {}; + struct armenian_tag {}; + struct avestan_tag {}; + struct balinese_tag {}; + struct bamum_tag {}; + struct bengali_tag {}; + struct bopomofo_tag {}; + struct braille_tag {}; + struct buginese_tag {}; + struct buhid_tag {}; + struct canadian_aboriginal_tag {}; + struct carian_tag {}; + struct cham_tag {}; + struct cherokee_tag {}; + struct coptic_tag {}; + struct cypriot_tag {}; + struct cyrillic_tag {}; + struct devanagari_tag {}; + struct deseret_tag {}; + struct egyptian_hieroglyphs_tag {}; + struct ethiopic_tag {}; + struct georgian_tag {}; + struct glagolitic_tag {}; + struct gothic_tag {}; + struct greek_tag {}; + struct gujarati_tag {}; + struct gurmukhi_tag {}; + struct hangul_tag {}; + struct han_tag {}; + struct hanunoo_tag {}; + struct hebrew_tag {}; + struct hiragana_tag {}; + struct katakana_or_hiragana_tag {}; + struct old_italic_tag {}; + struct javanese_tag {}; + struct kayah_li_tag {}; + struct katakana_tag {}; + struct kharoshthi_tag {}; + struct khmer_tag {}; + struct kannada_tag {}; + struct kaithi_tag {}; + struct tai_tham_tag {}; + struct lao_tag {}; + struct latin_tag {}; + struct lepcha_tag {}; + struct limbu_tag {}; + struct linear_b_tag {}; + struct lisu_tag {}; + struct lycian_tag {}; + struct lydian_tag {}; + struct malayalam_tag {}; + struct mongolian_tag {}; + struct meetei_mayek_tag {}; + struct myanmar_tag {}; + struct nko_tag {}; + struct ogham_tag {}; + struct ol_chiki_tag {}; + struct old_turkic_tag {}; + struct oriya_tag {}; + struct osmanya_tag {}; + struct phags_pa_tag {}; + struct inscriptional_pahlavi_tag {}; + struct phoenician_tag {}; + struct inscriptional_parthian_tag {}; + struct rejang_tag {}; + struct runic_tag {}; + struct samaritan_tag {}; + struct old_south_arabian_tag {}; + struct saurashtra_tag {}; + struct shavian_tag {}; + struct sinhala_tag {}; + struct sundanese_tag {}; + struct syloti_nagri_tag {}; + struct syriac_tag {}; + struct tagbanwa_tag {}; + struct tai_le_tag {}; + struct new_tai_lue_tag {}; + struct tamil_tag {}; + struct tai_viet_tag {}; + struct telugu_tag {}; + struct tifinagh_tag {}; + struct tagalog_tag {}; + struct thaana_tag {}; + struct thai_tag {}; + struct tibetan_tag {}; + struct ugaritic_tag {}; + struct vai_tag {}; + struct old_persian_tag {}; + struct cuneiform_tag {}; + struct yi_tag {}; + struct inherited_tag {}; + struct common_tag {}; + struct unknown_tag {}; + + /////////////////////////////////////////////////////////////////////////// + struct unicode_char_class_base + { + typedef char_encoding::unicode encoding; + typedef char_encoding::unicode::char_type char_type; + +#define BOOST_SPIRIT_X3_BASIC_CLASSIFY(name) \ + template <typename Char> \ + static bool \ + is(name##_tag, Char ch) \ + { \ + return encoding::is ##name \ + BOOST_PREVENT_MACRO_SUBSTITUTION \ + (detail::cast_char<char_type>(ch)); \ + } \ + /***/ + +#define BOOST_SPIRIT_X3_CLASSIFY(name) \ + template <typename Char> \ + static bool \ + is(name##_tag, Char ch) \ + { \ + return encoding::is_##name \ + BOOST_PREVENT_MACRO_SUBSTITUTION \ + (detail::cast_char<char_type>(ch)); \ + } \ + /***/ + + + /////////////////////////////////////////////////////////////////////////// + // Unicode Major Categories + /////////////////////////////////////////////////////////////////////////// + BOOST_SPIRIT_X3_BASIC_CLASSIFY(char) + BOOST_SPIRIT_X3_BASIC_CLASSIFY(alnum) + BOOST_SPIRIT_X3_BASIC_CLASSIFY(alpha) + BOOST_SPIRIT_X3_BASIC_CLASSIFY(digit) + BOOST_SPIRIT_X3_BASIC_CLASSIFY(xdigit) + BOOST_SPIRIT_X3_BASIC_CLASSIFY(cntrl) + BOOST_SPIRIT_X3_BASIC_CLASSIFY(graph) + BOOST_SPIRIT_X3_BASIC_CLASSIFY(lower) + BOOST_SPIRIT_X3_BASIC_CLASSIFY(print) + BOOST_SPIRIT_X3_BASIC_CLASSIFY(punct) + BOOST_SPIRIT_X3_BASIC_CLASSIFY(space) + BOOST_SPIRIT_X3_BASIC_CLASSIFY(blank) + BOOST_SPIRIT_X3_BASIC_CLASSIFY(upper) + + /////////////////////////////////////////////////////////////////////////// + // Unicode Major Categories + /////////////////////////////////////////////////////////////////////////// + BOOST_SPIRIT_X3_CLASSIFY(letter) + BOOST_SPIRIT_X3_CLASSIFY(mark) + BOOST_SPIRIT_X3_CLASSIFY(number) + BOOST_SPIRIT_X3_CLASSIFY(separator) + BOOST_SPIRIT_X3_CLASSIFY(other) + BOOST_SPIRIT_X3_CLASSIFY(punctuation) + BOOST_SPIRIT_X3_CLASSIFY(symbol) + + /////////////////////////////////////////////////////////////////////////// + // Unicode General Categories + /////////////////////////////////////////////////////////////////////////// + BOOST_SPIRIT_X3_CLASSIFY(uppercase_letter) + BOOST_SPIRIT_X3_CLASSIFY(lowercase_letter) + BOOST_SPIRIT_X3_CLASSIFY(titlecase_letter) + BOOST_SPIRIT_X3_CLASSIFY(modifier_letter) + BOOST_SPIRIT_X3_CLASSIFY(other_letter) + + BOOST_SPIRIT_X3_CLASSIFY(nonspacing_mark) + BOOST_SPIRIT_X3_CLASSIFY(enclosing_mark) + BOOST_SPIRIT_X3_CLASSIFY(spacing_mark) + + BOOST_SPIRIT_X3_CLASSIFY(decimal_number) + BOOST_SPIRIT_X3_CLASSIFY(letter_number) + BOOST_SPIRIT_X3_CLASSIFY(other_number) + + BOOST_SPIRIT_X3_CLASSIFY(space_separator) + BOOST_SPIRIT_X3_CLASSIFY(line_separator) + BOOST_SPIRIT_X3_CLASSIFY(paragraph_separator) + + BOOST_SPIRIT_X3_CLASSIFY(control) + BOOST_SPIRIT_X3_CLASSIFY(format) + BOOST_SPIRIT_X3_CLASSIFY(private_use) + BOOST_SPIRIT_X3_CLASSIFY(surrogate) + BOOST_SPIRIT_X3_CLASSIFY(unassigned) + + BOOST_SPIRIT_X3_CLASSIFY(dash_punctuation) + BOOST_SPIRIT_X3_CLASSIFY(open_punctuation) + BOOST_SPIRIT_X3_CLASSIFY(close_punctuation) + BOOST_SPIRIT_X3_CLASSIFY(connector_punctuation) + BOOST_SPIRIT_X3_CLASSIFY(other_punctuation) + BOOST_SPIRIT_X3_CLASSIFY(initial_punctuation) + BOOST_SPIRIT_X3_CLASSIFY(final_punctuation) + + BOOST_SPIRIT_X3_CLASSIFY(math_symbol) + BOOST_SPIRIT_X3_CLASSIFY(currency_symbol) + BOOST_SPIRIT_X3_CLASSIFY(modifier_symbol) + BOOST_SPIRIT_X3_CLASSIFY(other_symbol) + + /////////////////////////////////////////////////////////////////////////// + // Unicode Derived Categories + /////////////////////////////////////////////////////////////////////////// + BOOST_SPIRIT_X3_CLASSIFY(alphabetic) + BOOST_SPIRIT_X3_CLASSIFY(uppercase) + BOOST_SPIRIT_X3_CLASSIFY(lowercase) + BOOST_SPIRIT_X3_CLASSIFY(white_space) + BOOST_SPIRIT_X3_CLASSIFY(hex_digit) + BOOST_SPIRIT_X3_CLASSIFY(noncharacter_code_point) + BOOST_SPIRIT_X3_CLASSIFY(default_ignorable_code_point) + + /////////////////////////////////////////////////////////////////////////// + // Unicode Scripts + /////////////////////////////////////////////////////////////////////////// + BOOST_SPIRIT_X3_CLASSIFY(arabic) + BOOST_SPIRIT_X3_CLASSIFY(imperial_aramaic) + BOOST_SPIRIT_X3_CLASSIFY(armenian) + BOOST_SPIRIT_X3_CLASSIFY(avestan) + BOOST_SPIRIT_X3_CLASSIFY(balinese) + BOOST_SPIRIT_X3_CLASSIFY(bamum) + BOOST_SPIRIT_X3_CLASSIFY(bengali) + BOOST_SPIRIT_X3_CLASSIFY(bopomofo) + BOOST_SPIRIT_X3_CLASSIFY(braille) + BOOST_SPIRIT_X3_CLASSIFY(buginese) + BOOST_SPIRIT_X3_CLASSIFY(buhid) + BOOST_SPIRIT_X3_CLASSIFY(canadian_aboriginal) + BOOST_SPIRIT_X3_CLASSIFY(carian) + BOOST_SPIRIT_X3_CLASSIFY(cham) + BOOST_SPIRIT_X3_CLASSIFY(cherokee) + BOOST_SPIRIT_X3_CLASSIFY(coptic) + BOOST_SPIRIT_X3_CLASSIFY(cypriot) + BOOST_SPIRIT_X3_CLASSIFY(cyrillic) + BOOST_SPIRIT_X3_CLASSIFY(devanagari) + BOOST_SPIRIT_X3_CLASSIFY(deseret) + BOOST_SPIRIT_X3_CLASSIFY(egyptian_hieroglyphs) + BOOST_SPIRIT_X3_CLASSIFY(ethiopic) + BOOST_SPIRIT_X3_CLASSIFY(georgian) + BOOST_SPIRIT_X3_CLASSIFY(glagolitic) + BOOST_SPIRIT_X3_CLASSIFY(gothic) + BOOST_SPIRIT_X3_CLASSIFY(greek) + BOOST_SPIRIT_X3_CLASSIFY(gujarati) + BOOST_SPIRIT_X3_CLASSIFY(gurmukhi) + BOOST_SPIRIT_X3_CLASSIFY(hangul) + BOOST_SPIRIT_X3_CLASSIFY(han) + BOOST_SPIRIT_X3_CLASSIFY(hanunoo) + BOOST_SPIRIT_X3_CLASSIFY(hebrew) + BOOST_SPIRIT_X3_CLASSIFY(hiragana) + BOOST_SPIRIT_X3_CLASSIFY(katakana_or_hiragana) + BOOST_SPIRIT_X3_CLASSIFY(old_italic) + BOOST_SPIRIT_X3_CLASSIFY(javanese) + BOOST_SPIRIT_X3_CLASSIFY(kayah_li) + BOOST_SPIRIT_X3_CLASSIFY(katakana) + BOOST_SPIRIT_X3_CLASSIFY(kharoshthi) + BOOST_SPIRIT_X3_CLASSIFY(khmer) + BOOST_SPIRIT_X3_CLASSIFY(kannada) + BOOST_SPIRIT_X3_CLASSIFY(kaithi) + BOOST_SPIRIT_X3_CLASSIFY(tai_tham) + BOOST_SPIRIT_X3_CLASSIFY(lao) + BOOST_SPIRIT_X3_CLASSIFY(latin) + BOOST_SPIRIT_X3_CLASSIFY(lepcha) + BOOST_SPIRIT_X3_CLASSIFY(limbu) + BOOST_SPIRIT_X3_CLASSIFY(linear_b) + BOOST_SPIRIT_X3_CLASSIFY(lisu) + BOOST_SPIRIT_X3_CLASSIFY(lycian) + BOOST_SPIRIT_X3_CLASSIFY(lydian) + BOOST_SPIRIT_X3_CLASSIFY(malayalam) + BOOST_SPIRIT_X3_CLASSIFY(mongolian) + BOOST_SPIRIT_X3_CLASSIFY(meetei_mayek) + BOOST_SPIRIT_X3_CLASSIFY(myanmar) + BOOST_SPIRIT_X3_CLASSIFY(nko) + BOOST_SPIRIT_X3_CLASSIFY(ogham) + BOOST_SPIRIT_X3_CLASSIFY(ol_chiki) + BOOST_SPIRIT_X3_CLASSIFY(old_turkic) + BOOST_SPIRIT_X3_CLASSIFY(oriya) + BOOST_SPIRIT_X3_CLASSIFY(osmanya) + BOOST_SPIRIT_X3_CLASSIFY(phags_pa) + BOOST_SPIRIT_X3_CLASSIFY(inscriptional_pahlavi) + BOOST_SPIRIT_X3_CLASSIFY(phoenician) + BOOST_SPIRIT_X3_CLASSIFY(inscriptional_parthian) + BOOST_SPIRIT_X3_CLASSIFY(rejang) + BOOST_SPIRIT_X3_CLASSIFY(runic) + BOOST_SPIRIT_X3_CLASSIFY(samaritan) + BOOST_SPIRIT_X3_CLASSIFY(old_south_arabian) + BOOST_SPIRIT_X3_CLASSIFY(saurashtra) + BOOST_SPIRIT_X3_CLASSIFY(shavian) + BOOST_SPIRIT_X3_CLASSIFY(sinhala) + BOOST_SPIRIT_X3_CLASSIFY(sundanese) + BOOST_SPIRIT_X3_CLASSIFY(syloti_nagri) + BOOST_SPIRIT_X3_CLASSIFY(syriac) + BOOST_SPIRIT_X3_CLASSIFY(tagbanwa) + BOOST_SPIRIT_X3_CLASSIFY(tai_le) + BOOST_SPIRIT_X3_CLASSIFY(new_tai_lue) + BOOST_SPIRIT_X3_CLASSIFY(tamil) + BOOST_SPIRIT_X3_CLASSIFY(tai_viet) + BOOST_SPIRIT_X3_CLASSIFY(telugu) + BOOST_SPIRIT_X3_CLASSIFY(tifinagh) + BOOST_SPIRIT_X3_CLASSIFY(tagalog) + BOOST_SPIRIT_X3_CLASSIFY(thaana) + BOOST_SPIRIT_X3_CLASSIFY(thai) + BOOST_SPIRIT_X3_CLASSIFY(tibetan) + BOOST_SPIRIT_X3_CLASSIFY(ugaritic) + BOOST_SPIRIT_X3_CLASSIFY(vai) + BOOST_SPIRIT_X3_CLASSIFY(old_persian) + BOOST_SPIRIT_X3_CLASSIFY(cuneiform) + BOOST_SPIRIT_X3_CLASSIFY(yi) + BOOST_SPIRIT_X3_CLASSIFY(inherited) + BOOST_SPIRIT_X3_CLASSIFY(common) + BOOST_SPIRIT_X3_CLASSIFY(unknown) + +#undef BOOST_SPIRIT_X3_BASIC_CLASSIFY +#undef BOOST_SPIRIT_X3_CLASSIFY + }; + + template <typename Tag> + struct unicode_char_class + : char_parser<unicode_char_class<Tag>> + { + typedef char_encoding::unicode encoding; + typedef Tag tag; + typedef typename encoding::char_type char_type; + typedef char_type attribute_type; + static bool const has_attribute = true; + + template <typename Char, typename Context> + bool test(Char ch, Context const&) const + { + return ((sizeof(Char) <= sizeof(char_type)) || encoding::ischar(ch)) + && unicode_char_class_base::is(tag(), ch); + } + }; + +#define BOOST_SPIRIT_X3_CHAR_CLASS(name) \ + typedef unicode_char_class<name##_tag> name##_type; \ + name##_type const name = name##_type(); \ + /***/ + + namespace unicode + { + typedef any_char<char_encoding::unicode> char_type; + char_type const char_ = char_type(); + + /////////////////////////////////////////////////////////////////////////// + // Unicode Major Categories + /////////////////////////////////////////////////////////////////////////// + BOOST_SPIRIT_X3_CHAR_CLASS(alnum) + BOOST_SPIRIT_X3_CHAR_CLASS(alpha) + BOOST_SPIRIT_X3_CHAR_CLASS(digit) + BOOST_SPIRIT_X3_CHAR_CLASS(xdigit) + BOOST_SPIRIT_X3_CHAR_CLASS(cntrl) + BOOST_SPIRIT_X3_CHAR_CLASS(graph) + BOOST_SPIRIT_X3_CHAR_CLASS(lower) + BOOST_SPIRIT_X3_CHAR_CLASS(print) + BOOST_SPIRIT_X3_CHAR_CLASS(punct) + BOOST_SPIRIT_X3_CHAR_CLASS(space) + BOOST_SPIRIT_X3_CHAR_CLASS(blank) + BOOST_SPIRIT_X3_CHAR_CLASS(upper) + + /////////////////////////////////////////////////////////////////////////// + // Unicode Major Categories + /////////////////////////////////////////////////////////////////////////// + BOOST_SPIRIT_X3_CHAR_CLASS(letter) + BOOST_SPIRIT_X3_CHAR_CLASS(mark) + BOOST_SPIRIT_X3_CHAR_CLASS(number) + BOOST_SPIRIT_X3_CHAR_CLASS(separator) + BOOST_SPIRIT_X3_CHAR_CLASS(other) + BOOST_SPIRIT_X3_CHAR_CLASS(punctuation) + BOOST_SPIRIT_X3_CHAR_CLASS(symbol) + + /////////////////////////////////////////////////////////////////////////// + // Unicode General Categories + /////////////////////////////////////////////////////////////////////////// + BOOST_SPIRIT_X3_CHAR_CLASS(uppercase_letter) + BOOST_SPIRIT_X3_CHAR_CLASS(lowercase_letter) + BOOST_SPIRIT_X3_CHAR_CLASS(titlecase_letter) + BOOST_SPIRIT_X3_CHAR_CLASS(modifier_letter) + BOOST_SPIRIT_X3_CHAR_CLASS(other_letter) + + BOOST_SPIRIT_X3_CHAR_CLASS(nonspacing_mark) + BOOST_SPIRIT_X3_CHAR_CLASS(enclosing_mark) + BOOST_SPIRIT_X3_CHAR_CLASS(spacing_mark) + + BOOST_SPIRIT_X3_CHAR_CLASS(decimal_number) + BOOST_SPIRIT_X3_CHAR_CLASS(letter_number) + BOOST_SPIRIT_X3_CHAR_CLASS(other_number) + + BOOST_SPIRIT_X3_CHAR_CLASS(space_separator) + BOOST_SPIRIT_X3_CHAR_CLASS(line_separator) + BOOST_SPIRIT_X3_CHAR_CLASS(paragraph_separator) + + BOOST_SPIRIT_X3_CHAR_CLASS(control) + BOOST_SPIRIT_X3_CHAR_CLASS(format) + BOOST_SPIRIT_X3_CHAR_CLASS(private_use) + BOOST_SPIRIT_X3_CHAR_CLASS(surrogate) + BOOST_SPIRIT_X3_CHAR_CLASS(unassigned) + + BOOST_SPIRIT_X3_CHAR_CLASS(dash_punctuation) + BOOST_SPIRIT_X3_CHAR_CLASS(open_punctuation) + BOOST_SPIRIT_X3_CHAR_CLASS(close_punctuation) + BOOST_SPIRIT_X3_CHAR_CLASS(connector_punctuation) + BOOST_SPIRIT_X3_CHAR_CLASS(other_punctuation) + BOOST_SPIRIT_X3_CHAR_CLASS(initial_punctuation) + BOOST_SPIRIT_X3_CHAR_CLASS(final_punctuation) + + BOOST_SPIRIT_X3_CHAR_CLASS(math_symbol) + BOOST_SPIRIT_X3_CHAR_CLASS(currency_symbol) + BOOST_SPIRIT_X3_CHAR_CLASS(modifier_symbol) + BOOST_SPIRIT_X3_CHAR_CLASS(other_symbol) + + /////////////////////////////////////////////////////////////////////////// + // Unicode Derived Categories + /////////////////////////////////////////////////////////////////////////// + BOOST_SPIRIT_X3_CHAR_CLASS(alphabetic) + BOOST_SPIRIT_X3_CHAR_CLASS(uppercase) + BOOST_SPIRIT_X3_CHAR_CLASS(lowercase) + BOOST_SPIRIT_X3_CHAR_CLASS(white_space) + BOOST_SPIRIT_X3_CHAR_CLASS(hex_digit) + BOOST_SPIRIT_X3_CHAR_CLASS(noncharacter_code_point) + BOOST_SPIRIT_X3_CHAR_CLASS(default_ignorable_code_point) + + /////////////////////////////////////////////////////////////////////////// + // Unicode Scripts + /////////////////////////////////////////////////////////////////////////// + BOOST_SPIRIT_X3_CHAR_CLASS(arabic) + BOOST_SPIRIT_X3_CHAR_CLASS(imperial_aramaic) + BOOST_SPIRIT_X3_CHAR_CLASS(armenian) + BOOST_SPIRIT_X3_CHAR_CLASS(avestan) + BOOST_SPIRIT_X3_CHAR_CLASS(balinese) + BOOST_SPIRIT_X3_CHAR_CLASS(bamum) + BOOST_SPIRIT_X3_CHAR_CLASS(bengali) + BOOST_SPIRIT_X3_CHAR_CLASS(bopomofo) + BOOST_SPIRIT_X3_CHAR_CLASS(braille) + BOOST_SPIRIT_X3_CHAR_CLASS(buginese) + BOOST_SPIRIT_X3_CHAR_CLASS(buhid) + BOOST_SPIRIT_X3_CHAR_CLASS(canadian_aboriginal) + BOOST_SPIRIT_X3_CHAR_CLASS(carian) + BOOST_SPIRIT_X3_CHAR_CLASS(cham) + BOOST_SPIRIT_X3_CHAR_CLASS(cherokee) + BOOST_SPIRIT_X3_CHAR_CLASS(coptic) + BOOST_SPIRIT_X3_CHAR_CLASS(cypriot) + BOOST_SPIRIT_X3_CHAR_CLASS(cyrillic) + BOOST_SPIRIT_X3_CHAR_CLASS(devanagari) + BOOST_SPIRIT_X3_CHAR_CLASS(deseret) + BOOST_SPIRIT_X3_CHAR_CLASS(egyptian_hieroglyphs) + BOOST_SPIRIT_X3_CHAR_CLASS(ethiopic) + BOOST_SPIRIT_X3_CHAR_CLASS(georgian) + BOOST_SPIRIT_X3_CHAR_CLASS(glagolitic) + BOOST_SPIRIT_X3_CHAR_CLASS(gothic) + BOOST_SPIRIT_X3_CHAR_CLASS(greek) + BOOST_SPIRIT_X3_CHAR_CLASS(gujarati) + BOOST_SPIRIT_X3_CHAR_CLASS(gurmukhi) + BOOST_SPIRIT_X3_CHAR_CLASS(hangul) + BOOST_SPIRIT_X3_CHAR_CLASS(han) + BOOST_SPIRIT_X3_CHAR_CLASS(hanunoo) + BOOST_SPIRIT_X3_CHAR_CLASS(hebrew) + BOOST_SPIRIT_X3_CHAR_CLASS(hiragana) + BOOST_SPIRIT_X3_CHAR_CLASS(katakana_or_hiragana) + BOOST_SPIRIT_X3_CHAR_CLASS(old_italic) + BOOST_SPIRIT_X3_CHAR_CLASS(javanese) + BOOST_SPIRIT_X3_CHAR_CLASS(kayah_li) + BOOST_SPIRIT_X3_CHAR_CLASS(katakana) + BOOST_SPIRIT_X3_CHAR_CLASS(kharoshthi) + BOOST_SPIRIT_X3_CHAR_CLASS(khmer) + BOOST_SPIRIT_X3_CHAR_CLASS(kannada) + BOOST_SPIRIT_X3_CHAR_CLASS(kaithi) + BOOST_SPIRIT_X3_CHAR_CLASS(tai_tham) + BOOST_SPIRIT_X3_CHAR_CLASS(lao) + BOOST_SPIRIT_X3_CHAR_CLASS(latin) + BOOST_SPIRIT_X3_CHAR_CLASS(lepcha) + BOOST_SPIRIT_X3_CHAR_CLASS(limbu) + BOOST_SPIRIT_X3_CHAR_CLASS(linear_b) + BOOST_SPIRIT_X3_CHAR_CLASS(lisu) + BOOST_SPIRIT_X3_CHAR_CLASS(lycian) + BOOST_SPIRIT_X3_CHAR_CLASS(lydian) + BOOST_SPIRIT_X3_CHAR_CLASS(malayalam) + BOOST_SPIRIT_X3_CHAR_CLASS(mongolian) + BOOST_SPIRIT_X3_CHAR_CLASS(meetei_mayek) + BOOST_SPIRIT_X3_CHAR_CLASS(myanmar) + BOOST_SPIRIT_X3_CHAR_CLASS(nko) + BOOST_SPIRIT_X3_CHAR_CLASS(ogham) + BOOST_SPIRIT_X3_CHAR_CLASS(ol_chiki) + BOOST_SPIRIT_X3_CHAR_CLASS(old_turkic) + BOOST_SPIRIT_X3_CHAR_CLASS(oriya) + BOOST_SPIRIT_X3_CHAR_CLASS(osmanya) + BOOST_SPIRIT_X3_CHAR_CLASS(phags_pa) + BOOST_SPIRIT_X3_CHAR_CLASS(inscriptional_pahlavi) + BOOST_SPIRIT_X3_CHAR_CLASS(phoenician) + BOOST_SPIRIT_X3_CHAR_CLASS(inscriptional_parthian) + BOOST_SPIRIT_X3_CHAR_CLASS(rejang) + BOOST_SPIRIT_X3_CHAR_CLASS(runic) + BOOST_SPIRIT_X3_CHAR_CLASS(samaritan) + BOOST_SPIRIT_X3_CHAR_CLASS(old_south_arabian) + BOOST_SPIRIT_X3_CHAR_CLASS(saurashtra) + BOOST_SPIRIT_X3_CHAR_CLASS(shavian) + BOOST_SPIRIT_X3_CHAR_CLASS(sinhala) + BOOST_SPIRIT_X3_CHAR_CLASS(sundanese) + BOOST_SPIRIT_X3_CHAR_CLASS(syloti_nagri) + BOOST_SPIRIT_X3_CHAR_CLASS(syriac) + BOOST_SPIRIT_X3_CHAR_CLASS(tagbanwa) + BOOST_SPIRIT_X3_CHAR_CLASS(tai_le) + BOOST_SPIRIT_X3_CHAR_CLASS(new_tai_lue) + BOOST_SPIRIT_X3_CHAR_CLASS(tamil) + BOOST_SPIRIT_X3_CHAR_CLASS(tai_viet) + BOOST_SPIRIT_X3_CHAR_CLASS(telugu) + BOOST_SPIRIT_X3_CHAR_CLASS(tifinagh) + BOOST_SPIRIT_X3_CHAR_CLASS(tagalog) + BOOST_SPIRIT_X3_CHAR_CLASS(thaana) + BOOST_SPIRIT_X3_CHAR_CLASS(thai) + BOOST_SPIRIT_X3_CHAR_CLASS(tibetan) + BOOST_SPIRIT_X3_CHAR_CLASS(ugaritic) + BOOST_SPIRIT_X3_CHAR_CLASS(vai) + BOOST_SPIRIT_X3_CHAR_CLASS(old_persian) + BOOST_SPIRIT_X3_CHAR_CLASS(cuneiform) + BOOST_SPIRIT_X3_CHAR_CLASS(yi) + BOOST_SPIRIT_X3_CHAR_CLASS(inherited) + BOOST_SPIRIT_X3_CHAR_CLASS(common) + BOOST_SPIRIT_X3_CHAR_CLASS(unknown) + } + +#undef BOOST_SPIRIT_X3_CHAR_CLASS + +}}} + +#endif diff --git a/boost/spirit/home/x3/core.hpp b/boost/spirit/home/x3/core.hpp new file mode 100644 index 0000000000..a4f875e38a --- /dev/null +++ b/boost/spirit/home/x3/core.hpp @@ -0,0 +1,20 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_CORE_APRIL_04_2012_0318PM) +#define BOOST_SPIRIT_X3_CORE_APRIL_04_2012_0318PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parse.hpp> +//~ #include <boost/spirit/home/x3/core/parse_attr.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/core/action.hpp> + +#endif diff --git a/boost/spirit/home/x3/core/action.hpp b/boost/spirit/home/x3/core/action.hpp new file mode 100644 index 0000000000..890933fff1 --- /dev/null +++ b/boost/spirit/home/x3/core/action.hpp @@ -0,0 +1,120 @@ +/*============================================================================= + Copyright (arg) 2001-2014 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_ACTION_JANUARY_07_2007_1128AM) +#define SPIRIT_ACTION_JANUARY_07_2007_1128AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/context.hpp> +#include <boost/spirit/home/x3/support/traits/attribute_of.hpp> +#include <boost/spirit/home/x3/support/traits/make_attribute.hpp> +#include <boost/spirit/home/x3/core/call.hpp> +#include <boost/spirit/home/x3/nonterminal/detail/transform_attribute.hpp> +#include <boost/range/iterator_range.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + struct raw_attribute_type; + struct parse_pass_context_tag; + + template <typename Context> + inline bool& _pass(Context const& context) + { + return x3::get<parse_pass_context_tag>(context); + } + + template <typename Subject, typename Action> + struct action : unary_parser<Subject, action<Subject, Action>> + { + typedef unary_parser<Subject, action<Subject, Action>> base_type; + static bool const is_pass_through_unary = true; + static bool const has_action = true; + + action(Subject const& subject, Action f) + : base_type(subject), f(f) {} + + template <typename Iterator, typename Context, typename RuleContext, typename Attribute> + bool call_action( + Iterator& first, Iterator const& last + , Context const& context, RuleContext& rcontext, Attribute& attr) const + { + bool pass = true; + auto action_context = make_context<parse_pass_context_tag>(pass, context); + call(f, first, last, action_context, rcontext, attr); + return pass; + } + + template <typename Iterator, typename Context + , typename RuleContext, typename Attribute> + bool parse_main(Iterator& first, Iterator const& last + , Context const& context, RuleContext& rcontext, Attribute& attr) const + { + Iterator save = first; + if (this->subject.parse(first, last, context, rcontext, attr)) + { + if (call_action(first, last, context, rcontext, attr)) + return true; + + // reset iterators if semantic action failed the match + // retrospectively + first = save; + } + return false; + } + + // attr==raw_attribute_type, action wants iterator_range (see raw.hpp) + template <typename Iterator, typename Context, typename RuleContext> + bool parse_main(Iterator& first, Iterator const& last + , Context const& context, RuleContext& rcontext, raw_attribute_type&) const + { + boost::iterator_range<Iterator> rng; + // synthesize the attribute since one is not supplied + return parse_main(first, last, context, rcontext, rng); + } + + // attr==unused, action wants attribute + template <typename Iterator, typename Context, typename RuleContext> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RuleContext& rcontext, unused_type) const + { + typedef typename + traits::attribute_of<action<Subject, Action>, Context>::type + attribute_type; + typedef traits::make_attribute<attribute_type, unused_type> make_attribute; + typedef traits::transform_attribute< + typename make_attribute::type, attribute_type, parser_id> + transform; + + // synthesize the attribute since one is not supplied + typename make_attribute::type made_attr = make_attribute::call(unused_type()); + typename transform::type attr = transform::pre(made_attr); + return parse_main(first, last, context, rcontext, attr); + } + + // main parse function + template <typename Iterator, typename Context + , typename RuleContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RuleContext& rcontext, Attribute& attr) const + { + return parse_main(first, last, context, rcontext, attr); + } + + Action f; + }; + + template <typename P, typename Action> + inline action<typename extension::as_parser<P>::value_type, Action> + operator/(P const& p, Action f) + { + return {as_parser(p), f}; + } +}}} + +#endif diff --git a/boost/spirit/home/x3/core/call.hpp b/boost/spirit/home/x3/core/call.hpp new file mode 100644 index 0000000000..a4139751df --- /dev/null +++ b/boost/spirit/home/x3/core/call.hpp @@ -0,0 +1,79 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_CALL_CONTEXT_MAY_26_2014_0234PM) +#define SPIRIT_CALL_CONTEXT_MAY_26_2014_0234PM + +#include <type_traits> + +#include <boost/spirit/home/x3/support/context.hpp> +#include <boost/spirit/home/x3/support/utility/is_callable.hpp> +#include <boost/range/iterator_range.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + //////////////////////////////////////////////////////////////////////////// + struct rule_val_context_tag; + + template <typename Context> + inline auto _val(Context const& context) + -> decltype(x3::get<rule_val_context_tag>(context)) + { + return x3::get<rule_val_context_tag>(context); + } + + //////////////////////////////////////////////////////////////////////////// + struct where_context_tag; + + template <typename Context> + inline auto _where(Context const& context) + -> decltype(x3::get<where_context_tag>(context)) + { + return x3::get<where_context_tag>(context); + } + + //////////////////////////////////////////////////////////////////////////// + struct attr_context_tag; + + template <typename Context> + inline auto _attr(Context const& context) + -> decltype(x3::get<attr_context_tag>(context)) + { + return x3::get<attr_context_tag>(context); + } + + //////////////////////////////////////////////////////////////////////////// + namespace detail + { + template <typename F, typename Context> + auto call(F f, Context const& context, mpl::true_) + { + return f(context); + } + + template <typename F, typename Context> + auto call(F f, Context const& context, mpl::false_) + { + return f(); + } + } + + template < + typename F, typename Iterator + , typename Context, typename RuleContext, typename Attribute> + auto call( + F f, Iterator& first, Iterator const& last + , Context const& context, RuleContext& rcontext, Attribute& attr) + { + boost::iterator_range<Iterator> rng(first, last); + auto val_context = make_context<rule_val_context_tag>(rcontext, context); + auto where_context = make_context<where_context_tag>(rng, val_context); + auto attr_context = make_context<attr_context_tag>(attr, where_context); + return detail::call(f, attr_context, is_callable<F(decltype(attr_context) const&)>()); + } +}}} + +#endif diff --git a/boost/spirit/home/x3/core/detail/parse_into_container.hpp b/boost/spirit/home/x3/core/detail/parse_into_container.hpp new file mode 100644 index 0000000000..4b19115a67 --- /dev/null +++ b/boost/spirit/home/x3/core/detail/parse_into_container.hpp @@ -0,0 +1,248 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_PARSE_INTO_CONTAINER_JAN_15_2013_0957PM) +#define SPIRIT_PARSE_INTO_CONTAINER_JAN_15_2013_0957PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <type_traits> + +#include <boost/spirit/home/x3/support/traits/container_traits.hpp> +#include <boost/spirit/home/x3/support/traits/value_traits.hpp> +#include <boost/spirit/home/x3/support/traits/attribute_of.hpp> +#include <boost/spirit/home/x3/support/traits/handles_container.hpp> +#include <boost/spirit/home/x3/support/traits/has_attribute.hpp> +#include <boost/spirit/home/x3/support/traits/is_substitute.hpp> +#include <boost/spirit/home/x3/support/traits/move_to.hpp> +#include <boost/mpl/and.hpp> +#include <boost/fusion/include/front.hpp> +#include <boost/fusion/include/back.hpp> +#include <boost/variant/apply_visitor.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace detail +{ + template <typename Attribute, typename Value> + struct saver_visitor; + + // save to associative fusion container where Key is simple type + template <typename Key, typename Enable = void> + struct save_to_assoc_attr + { + template <typename Value, typename Attribute> + static void call(const Key, Value& value, Attribute& attr) + { + traits::move_to(value, fusion::at_key<Key>(attr)); + } + }; + + + // save to associative fusion container where Key + // is variant over possible keys + template <typename ...T> + struct save_to_assoc_attr<variant<T...> > + { + typedef variant<T...> variant_t; + + template <typename Value, typename Attribute> + static void call(const variant_t key, Value& value, Attribute& attr) + { + apply_visitor(saver_visitor<Attribute, Value>(attr, value), key); + } + }; + + template <typename Attribute, typename Value> + struct saver_visitor : boost::static_visitor<void> + { + saver_visitor(Attribute& attr, Value& value) + : attr(attr), value(value) {}; + + Attribute& attr; + Value& value; + + template <typename Key> + void operator()(Key) const + { + save_to_assoc_attr<Key>::call(Key(), value,attr); + } + }; + + + template <typename Parser> + struct parse_into_container_base_impl + { + private: + + // Parser has attribute (synthesize; Attribute is a container) + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + static bool call_synthesize( + Parser const& parser + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) + { + // synthesized attribute needs to be value initialized + typedef typename + traits::container_value<Attribute>::type + value_type; + value_type val = traits::value_initialize<value_type>::call(); + + if (!parser.parse(first, last, context, rcontext, val)) + return false; + + // push the parsed value into our attribute + traits::push_back(attr, val); + return true; + } + + // Parser has attribute (synthesize; Attribute is a single element fusion sequence) + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + static bool call_synthesize_into_fusion_seq(Parser const& parser + , Iterator& first, Iterator const& last, Context const& context + , RContext& rcontext, Attribute& attr, mpl::false_ /* is_associative */) + { + static_assert(traits::has_size<Attribute, 1>::value, + "Expecting a single element fusion sequence"); + return call_synthesize(parser, first, last, context, rcontext, + fusion::front(attr)); + } + + // Parser has attribute (synthesize; Attribute is fusion map sequence) + template <typename Iterator, typename Context, typename RContext, typename Attribute> + static bool call_synthesize_into_fusion_seq( + Parser const& parser + , Iterator& first, Iterator const& last, Context const& context + , RContext& rcontext, Attribute& attr, mpl::true_ /*is_associative*/) + { + using attribute_type = typename traits::attribute_of<Parser, Context>::type; + static_assert(traits::has_size<attribute_type, 2>::value, + "To parse directly into fusion map parser must produce 2 element attr"); + + // use type of first element of attribute as key + using key = typename std::remove_reference< + typename fusion::result_of::front<attribute_type>::type>::type; + + attribute_type attr_; + if (!parser.parse(first, last, context, rcontext, attr_)) + return false; + + save_to_assoc_attr<key>::call(fusion::front(attr_), fusion::back(attr_), attr); + return true; + } + + template <typename Iterator, typename Context, typename RContext, typename Attribute> + static bool call_synthesize_dispatch_by_seq(Parser const& parser + , Iterator& first, Iterator const& last, Context const& context + , RContext& rcontext, Attribute& attr, mpl::true_ /*is_sequence*/) + { + return call_synthesize_into_fusion_seq( + parser, first, last, context, rcontext, attr + , fusion::traits::is_associative<Attribute>()); + } + + template <typename Iterator, typename Context, typename RContext, typename Attribute> + static bool call_synthesize_dispatch_by_seq(Parser const& parser + , Iterator& first, Iterator const& last, Context const& context + , RContext& rcontext, Attribute& attr, mpl::false_ /*is_sequence*/) + { + return call_synthesize(parser, first, last, context, rcontext, attr); + } + + // Parser has attribute (synthesize) + template <typename Iterator, typename Context, typename RContext, typename Attribute> + static bool call(Parser const& parser + , Iterator& first, Iterator const& last, Context const& context + , RContext& rcontext, Attribute& attr, mpl::true_) + { + return call_synthesize_dispatch_by_seq(parser, first, last, context, rcontext, attr + , fusion::traits::is_sequence<Attribute>()); + } + + // Parser has no attribute (pass unused) + template <typename Iterator, typename Context, typename RContext, typename Attribute> + static bool call( + Parser const& parser + , Iterator& first, Iterator const& last, Context const& context + , RContext& rcontext, Attribute& attr, mpl::false_) + { + return parser.parse(first, last, context, rcontext, unused); + } + + + public: + + template <typename Iterator, typename Context, typename RContext, typename Attribute> + static bool call(Parser const& parser + , Iterator& first, Iterator const& last, Context const& context + , RContext& rcontext, Attribute& attr) + { + return call(parser, first, last, context, rcontext, attr + , mpl::bool_<traits::has_attribute<Parser, Context>::value>()); + } + }; + + template <typename Parser, typename Context, typename RContext, typename Enable = void> + struct parse_into_container_impl : parse_into_container_base_impl<Parser> {}; + + template <typename Parser, typename Container, typename RContext, typename Context> + struct parser_attr_is_substitute_for_container_value + : traits::is_substitute< + typename traits::attribute_of<Parser, Context>::type + , typename traits::container_value<Container>::type + > + {}; + + template <typename Parser, typename Context, typename RContext> + struct parse_into_container_impl<Parser, Context, RContext, + typename enable_if<traits::handles_container<Parser, Context>>::type> + { + template <typename Iterator, typename Attribute> + static bool call( + Parser const& parser + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr, mpl::true_) + { + return parse_into_container_base_impl<Parser>::call( + parser, first, last, context, rcontext, attr); + } + + template <typename Iterator, typename Attribute> + static bool call( + Parser const& parser + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr, mpl::false_) + { + return parser.parse(first, last, context, rcontext, attr); + } + + template <typename Iterator, typename Attribute> + static bool call(Parser const& parser + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) + { + return call(parser, first, last, context, rcontext, attr, + parser_attr_is_substitute_for_container_value< + Parser, Attribute, Context, RContext>()); + } + }; + + template <typename Parser, typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse_into_container( + Parser const& parser + , Iterator& first, Iterator const& last, Context const& context + , RContext& rcontext, Attribute& attr) + { + return parse_into_container_impl<Parser, Context, RContext>::call( + parser, first, last, context, rcontext, attr); + } + +}}}} + +#endif diff --git a/boost/spirit/home/x3/core/parse.hpp b/boost/spirit/home/x3/core/parse.hpp new file mode 100644 index 0000000000..ac36e3c7ea --- /dev/null +++ b/boost/spirit/home/x3/core/parse.hpp @@ -0,0 +1,190 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_PARSE_APRIL_16_2006_0442PM) +#define BOOST_SPIRIT_X3_PARSE_APRIL_16_2006_0442PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/context.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/concept_check.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Parser, typename Attribute> + inline bool + parse_main( + Iterator& first + , Iterator last + , Parser const& p + , Attribute& 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>)); + + // If you get an error no matching function for call to 'as_parser' + // here, then p is not a parser or there is no suitable conversion + // from p to a parser. + return as_parser(p).parse(first, last, unused, unused, attr); + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Parser, typename Attribute> + inline bool + parse( + Iterator& first + , Iterator last + , Parser const& p + , Attribute& attr) + { + return parse_main(first, last, p, attr); + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Parser, typename Attribute> + inline bool + parse( + Iterator const& first_ + , Iterator last + , Parser const& p + , Attribute& attr) + { + Iterator first = first_; + return parse_main(first, last, p, attr); + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Parser> + inline bool + parse( + Iterator& first + , Iterator last + , Parser const& p) + { + return parse_main(first, last, p, unused); + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Parser> + inline bool + parse( + Iterator const& first_ + , Iterator last + , Parser const& p) + { + Iterator first = first_; + return parse_main(first, last, p, unused); + } + + /////////////////////////////////////////////////////////////////////////// + enum class skip_flag + { + post_skip, // force post-skipping in phrase_parse() + dont_post_skip // inhibit post-skipping in phrase_parse() + }; + + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Parser, typename Skipper, typename Attribute> + inline bool + phrase_parse_main( + Iterator& first + , Iterator last + , Parser const& p + , Skipper const& s + , Attribute& attr + , skip_flag post_skip = skip_flag::post_skip) + { + // 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>)); + + // If you get an error no matching function for call to 'as_parser' + // here, for either p or s, then p or s is not a parser or there is + // no suitable conversion from p to a parser. + auto skipper_ctx = make_context<skipper_tag>(as_parser(s)); + bool r = as_parser(p).parse(first, last, skipper_ctx, unused, attr); + if (post_skip == skip_flag::post_skip) + x3::skip_over(first, last, skipper_ctx); + return r; + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Parser, typename Skipper, typename Attribute> + inline bool + phrase_parse( + Iterator& first + , Iterator last + , Parser const& p + , Skipper const& s + , Attribute& attr + , skip_flag post_skip = skip_flag::post_skip) + { + return phrase_parse_main(first, last, p, s, attr, post_skip); + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Parser, typename Skipper, typename Attribute> + inline bool + phrase_parse( + Iterator const& first_ + , Iterator last + , Parser const& p + , Skipper const& s + , Attribute& attr + , skip_flag post_skip = skip_flag::post_skip) + { + Iterator first = first_; + return phrase_parse_main(first, last, p, s, attr, post_skip); + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Parser, typename Skipper> + inline bool + phrase_parse( + Iterator& first + , Iterator last + , Parser const& p + , Skipper const& s + , skip_flag post_skip = skip_flag::post_skip) + { + return phrase_parse_main(first, last, p, s, unused, post_skip); + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Parser, typename Skipper> + inline bool + phrase_parse( + Iterator const& first_ + , Iterator last + , Parser const& p + , Skipper const& s + , skip_flag post_skip = skip_flag::post_skip) + { + Iterator first = first_; + return phrase_parse_main(first, last, p, s, unused, post_skip); + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Skipper> + struct phrase_parse_context + { + typedef decltype( + make_context<skipper_tag>(as_parser(std::declval<Skipper>()))) + type; + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/core/parser.hpp b/boost/spirit/home/x3/core/parser.hpp new file mode 100644 index 0000000000..bc63a7438b --- /dev/null +++ b/boost/spirit/home/x3/core/parser.hpp @@ -0,0 +1,239 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2013 Agustin Berge + + 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_X3_PARSER_OCTOBER_16_2008_0254PM) +#define BOOST_SPIRIT_X3_PARSER_OCTOBER_16_2008_0254PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/mpl/bool.hpp> +#include <boost/type_traits/is_base_of.hpp> +#include <boost/type_traits/remove_cv.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/utility/declval.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/support/context.hpp> +#include <boost/spirit/home/x3/support/traits/has_attribute.hpp> +#include <boost/spirit/home/x3/support/utility/sfinae.hpp> +#include <string> + +#if !defined(BOOST_SPIRIT_X3_NO_RTTI) +#include <typeinfo> +#endif + +namespace boost { namespace spirit { namespace x3 +{ + using x3::unused_type; + using x3::unused; + using x3::get; + + template <typename Subject, typename Action> + struct action; + + template <typename Subject, typename Handler> + struct guard; + + struct parser_base {}; + struct parser_id; + + template <typename Derived> + struct parser : parser_base + { + typedef Derived derived_type; + static bool const handles_container = false; + static bool const is_pass_through_unary = false; + static bool const has_action = false; + + Derived const& derived() const + { + return *static_cast<Derived const*>(this); + } + + template <typename Action> + action<Derived, Action> + operator[](Action f) const + { + return action<Derived, Action>(this->derived(), f); + } + + template <typename Handler> + guard<Derived, Handler> + on_error(Handler f) const + { + return guard<Derived, Handler>(this->derived(), f); + } + }; + + struct unary_category; + struct binary_category; + + template <typename Subject, typename Derived> + struct unary_parser : parser<Derived> + { + typedef unary_category category; + typedef Subject subject_type; + static bool const has_action = Subject::has_action; + + unary_parser(Subject subject) + : subject(subject) {} + + unary_parser const& get_unary() const { return *this; } + + Subject subject; + }; + + template <typename Left, typename Right, typename Derived> + struct binary_parser : parser<Derived> + { + typedef binary_category category; + typedef Left left_type; + typedef Right right_type; + static bool const has_action = + left_type::has_action || right_type::has_action; + + binary_parser(Left left, Right right) + : left(left), right(right) {} + + binary_parser const& get_binary() const { return *this; } + + Left left; + Right right; + }; + + /////////////////////////////////////////////////////////////////////////// + // as_parser: convert a type, T, into a parser. + /////////////////////////////////////////////////////////////////////////// + namespace extension + { + namespace detail + { + namespace as_parser_guard + { + void as_spirit_parser(...); + + template<typename T, typename R = + decltype(as_spirit_parser(boost::declval<T const&>()))> + struct deduce_as_parser + { + typedef R type; + typedef typename + boost::remove_cv< + typename boost::remove_reference<R>::type + >::type + value_type; + + static type call(T const& v) + { + return as_spirit_parser(v); + } + }; + template<typename T> + struct deduce_as_parser<T, void> + {}; + } + using as_parser_guard::deduce_as_parser; + } + + template <typename T, typename Enable = void> + struct as_parser : detail::deduce_as_parser<T> {}; + + template <> + struct as_parser<unused_type> + { + typedef unused_type type; + typedef unused_type value_type; + static type call(unused_type) + { + return unused; + } + }; + + template <typename Derived> + struct as_parser<Derived + , typename enable_if<is_base_of<parser_base, Derived>>::type> + { + typedef Derived const& type; + typedef Derived value_type; + static type call(Derived const& p) + { + return p; + } + }; + + template <typename Derived> + struct as_parser<parser<Derived>> + { + typedef Derived const& type; + typedef Derived value_type; + static type call(parser<Derived> const& p) + { + return p.derived(); + } + }; + } + + template <typename T> + inline typename extension::as_parser<T>::type + as_parser(T const& x) + { + return extension::as_parser<T>::call(x); + } + + template <typename Derived> + inline Derived const& + as_parser(parser<Derived> const& p) + { + return p.derived(); + } + + /////////////////////////////////////////////////////////////////////////// + // The main what function + // + // Note: unlike Spirit2, spirit parsers are no longer required to have a + // "what" member function. In X3, we specialize the get_info struct + // below where needed. If a specialization is not provided, the default + // below will be used. The default "what" result will be the typeid + // name of the parser if BOOST_SPIRIT_X3_NO_RTTI is not defined, otherwise + // "undefined" + /////////////////////////////////////////////////////////////////////////// + template <typename Parser, typename Enable = void> + struct get_info + { + typedef std::string result_type; + std::string operator()(Parser const&) const + { +#if !defined(BOOST_SPIRIT_X3_NO_RTTI) + return typeid(Parser).name(); +#else + return "undefined"; +#endif + } + }; + + template <typename Parser> + std::string what(Parser const& p) + { + return get_info<Parser>()(p); + } +}}} + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Subject, typename Derived, typename Context> + struct has_attribute<x3::unary_parser<Subject, Derived>, Context> + : has_attribute<Subject, Context> {}; + + template <typename Left, typename Right, typename Derived, typename Context> + struct has_attribute<x3::binary_parser<Left, Right, Derived>, Context> + : mpl::bool_<has_attribute<Left, Context>::value || + has_attribute<Right, Context>::value> {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/core/proxy.hpp b/boost/spirit/home/x3/core/proxy.hpp new file mode 100644 index 0000000000..1a0ade59a8 --- /dev/null +++ b/boost/spirit/home/x3/core/proxy.hpp @@ -0,0 +1,52 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_PROXY_FEBRUARY_1_2013_0211PM) +#define BOOST_SPIRIT_X3_PROXY_FEBRUARY_1_2013_0211PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/core/detail/parse_into_container.hpp> +#include <boost/spirit/home/x3/support/traits/attribute_category.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Subject, typename Derived> + struct proxy : unary_parser<Subject, Derived> + { + static bool const is_pass_through_unary = true; + + proxy(Subject const& subject) + : unary_parser<Subject, Derived>(subject) {} + + // Overload this when appropriate. The proxy parser will pick up + // the most derived overload. + template <typename Iterator, typename Context + , typename RuleContext, typename Attribute, typename Category> + bool parse_subject(Iterator& first, Iterator const& last + , Context const& context, RuleContext& rcontext, Attribute& attr, Category) const + { + this->subject.parse(first, last, context, rcontext, attr); + return true; + } + + // Main entry point. + template <typename Iterator, typename Context + , typename RuleContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RuleContext& rcontext, Attribute& attr) const + { + return this->derived().parse_subject(first, last, context, rcontext, attr + , typename traits::attribute_category<Attribute>::type()); + } + }; + +}}} + +#endif diff --git a/boost/spirit/home/x3/core/skip_over.hpp b/boost/spirit/home/x3/core/skip_over.hpp new file mode 100644 index 0000000000..643ddb1f5b --- /dev/null +++ b/boost/spirit/home/x3/core/skip_over.hpp @@ -0,0 +1,104 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_SKIP_APRIL_16_2006_0625PM) +#define BOOST_SPIRIT_X3_SKIP_APRIL_16_2006_0625PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/support/context.hpp> +#include <boost/spirit/home/x3/support/traits/attribute_category.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/not.hpp> +#include <boost/type_traits/remove_cv.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/utility/declval.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + /////////////////////////////////////////////////////////////////////////// + // Move the /first/ iterator to the first non-matching position + // given a skip-parser. The function is a no-op if unused_type or + // unused_skipper is passed as the skip-parser. + /////////////////////////////////////////////////////////////////////////// + template <typename Skipper> + struct unused_skipper : unused_type + { + unused_skipper(Skipper const& skipper) + : skipper(skipper) {} + Skipper const& skipper; + }; + + namespace detail + { + template <typename Skipper> + struct is_unused_skipper + : mpl::false_ {}; + + template <typename Skipper> + struct is_unused_skipper<unused_skipper<Skipper>> + : mpl::true_ {}; + + template <> + struct is_unused_skipper<unused_type> + : mpl::true_ {}; + + template <typename Skipper> + inline Skipper const& + get_unused_skipper(Skipper const& skipper) + { + return skipper; + } + template <typename Skipper> + inline Skipper const& + get_unused_skipper(unused_skipper<Skipper> const& unused_skipper) + { + return unused_skipper.skipper; + } + + template <typename Iterator, typename Skipper> + inline void skip_over( + Iterator& first, Iterator const& last, Skipper const& skipper) + { + while (first != last && skipper.parse(first, last, unused, unused, unused)) + /***/; + } + + template <typename Iterator> + inline void skip_over(Iterator&, Iterator const&, unused_type) + { + } + + template <typename Iterator, typename Skipper> + inline void skip_over( + Iterator&, Iterator const&, unused_skipper<Skipper> const&) + { + } + } + + // this tag is used to find the skipper from the context + struct skipper_tag; + + template <typename Context> + struct has_skipper + : mpl::not_<detail::is_unused_skipper< + typename remove_cv<typename remove_reference< + decltype(x3::get<skipper_tag>(boost::declval<Context>())) + >::type>::type + >> {}; + + template <typename Iterator, typename Context> + inline void skip_over( + Iterator& first, Iterator const& last, Context const& context) + { + detail::skip_over(first, last, x3::get<skipper_tag>(context)); + } +}}} + +#endif diff --git a/boost/spirit/home/x3/directive.hpp b/boost/spirit/home/x3/directive.hpp new file mode 100644 index 0000000000..81f7a8536a --- /dev/null +++ b/boost/spirit/home/x3/directive.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_DIRECTIVE_FEBRUARY_05_2007_0313PM) +#define BOOST_SPIRIT_X3_DIRECTIVE_FEBRUARY_05_2007_0313PM + +#if defined(_MSC_VER) +#pragma once +#endif + +//~ #include <boost/spirit/home/x3/directive/as.hpp> +//~ #include <boost/spirit/home/x3/directive/encoding.hpp> +//~ #include <boost/spirit/home/x3/directive/hold.hpp> +#include <boost/spirit/home/x3/directive/expect.hpp> +#include <boost/spirit/home/x3/directive/lexeme.hpp> +#include <boost/spirit/home/x3/directive/no_skip.hpp> +//~ #include <boost/spirit/home/x3/directive/matches.hpp> +//~ #include <boost/spirit/home/x3/directive/no_case.hpp> +#include <boost/spirit/home/x3/directive/omit.hpp> +#include <boost/spirit/home/x3/directive/raw.hpp> +//~ #include <boost/spirit/home/x3/directive/repeat.hpp> +#include <boost/spirit/home/x3/directive/skip.hpp> +#include <boost/spirit/home/x3/directive/with.hpp> + +#endif diff --git a/boost/spirit/home/x3/directive/expect.hpp b/boost/spirit/home/x3/directive/expect.hpp new file mode 100644 index 0000000000..4e59ce5dca --- /dev/null +++ b/boost/spirit/home/x3/directive/expect.hpp @@ -0,0 +1,80 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_EXPECT_MARCH_16_2012_1024PM) +#define SPIRIT_EXPECT_MARCH_16_2012_1024PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/context.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/throw_exception.hpp> +#include <stdexcept> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Iterator> + struct expectation_failure : std::runtime_error + { + public: + + expectation_failure(Iterator where, std::string const& which) + : std::runtime_error("boost::spirit::x3::expectation_failure") + , where_(where), which_(which) + {} + ~expectation_failure() throw() {} + + std::string which() const { return which_; } + Iterator const& where() const { return where_; } + + private: + + Iterator where_; + std::string which_; + }; + + template <typename Subject> + struct expect_directive : unary_parser<Subject, expect_directive<Subject>> + { + typedef unary_parser<Subject, expect_directive<Subject> > base_type; + static bool const is_pass_through_unary = true; + + expect_directive(Subject const& subject) + : base_type(subject) {} + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + bool r = this->subject.parse(first, last, context, rcontext, attr); + + if (!r) + { + boost::throw_exception( + expectation_failure<Iterator>( + first, what(this->subject))); + } + return r; + } + }; + + struct expect_gen + { + template <typename Subject> + expect_directive<typename extension::as_parser<Subject>::value_type> + operator[](Subject const& subject) const + { + return {as_parser(subject)}; + } + }; + + expect_gen const expect = expect_gen(); +}}} + +#endif diff --git a/boost/spirit/home/x3/directive/lexeme.hpp b/boost/spirit/home/x3/directive/lexeme.hpp new file mode 100644 index 0000000000..e5104272f9 --- /dev/null +++ b/boost/spirit/home/x3/directive/lexeme.hpp @@ -0,0 +1,84 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_LEXEME_MARCH_24_2007_0802AM) +#define SPIRIT_LEXEME_MARCH_24_2007_0802AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/context.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/utility/enable_if.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Subject> + struct lexeme_directive : unary_parser<Subject, lexeme_directive<Subject>> + { + typedef unary_parser<Subject, lexeme_directive<Subject> > base_type; + static bool const is_pass_through_unary = true; + static bool const handles_container = Subject::handles_container; + + lexeme_directive(Subject const& subject) + : base_type(subject) {} + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + typename enable_if<has_skipper<Context>, bool>::type + parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + x3::skip_over(first, last, context); + auto const& skipper = x3::get<skipper_tag>(context); + + typedef unused_skipper< + typename remove_reference<decltype(skipper)>::type> + unused_skipper_type; + unused_skipper_type unused_skipper(skipper); + + return this->subject.parse( + first, last + , make_context<skipper_tag>(unused_skipper, context) + , rcontext + , attr); + } + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + typename disable_if<has_skipper<Context>, bool>::type + parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + // no need to pre-skip if skipper is unused + //- x3::skip_over(first, last, context); + + return this->subject.parse( + first, last + , context + , rcontext + , attr); + } + }; + + struct lexeme_gen + { + template <typename Subject> + lexeme_directive<typename extension::as_parser<Subject>::value_type> + operator[](Subject const& subject) const + { + return {as_parser(subject)}; + } + }; + + lexeme_gen const lexeme = lexeme_gen(); +}}} + +#endif diff --git a/boost/spirit/home/x3/directive/no_skip.hpp b/boost/spirit/home/x3/directive/no_skip.hpp new file mode 100644 index 0000000000..14dee4d85c --- /dev/null +++ b/boost/spirit/home/x3/directive/no_skip.hpp @@ -0,0 +1,82 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + Copyright (c) 2013 Agustin Berge + + 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_NO_SKIP_JAN_16_2010_0802PM) +#define SPIRIT_NO_SKIP_JAN_16_2010_0802PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/context.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/utility/enable_if.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + // same as lexeme[], but does not pre-skip + template <typename Subject> + struct no_skip_directive : unary_parser<Subject, no_skip_directive<Subject>> + { + typedef unary_parser<Subject, no_skip_directive<Subject> > base_type; + static bool const is_pass_through_unary = true; + static bool const handles_container = Subject::handles_container; + + no_skip_directive(Subject const& subject) + : base_type(subject) {} + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + typename enable_if<has_skipper<Context>, bool>::type + parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + auto const& skipper = x3::get<skipper_tag>(context); + + typedef unused_skipper< + typename remove_reference<decltype(skipper)>::type> + unused_skipper_type; + unused_skipper_type unused_skipper(skipper); + + return this->subject.parse( + first, last + , make_context<skipper_tag>(unused_skipper, context) + , rcontext + , attr); + } + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + typename disable_if<has_skipper<Context>, bool>::type + parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + return this->subject.parse( + first, last + , context + , rcontext + , attr); + } + }; + + struct no_skip_gen + { + template <typename Subject> + no_skip_directive<typename extension::as_parser<Subject>::value_type> + operator[](Subject const& subject) const + { + return {as_parser(subject)}; + } + }; + + no_skip_gen const no_skip = no_skip_gen(); +}}} + +#endif diff --git a/boost/spirit/home/x3/directive/omit.hpp b/boost/spirit/home/x3/directive/omit.hpp new file mode 100644 index 0000000000..43ebd49aaf --- /dev/null +++ b/boost/spirit/home/x3/directive/omit.hpp @@ -0,0 +1,55 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_OMIT_MARCH_24_2007_0802AM) +#define SPIRIT_OMIT_MARCH_24_2007_0802AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + /////////////////////////////////////////////////////////////////////////// + // omit_directive forces the attribute of subject parser + // to be unused_type + /////////////////////////////////////////////////////////////////////////// + template <typename Subject> + struct omit_directive : unary_parser<Subject, omit_directive<Subject>> + { + typedef unary_parser<Subject, omit_directive<Subject> > base_type; + typedef unused_type attribute_type; + static bool const has_attribute = false; + + typedef Subject subject_type; + omit_directive(Subject const& subject) + : base_type(subject) {} + + template <typename Iterator, typename Context, typename RContext> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, unused_type) const + { + return this->subject.parse(first, last, context, rcontext, unused); + } + }; + + struct omit_gen + { + template <typename Subject> + omit_directive<typename extension::as_parser<Subject>::value_type> + operator[](Subject const& subject) const + { + return {as_parser(subject)}; + } + }; + + omit_gen const omit = omit_gen(); +}}} + +#endif diff --git a/boost/spirit/home/x3/directive/raw.hpp b/boost/spirit/home/x3/directive/raw.hpp new file mode 100644 index 0000000000..e6bcd9a3a1 --- /dev/null +++ b/boost/spirit/home/x3/directive/raw.hpp @@ -0,0 +1,70 @@ +/*============================================================================= + Copyright (c) 2014 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_X3_RAW_APRIL_9_2007_0912AM) +#define SPIRIT_X3_RAW_APRIL_9_2007_0912AM + +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/support/traits/move_to.hpp> +#include <boost/range/iterator_range.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + // this is a pseudo attribute type indicating that the parser wants the + // iterator range pointing to the [first, last) matching characters from + // the input iterators. + struct raw_attribute_type {}; + + template <typename Subject> + struct raw_directive : unary_parser<Subject, raw_directive<Subject>> + { + typedef unary_parser<Subject, raw_directive<Subject> > base_type; + typedef raw_attribute_type attribute_type; + static bool const handles_container = Subject::handles_container; + typedef Subject subject_type; + + raw_directive(Subject const& subject) + : base_type(subject) {} + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + x3::skip_over(first, last, context); + Iterator i = first; + if (this->subject.parse(i, last, context, rcontext, unused)) + { + traits::move_to(first, i, attr); + first = i; + return true; + } + return false; + } + + template <typename Iterator, typename Context, typename RContext> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, unused_type) const + { + return this->subject.parse(first, last, context, rcontext, unused); + } + }; + + struct raw_gen + { + template <typename Subject> + raw_directive<typename extension::as_parser<Subject>::value_type> + operator[](Subject const& subject) const + { + return {as_parser(subject)}; + } + }; + + raw_gen const raw = raw_gen(); +}}} + +#endif diff --git a/boost/spirit/home/x3/directive/skip.hpp b/boost/spirit/home/x3/directive/skip.hpp new file mode 100644 index 0000000000..c880720791 --- /dev/null +++ b/boost/spirit/home/x3/directive/skip.hpp @@ -0,0 +1,124 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2013 Agustin Berge + + 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_SKIP_JANUARY_26_2008_0422PM) +#define SPIRIT_SKIP_JANUARY_26_2008_0422PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/context.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/utility/enable_if.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Subject> + struct reskip_directive : unary_parser<Subject, reskip_directive<Subject>> + { + typedef unary_parser<Subject, reskip_directive<Subject>> base_type; + static bool const is_pass_through_unary = true; + static bool const handles_container = Subject::handles_container; + + reskip_directive(Subject const& subject) + : base_type(subject) {} + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + typename disable_if<has_skipper<Context>, bool>::type + parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + auto const& skipper = + detail::get_unused_skipper(x3::get<skipper_tag>(context)); + + return this->subject.parse( + first, last + , make_context<skipper_tag>(skipper, context) + , rcontext + , attr); + } + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + typename enable_if<has_skipper<Context>, bool>::type + parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + return this->subject.parse( + first, last + , context + , rcontext + , attr); + } + }; + + template <typename Subject, typename Skipper> + struct skip_directive : unary_parser<Subject, skip_directive<Subject, Skipper>> + { + typedef unary_parser<Subject, skip_directive<Subject, Skipper>> base_type; + static bool const is_pass_through_unary = true; + static bool const handles_container = Subject::handles_container; + + skip_directive(Subject const& subject, Skipper const& skipper) + : base_type(subject) + , skipper(skipper) + {} + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + return this->subject.parse( + first, last + , make_context<skipper_tag>(skipper, context) + , rcontext + , attr); + } + + Skipper const skipper; + }; + + struct reskip_gen + { + template <typename Skipper> + struct skip_gen + { + explicit skip_gen(Skipper const& skipper) + : skipper_(skipper) {} + + template <typename Subject> + skip_directive<typename extension::as_parser<Subject>::value_type, Skipper> + operator[](Subject const& subject) const + { + return {as_parser(subject), skipper_}; + } + + Skipper skipper_; + }; + + template <typename Skipper> + skip_gen<Skipper> const operator()(Skipper const& skipper) const + { + return skip_gen<Skipper>(skipper); + } + + template <typename Subject> + reskip_directive<typename extension::as_parser<Subject>::value_type> + operator[](Subject const& subject) const + { + return {as_parser(subject)}; + } + }; + + reskip_gen const skip = reskip_gen(); +}}} + +#endif diff --git a/boost/spirit/home/x3/directive/with.hpp b/boost/spirit/home/x3/directive/with.hpp new file mode 100644 index 0000000000..cc6c442a34 --- /dev/null +++ b/boost/spirit/home/x3/directive/with.hpp @@ -0,0 +1,107 @@ +/*============================================================================= + Copyright (c) 2014 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_X3_WITH_MAY_02_2014_0749AM) +#define SPIRIT_X3_WITH_MAY_02_2014_0749AM + +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + /////////////////////////////////////////////////////////////////////////// + // with directive injects a value into the context prior to parsing. + /////////////////////////////////////////////////////////////////////////// + template <typename Subject, typename Derived, typename T> + struct with_value_holder + : unary_parser<Subject, Derived> + { + typedef unary_parser<Subject, Derived> base_type; + mutable T val; + with_value_holder(Subject const& subject, T const& val) + : base_type(subject) + , val(val) {} + }; + + template <typename Subject, typename Derived, typename T> + struct with_value_holder<Subject, Derived, T const> + : unary_parser<Subject, Derived> + { + typedef unary_parser<Subject, Derived> base_type; + T val; + with_value_holder(Subject const& subject, T const& val) + : base_type(subject) + , val(val) {} + }; + + template <typename Subject, typename ID, typename T> + struct with_directive + : with_value_holder<Subject, with_directive<Subject, ID, T>, T> + { + typedef with_value_holder<Subject, with_directive<Subject, ID, T>, T> base_type; + static bool const is_pass_through_unary = true; + static bool const handles_container = Subject::handles_container; + + typedef Subject subject_type; + + with_directive(Subject const& subject, T const& val) + : base_type(subject, val) {} + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + return this->subject.parse( + first, last + , make_context<ID>(this->val, context) + , rcontext + , attr); + } + }; + + template <typename ID, typename T, typename NextContext = unused_type> + struct with_context + { + typedef context<ID, T, NextContext> type; + }; + + template <typename ID, typename T> + struct with_context<ID, T, unused_type> + { + typedef context<ID, T> const type; + }; + + template <typename ID, typename T> + struct with_gen + { + T& val; + + with_gen(T& val) + : val(val) {} + + template <typename Subject> + with_directive<typename extension::as_parser<Subject>::value_type, ID, T> + operator[](Subject const& subject) const + { + return {as_parser(subject), val}; + } + }; + + template <typename ID, typename T> + inline with_gen<ID, T> with(T& val) + { + return with_gen<ID, T>{val}; + } + + template <typename ID, typename T> + inline with_gen<ID, T const> with(T const& val) + { + return with_gen<ID, T const>{val}; + } +}}} + +#endif diff --git a/boost/spirit/home/x3/extensions.hpp b/boost/spirit/home/x3/extensions.hpp new file mode 100644 index 0000000000..a40b719c35 --- /dev/null +++ b/boost/spirit/home/x3/extensions.hpp @@ -0,0 +1,18 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2014 Thomas Bernard + Copyright (c) 2014 Lee Clagett + + 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_X3_EXTENSIONS_APRIL_6_2014_1421PM) +#define BOOST_SPIRIT_X3_EXTENSIONS_APRIL_6_2014_1421PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/extensions/seek.hpp> + +#endif diff --git a/boost/spirit/home/x3/extensions/seek.hpp b/boost/spirit/home/x3/extensions/seek.hpp new file mode 100644 index 0000000000..bcd9544794 --- /dev/null +++ b/boost/spirit/home/x3/extensions/seek.hpp @@ -0,0 +1,70 @@ +/*============================================================================= + Copyright (c) 2011 Jamboree + Copyright (c) 2014 Lee Clagett + + 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_X3_SEEK_APRIL_13_2014_1920PM) +#define BOOST_SPIRIT_X3_SEEK_APRIL_13_2014_1920PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template<typename Subject> + struct seek_directive : unary_parser<Subject, seek_directive<Subject>> + { + typedef unary_parser<Subject, seek_directive<Subject>> base_type; + static bool const is_pass_through_unary = true; + static bool const handles_container = Subject::handles_container; + + seek_directive(Subject const& subject) : + base_type(subject) {} + + template<typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse( + Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + Iterator current(first); + for (/**/; current != last; ++current) + { + if (this->subject.parse(current, last, context, rcontext, attr)) + { + first = current; + return true; + } + } + + // Test for when subjects match on input empty. Example: + // comment = "//" >> seek[eol | eoi] + if (this->subject.parse(current, last, context, rcontext, attr)) + { + first = current; + return true; + } + + return false; + } + }; + + struct seek_gen + { + template<typename Subject> + seek_directive<typename extension::as_parser<Subject>::value_type> + operator[](Subject const& subject) const + { + return {as_parser(subject)}; + } + }; + + seek_gen const seek = seek_gen(); +}}} + +#endif diff --git a/boost/spirit/home/x3/nonterminal.hpp b/boost/spirit/home/x3/nonterminal.hpp new file mode 100644 index 0000000000..1e589bd903 --- /dev/null +++ b/boost/spirit/home/x3/nonterminal.hpp @@ -0,0 +1,19 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_NONTERMINAL_FEBRUARY_12_2007_1018AM) +#define BOOST_SPIRIT_X3_NONTERMINAL_FEBRUARY_12_2007_1018AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/nonterminal/rule.hpp> +//~ #include <boost/spirit/home/x3/nonterminal/error_handler.hpp> +//~ #include <boost/spirit/home/x3/nonterminal/debug_handler.hpp> +//~ #include <boost/spirit/home/x3/nonterminal/success_handler.hpp> + +#endif diff --git a/boost/spirit/home/x3/nonterminal/debug_handler_state.hpp b/boost/spirit/home/x3/nonterminal/debug_handler_state.hpp new file mode 100644 index 0000000000..800023f013 --- /dev/null +++ b/boost/spirit/home/x3/nonterminal/debug_handler_state.hpp @@ -0,0 +1,24 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_DEBUG_HANDLER_STATE_APR_21_2010_0733PM) +#define BOOST_SPIRIT_X3_DEBUG_HANDLER_STATE_APR_21_2010_0733PM + +#if defined(_MSC_VER) +#pragma once +#endif + +namespace boost { namespace spirit { namespace x3 +{ + enum debug_handler_state + { + pre_parse + , successful_parse + , failed_parse + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/nonterminal/detail/rule.hpp b/boost/spirit/home/x3/nonterminal/detail/rule.hpp new file mode 100644 index 0000000000..54e2eef234 --- /dev/null +++ b/boost/spirit/home/x3/nonterminal/detail/rule.hpp @@ -0,0 +1,385 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_DETAIL_RULE_JAN_08_2012_0326PM) +#define BOOST_SPIRIT_X3_DETAIL_RULE_JAN_08_2012_0326PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/support/traits/make_attribute.hpp> +#include <boost/spirit/home/x3/support/utility/sfinae.hpp> +#include <boost/spirit/home/x3/nonterminal/detail/transform_attribute.hpp> +#include <boost/utility/addressof.hpp> + +#if defined(BOOST_SPIRIT_X3_DEBUG) +#include <boost/spirit/home/x3/nonterminal/simple_trace.hpp> +#endif + +namespace boost { namespace spirit { namespace x3 +{ + template <typename ID> + struct identity; + + template <typename ID, typename Attribute = unused_type> + struct rule; + + struct parse_pass_context_tag; + + namespace detail + { + // we use this so we can detect if the default parse_rule + // is the being called. + struct default_parse_rule_result + { + default_parse_rule_result(bool r) + : r(r) {} + operator bool() const { return r; } + bool r; + }; + } + + // default parse_rule implementation + template <typename ID, typename Attribute, typename Iterator + , typename Context, typename ActualAttribute> + inline detail::default_parse_rule_result + parse_rule( + rule<ID, Attribute> rule_ + , Iterator& first, Iterator const& last + , Context const& context, ActualAttribute& attr); +}}} + +namespace boost { namespace spirit { namespace x3 { namespace detail +{ +#if defined(BOOST_SPIRIT_X3_DEBUG) + template <typename Iterator, typename Attribute> + struct context_debug + { + context_debug( + char const* rule_name + , Iterator const& first, Iterator const& last + , Attribute const& attr + , bool const& ok_parse //was parse successful? + ) + : ok_parse(ok_parse), rule_name(rule_name) + , first(first), last(last) + , attr(attr) + , f(detail::get_simple_trace()) + { + f(first, last, attr, pre_parse, rule_name); + } + + ~context_debug() + { + auto status = ok_parse ? successful_parse : failed_parse ; + f(first, last, attr, status, rule_name); + } + + bool const& ok_parse; + char const* rule_name; + Iterator const& first; + Iterator const& last; + Attribute const& attr; + detail::simple_trace_type& f; + }; +#endif + + template <typename ID, typename Iterator, typename Context, typename Enable = void> + struct has_on_error : mpl::false_ {}; + + template <typename ID, typename Iterator, typename Context> + struct has_on_error<ID, Iterator, Context, + typename disable_if_substitution_failure< + decltype( + std::declval<ID>().on_error( + std::declval<Iterator&>() + , std::declval<Iterator>() + , std::declval<expectation_failure<Iterator>>() + , std::declval<Context>() + ) + )>::type + > + : mpl::true_ + {}; + + template <typename ID, typename Iterator, typename Attribute, typename Context, typename Enable = void> + struct has_on_success : mpl::false_ {}; + + template <typename ID, typename Iterator, typename Attribute, typename Context> + struct has_on_success<ID, Iterator, Context, Attribute, + typename disable_if_substitution_failure< + decltype( + std::declval<ID>().on_success( + std::declval<Iterator&>() + , std::declval<Iterator>() + , std::declval<Attribute&>() + , std::declval<Context>() + ) + )>::type + > + : mpl::true_ + {}; + + template <typename ID> + struct make_id + { + typedef identity<ID> type; + }; + + template <typename ID> + struct make_id<identity<ID>> + { + typedef identity<ID> type; + }; + + template <typename ID, typename RHS, typename Context> + Context const& + make_rule_context(RHS const& rhs, Context const& context + , mpl::false_ /* is_default_parse_rule */) + { + return context; + } + + template <typename ID, typename RHS, typename Context> + auto make_rule_context(RHS const& rhs, Context const& context + , mpl::true_ /* is_default_parse_rule */ ) + { + return make_unique_context<ID>(rhs, context); + } + + template <typename Attribute, typename ID> + struct rule_parser + { + template <typename Iterator, typename Context, typename ActualAttribute> + static bool call_on_success( + Iterator& first, Iterator const& last + , Context const& context, ActualAttribute& attr + , mpl::false_ /* No on_success handler */ ) + { + return true; + } + + template <typename Iterator, typename Context, typename ActualAttribute> + static bool call_on_success( + Iterator& first, Iterator const& last + , Context const& context, ActualAttribute& attr + , mpl::true_ /* Has on_success handler */) + { + bool pass = true; + ID().on_success( + first + , last + , attr + , make_context<parse_pass_context_tag>(pass, context) + ); + return pass; + } + + template <typename RHS, typename Iterator, typename Context + , typename RContext, typename ActualAttribute> + static bool parse_rhs_main( + RHS const& rhs + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, ActualAttribute& attr + , mpl::false_) + { + // see if the user has a BOOST_SPIRIT_DEFINE for this rule + typedef + decltype(parse_rule( + rule<ID, Attribute>(), first, last + , make_unique_context<ID>(rhs, context), attr)) + parse_rule_result; + + // If there is no BOOST_SPIRIT_DEFINE for this rule, + // we'll make a context for this rule tagged by its ID + // so we can extract the rule later on in the default + // (generic) parse_rule function. + typedef + is_same<parse_rule_result, default_parse_rule_result> + is_default_parse_rule; + + Iterator i = first; + bool r = rhs.parse( + i + , last + , make_rule_context<ID>(rhs, context, is_default_parse_rule()) + , rcontext + , attr + ); + + if (r) + { + auto first_ = first; + x3::skip_over(first_, last, context); + r = call_on_success(first_, i, context, attr + , has_on_success<ID, Iterator, Context, ActualAttribute>()); + } + + if (r) + first = i; + return r; + } + + template <typename RHS, typename Iterator, typename Context + , typename RContext, typename ActualAttribute> + static bool parse_rhs_main( + RHS const& rhs + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, ActualAttribute& attr + , mpl::true_ /* on_error is found */) + { + for (;;) + { + try + { + return parse_rhs_main( + rhs, first, last, context, rcontext, attr, mpl::false_()); + } + catch (expectation_failure<Iterator> const& x) + { + switch (ID().on_error(first, last, x, context)) + { + case error_handler_result::fail: + return false; + case error_handler_result::retry: + continue; + case error_handler_result::accept: + return true; + case error_handler_result::rethrow: + throw; + } + } + } + } + + template <typename RHS, typename Iterator + , typename Context, typename RContext, typename ActualAttribute> + static bool parse_rhs_main( + RHS const& rhs + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, ActualAttribute& attr) + { + return parse_rhs_main( + rhs, first, last, context, rcontext, attr + , has_on_error<ID, Iterator, Context>() + ); + } + + template <typename RHS, typename Iterator + , typename Context, typename RContext, typename ActualAttribute> + static bool parse_rhs( + RHS const& rhs + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, ActualAttribute& attr + , mpl::false_) + { + return parse_rhs_main(rhs, first, last, context, rcontext, attr); + } + + template <typename RHS, typename Iterator + , typename Context, typename RContext, typename ActualAttribute> + static bool parse_rhs( + RHS const& rhs + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, ActualAttribute& attr + , mpl::true_) + { + return parse_rhs_main(rhs, first, last, context, rcontext, unused); + } + + template <typename RHS, typename Iterator, typename Context + , typename ActualAttribute, typename ExplicitAttrPropagation> + static bool call_rule_definition( + RHS const& rhs + , char const* rule_name + , Iterator& first, Iterator const& last + , Context const& context, ActualAttribute& attr + , ExplicitAttrPropagation) + { + typedef traits::make_attribute<Attribute, ActualAttribute> make_attribute; + + // do down-stream transformation, provides attribute for + // rhs parser + typedef traits::transform_attribute< + typename make_attribute::type, Attribute, parser_id> + transform; + + typedef typename make_attribute::value_type value_type; + typedef typename transform::type transform_attr; + value_type made_attr = make_attribute::call(attr); + transform_attr attr_ = transform::pre(made_attr); + + bool ok_parse + //Creates a place to hold the result of parse_rhs + //called inside the following scope. + ; + { + //Create a scope to cause the dbg variable below (within + //the #if...#endif) to call it's DTOR before any + //modifications are made to the attribute, attr_ passed + //to parse_rhs (such as might be done in + //traits::post_transform when, for example, + //ActualAttribute is a recursive variant). +#if defined(BOOST_SPIRIT_X3_DEBUG) + context_debug<Iterator, typename make_attribute::value_type> + dbg(rule_name, first, last, attr_, ok_parse); +#endif + ok_parse=parse_rhs(rhs, first, last, context, attr_, attr_ + , mpl::bool_ + < ( RHS::has_action + && !ExplicitAttrPropagation::value + ) + >() + ); + } + if(ok_parse) + { + // do up-stream transformation, this integrates the results + // back into the original attribute value, if appropriate + traits::post_transform(attr, attr_); + } + return ok_parse; + } + +// template <typename RuleDef, typename Iterator, typename Context +// , typename ActualAttribute, typename AttributeContext> +// static bool call_from_rule( +// RuleDef const& rule_def +// , char const* rule_name +// , Iterator& first, Iterator const& last +// , Context const& context, ActualAttribute& attr, AttributeContext& attr_ctx) +// { +// // This is called when a rule-body has already been established. +// // The rule body is already established by the rule_definition class, +// // we will not do it again. We'll simply call the RHS by calling +// // call_rule_definition. +// +// return call_rule_definition( +// rule_def.rhs, rule_name, first, last +// , context, attr, attr_ctx.attr_ptr +// , mpl::bool_<(RuleDef::explicit_attribute_propagation)>()); +// } +// +// template <typename RuleDef, typename Iterator, typename Context +// , typename ActualAttribute> +// static bool call_from_rule( +// RuleDef const& rule_def +// , char const* rule_name +// , Iterator& first, Iterator const& last +// , Context const& context, ActualAttribute& attr, unused_type) +// { +// // This is called when a rule-body has *not yet* been established. +// // The rule body is established by the rule_definition class, so +// // we call it to parse and establish the rule-body. +// +// return rule_def.parse(first, last, context, unused, attr); // $$$ fix unused param $$$ +// } + }; +}}}} + +#endif diff --git a/boost/spirit/home/x3/nonterminal/detail/transform_attribute.hpp b/boost/spirit/home/x3/nonterminal/detail/transform_attribute.hpp new file mode 100644 index 0000000000..b1929f8993 --- /dev/null +++ b/boost/spirit/home/x3/nonterminal/detail/transform_attribute.hpp @@ -0,0 +1,108 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_X3_DETAIL_ATTRIBUTES_APR_18_2010_0458PM) +#define SPIRIT_X3_DETAIL_ATTRIBUTES_APR_18_2010_0458PM + +#include <boost/spirit/home/x3/support/traits/transform_attribute.hpp> +#include <boost/spirit/home/x3/support/traits/move_to.hpp> + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { namespace x3 +{ + struct parser_id; + + template <typename Exposed, typename Transformed> + struct default_transform_attribute + { + typedef Transformed type; + + static Transformed pre(Exposed&) { return Transformed(); } + + static void post(Exposed& val, Transformed& attr) + { + traits::move_to(attr, val); + } + }; + + // handle case where no transformation is required as the types are the same + template <typename Attribute> + struct default_transform_attribute<Attribute, Attribute> + { + typedef Attribute& type; + static Attribute& pre(Attribute& val) { return val; } + static void post(Attribute&, Attribute const&) {} + }; + + // main specialization for x3 + template <typename Exposed, typename Transformed, typename Enable = void> + struct transform_attribute + : default_transform_attribute<Exposed, Transformed> {}; + + // reference types need special handling + template <typename Attribute> + struct transform_attribute<Attribute&, Attribute> + { + typedef Attribute& type; + static Attribute& pre(Attribute& val) { return val; } + static void post(Attribute&, Attribute const&) {} + }; + + // unused_type needs some special handling as well + template <> + struct transform_attribute<unused_type, unused_type> + { + typedef unused_type type; + static unused_type pre(unused_type) { return unused; } + static void post(unused_type, unused_type) {} + }; + + template <> + struct transform_attribute<unused_type const, unused_type> + : 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> {}; + + template <typename Attribute> + struct transform_attribute<Attribute const, unused_type> + : transform_attribute<unused_type, unused_type> {}; +}}} + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Exposed, typename Transformed> + struct transform_attribute<Exposed, Transformed, x3::parser_id> + : x3::transform_attribute<Exposed, Transformed> {}; + + template <typename Exposed, typename Transformed> + struct transform_attribute<Exposed&, Transformed, x3::parser_id> + : transform_attribute<Exposed, Transformed, x3::parser_id> {}; + + template <typename Attribute> + struct transform_attribute<Attribute&, Attribute, x3::parser_id> + : x3::transform_attribute<Attribute&, Attribute> {}; + + /////////////////////////////////////////////////////////////////////////// + template <typename Exposed, typename Transformed> + void post_transform(Exposed& dest, Transformed&& attr) + { + return transform_attribute<Exposed, Transformed, x3::parser_id>::post(dest, attr); + } +}}}} + +#endif diff --git a/boost/spirit/home/x3/nonterminal/rule.hpp b/boost/spirit/home/x3/nonterminal/rule.hpp new file mode 100644 index 0000000000..049c6be57b --- /dev/null +++ b/boost/spirit/home/x3/nonterminal/rule.hpp @@ -0,0 +1,186 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_RULE_JAN_08_2012_0326PM) +#define BOOST_SPIRIT_X3_RULE_JAN_08_2012_0326PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/nonterminal/detail/rule.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/spirit/home/x3/support/context.hpp> +#include <boost/preprocessor/variadic/to_seq.hpp> +#include <boost/preprocessor/variadic/elem.hpp> +#include <boost/preprocessor/seq/for_each.hpp> + +#if !defined(BOOST_SPIRIT_X3_NO_RTTI) +#include <typeinfo> +#endif + +namespace boost { namespace spirit { namespace x3 +{ + template <typename ID> + struct identity {}; + + // default parse_rule implementation + template <typename ID, typename Attribute, typename Iterator + , typename Context, typename ActualAttribute> + inline detail::default_parse_rule_result + parse_rule( + rule<ID, Attribute> rule_ + , Iterator& first, Iterator const& last + , Context const& context, ActualAttribute& attr) + { + static_assert(!is_same<decltype(get<ID>(context)), unused_type>::value, + "BOOST_SPIRIT_DEFINE undefined for this rule."); + return get<ID>(context).parse(first, last, context, unused, attr); + } + + template <typename ID, typename RHS, typename Attribute, bool force_attribute_> + struct rule_definition : parser<rule_definition<ID, RHS, Attribute, force_attribute_>> + { + typedef rule_definition<ID, RHS, Attribute, force_attribute_> this_type; + typedef ID id; + typedef RHS rhs_type; + typedef rule<ID, Attribute> lhs_type; + typedef Attribute attribute_type; + + static bool const has_attribute = + !is_same<Attribute, unused_type>::value; + static bool const handles_container = + traits::is_container<Attribute>::value; + static bool const force_attribute = + force_attribute_; + + rule_definition(RHS rhs, char const* name) + : rhs(rhs), name(name) {} + + template <typename Iterator, typename Context, typename Attribute_> + bool parse(Iterator& first, Iterator const& last + , Context const& context, unused_type, Attribute_& attr) const + { + return detail::rule_parser<attribute_type, ID> + ::call_rule_definition( + rhs, name, first, last + , context + , attr + , mpl::bool_<force_attribute>()); + } + + RHS rhs; + char const* name; + }; + + template <typename ID, typename Attribute> + struct rule : parser<rule<ID, Attribute>> + { + typedef ID id; + typedef Attribute attribute_type; + static bool const has_attribute = + !is_same<Attribute, unused_type>::value; + static bool const handles_container = + traits::is_container<Attribute>::value; + +#if !defined(BOOST_SPIRIT_X3_NO_RTTI) + rule() : name(typeid(rule).name()) {} +#else + rule() : name("unnamed") {} +#endif + + rule(char const* name) + : name(name) {} + + template <typename RHS> + rule_definition< + ID, typename extension::as_parser<RHS>::value_type, Attribute, false> + operator=(RHS const& rhs) const + { + return {as_parser(rhs), name}; + } + + template <typename RHS> + rule_definition< + ID, typename extension::as_parser<RHS>::value_type, Attribute, true> + operator%=(RHS const& rhs) const + { + return {as_parser(rhs), name}; + } + + + template <typename Iterator, typename Context, typename Attribute_> + bool parse(Iterator& first, Iterator const& last + , Context const& context, unused_type, Attribute_& attr) const + { + return parse_rule(*this, first, last, context, attr); + } + + char const* name; + }; + + namespace traits + { + template <typename T, typename Enable = void> + struct is_rule : mpl::false_ {}; + + template <typename ID, typename Attribute> + struct is_rule<rule<ID, Attribute>> : mpl::true_ {}; + + template <typename ID, typename Attribute, typename RHS, bool force_attribute> + struct is_rule<rule_definition<ID, RHS, Attribute, force_attribute>> : mpl::true_ {}; + } + + template <typename T> + struct get_info<T, typename enable_if<traits::is_rule<T>>::type> + { + typedef std::string result_type; + std::string operator()(T const& r) const + { + return r.name; + } + }; + +#define BOOST_SPIRIT_DECLARE_(r, data, rule_type) \ + template <typename Iterator, typename Context, typename Attribute> \ + bool parse_rule( \ + rule_type rule_ \ + , Iterator& first, Iterator const& last \ + , Context const& context, Attribute& attr); \ + /***/ + +#define BOOST_SPIRIT_DECLARE(...) BOOST_PP_SEQ_FOR_EACH( \ + BOOST_SPIRIT_DECLARE_, _, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) \ + /***/ + +#define BOOST_SPIRIT_DEFINE_(r, data, def) \ + template <typename Iterator, typename Context, typename Attribute> \ + inline bool parse_rule( \ + decltype(def)::lhs_type rule_ \ + , Iterator& first, Iterator const& last \ + , Context const& context, Attribute& attr) \ + { \ + using boost::spirit::x3::unused; \ + auto const& def_ = (def); \ + return def_.parse(first, last, context, unused, attr); \ + } \ + /***/ + +#define BOOST_SPIRIT_DEFINE(...) BOOST_PP_SEQ_FOR_EACH( \ + BOOST_SPIRIT_DEFINE_, _, BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__)) \ + /***/ + +#define BOOST_SPIRIT_INSTANTIATE(rule_type, Iterator, Context) \ + template bool parse_rule<Iterator, Context, rule_type::attribute_type>( \ + rule_type rule_ \ + , Iterator& first, Iterator const& last \ + , Context const& context, rule_type::attribute_type& attr); \ + /***/ + + +}}} + +#endif diff --git a/boost/spirit/home/x3/nonterminal/simple_trace.hpp b/boost/spirit/home/x3/nonterminal/simple_trace.hpp new file mode 100644 index 0000000000..b049b4ec3c --- /dev/null +++ b/boost/spirit/home/x3/nonterminal/simple_trace.hpp @@ -0,0 +1,150 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_X3_SIMPLE_TRACE_DECEMBER_06_2008_1102AM) +#define BOOST_SPIRIT_X3_SIMPLE_TRACE_DECEMBER_06_2008_1102AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/support/traits/print_token.hpp> +#include <boost/spirit/home/x3/support/traits/print_attribute.hpp> +#include <boost/spirit/home/x3/nonterminal/debug_handler_state.hpp> +#include <boost/fusion/include/out.hpp> +#include <boost/type_traits/is_same.hpp> +#include <ostream> + +// The stream to use for debug output +#if !defined(BOOST_SPIRIT_X3_DEBUG_OUT) +#define BOOST_SPIRIT_X3_DEBUG_OUT std::cerr +#endif + +// number of tokens to print while debugging +#if !defined(BOOST_SPIRIT_X3_DEBUG_PRINT_SOME) +#define BOOST_SPIRIT_X3_DEBUG_PRINT_SOME 20 +#endif + +// number of spaces to indent +#if !defined(BOOST_SPIRIT_X3_DEBUG_INDENT) +#define BOOST_SPIRIT_X3_DEBUG_INDENT 2 +#endif + +namespace boost { namespace spirit { namespace x3 +{ + namespace detail + { + template <typename Char> + inline void token_printer(std::ostream& o, Char c) + { + // allow customization of the token printer routine + x3::traits::print_token(o, c); + } + } + + template <int IndentSpaces = 2, int CharsToPrint = 20> + struct simple_trace + { + simple_trace(std::ostream& out) + : out(out), indent(0) {} + + void print_indent(int n) const + { + n *= IndentSpaces; + for (int i = 0; i != n; ++i) + out << ' '; + } + + template <typename Iterator> + void print_some( + char const* tag + , Iterator first, Iterator const& last) const + { + print_indent(indent); + out << '<' << tag << '>'; + int const n = CharsToPrint; + for (int i = 0; first != last && i != n && *first; ++i, ++first) + detail::token_printer(out, *first); + out << "</" << tag << '>' << std::endl; + + // $$$ FIXME convert invalid xml characters (e.g. '<') to valid + // character entities. $$$ + } + + template <typename Iterator, typename Attribute, typename State> + void operator()( + Iterator const& first + , Iterator const& last + , Attribute const& attr + , State state + , std::string const& rule_name) const + { + switch (state) + { + case pre_parse: + print_indent(indent++); + out + << '<' << rule_name << '>' + << std::endl; + print_some("try", first, last); + break; + + case successful_parse: + print_some("success", first, last); + if (!is_same<Attribute, unused_type>::value) + { + print_indent(indent); + out + << "<attributes>"; + traits::print_attribute(out, attr); + out + << "</attributes>"; + out << std::endl; + } + //~ if (!fusion::empty(context.locals)) + //~ out + //~ << "<locals>" + //~ << context.locals + //~ << "</locals>"; + print_indent(--indent); + out + << "</" << rule_name << '>' + << std::endl; + break; + + case failed_parse: + print_indent(indent); + out << "<fail/>" << std::endl; + print_indent(--indent); + out + << "</" << rule_name << '>' + << std::endl; + break; + } + } + + std::ostream& out; + mutable int indent; + }; + + namespace detail + { + typedef simple_trace< + BOOST_SPIRIT_X3_DEBUG_INDENT, BOOST_SPIRIT_X3_DEBUG_PRINT_SOME> + simple_trace_type; + + inline simple_trace_type& + get_simple_trace() + { + static simple_trace_type tracer(BOOST_SPIRIT_X3_DEBUG_OUT); + return tracer; + } + } +}}} + +#endif diff --git a/boost/spirit/home/x3/numeric.hpp b/boost/spirit/home/x3/numeric.hpp new file mode 100644 index 0000000000..c44d668569 --- /dev/null +++ b/boost/spirit/home/x3/numeric.hpp @@ -0,0 +1,19 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_NUMERIC_FEBRUARY_05_2007_1231PM) +#define BOOST_SPIRIT_X3_NUMERIC_FEBRUARY_05_2007_1231PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/numeric/bool.hpp> +#include <boost/spirit/home/x3/numeric/int.hpp> +#include <boost/spirit/home/x3/numeric/uint.hpp> +#include <boost/spirit/home/x3/numeric/real.hpp> + +#endif diff --git a/boost/spirit/home/x3/numeric/bool.hpp b/boost/spirit/home/x3/numeric/bool.hpp new file mode 100644 index 0000000000..1fb21c16fe --- /dev/null +++ b/boost/spirit/home/x3/numeric/bool.hpp @@ -0,0 +1,106 @@ +/*============================================================================= + Copyright (c) 2009 Hartmut Kaiser + Copyright (c) 2014 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_X3_BOOL_SEP_29_2009_0709AM) +#define SPIRIT_X3_BOOL_SEP_29_2009_0709AM + +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/numeric/bool_policies.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename T, typename BoolPolicies = bool_policies<T>> + struct bool_parser : parser<bool_parser<T, BoolPolicies>> + { + typedef T attribute_type; + static bool const has_attribute = true; + + bool_parser() + : policies() {} + + bool_parser(BoolPolicies const& policies) + : policies(policies) {} + + template <typename Iterator, typename Context> + bool parse(Iterator& first, Iterator const& last + , Context& context, unused_type, T& attr) const + { + x3::skip_over(first, last, context); + return policies.parse_true(first, last, attr) + || policies.parse_false(first, last, attr); + } + + template <typename Iterator, typename Context, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context& context, unused_type, Attribute& attr_param) const + { + // this case is called when Attribute is not T + T attr_; + if (parse(first, last, context, unused, attr_)) + { + traits::move_to(attr_, attr_param); + return true; + } + return false; + } + + BoolPolicies policies; + }; + + template <typename T, typename BoolPolicies = bool_policies<T>> + struct literal_bool_parser : parser<bool_parser<T, BoolPolicies>> + { + typedef T attribute_type; + static bool const has_attribute = true; + + template <typename Value> + literal_bool_parser(Value const& n) + : policies(), n_(n) {} + + template <typename Value> + literal_bool_parser(Value const& n, BoolPolicies const& policies) + : policies(policies), n_(n) {} + + template <typename Iterator, typename Context> + bool parse(Iterator& first, Iterator const& last + , Context& context, unused_type, T& attr) const + { + x3::skip_over(first, last, context); + return (n_ && policies.parse_true(first, last, attr)) + || (!n_ && policies.parse_false(first, last, attr)); + } + + template <typename Iterator, typename Context, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context& context, unused_type, Attribute& attr_param) const + { + // this case is called when Attribute is not T + T attr_; + if (parse(first, last, context, unused, attr_)) + { + traits::move_to(attr_, attr_param); + return true; + } + return false; + } + + BoolPolicies policies; + T n_; + }; + + typedef bool_parser<bool> bool_type; + bool_type const bool_ = {}; + + typedef literal_bool_parser<bool> true_type; + true_type const true_ = { true }; + + typedef literal_bool_parser<bool> false_type; + false_type const false_ = { false }; +}}} + +#endif diff --git a/boost/spirit/home/x3/numeric/bool_policies.hpp b/boost/spirit/home/x3/numeric/bool_policies.hpp new file mode 100644 index 0000000000..bafc5b5294 --- /dev/null +++ b/boost/spirit/home/x3/numeric/bool_policies.hpp @@ -0,0 +1,52 @@ +/*============================================================================= + Copyright (c) 2009 Hartmut Kaiser + Copyright (c) 2014 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_QI_BOOL_POLICIES_SEP_29_2009_0710AM) +#define SPIRIT_QI_BOOL_POLICIES_SEP_29_2009_0710AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/string/detail/string_parse.hpp> +#include <boost/spirit/home/x3/support/traits/move_to.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + /////////////////////////////////////////////////////////////////////////// + // Default boolean policies + /////////////////////////////////////////////////////////////////////////// + template <typename T = bool> + struct bool_policies + { + template <typename Iterator, typename Attribute> + static bool + parse_true(Iterator& first, Iterator const& last, Attribute& attr_) + { + if (detail::string_parse("true", first, last, unused)) + { + traits::move_to(T(true), attr_); // result is true + return true; + } + return false; + } + + template <typename Iterator, typename Attribute> + static bool + parse_false(Iterator& first, Iterator const& last, Attribute& attr_) + { + if (detail::string_parse("false", first, last, unused)) + { + traits::move_to(T(false), attr_); // result is false + return true; + } + return false; + } + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/numeric/int.hpp b/boost/spirit/home/x3/numeric/int.hpp new file mode 100644 index 0000000000..ba9ceb8243 --- /dev/null +++ b/boost/spirit/home/x3/numeric/int.hpp @@ -0,0 +1,66 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_INT_APR_17_2006_0830AM) +#define BOOST_SPIRIT_X3_INT_APR_17_2006_0830AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/support/numeric_utils/extract_int.hpp> +#include <cstdint> + +namespace boost { namespace spirit { namespace x3 +{ + /////////////////////////////////////////////////////////////////////////// + template < + typename T + , unsigned Radix = 10 + , unsigned MinDigits = 1 + , int MaxDigits = -1> + struct int_parser : parser<int_parser<T, Radix, MinDigits, MaxDigits>> + { + // check template parameter 'Radix' for validity + static_assert( + (Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16), + "Error Unsupported Radix"); + + typedef T attribute_type; + static bool const has_attribute = true; + + template <typename Iterator, typename Context, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, unused_type, Attribute& attr) const + { + typedef extract_int<T, Radix, MinDigits, MaxDigits> extract; + x3::skip_over(first, last, context); + return extract::call(first, last, attr); + } + }; + +#define BOOST_SPIRIT_X3_INT_PARSER(int_type, name) \ + typedef int_parser<int_type> name##type; \ + name##type const name = {}; \ + /***/ + + BOOST_SPIRIT_X3_INT_PARSER(long, long_) + BOOST_SPIRIT_X3_INT_PARSER(short, short_) + BOOST_SPIRIT_X3_INT_PARSER(int, int_) + BOOST_SPIRIT_X3_INT_PARSER(long long, long_long) + + BOOST_SPIRIT_X3_INT_PARSER(int8_t, int8) + BOOST_SPIRIT_X3_INT_PARSER(int16_t, int16) + BOOST_SPIRIT_X3_INT_PARSER(int32_t, int32) + BOOST_SPIRIT_X3_INT_PARSER(int64_t, int64) + +#undef BOOST_SPIRIT_X3_INT_PARSER + +}}} + +#endif diff --git a/boost/spirit/home/x3/numeric/real.hpp b/boost/spirit/home/x3/numeric/real.hpp new file mode 100644 index 0000000000..91da536421 --- /dev/null +++ b/boost/spirit/home/x3/numeric/real.hpp @@ -0,0 +1,62 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_REAL_APRIL_18_2006_0850AM) +#define BOOST_SPIRIT_X3_REAL_APRIL_18_2006_0850AM + +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/numeric/real_policies.hpp> +#include <boost/spirit/home/x3/support/numeric_utils/extract_real.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename T, typename RealPolicies = real_policies<T> > + struct real_parser : parser<real_parser<T, RealPolicies> > + { + typedef T attribute_type; + static bool const has_attribute = true; + + real_parser() + : policies() {} + + real_parser(RealPolicies const& policies) + : policies(policies) {} + + template <typename Iterator, typename Context> + bool parse(Iterator& first, Iterator const& last + , Context& context, unused_type, T& attr_) const + { + x3::skip_over(first, last, context); + return extract_real<T, RealPolicies>::parse(first, last, attr_, policies); + } + + template <typename Iterator, typename Context, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context& context, unused_type, Attribute& attr_param) const + { + // this case is called when Attribute is not T + T attr_; + if (parse(first, last, context, unused, attr_)) + { + traits::move_to(attr_, attr_param); + return true; + } + return false; + } + + RealPolicies policies; + }; + + typedef real_parser<float> float_type; + float_type const float_ = {}; + + typedef real_parser<double> double_type; + double_type const double_ = {}; + +}}} + +#endif diff --git a/boost/spirit/home/x3/numeric/real_policies.hpp b/boost/spirit/home/x3/numeric/real_policies.hpp new file mode 100644 index 0000000000..4e02b266c5 --- /dev/null +++ b/boost/spirit/home/x3/numeric/real_policies.hpp @@ -0,0 +1,186 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_REAL_POLICIES_APRIL_17_2006_1158PM) +#define SPIRIT_REAL_POLICIES_APRIL_17_2006_1158PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/string/detail/string_parse.hpp> +#include <boost/spirit/home/x3/support/numeric_utils/extract_int.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + /////////////////////////////////////////////////////////////////////////// + // Default (unsigned) real number policies + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct ureal_policies + { + // trailing dot policy suggested by Gustavo Guerra + static bool const allow_leading_dot = true; + static bool const allow_trailing_dot = true; + static bool const expect_dot = false; + + template <typename Iterator> + static bool + parse_sign(Iterator& /*first*/, Iterator const& /*last*/) + { + return false; + } + + template <typename Iterator, typename Attribute> + static bool + parse_n(Iterator& first, Iterator const& last, Attribute& attr_) + { + return extract_uint<T, 10, 1, -1>::call(first, last, attr_); + } + + template <typename Iterator> + static bool + parse_dot(Iterator& first, Iterator const& last) + { + if (first == last || *first != '.') + return false; + ++first; + return true; + } + + template <typename Iterator, typename Attribute> + static bool + parse_frac_n(Iterator& first, Iterator const& last, Attribute& attr_) + { + return extract_uint<T, 10, 1, -1, true>::call(first, last, attr_); + } + + template <typename Iterator> + static bool + parse_exp(Iterator& first, Iterator const& last) + { + if (first == last || (*first != 'e' && *first != 'E')) + return false; + ++first; + return true; + } + + template <typename Iterator> + static bool + parse_exp_n(Iterator& first, Iterator const& last, int& attr_) + { + return extract_int<int, 10, 1, -1>::call(first, last, attr_); + } + + /////////////////////////////////////////////////////////////////////// + // 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 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 + // Inf). The optional sign will be automatically applied afterwards. + // + // The default implementation below recognizes representations of NaN + // and Inf as mandated by the C99 Standard and as proposed for + // inclusion into the C++0x Standard: nan, nan(...), inf and infinity + // (the matching is performed case-insensitively). + /////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Attribute> + static bool + parse_nan(Iterator& first, Iterator const& last, Attribute& attr_) + { + if (first == last) + return false; // end of input reached + + if (*first != 'n' && *first != 'N') + return false; // not "nan" + + // nan[(...)] ? + if (detail::string_parse("nan", "NAN", first, last, unused)) + { + if (*first == '(') + { + // skip trailing (...) part + Iterator i = first; + + while (++i != last && *i != ')') + ; + if (i == last) + return false; // no trailing ')' found, give up + + first = ++i; + } + attr_ = std::numeric_limits<T>::quiet_NaN(); + return true; + } + return false; + } + + template <typename Iterator, typename Attribute> + static bool + parse_inf(Iterator& first, Iterator const& last, Attribute& attr_) + { + if (first == last) + return false; // end of input reached + + if (*first != 'i' && *first != 'I') + return false; // not "inf" + + // inf or infinity ? + if (detail::string_parse("inf", "INF", first, last, unused)) + { + // skip allowed 'inity' part of infinity + detail::string_parse("inity", "INITY", first, last, unused); + attr_ = std::numeric_limits<T>::infinity(); + return true; + } + return false; + } + }; + + /////////////////////////////////////////////////////////////////////////// + // Default (signed) real number policies + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct real_policies : ureal_policies<T> + { + template <typename Iterator> + static bool + parse_sign(Iterator& first, Iterator const& last) + { + return extract_sign(first, last); + } + }; + + template <typename T> + struct strict_ureal_policies : ureal_policies<T> + { + static bool const expect_dot = true; + }; + + template <typename T> + struct strict_real_policies : real_policies<T> + { + static bool const expect_dot = true; + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/numeric/uint.hpp b/boost/spirit/home/x3/numeric/uint.hpp new file mode 100644 index 0000000000..624bae52de --- /dev/null +++ b/boost/spirit/home/x3/numeric/uint.hpp @@ -0,0 +1,79 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2011 Jan Frederick Eick + + 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_X3_UINT_APR_17_2006_0901AM) +#define BOOST_SPIRIT_X3_UINT_APR_17_2006_0901AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/support/numeric_utils/extract_int.hpp> +#include <cstdint> + +namespace boost { namespace spirit { namespace x3 +{ + /////////////////////////////////////////////////////////////////////////// + template < + typename T + , unsigned Radix = 10 + , unsigned MinDigits = 1 + , int MaxDigits = -1> + struct uint_parser : parser<uint_parser<T, Radix, MinDigits, MaxDigits>> + { + // check template parameter 'Radix' for validity + static_assert( + (Radix >= 2 && Radix <= 36), + "Error Unsupported Radix"); + + typedef T attribute_type; + static bool const has_attribute = true; + + template <typename Iterator, typename Context, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, unused_type, Attribute& attr) const + { + typedef extract_uint<T, Radix, MinDigits, MaxDigits> extract; + x3::skip_over(first, last, context); + return extract::call(first, last, attr); + } + }; + +#define BOOST_SPIRIT_X3_UINT_PARSER(uint_type, name) \ + typedef uint_parser<uint_type> name##type; \ + name##type const name = {}; \ + /***/ + + BOOST_SPIRIT_X3_UINT_PARSER(unsigned long, ulong_) + BOOST_SPIRIT_X3_UINT_PARSER(unsigned short, ushort_) + BOOST_SPIRIT_X3_UINT_PARSER(unsigned int, uint_) + BOOST_SPIRIT_X3_UINT_PARSER(unsigned long long, ulong_long) + + BOOST_SPIRIT_X3_UINT_PARSER(uint8_t, uint8) + BOOST_SPIRIT_X3_UINT_PARSER(uint16_t, uint16) + BOOST_SPIRIT_X3_UINT_PARSER(uint32_t, uint32) + BOOST_SPIRIT_X3_UINT_PARSER(uint64_t, uint64) + +#undef BOOST_SPIRIT_X3_UINT_PARSER + +#define BOOST_SPIRIT_X3_UINT_PARSER(uint_type, radix, name) \ + typedef uint_parser<uint_type, radix> name##type; \ + name##type const name = name##type(); \ + /***/ + + BOOST_SPIRIT_X3_UINT_PARSER(unsigned, 2, bin) + BOOST_SPIRIT_X3_UINT_PARSER(unsigned, 8, oct) + BOOST_SPIRIT_X3_UINT_PARSER(unsigned, 16, hex) + +#undef BOOST_SPIRIT_X3_UINT_PARSER + + +}}} + +#endif diff --git a/boost/spirit/home/x3/operator.hpp b/boost/spirit/home/x3/operator.hpp new file mode 100644 index 0000000000..1244e2f04d --- /dev/null +++ b/boost/spirit/home/x3/operator.hpp @@ -0,0 +1,26 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_OPERATOR_FEBRUARY_02_2007_0558PM) +#define BOOST_SPIRIT_X3_OPERATOR_FEBRUARY_02_2007_0558PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/operator/sequence.hpp> +#include <boost/spirit/home/x3/operator/alternative.hpp> +//~ #include <boost/spirit/home/x3/operator/sequential_or.hpp> +//~ #include <boost/spirit/home/x3/operator/permutation.hpp> +#include <boost/spirit/home/x3/operator/difference.hpp> +#include <boost/spirit/home/x3/operator/list.hpp> +#include <boost/spirit/home/x3/operator/optional.hpp> +#include <boost/spirit/home/x3/operator/kleene.hpp> +#include <boost/spirit/home/x3/operator/plus.hpp> +#include <boost/spirit/home/x3/operator/and_predicate.hpp> +#include <boost/spirit/home/x3/operator/not_predicate.hpp> + +#endif diff --git a/boost/spirit/home/x3/operator/alternative.hpp b/boost/spirit/home/x3/operator/alternative.hpp new file mode 100644 index 0000000000..1566780bc6 --- /dev/null +++ b/boost/spirit/home/x3/operator/alternative.hpp @@ -0,0 +1,68 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_ALTERNATIVE_JAN_07_2013_1131AM) +#define SPIRIT_ALTERNATIVE_JAN_07_2013_1131AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/traits/attribute_of.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/operator/detail/alternative.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Left, typename Right> + struct alternative : binary_parser<Left, Right, alternative<Left, Right>> + { + typedef binary_parser<Left, Right, alternative<Left, Right>> base_type; + + alternative(Left left, Right right) + : base_type(left, right) {} + + template <typename Iterator, typename Context, typename RContext> + bool parse( + Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, unused_type) const + { + return this->left.parse(first, last, context, rcontext, unused) + || this->right.parse(first, last, context, rcontext, unused); + } + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse( + Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + if (detail::parse_alternative(this->left, first, last, context, rcontext, attr)) + return true; + if (detail::parse_alternative(this->right, first, last, context, rcontext, attr)) + return true; + return false; + } + }; + + template <typename Left, typename Right> + inline alternative< + typename extension::as_parser<Left>::value_type + , typename extension::as_parser<Right>::value_type> + operator|(Left const& left, Right const& right) + { + return {as_parser(left), as_parser(right)}; + } +}}} + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Left, typename Right, typename Context> + struct attribute_of<x3::alternative<Left, Right>, Context> + : x3::detail::attribute_of_alternative<Left, Right, Context> {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/operator/and_predicate.hpp b/boost/spirit/home/x3/operator/and_predicate.hpp new file mode 100644 index 0000000000..e0892cd8cf --- /dev/null +++ b/boost/spirit/home/x3/operator/and_predicate.hpp @@ -0,0 +1,47 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_AND_PREDICATE_MARCH_23_2007_0617PM) +#define SPIRIT_AND_PREDICATE_MARCH_23_2007_0617PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Subject> + struct and_predicate : unary_parser<Subject, and_predicate<Subject>> + { + typedef unary_parser<Subject, and_predicate<Subject>> base_type; + + typedef unused_type attribute_type; + static bool const has_attribute = false; + + and_predicate(Subject const& subject) + : base_type(subject) {} + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& /*attr*/) const + { + Iterator i = first; + return this->subject.parse(i, last, context, rcontext, unused); + } + }; + + template <typename Subject> + inline and_predicate<typename extension::as_parser<Subject>::value_type> + operator&(Subject const& subject) + { + return {as_parser(subject)}; + } +}}} + +#endif diff --git a/boost/spirit/home/x3/operator/detail/alternative.hpp b/boost/spirit/home/x3/operator/detail/alternative.hpp new file mode 100644 index 0000000000..54f86e00df --- /dev/null +++ b/boost/spirit/home/x3/operator/detail/alternative.hpp @@ -0,0 +1,317 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_ALTERNATIVE_DETAIL_JAN_07_2013_1245PM) +#define SPIRIT_ALTERNATIVE_DETAIL_JAN_07_2013_1245PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/traits/attribute_of.hpp> +#include <boost/spirit/home/x3/support/traits/is_variant.hpp> +#include <boost/spirit/home/x3/support/traits/tuple_traits.hpp> +#include <boost/spirit/home/x3/support/traits/move_to.hpp> +#include <boost/spirit/home/x3/support/traits/variant_has_substitute.hpp> +#include <boost/spirit/home/x3/support/traits/variant_find_substitute.hpp> +#include <boost/spirit/home/x3/core/detail/parse_into_container.hpp> +#include <boost/variant/variant.hpp> + +#include <boost/mpl/copy_if.hpp> +#include <boost/mpl/not.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/mpl/joint_view.hpp> + +#include <boost/fusion/include/front.hpp> + +#include <boost/type_traits/is_same.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Left, typename Right> + struct alternative; +}}} + +namespace boost { namespace spirit { namespace x3 { namespace detail +{ + struct pass_variant_unused + { + typedef unused_type type; + + template <typename T> + static unused_type + call(T&) + { + return unused_type(); + } + }; + + template <typename Attribute> + struct pass_variant_used + { + typedef Attribute& type; + + static Attribute& + call(Attribute& v) + { + return v; + } + }; + + template <> + struct pass_variant_used<unused_type> : pass_variant_unused {}; + + template <typename Parser, typename Attribute, typename Context + , typename Enable = void> + struct pass_parser_attribute + { + typedef typename + traits::attribute_of<Parser, Context>::type + attribute_type; + typedef typename + traits::variant_find_substitute<Attribute, attribute_type>::type + substitute_type; + + typedef typename + mpl::if_< + is_same<Attribute, substitute_type> + , Attribute& + , substitute_type + >::type + type; + + template <typename Attribute_> + static Attribute_& + call(Attribute_& attr, mpl::true_) + { + return attr; + } + + template <typename Attribute_> + static type + call(Attribute_&, mpl::false_) + { + return type(); + } + + template <typename Attribute_> + static type + call(Attribute_& attr) + { + return call(attr, is_same<Attribute_, typename remove_reference<type>::type>()); + } + }; + + // Pass non-variant attributes as-is + template <typename Parser, typename Attribute, typename Context + , typename Enable = void> + struct pass_non_variant_attribute + { + typedef Attribute& type; + + static Attribute& + call(Attribute& attr) + { + return attr; + } + }; + + // Unwrap single element sequences + template <typename Parser, typename Attribute, typename Context> + struct pass_non_variant_attribute<Parser, Attribute, Context, + typename enable_if<traits::is_size_one_sequence<Attribute>>::type> + { + typedef typename remove_reference< + typename fusion::result_of::front<Attribute>::type>::type + attr_type; + + typedef pass_parser_attribute<Parser, attr_type, Context> pass; + typedef typename pass::type type; + + template <typename Attribute_> + static type + call(Attribute_& attr) + { + return pass::call(fusion::front(attr)); + } + }; + + template <typename Parser, typename Attribute, typename Context> + struct pass_parser_attribute<Parser, Attribute, Context, + typename enable_if_c<(!traits::is_variant<Attribute>::value)>::type> + : pass_non_variant_attribute<Parser, Attribute, Context> + {}; + + template <typename Parser, typename Context> + struct pass_parser_attribute<Parser, unused_type, Context> + : pass_variant_unused {}; + + template <typename Parser, typename Attribute, typename Context> + struct pass_variant_attribute : + mpl::if_c<traits::has_attribute<Parser, Context>::value + , pass_parser_attribute<Parser, Attribute, Context> + , pass_variant_unused>::type + { + typedef typename mpl::false_ is_alternative; + }; + + template <typename L, typename R, typename Attribute, typename Context> + struct pass_variant_attribute<alternative<L, R>, Attribute, Context> : + mpl::if_c<traits::has_attribute<alternative<L, R>, Context>::value + , pass_variant_used<Attribute> + , pass_variant_unused>::type + { + typedef typename mpl::true_ is_alternative; + }; + + template <typename L, typename R, typename C> + struct get_alternative_types + { + typedef + mpl::vector< + typename traits::attribute_of<L, C>::type + , typename traits::attribute_of<R, C>::type + > + type; + }; + + template <typename LL, typename LR, typename R, typename C> + struct get_alternative_types<alternative<LL, LR>, R, C> + { + typedef typename + mpl::push_back< + typename get_alternative_types<LL, LR, C>::type + , typename traits::attribute_of<R, C>::type + >::type + type; + }; + + template <typename L, typename RL, typename RR, typename C> + struct get_alternative_types<L, alternative<RL, RR>, C> + { + typedef typename + mpl::push_front< + typename get_alternative_types<RL, RR, C>::type + , typename traits::attribute_of<L, C>::type + >::type + type; + }; + + template <typename LL, typename LR, typename RL, typename RR, typename C> + struct get_alternative_types<alternative<LL, LR>, alternative<RL, RR>, C> + { + typedef + mpl::joint_view< + typename get_alternative_types<LL, LR, C>::type + , typename get_alternative_types<RL, RR, C>::type + > + type; + }; + + template <typename L, typename R, typename C> + struct attribute_of_alternative + { + // Get all alternative attribute types + typedef typename get_alternative_types<L, R, C>::type all_types; + + // Filter all unused_types + typedef typename + mpl::copy_if< + all_types + , mpl::not_<is_same<mpl::_1, unused_type>> + , mpl::back_inserter<mpl::vector<>> + >::type + filtered_types; + + // Build a variant if filtered_types is not empty, + // else just return unused_type + typedef typename + mpl::eval_if< + mpl::empty<filtered_types> + , mpl::identity<unused_type> + , make_variant_over<filtered_types> + >::type + type; + }; + + template <typename IsAlternative> + struct move_if_not_alternative + { + template<typename T1, typename T2> + static void call(T1& attr_, T2& attr) {} + }; + + template <> + struct move_if_not_alternative<mpl::false_ /*is alternative*/> + { + template<typename T1, typename T2> + static void call(T1& attr_, T2& attr) + { + traits::move_to(attr_, attr); + } + }; + + template <typename Parser, typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse_alternative(Parser const& p, Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) + { + typedef detail::pass_variant_attribute<Parser, Attribute, Context> pass; + + typename pass::type attr_ = pass::call(attr); + if (p.parse(first, last, context, rcontext, attr_)) + { + move_if_not_alternative<typename pass::is_alternative>::call(attr_, attr); + return true; + } + return false; + } + + + template <typename Left, typename Right, typename Context, typename RContext> + struct parse_into_container_impl<alternative<Left, Right>, Context, RContext> + { + typedef alternative<Left, Right> parser_type; + + template <typename Iterator, typename Attribute> + static bool call( + parser_type const& parser + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr, mpl::true_) + { + return parse_alternative(parser, first, last, context, rcontext, attr); + } + + template <typename Iterator, typename Attribute> + static bool call( + parser_type const& parser + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr, mpl::false_) + { + return parse_into_container_base_impl<parser_type>::call( + parser, first, last, context, rcontext, attr); + } + + template <typename Iterator, typename Attribute> + static bool call( + parser_type const& parser + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) + { + typedef typename + traits::attribute_of<parser_type, Context>::type + attribute_type; + + return call(parser, first, last, context, rcontext, attr + , traits::variant_has_substitute<attribute_type, Attribute>()); + } + }; + +}}}} + +#endif diff --git a/boost/spirit/home/x3/operator/detail/sequence.hpp b/boost/spirit/home/x3/operator/detail/sequence.hpp new file mode 100644 index 0000000000..1163707128 --- /dev/null +++ b/boost/spirit/home/x3/operator/detail/sequence.hpp @@ -0,0 +1,501 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_SEQUENCE_DETAIL_JAN_06_2013_1015AM) +#define SPIRIT_SEQUENCE_DETAIL_JAN_06_2013_1015AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/traits/attribute_of.hpp> +#include <boost/spirit/home/x3/support/traits/attribute_category.hpp> +#include <boost/spirit/home/x3/support/traits/make_attribute.hpp> +#include <boost/spirit/home/x3/support/traits/has_attribute.hpp> +#include <boost/spirit/home/x3/support/traits/is_substitute.hpp> +#include <boost/spirit/home/x3/support/traits/container_traits.hpp> +#include <boost/spirit/home/x3/core/detail/parse_into_container.hpp> + +#include <boost/fusion/include/begin.hpp> +#include <boost/fusion/include/end.hpp> +#include <boost/fusion/include/advance.hpp> +#include <boost/fusion/include/empty.hpp> +#include <boost/fusion/include/front.hpp> +#include <boost/fusion/include/iterator_range.hpp> +#include <boost/fusion/include/as_deque.hpp> +#include <boost/fusion/include/mpl.hpp> + +#include <boost/mpl/copy_if.hpp> +#include <boost/mpl/not.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/identity.hpp> + +#include <boost/type_traits/add_reference.hpp> +#include <boost/type_traits/is_same.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Left, typename Right> + struct sequence; +}}} + +namespace boost { namespace spirit { namespace x3 { namespace detail +{ + template <typename Parser, typename Context, typename Enable = void> + struct sequence_size + { + static int const value = traits::has_attribute<Parser, Context>::value; + }; + + template <typename Parser, typename Context> + struct sequence_size_subject + : sequence_size<typename Parser::subject_type, Context> {}; + + template <typename Parser, typename Context> + struct sequence_size<Parser, Context + , typename enable_if_c<(Parser::is_pass_through_unary)>::type> + : sequence_size_subject<Parser, Context> {}; + + template <typename L, typename R, typename Context> + struct sequence_size<sequence<L, R>, Context> + { + static int const value = + sequence_size<L, Context>::value + + sequence_size<R, Context>::value; + }; + + struct pass_sequence_attribute_unused + { + typedef unused_type type; + + template <typename T> + static unused_type + call(T&) + { + return unused_type(); + } + }; + + template <typename Attribute> + struct pass_sequence_attribute_front + { + typedef typename fusion::result_of::front<Attribute>::type type; + + static typename add_reference<type>::type + call(Attribute& attr) + { + return fusion::front(attr); + } + }; + + template <typename Attribute> + struct pass_through_sequence_attribute + { + typedef Attribute& type; + + template <typename Attribute_> + static Attribute_& + call(Attribute_& attr) + { + return attr; + } + }; + + template <typename Parser, typename Attribute> + struct pass_sequence_attribute_used : + mpl::if_< + traits::is_size_one_sequence<Attribute> + , pass_sequence_attribute_front<Attribute> + , pass_through_sequence_attribute<Attribute>>::type {}; + + template <typename Parser, typename Attribute, typename Enable = void> + struct pass_sequence_attribute : + mpl::if_< + fusion::result_of::empty<Attribute> + , pass_sequence_attribute_unused + , pass_sequence_attribute_used<Parser, Attribute>>::type {}; + + template <typename L, typename R, typename Attribute> + struct pass_sequence_attribute<sequence<L, R>, Attribute> + : pass_through_sequence_attribute<Attribute> {}; + + template <typename Parser, typename Attribute> + struct pass_sequence_attribute_subject : + pass_sequence_attribute<typename Parser::subject_type, Attribute> {}; + + template <typename Parser, typename Attribute> + struct pass_sequence_attribute<Parser, Attribute + , typename enable_if_c<(Parser::is_pass_through_unary)>::type> + : pass_sequence_attribute_subject<Parser, Attribute> {}; + + template <typename L, typename R, typename Attribute, typename Context + , typename Enable = void> + struct partition_attribute + { + static int const l_size = sequence_size<L, Context>::value; + static int const r_size = sequence_size<R, Context>::value; + + // If you got an error here, then you are trying to pass + // a fusion sequence with the wrong number of elements + // as that expected by the (sequence) parser. + static_assert( + fusion::result_of::size<Attribute>::value == (l_size + r_size) + , "Attribute does not have the expected size." + ); + + typedef typename fusion::result_of::begin<Attribute>::type l_begin; + typedef typename fusion::result_of::advance_c<l_begin, l_size>::type l_end; + typedef typename fusion::result_of::end<Attribute>::type r_end; + typedef fusion::iterator_range<l_begin, l_end> l_part; + typedef fusion::iterator_range<l_end, r_end> r_part; + typedef pass_sequence_attribute<L, l_part> l_pass; + typedef pass_sequence_attribute<R, r_part> r_pass; + + static l_part left(Attribute& s) + { + auto i = fusion::begin(s); + return l_part(i, fusion::advance_c<l_size>(i)); + } + + static r_part right(Attribute& s) + { + return r_part( + fusion::advance_c<l_size>(fusion::begin(s)) + , fusion::end(s)); + } + }; + + template <typename L, typename R, typename Attribute, typename Context> + struct partition_attribute<L, R, Attribute, Context, + typename enable_if_c<(!traits::has_attribute<L, Context>::value && + traits::has_attribute<R, Context>::value)>::type> + { + typedef unused_type l_part; + typedef Attribute& r_part; + typedef pass_sequence_attribute_unused l_pass; + typedef pass_sequence_attribute<R, Attribute> r_pass; + + static unused_type left(Attribute&) + { + return unused; + } + + static Attribute& right(Attribute& s) + { + return s; + } + }; + + template <typename L, typename R, typename Attribute, typename Context> + struct partition_attribute<L, R, Attribute, Context, + typename enable_if_c<(traits::has_attribute<L, Context>::value && + !traits::has_attribute<R, Context>::value)>::type> + { + typedef Attribute& l_part; + typedef unused_type r_part; + typedef pass_sequence_attribute<L, Attribute> l_pass; + typedef pass_sequence_attribute_unused r_pass; + + static Attribute& left(Attribute& s) + { + return s; + } + + static unused_type right(Attribute&) + { + return unused; + } + }; + + template <typename L, typename R, typename Attribute, typename Context> + struct partition_attribute<L, R, Attribute, Context, + typename enable_if_c<(!traits::has_attribute<L, Context>::value && + !traits::has_attribute<R, Context>::value)>::type> + { + typedef unused_type l_part; + typedef unused_type r_part; + typedef pass_sequence_attribute_unused l_pass; + typedef pass_sequence_attribute_unused r_pass; + + static unused_type left(Attribute&) + { + return unused; + } + + static unused_type right(Attribute&) + { + return unused; + } + }; + + template <typename L, typename R, typename C> + struct get_sequence_types + { + typedef + mpl::vector< + typename traits::attribute_of<L, C>::type + , typename traits::attribute_of<R, C>::type + > + type; + }; + + template <typename LL, typename LR, typename R, typename C> + struct get_sequence_types<sequence<LL, LR>, R, C> + { + typedef typename + mpl::push_back< + typename get_sequence_types<LL, LR, C>::type + , typename traits::attribute_of<R, C>::type + >::type + type; + }; + + template <typename L, typename RL, typename RR, typename C> + struct get_sequence_types<L, sequence<RL, RR>, C> + { + typedef typename + mpl::push_front< + typename get_sequence_types<RL, RR, C>::type + , typename traits::attribute_of<L, C>::type + >::type + type; + }; + + template <typename LL, typename LR, typename RL, typename RR, typename C> + struct get_sequence_types<sequence<LL, LR>, sequence<RL, RR>, C> + { + typedef + mpl::joint_view< + typename get_sequence_types<LL, LR, C>::type + , typename get_sequence_types<RL, RR, C>::type + > + type; + }; + + template <typename L, typename R, typename C> + struct attribute_of_sequence + { + // Get all sequence attribute types + typedef typename get_sequence_types<L, R, C>::type all_types; + + // Filter all unused_types + typedef typename + mpl::copy_if< + all_types + , mpl::not_<is_same<mpl::_1, unused_type>> + , mpl::back_inserter<mpl::vector<>> + >::type + filtered_types; + + // Build a fusion::deque if filtered_types is not empty, + // else just return unused_type + typedef typename + mpl::eval_if< + mpl::empty<filtered_types> + , mpl::identity<unused_type> + , mpl::if_<mpl::equal_to<mpl::size<filtered_types>, mpl::int_<1> >, + typename mpl::front<filtered_types>::type + , typename fusion::result_of::as_deque<filtered_types>::type > + >::type + type; + }; + + template <typename Parser, typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse_sequence( + Parser const& parser, Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr + , traits::tuple_attribute) + { + typedef typename Parser::left_type Left; + typedef typename Parser::right_type Right; + typedef partition_attribute<Left, Right, Attribute, Context> partition; + typedef typename partition::l_pass l_pass; + typedef typename partition::r_pass r_pass; + + typename partition::l_part l_part = partition::left(attr); + typename partition::r_part r_part = partition::right(attr); + typename l_pass::type l_attr = l_pass::call(l_part); + typename r_pass::type r_attr = r_pass::call(r_part); + + Iterator save = first; + if (parser.left.parse(first, last, context, rcontext, l_attr) + && parser.right.parse(first, last, context, rcontext, r_attr)) + return true; + first = save; + return false; + } + + template <typename Parser, typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse_sequence( + Parser const& parser , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr + , traits::plain_attribute) + { + typedef typename Parser::left_type Left; + typedef typename Parser::right_type Right; + typedef typename traits::attribute_of<Left, Context>::type l_attr_type; + typedef typename traits::attribute_of<Right, Context>::type r_attr_type; + typedef traits::make_attribute<l_attr_type, Attribute> l_make_attribute; + typedef traits::make_attribute<r_attr_type, Attribute> r_make_attribute; + + typename l_make_attribute::type l_attr = l_make_attribute::call(attr); + typename r_make_attribute::type r_attr = r_make_attribute::call(attr); + + Iterator save = first; + if (parser.left.parse(first, last, context, rcontext, l_attr) + && parser.right.parse(first, last, context, rcontext, r_attr)) + return true; + first = save; + return false; + } + + template <typename Left, typename Right, typename Iterator + , typename Context, typename RContext, typename Attribute> + bool parse_sequence( + Left const& left, Right const& right + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr + , traits::container_attribute); + + template <typename Parser, typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse_sequence( + Parser const& parser , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr + , traits::container_attribute) + { + Iterator save = first; + if (parse_into_container(parser.left, first, last, context, rcontext, attr) + && parse_into_container(parser.right, first, last, context, rcontext, attr)) + return true; + first = save; + return false; + } + + template <typename Parser, typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse_sequence_assoc( + Parser const& parser , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr, mpl::false_ /*should_split*/) + { + return parse_into_container(parser, first, last, context, rcontext, attr); + } + + template <typename Parser, typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse_sequence_assoc( + Parser const& parser , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr, mpl::true_ /*should_split*/) + { + Iterator save = first; + if (parser.left.parse( first, last, context, rcontext, attr) + && parser.right.parse(first, last, context, rcontext, attr)) + return true; + first = save; + return false; + } + + template <typename Parser, typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse_sequence( + Parser const& parser, Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr + , traits::associative_attribute) + { + // we can come here in 2 cases: + // - when sequence is key >> value and therefore must + // be parsed with tuple synthesized attribute and then + // that tuple is used to save into associative attribute provided here. + // Example: key >> value; + // + // - when either this->left or this->right provides full key-value + // pair (like in case 1) and another one provides nothing. + // Example: eps >> rule<class x; fusion::map<...> > + // + // first case must be parsed as whole, and second one should + // be parsed separately for left and right. + + typedef typename traits::attribute_of< + decltype(parser.left), Context>::type l_attr_type; + typedef typename traits::attribute_of< + decltype(parser.right), Context>::type r_attr_type; + + typedef typename + mpl::or_< + is_same<l_attr_type, unused_type> + , is_same<r_attr_type, unused_type> > + should_split; + + return parse_sequence_assoc(parser, first, last, context, rcontext, attr + , should_split()); + } + + template <typename Left, typename Right, typename Context, typename RContext> + struct parse_into_container_impl<sequence<Left, Right>, Context, RContext> + { + typedef sequence<Left, Right> parser_type; + + template <typename Iterator, typename Attribute> + static bool call( + parser_type const& parser + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr, mpl::false_) + { + // inform user what went wrong if we jumped here in attempt to + // parse incompatible sequence into fusion::map + static_assert(!is_same< typename traits::attribute_category<Attribute>::type, + traits::associative_attribute>::value, + "To parse directly into fusion::map sequence must produce tuple attribute " + "where type of first element is existing key in fusion::map and second element " + "is value to be stored under that key"); + + Attribute attr_; + if (!parse_sequence(parser + , first, last, context, rcontext, attr_, traits::container_attribute())) + { + return false; + } + traits::append(attr, traits::begin(attr_), traits::end(attr_)); + return true; + } + + template <typename Iterator, typename Attribute> + static bool call( + parser_type const& parser + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr, mpl::true_) + { + return parse_into_container_base_impl<parser_type>::call( + parser, first, last, context, rcontext, attr); + } + + template <typename Iterator, typename Attribute> + static bool call( + parser_type const& parser + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) + { + typedef typename + traits::attribute_of<parser_type, Context>::type + attribute_type; + + typedef typename + traits::container_value<Attribute>::type + value_type; + + return call(parser, first, last, context, rcontext, attr + , typename traits::is_substitute<attribute_type, value_type>::type()); + } + }; + +}}}} + +#endif diff --git a/boost/spirit/home/x3/operator/difference.hpp b/boost/spirit/home/x3/operator/difference.hpp new file mode 100644 index 0000000000..13a9274de0 --- /dev/null +++ b/boost/spirit/home/x3/operator/difference.hpp @@ -0,0 +1,75 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_DIFFERENCE_FEBRUARY_11_2007_1250PM) +#define SPIRIT_DIFFERENCE_FEBRUARY_11_2007_1250PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/traits/attribute_of.hpp> +#include <boost/spirit/home/x3/support/traits/has_attribute.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Left, typename Right> + struct difference : binary_parser<Left, Right, difference<Left, Right>> + { + typedef binary_parser<Left, Right, difference<Left, Right>> base_type; + static bool const handles_container = Left::handles_container; + + difference(Left const& left, Right const& right) + : base_type(left, right) {} + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + // Try Right first + Iterator start = first; + if (this->right.parse(first, last, context, rcontext, unused)) + { + // Right succeeds, we fail. + first = start; + return false; + } + // Right fails, now try Left + return this->left.parse(first, last, context, rcontext, attr); + } + + template <typename Left_, typename Right_> + difference<Left_, Right_> + make(Left_ const& left, Right_ const& right) const + { + return difference<Left_, Right_>(left, right); + } + }; + + template <typename Left, typename Right> + inline difference< + typename extension::as_parser<Left>::value_type + , typename extension::as_parser<Right>::value_type> + operator-(Left const& left, Right const& right) + { + return {as_parser(left), as_parser(right)}; + } +}}} + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Left, typename Right, typename Context> + struct attribute_of<x3::difference<Left, Right>, Context> + : attribute_of<Left, Context> {}; + + template <typename Left, typename Right, typename Context> + struct has_attribute<x3::difference<Left, Right>, Context> + : has_attribute<Left, Context> {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/operator/kleene.hpp b/boost/spirit/home/x3/operator/kleene.hpp new file mode 100644 index 0000000000..7e02bf4a02 --- /dev/null +++ b/boost/spirit/home/x3/operator/kleene.hpp @@ -0,0 +1,59 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_KLEENE_JANUARY_07_2007_0818AM) +#define SPIRIT_KLEENE_JANUARY_07_2007_0818AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/support/traits/container_traits.hpp> +#include <boost/spirit/home/x3/support/traits/attribute_of.hpp> +#include <boost/spirit/home/x3/core/detail/parse_into_container.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Subject> + struct kleene : unary_parser<Subject, kleene<Subject>> + { + typedef unary_parser<Subject, kleene<Subject>> base_type; + static bool const handles_container = true; + + kleene(Subject const& subject) + : base_type(subject) {} + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + while (detail::parse_into_container( + this->subject, first, last, context, rcontext, attr)) + ; + return true; + } + }; + + template <typename Subject> + inline kleene<typename extension::as_parser<Subject>::value_type> + operator*(Subject const& subject) + { + return {as_parser(subject)}; + } +}}} + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Subject, typename Context> + struct attribute_of<x3::kleene<Subject>, Context> + : build_container< + typename attribute_of<Subject, Context>::type> {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/operator/list.hpp b/boost/spirit/home/x3/operator/list.hpp new file mode 100644 index 0000000000..a463a7f9e0 --- /dev/null +++ b/boost/spirit/home/x3/operator/list.hpp @@ -0,0 +1,73 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_LIST_MARCH_24_2007_1031AM) +#define SPIRIT_LIST_MARCH_24_2007_1031AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/support/traits/container_traits.hpp> +#include <boost/spirit/home/x3/support/traits/attribute_of.hpp> +#include <boost/spirit/home/x3/core/detail/parse_into_container.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Left, typename Right> + struct list : binary_parser<Left, Right, list<Left, Right>> + { + typedef binary_parser<Left, Right, list<Left, Right>> base_type; + static bool const handles_container = true; + static bool const has_attribute = true; + + list(Left const& left, Right const& right) + : base_type(left, right) {} + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + // in order to succeed we need to match at least one element + if (!detail::parse_into_container( + this->left, first, last, context, rcontext, attr)) + return false; + + Iterator save = first; + while (this->right.parse(first, last, context, rcontext, unused) + && detail::parse_into_container( + this->left, first, last, context, rcontext, attr)) + { + save = first; + } + + first = save; + return true; + } + }; + + template <typename Left, typename Right> + inline list< + typename extension::as_parser<Left>::value_type + , typename extension::as_parser<Right>::value_type> + operator%(Left const& left, Right const& right) + { + return {as_parser(left), as_parser(right)}; + } +}}} + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Left, typename Right, typename Context> + struct attribute_of<x3::list<Left, Right>, Context> + : traits::build_container< + typename attribute_of<Left, Context>::type> {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/operator/not_predicate.hpp b/boost/spirit/home/x3/operator/not_predicate.hpp new file mode 100644 index 0000000000..38b24bd2e2 --- /dev/null +++ b/boost/spirit/home/x3/operator/not_predicate.hpp @@ -0,0 +1,47 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_NOT_PREDICATE_MARCH_23_2007_0618PM) +#define SPIRIT_NOT_PREDICATE_MARCH_23_2007_0618PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Subject> + struct not_predicate : unary_parser<Subject, not_predicate<Subject>> + { + typedef unary_parser<Subject, not_predicate<Subject>> base_type; + + typedef unused_type attribute_type; + static bool const has_attribute = false; + + not_predicate(Subject const& subject) + : base_type(subject) {} + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& /*attr*/) const + { + Iterator i = first; + return !this->subject.parse(i, last, context, rcontext, unused); + } + }; + + template <typename Subject> + inline not_predicate<typename extension::as_parser<Subject>::value_type> + operator!(Subject const& subject) + { + return {as_parser(subject)}; + } +}}} + +#endif diff --git a/boost/spirit/home/x3/operator/optional.hpp b/boost/spirit/home/x3/operator/optional.hpp new file mode 100644 index 0000000000..16432f89d1 --- /dev/null +++ b/boost/spirit/home/x3/operator/optional.hpp @@ -0,0 +1,86 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_OPTIONAL_MARCH_23_2007_1117PM) +#define SPIRIT_OPTIONAL_MARCH_23_2007_1117PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/proxy.hpp> +#include <boost/spirit/home/x3/core/detail/parse_into_container.hpp> +#include <boost/spirit/home/x3/support/traits/attribute_of.hpp> +#include <boost/spirit/home/x3/support/traits/move_to.hpp> +#include <boost/spirit/home/x3/support/traits/optional_traits.hpp> +#include <boost/spirit/home/x3/support/traits/attribute_category.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Subject> + struct optional : proxy<Subject, optional<Subject>> + { + typedef proxy<Subject, optional<Subject>> base_type; + static bool const handles_container = true; + + optional(Subject const& subject) + : base_type(subject) {} + + using base_type::parse_subject; + + // Attribute is a container + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse_subject(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr + , traits::container_attribute) const + { + detail::parse_into_container( + this->subject, first, last, context, rcontext, attr); + return true; + } + + // Attribute is an optional + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse_subject(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr + , traits::optional_attribute) const + { + typedef typename + x3::traits::optional_value<Attribute>::type + value_type; + + // create a local value + value_type val = value_type(); + + if (this->subject.parse(first, last, context, rcontext, val)) + { + // assign the parsed value into our attribute + x3::traits::move_to(val, attr); + } + return true; + } + }; + + template <typename Subject> + inline optional<typename extension::as_parser<Subject>::value_type> + operator-(Subject const& subject) + { + return {as_parser(subject)}; + } +}}} + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Subject, typename Context> + struct attribute_of<x3::optional<Subject>, Context> + : build_optional< + typename attribute_of<Subject, Context>::type> {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/operator/plus.hpp b/boost/spirit/home/x3/operator/plus.hpp new file mode 100644 index 0000000000..32c7dbfffb --- /dev/null +++ b/boost/spirit/home/x3/operator/plus.hpp @@ -0,0 +1,63 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_PLUS_MARCH_13_2007_0127PM) +#define SPIRIT_PLUS_MARCH_13_2007_0127PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/support/traits/container_traits.hpp> +#include <boost/spirit/home/x3/support/traits/attribute_of.hpp> +#include <boost/spirit/home/x3/core/detail/parse_into_container.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Subject> + struct plus : unary_parser<Subject, plus<Subject>> + { + typedef unary_parser<Subject, plus<Subject>> base_type; + static bool const handles_container = true; + + plus(Subject const& subject) + : base_type(subject) {} + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + if (!detail::parse_into_container( + this->subject, first, last, context, rcontext, attr)) + return false; + + while (detail::parse_into_container( + this->subject, first, last, context, rcontext, attr)) + ; + return true; + } + }; + + template <typename Subject> + inline plus<typename extension::as_parser<Subject>::value_type> + operator+(Subject const& subject) + { + return {as_parser(subject)}; + } +}}} + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Subject, typename Context> + struct attribute_of<x3::plus<Subject>, Context> + : build_container< + typename attribute_of<Subject, Context>::type> {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/operator/sequence.hpp b/boost/spirit/home/x3/operator/sequence.hpp new file mode 100644 index 0000000000..23d5e3d8d9 --- /dev/null +++ b/boost/spirit/home/x3/operator/sequence.hpp @@ -0,0 +1,79 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_SEQUENCE_JAN_06_2013_1015AM) +#define SPIRIT_SEQUENCE_JAN_06_2013_1015AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/traits/attribute_of.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/operator/detail/sequence.hpp> +#include <boost/spirit/home/x3/directive/expect.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Left, typename Right> + struct sequence : binary_parser<Left, Right, sequence<Left, Right>> + { + typedef binary_parser<Left, Right, sequence<Left, Right>> base_type; + + sequence(Left left, Right right) + : base_type(left, right) {} + + template <typename Iterator, typename Context, typename RContext> + bool parse( + Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, unused_type) const + { + Iterator save = first; + if (this->left.parse(first, last, context, rcontext, unused) + && this->right.parse(first, last, context, rcontext, unused)) + return true; + first = save; + return false; + } + + template <typename Iterator, typename Context + , typename RContext, typename Attribute> + bool parse( + Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) const + { + return detail::parse_sequence(*this, first, last, context, rcontext, attr + , typename traits::attribute_category<Attribute>::type()); + } + }; + + template <typename Left, typename Right> + inline sequence< + typename extension::as_parser<Left>::value_type + , typename extension::as_parser<Right>::value_type> + operator>>(Left const& left, Right const& right) + { + return {as_parser(left), as_parser(right)}; + } + + template <typename Left, typename Right> + inline sequence< + typename extension::as_parser<Left>::value_type + , expect_directive<typename extension::as_parser<Right>::value_type>> + operator>(Left const& left, Right const& right) + { + return {as_parser(left), as_parser(right)}; + } +}}} + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Left, typename Right, typename Context> + struct attribute_of<x3::sequence<Left, Right>, Context> + : x3::detail::attribute_of_sequence<Left, Right, Context> {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/string.hpp b/boost/spirit/home/x3/string.hpp new file mode 100644 index 0000000000..e0f5c6ebac --- /dev/null +++ b/boost/spirit/home/x3/string.hpp @@ -0,0 +1,17 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_STRING_FEBRUARY_03_2007_0355PM) +#define BOOST_SPIRIT_X3_STRING_FEBRUARY_03_2007_0355PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/string/literal_string.hpp> +#include <boost/spirit/home/x3/string/symbols.hpp> + +#endif diff --git a/boost/spirit/home/x3/string/detail/string_parse.hpp b/boost/spirit/home/x3/string/detail/string_parse.hpp new file mode 100644 index 0000000000..f7a77df804 --- /dev/null +++ b/boost/spirit/home/x3/string/detail/string_parse.hpp @@ -0,0 +1,89 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_STRING_PARSE_APR_18_2006_1125PM) +#define BOOST_SPIRIT_X3_STRING_PARSE_APR_18_2006_1125PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/traits/move_to.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace detail +{ + template <typename Char, typename Iterator, typename Attribute> + inline bool string_parse( + Char const* str + , Iterator& first, Iterator const& last, Attribute& attr) + { + Iterator i = first; + Char ch = *str; + + for (; !!ch; ++i) + { + if (i == last || (ch != *i)) + return false; + ch = *++str; + } + + x3::traits::move_to(first, i, attr); + first = i; + return true; + } + + template <typename String, typename Iterator, typename Attribute> + inline bool string_parse( + String const& str + , Iterator& first, Iterator const& last, Attribute& attr) + { + Iterator i = first; + typename String::const_iterator stri = str.begin(); + typename String::const_iterator str_last = str.end(); + + for (; stri != str_last; ++stri, ++i) + if (i == last || (*stri != *i)) + return false; + x3::traits::move_to(first, i, attr); + first = i; + return true; + } + + template <typename Char, typename Iterator, typename Attribute> + inline bool string_parse( + Char const* uc_i, Char const* lc_i + , Iterator& first, Iterator const& last, Attribute& attr) + { + Iterator i = first; + + for (; *uc_i && *lc_i; ++uc_i, ++lc_i, ++i) + if (i == last || ((*uc_i != *i) && (*lc_i != *i))) + return false; + x3::traits::move_to(first, i, attr); + first = i; + return true; + } + + template <typename String, typename Iterator, typename Attribute> + inline bool string_parse( + String const& ucstr, String const& lcstr + , Iterator& first, Iterator const& last, Attribute& attr) + { + typename String::const_iterator uc_i = ucstr.begin(); + typename String::const_iterator uc_last = ucstr.end(); + typename String::const_iterator lc_i = lcstr.begin(); + Iterator i = first; + + for (; uc_i != uc_last; ++uc_i, ++lc_i, ++i) + if (i == last || ((*uc_i != *i) && (*lc_i != *i))) + return false; + x3::traits::move_to(first, i, attr); + first = i; + return true; + } +}}}} + +#endif diff --git a/boost/spirit/home/x3/string/detail/tst.hpp b/boost/spirit/home/x3/string/detail/tst.hpp new file mode 100644 index 0000000000..df61f4dec7 --- /dev/null +++ b/boost/spirit/home/x3/string/detail/tst.hpp @@ -0,0 +1,213 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_TST_MARCH_09_2007_0905AM) +#define BOOST_SPIRIT_X3_TST_MARCH_09_2007_0905AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/call_traits.hpp> +#include <boost/detail/iterator.hpp> +#include <boost/foreach.hpp> +#include <boost/assert.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace detail +{ + // This file contains low level TST routines, not for + // public consumption. + + template <typename Char, typename T> + struct tst_node + { + tst_node(Char id) + : id(id), data(0), lt(0), eq(0), gt(0) + { + } + + template <typename Alloc> + static void + destruct_node(tst_node* p, Alloc* alloc) + { + if (p) + { + if (p->data) + alloc->delete_data(p->data); + destruct_node(p->lt, alloc); + destruct_node(p->eq, alloc); + destruct_node(p->gt, alloc); + alloc->delete_node(p); + } + } + + template <typename Alloc> + static tst_node* + clone_node(tst_node* p, Alloc* alloc) + { + if (p) + { + tst_node* clone = alloc->new_node(p->id); + if (p->data) + clone->data = alloc->new_data(*p->data); + clone->lt = clone_node(p->lt, alloc); + clone->eq = clone_node(p->eq, alloc); + clone->gt = clone_node(p->gt, alloc); + return clone; + } + return 0; + } + + template <typename Iterator, typename Filter> + static T* + find(tst_node* start, Iterator& first, Iterator last, Filter filter) + { + if (first == last) + return 0; + + Iterator i = first; + Iterator latest = first; + tst_node* p = start; + T* found = 0; + + while (p && i != last) + { + typename + boost::detail::iterator_traits<Iterator>::value_type + c = filter(*i); // filter only the input + + if (c == p->id) + { + if (p->data) + { + found = p->data; + latest = i; + } + p = p->eq; + i++; + } + else if (c < p->id) + { + p = p->lt; + } + else + { + p = p->gt; + } + } + + if (found) + first = ++latest; // one past the last matching char + return found; + } + + template <typename Iterator, typename Alloc> + static T* + add( + tst_node*& start + , Iterator first + , Iterator last + , typename boost::call_traits<T>::param_type val + , Alloc* alloc) + { + if (first == last) + return 0; + + tst_node** pp = &start; + for(;;) + { + typename + boost::detail::iterator_traits<Iterator>::value_type + c = *first; + + if (*pp == 0) + *pp = alloc->new_node(c); + tst_node* p = *pp; + + if (c == p->id) + { + if (++first == last) + { + if (p->data == 0) + p->data = alloc->new_data(val); + return p->data; + } + pp = &p->eq; + } + else if (c < p->id) + { + pp = &p->lt; + } + else + { + pp = &p->gt; + } + } + } + + template <typename Iterator, typename Alloc> + static void + remove(tst_node*& p, Iterator first, Iterator last, Alloc* alloc) + { + if (p == 0 || first == last) + return; + + typename + boost::detail::iterator_traits<Iterator>::value_type + c = *first; + + if (c == p->id) + { + if (++first == last) + { + if (p->data) + { + alloc->delete_data(p->data); + p->data = 0; + } + } + remove(p->eq, first, last, alloc); + } + else if (c < p->id) + { + remove(p->lt, first, last, alloc); + } + else + { + remove(p->gt, first, last, alloc); + } + + if (p->data == 0 && p->lt == 0 && p->eq == 0 && p->gt == 0) + { + alloc->delete_node(p); + p = 0; + } + } + + template <typename F> + static void + for_each(tst_node* p, std::basic_string<Char> prefix, F f) + { + if (p) + { + for_each(p->lt, prefix, f); + std::basic_string<Char> s = prefix + p->id; + for_each(p->eq, s, f); + if (p->data) + f(s, *p->data); + for_each(p->gt, prefix, f); + } + } + + Char id; // the node's identity character + T* data; // optional data + tst_node* lt; // left pointer + tst_node* eq; // middle pointer + tst_node* gt; // right pointer + }; +}}}} + +#endif diff --git a/boost/spirit/home/x3/string/literal_string.hpp b/boost/spirit/home/x3/string/literal_string.hpp new file mode 100644 index 0000000000..bf05a9a08e --- /dev/null +++ b/boost/spirit/home/x3/string/literal_string.hpp @@ -0,0 +1,124 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_LITERAL_STRING_APR_18_2006_1125PM) +#define BOOST_SPIRIT_X3_LITERAL_STRING_APR_18_2006_1125PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/string/detail/string_parse.hpp> +#include <boost/spirit/home/x3/support/utility/utf8.hpp> +#include <boost/spirit/home/support/char_encoding/ascii.hpp> +#include <boost/spirit/home/support/char_encoding/standard.hpp> +#include <boost/spirit/home/support/char_encoding/standard_wide.hpp> + +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/add_reference.hpp> +#include <string> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename String, typename Encoding, + typename Attribute = std::basic_string<typename Encoding::char_type>> + struct literal_string : parser<literal_string<String, Encoding, Attribute>> + { + typedef typename Encoding::char_type char_type; + typedef Encoding encoding; + typedef Attribute attribute_type; + static bool const has_attribute = + !is_same<unused_type, attribute_type>::value; + static bool const handles_container = has_attribute; + + literal_string(typename add_reference<String>::type str) + : str(str) + {} + + template <typename Iterator, typename Context, typename Attribute_> + bool parse(Iterator& first, Iterator const& last + , Context const& context, unused_type, Attribute_& attr) const + { + x3::skip_over(first, last, context); + return detail::string_parse(str, first, last, attr); + } + + String str; + }; + + namespace standard + { + inline literal_string<char const*, char_encoding::standard> + string(char const* s) + { + return literal_string<char const*, char_encoding::standard>(s); + } + } + using standard::string; + + namespace extension + { + template <int N> + struct as_parser<char[N]> + { + typedef + literal_string< + char const*, char_encoding::standard, unused_type> + type; + + typedef type value_type; + + static type call(char const* s) + { + return type(s); + } + }; + + template <int N> + struct as_parser<char const[N]> : as_parser<char[N]> {}; + + template <int N> + struct as_parser<wchar_t[N]> + { + typedef + literal_string< + wchar_t const*, char_encoding::standard_wide, unused_type> + type; + + typedef type value_type; + + static type call(wchar_t const* s) + { + return type(s); + } + }; + + template <int N> + struct as_parser<wchar_t const[N]> : as_parser<wchar_t[N]> {}; + } + + using standard::string; + + inline literal_string<char const*, char_encoding::standard, unused_type> + lit(char const* s) + { + return literal_string<char const*, char_encoding::standard, unused_type>(s); + } + + template <typename String, typename Encoding, typename Attribute> + struct get_info<literal_string<String, Encoding, Attribute>> + { + typedef std::string result_type; + std::string operator()(literal_string<String, Encoding, Attribute> const& p) const + { + return '"' + to_utf8(p.str) + '"'; + } + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/string/symbols.hpp b/boost/spirit/home/x3/string/symbols.hpp new file mode 100644 index 0000000000..b35a00a121 --- /dev/null +++ b/boost/spirit/home/x3/string/symbols.hpp @@ -0,0 +1,358 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2013 Carl Barron + + 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_X3_SYMBOLS_MARCH_11_2007_1055AM) +#define BOOST_SPIRIT_X3_SYMBOLS_MARCH_11_2007_1055AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/core/skip_over.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/string/tst.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/support/traits/string_traits.hpp> +#include <boost/spirit/home/x3/support/traits/move_to.hpp> + +#include <boost/fusion/include/at.hpp> +#include <boost/range.hpp> +#include <boost/type_traits/add_reference.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/shared_ptr.hpp> + +#include <initializer_list> + +#if defined(BOOST_MSVC) +# pragma warning(push) +# pragma warning(disable: 4355) // 'this' : used in base member initializer list warning +#endif + +namespace boost { namespace spirit { namespace x3 +{ + template < + typename Char = char + , typename T = unused_type + , typename Lookup = tst<Char, T> + , typename Filter = tst_pass_through> + struct symbols : parser<symbols<Char, T, Lookup, Filter>> + { + typedef Char char_type; // the character type + typedef T value_type; // the value associated with each entry + typedef symbols<Char, T, Lookup, Filter> this_type; + typedef value_type attribute_type; + + static bool const has_attribute = + !is_same<unused_type, attribute_type>::value; + static bool const handles_container = + traits::is_container<attribute_type>::value; + + symbols(std::string const& name = "symbols") + : add(*this) + , remove(*this) + , lookup(new Lookup()) + , name_(name) + { + } + + symbols(symbols const& syms) + : add(*this) + , remove(*this) + , lookup(syms.lookup) + , name_(syms.name_) + { + } + + template <typename Filter_> + symbols(symbols<Char, T, Lookup, Filter_> const& syms) + : add(*this) + , remove(*this) + , lookup(syms.lookup) + , name_(syms.name_) + { + } + + template <typename Symbols> + symbols(Symbols const& syms, std::string const& name = "symbols") + : add(*this) + , remove(*this) + , lookup(new Lookup()) + , name_(name) + { + typename range_const_iterator<Symbols>::type si = boost::begin(syms); + while (si != boost::end(syms)) + add(*si++); + } + + template <typename Symbols, typename Data> + symbols(Symbols const& syms, Data const& data + , std::string const& name = "symbols") + : add(*this) + , remove(*this) + , lookup(new Lookup()) + , name_(name) + { + typename range_const_iterator<Symbols>::type si = boost::begin(syms); + typename range_const_iterator<Data>::type di = boost::begin(data); + while (si != boost::end(syms)) + add(*si++, *di++); + } + + symbols(std::initializer_list<std::pair<Char const*, T>> syms + , std::string const & name="symbols") + : add(*this) + , remove(*this) + , lookup(new Lookup()) + , name_(name) + { + typedef std::initializer_list<std::pair<Char const*, T>> symbols_t; + typename range_const_iterator<symbols_t>::type si = boost::begin(syms); + for (;si != boost::end(syms); ++si) + add(si->first, si->second); + } + + symbols(std::initializer_list<Char const*> syms + , std::string const &name="symbols") + : add(*this) + , remove(*this) + , lookup(new Lookup()) + , name_(name) + { + typedef std::initializer_list<Char const*> symbols_t; + typename range_const_iterator<symbols_t>::type si = boost::begin(syms); + while (si != boost::end(syms)) + add(*si++); + } + + symbols& + operator=(symbols const& rhs) + { + name_ = rhs.name_; + lookup = rhs.lookup; + return *this; + } + + template <typename Filter_> + symbols& + operator=(symbols<Char, T, Lookup, Filter_> const& rhs) + { + name_ = rhs.name_; + lookup = rhs.lookup; + return *this; + } + + void clear() + { + lookup->clear(); + } + + struct adder; + struct remover; + + template <typename Str> + adder const& + operator=(Str const& str) + { + lookup->clear(); + return add(str); + } + + template <typename Str> + friend adder const& + operator+=(symbols& sym, Str const& str) + { + return sym.add(str); + } + + template <typename Str> + friend remover const& + operator-=(symbols& sym, Str const& str) + { + return sym.remove(str); + } + + template <typename F> + void for_each(F f) const + { + lookup->for_each(f); + } + + template <typename Str> + value_type& at(Str const& str) + { + return *lookup->add(traits::get_string_begin<Char>(str) + , traits::get_string_end<Char>(str), T()); + } + + template <typename Iterator> + value_type* prefix_find(Iterator& first, Iterator const& last) + { + return lookup->find(first, last, Filter()); + } + + template <typename Iterator> + value_type const* prefix_find(Iterator& first, Iterator const& last) const + { + return lookup->find(first, last, Filter()); + } + + template <typename Str> + value_type* find(Str const& str) + { + return find_impl(traits::get_string_begin<Char>(str) + , traits::get_string_end<Char>(str)); + } + + template <typename Str> + value_type const* find(Str const& str) const + { + return find_impl(traits::get_string_begin<Char>(str) + , traits::get_string_end<Char>(str)); + } + + private: + template <typename Iterator> + value_type* find_impl(Iterator begin, Iterator end) + { + value_type* r = lookup->find(begin, end, Filter()); + return begin == end ? r : 0; + } + + template <typename Iterator> + value_type const* find_impl(Iterator begin, Iterator end) const + { + value_type const* r = lookup->find(begin, end, Filter()); + return begin == end ? r : 0; + } + + public: + template <typename Iterator, typename Context, typename Attribute> + bool parse(Iterator& first, Iterator const& last + , Context const& context, unused_type, Attribute& attr) const + { + x3::skip_over(first, last, context); + + if (value_type* val_ptr + = lookup->find(first, last, Filter())) + { + x3::traits::move_to(*val_ptr, attr); + return true; + } + return false; + } + + void name(std::string const &str) + { + name_ = str; + } + std::string const &name() const + { + return name_; + } + + struct adder + { + template <typename, typename = unused_type, typename = unused_type> + struct result { typedef adder const& type; }; + + adder(symbols& sym) + : sym(sym) + { + } + + template <typename Iterator> + adder const& + operator()(Iterator first, Iterator last, T const& val) const + { + sym.lookup->add(first, last, val); + return *this; + } + + template <typename Str> + adder const& + operator()(Str const& s, T const& val = T()) const + { + sym.lookup->add(traits::get_string_begin<Char>(s) + , traits::get_string_end<Char>(s), val); + return *this; + } + + template <typename Str> + adder const& + operator,(Str const& s) const + { + sym.lookup->add(traits::get_string_begin<Char>(s) + , traits::get_string_end<Char>(s), T()); + return *this; + } + + symbols& sym; + }; + + struct remover + { + template <typename, typename = unused_type, typename = unused_type> + struct result { typedef remover const& type; }; + + remover(symbols& sym) + : sym(sym) + { + } + + template <typename Iterator> + remover const& + operator()(Iterator const& first, Iterator const& last) const + { + sym.lookup->remove(first, last); + return *this; + } + + template <typename Str> + remover const& + operator()(Str const& s) const + { + sym.lookup->remove(traits::get_string_begin<Char>(s) + , traits::get_string_end<Char>(s)); + return *this; + } + + template <typename Str> + remover const& + operator,(Str const& s) const + { + sym.lookup->remove(traits::get_string_begin<Char>(s) + , traits::get_string_end<Char>(s)); + return *this; + } + + symbols& sym; + }; + + adder add; + remover remove; + shared_ptr<Lookup> lookup; + std::string name_; + }; + + template <typename Char, typename T, typename Lookup, typename Filter> + struct get_info<symbols<Char, T, Lookup, Filter>> + { + typedef std::string result_type; + result_type operator()(symbols< Char, T + , Lookup, Filter + > const& symbols) const + { + return symbols.name(); + } + }; +}}} + +#if defined(BOOST_MSVC) +# pragma warning(pop) +#endif + +#endif diff --git a/boost/spirit/home/x3/string/tst.hpp b/boost/spirit/home/x3/string/tst.hpp new file mode 100644 index 0000000000..5379b032be --- /dev/null +++ b/boost/spirit/home/x3/string/tst.hpp @@ -0,0 +1,137 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_TST_JUNE_03_2007_1031AM) +#define BOOST_SPIRIT_X3_TST_JUNE_03_2007_1031AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/string/detail/tst.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + struct tst_pass_through + { + template <typename Char> + Char operator()(Char ch) const + { + return ch; + } + }; + + template <typename Char, typename T> + struct tst + { + typedef Char char_type; // the character type + typedef T value_type; // the value associated with each entry + typedef detail::tst_node<Char, T> node; + + tst() + : root(0) + { + } + + ~tst() + { + clear(); + } + + tst(tst const& rhs) + : root(0) + { + copy(rhs); + } + + tst& operator=(tst const& rhs) + { + return assign(rhs); + } + + template <typename Iterator, typename Filter> + T* find(Iterator& first, Iterator last, Filter filter) const + { + return node::find(root, first, last, filter); + } + + template <typename Iterator> + T* find(Iterator& first, Iterator last) const + { + return find(first, last, tst_pass_through()); + } + + template <typename Iterator> + T* add( + Iterator first + , Iterator last + , typename boost::call_traits<T>::param_type val) + { + return node::add(root, first, last, val, this); + } + + template <typename Iterator> + void remove(Iterator first, Iterator last) + { + node::remove(root, first, last, this); + } + + void clear() + { + node::destruct_node(root, this); + root = 0; + } + + template <typename F> + void for_each(F f) const + { + node::for_each(root, std::basic_string<Char>(), f); + } + + private: + + friend struct detail::tst_node<Char, T>; + + void copy(tst const& rhs) + { + root = node::clone_node(rhs.root, this); + } + + tst& assign(tst const& rhs) + { + if (this != &rhs) + { + clear(); + copy(rhs); + } + return *this; + } + + node* root; + + node* new_node(Char id) + { + return new node(id); + } + + T* new_data(typename boost::call_traits<T>::param_type val) + { + return new T(val); + } + + void delete_node(node* p) + { + delete p; + } + + void delete_data(T* p) + { + delete p; + } + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/string/tst_map.hpp b/boost/spirit/home/x3/string/tst_map.hpp new file mode 100644 index 0000000000..2501324de6 --- /dev/null +++ b/boost/spirit/home/x3/string/tst_map.hpp @@ -0,0 +1,216 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_TST_MAP_JUNE_03_2007_1143AM) +#define BOOST_SPIRIT_X3_TST_MAP_JUNE_03_2007_1143AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/string/detail/tst.hpp> +#include <unordered_map> +#include <boost/pool/object_pool.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + struct tst_pass_through; // declared in tst.hpp + + template <typename Char, typename T> + struct tst_map + { + typedef Char char_type; // the character type + typedef T value_type; // the value associated with each entry + typedef detail::tst_node<Char, T> node; + + tst_map() + { + } + + ~tst_map() + { + // Nothing to do here. + // The pools do the right thing for us + } + + tst_map(tst_map const& rhs) + { + copy(rhs); + } + + tst_map& operator=(tst_map const& rhs) + { + return assign(rhs); + } + + template <typename Iterator, typename Filter> + T* find(Iterator& first, Iterator last, Filter filter) const + { + if (first != last) + { + Iterator save = first; + typename map_type::const_iterator + i = map.find(filter(*first++)); + if (i == map.end()) + { + first = save; + return 0; + } + if (T* p = node::find(i->second.root, first, last, filter)) + { + return p; + } + return i->second.data; + } + return 0; + } + + template <typename Iterator> + T* find(Iterator& first, Iterator last) const + { + return find(first, last, tst_pass_through()); + } + + template <typename Iterator> + bool add( + Iterator first + , Iterator last + , typename boost::call_traits<T>::param_type val) + { + if (first != last) + { + map_data x = {0, 0}; + std::pair<typename map_type::iterator, bool> + r = map.insert(std::pair<Char, map_data>(*first++, x)); + + if (first != last) + { + return node::add(r.first->second.root + , first, last, val, this) ? true : false; + } + else + { + if (r.first->second.data) + return false; + r.first->second.data = this->new_data(val); + } + return true; + } + return false; + } + + template <typename Iterator> + void remove(Iterator first, Iterator last) + { + if (first != last) + { + typename map_type::iterator i = map.find(*first++); + if (i != map.end()) + { + if (first != last) + { + node::remove(i->second.root, first, last, this); + } + else if (i->second.data) + { + this->delete_data(i->second.data); + i->second.data = 0; + } + if (i->second.data == 0 && i->second.root == 0) + { + map.erase(i); + } + } + } + } + + void clear() + { + BOOST_FOREACH(typename map_type::value_type& x, map) + { + node::destruct_node(x.second.root, this); + if (x.second.data) + this->delete_data(x.second.data); + } + map.clear(); + } + + template <typename F> + void for_each(F f) const + { + BOOST_FOREACH(typename map_type::value_type const& x, map) + { + std::basic_string<Char> s(1, x.first); + node::for_each(x.second.root, s, f); + if (x.second.data) + f(s, *x.second.data); + } + } + + private: + + friend struct detail::tst_node<Char, T>; + + struct map_data + { + node* root; + T* data; + }; + + typedef std::unordered_map<Char, map_data> map_type; + + void copy(tst_map const& rhs) + { + BOOST_FOREACH(typename map_type::value_type const& x, rhs.map) + { + map_data xx = {node::clone_node(x.second.root, this), 0}; + if (x.second.data) + xx.data = data_pool.construct(*x.second.data); + map[x.first] = xx; + } + } + + tst_map& assign(tst_map const& rhs) + { + if (this != &rhs) + { + BOOST_FOREACH(typename map_type::value_type& x, map) + { + node::destruct_node(x.second.root, this); + } + map.clear(); + copy(rhs); + } + return *this; + } + + node* new_node(Char id) + { + return node_pool.construct(id); + } + + T* new_data(typename boost::call_traits<T>::param_type val) + { + return data_pool.construct(val); + } + + void delete_node(node* p) + { + node_pool.destroy(p); + } + + void delete_data(T* p) + { + data_pool.destroy(p); + } + + map_type map; + object_pool<node> node_pool; + object_pool<T> data_pool; + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/support/ast/position_tagged.hpp b/boost/spirit/home/x3/support/ast/position_tagged.hpp new file mode 100644 index 0000000000..22cfd7588b --- /dev/null +++ b/boost/spirit/home/x3/support/ast/position_tagged.hpp @@ -0,0 +1,96 @@ +/*============================================================================= + Copyright (c) 2014 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_X3_POSITION_TAGGED_MAY_01_2014_0321PM) +#define BOOST_SPIRIT_X3_POSITION_TAGGED_MAY_01_2014_0321PM + +#include <boost/range.hpp> +#include <boost/type_traits/is_base_of.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + struct position_tagged + { + // Use this to annotate an AST with the iterator position. + // These ids are used as a key to the position_cache (below) + // and marks the start and end of an AST node. + int id_first = -1; + int id_last = -1; + }; + + template <typename Container> + class position_cache + { + public: + + typedef typename Container::value_type iterator_type; + + position_cache( + iterator_type first + , iterator_type last) + : first_(first), last_(last) {} + + // This will catch all nodes inheriting from position_tagged + boost::iterator_range<iterator_type> + position_of(position_tagged const& ast) const + { + return + boost::iterator_range<iterator_type>( + positions.at(ast.id_first) // throws if out of range + , positions.at(ast.id_last) // throws if out of range + ); + } + + // This will catch all nodes except those inheriting from position_tagged + template <typename AST> + boost::iterator_range<iterator_type> + position_of(AST const& ast) const + { + // returns an empty position + return boost::iterator_range<iterator_type>(); + } + + // This will catch all nodes except those inheriting from position_tagged + template <typename AST> + void annotate(AST& ast, iterator_type first, iterator_type last, mpl::false_) + { + // (no-op) no need for tags + } + + // This will catch all nodes inheriting from position_tagged + void annotate(position_tagged& ast, iterator_type first, iterator_type last, mpl::true_) + { + ast.id_first = int(positions.size()); + positions.push_back(first); + ast.id_last = int(positions.size()); + positions.push_back(last); + } + + template <typename AST> + void annotate(AST& ast, iterator_type first, iterator_type last) + { + annotate(ast, first, last, is_base_of<position_tagged, AST>()); + } + + Container const& + get_positions() const + { + return positions; + } + + iterator_type first() const { return first_; } + iterator_type last() const { return last_; } + + private: + + Container positions; + iterator_type first_; + iterator_type last_; + }; + +}}} + +#endif diff --git a/boost/spirit/home/x3/support/ast/variant.hpp b/boost/spirit/home/x3/support/ast/variant.hpp new file mode 100644 index 0000000000..cf626e88be --- /dev/null +++ b/boost/spirit/home/x3/support/ast/variant.hpp @@ -0,0 +1,249 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_VARIANT_AUGUST_6_2011_0859AM) +#define BOOST_SPIRIT_X3_VARIANT_AUGUST_6_2011_0859AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/variant.hpp> +#include <boost/mpl/list.hpp> +#include <boost/type_traits/is_base_of.hpp> + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { namespace x3 +{ + template <typename T> + class forward_ast + { + public: + + typedef T type; + + public: + + forward_ast() : p_(new T) {} + + forward_ast(forward_ast const& operand) + : p_(new T(operand.get())) {} + + forward_ast(forward_ast&& operand) + : p_(operand.p_) + { + operand.p_ = 0; + } + + forward_ast(T const& operand) + : p_(new T(operand)) {} + + forward_ast(T&& operand) + : p_(new T(std::move(operand))) {} + + ~forward_ast() + { + boost::checked_delete(p_); + } + + forward_ast& operator=(forward_ast const& rhs) + { + assign(rhs.get()); + return *this; + } + + void swap(forward_ast& operand) BOOST_NOEXCEPT + { + T* temp = operand.p_; + operand.p_ = p_; + p_ = temp; + } + + forward_ast& operator=(T const& rhs) + { + assign(rhs); + return *this; + } + + forward_ast& operator=(forward_ast&& rhs) BOOST_NOEXCEPT + { + swap(rhs); + return *this; + } + + forward_ast& operator=(T&& rhs) + { + get() = std::move(rhs); + return *this; + } + + T& get() { return *get_pointer(); } + const T& get() const { return *get_pointer(); } + + T* get_pointer() { return p_; } + const T* get_pointer() const { return p_; } + + operator T const&() const { return this->get(); } + operator T&() { return this->get(); } + + private: + + void assign(const T& rhs) + { + this->get() = rhs; + } + + T* p_; + }; + + // function template swap + // + // Swaps two forward_ast<T> objects of the same type T. + // + template <typename T> + inline void swap(forward_ast<T>& lhs, forward_ast<T>& rhs) BOOST_NOEXCEPT + { + lhs.swap(rhs); + } + + namespace detail + { + template <typename T> + struct remove_forward : mpl::identity<T> + {}; + + template <typename T> + struct remove_forward<forward_ast<T>> : mpl::identity<T> + {}; + } + + template <typename ...Types> + struct variant + { + // tell spirit that this is an adapted variant + struct adapted_variant_tag; + + typedef boost::variant<Types...> variant_type; + typedef mpl::list<typename detail::remove_forward<Types>::type...> types; + typedef variant<Types...> base_type; + + variant() : var() {} + + template <typename T, typename disable_if<is_base_of<base_type, T>>::type> + explicit variant(T const& rhs) + : var(rhs) {} + + template <typename T, typename disable_if<is_base_of<base_type, T>>::type> + explicit variant(T&& rhs) + : var(std::forward<T>(rhs)) {} + + variant(variant const& rhs) + : var(rhs.var) {} + + variant(variant& rhs) + : var(rhs.var) {} + + variant(variant&& rhs) + : var(std::forward<variant_type>(rhs.var)) {} + + variant& operator=(variant const& rhs) + { + var = rhs.get(); + return *this; + } + + variant& operator=(variant&& rhs) + { + var = std::forward<variant_type>(rhs.get()); + return *this; + } + + template <typename T> + //typename disable_if<is_base_of<base_type, T>, variant&>::type + variant& operator=(T const& rhs) + { + var = rhs; + return *this; + } + + template <typename T> + //typename disable_if<is_base_of<base_type, T>, variant&>::type + variant& operator=(T&& rhs) + { + var = std::forward<T>(rhs); + return *this; + } + + template <typename F> + typename F::result_type apply_visitor(F const& v) + { + return var.apply_visitor(v); + } + + template <typename F> + typename F::result_type apply_visitor(F const& v) const + { + return var.apply_visitor(v); + } + + template <typename F> + typename F::result_type apply_visitor(F& v) + { + return var.apply_visitor(v); + } + + template <typename F> + typename F::result_type apply_visitor(F& v) const + { + return var.apply_visitor(v); + } + + variant_type const& get() const + { + return var; + } + + variant_type& get() + { + return var; + } + + variant_type var; + }; +}}} + +namespace boost +{ + template <typename T, typename ...Types> + inline T const& + get(boost::spirit::x3::variant<Types...> const& x) + { + return boost::get<T>(x.get()); + } + + template <typename T, typename ...Types> + inline T& + get(boost::spirit::x3::variant<Types...>& x) + { + return boost::get<T>(x.get()); + } + + template <typename T, typename ...Types> + inline T const* + get(boost::spirit::x3::variant<Types...> const* x) + { + return boost::get<T>(&x->get()); + } + + template <typename T, typename ...Types> + inline T* + get(boost::spirit::x3::variant<Types...>* x) + { + return boost::get<T>(&x->get()); + } +} + +#endif diff --git a/boost/spirit/home/x3/support/context.hpp b/boost/spirit/home/x3/support/context.hpp new file mode 100644 index 0000000000..93bcb24070 --- /dev/null +++ b/boost/spirit/home/x3/support/context.hpp @@ -0,0 +1,135 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + http://spirit.sourceforge.net/ + + 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_X3_CONTEXT_JAN_4_2012_1215PM) +#define BOOST_SPIRIT_X3_CONTEXT_JAN_4_2012_1215PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/mpl/identity.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename ID, typename T, typename Next = unused_type> + struct context + { + context(T& val, Next const& next) + : val(val), next(next) {} + + template <typename ID_, typename Unused = void> + struct get_result + { + typedef typename Next::template get_result<ID_>::type type; + }; + + template <typename Unused> + struct get_result<mpl::identity<ID>, Unused> + { + typedef T& type; + }; + + T& get(mpl::identity<ID>) const + { + return val; + } + + template <typename ID_> + typename Next::template get_result<ID_>::type + get(ID_ id) const + { + return next.get(id); + } + + T& val; + Next const& next; + }; + + template <typename ID, typename T> + struct context<ID, T, unused_type> + { + context(T& val) + : val(val) {} + + context(T& val, unused_type) + : val(val) {} + + template <typename ID_, typename Unused = void> + struct get_result + { + typedef unused_type type; + }; + + template <typename Unused> + struct get_result<mpl::identity<ID>, Unused> + { + typedef T& type; + }; + + T& get(mpl::identity<ID>) const + { + return val; + } + + template <typename ID_> + unused_type + get(ID_) const + { + return unused; + } + + T& val; + }; + + template <typename Tag, typename Context> + inline auto + get(Context const& context) + -> decltype(context.get(mpl::identity<Tag>())) + { + return context.get(mpl::identity<Tag>()); + } + + template <typename ID, typename T, typename Next> + inline context<ID, T, Next> make_context(T& val, Next const& next) + { + return context<ID, T, Next>(val, next); + } + + template <typename ID, typename T> + inline context<ID, T> make_context(T& val) + { + return context<ID, T>(val); + } + + namespace detail + { + template <typename ID, typename T, typename Next, typename FoundVal> + inline Next const& + make_unique_context(T& val, Next const& next, FoundVal&) + { + return next; + } + + template <typename ID, typename T, typename Next> + inline context<ID, T, Next> + make_unique_context(T& val, Next const& next, unused_type) + { + return context<ID, T, Next>(val, next); + } + } + + template <typename ID, typename T, typename Next> + inline auto + make_unique_context(T& val, Next const& next) + { + return detail::make_unique_context<ID>(val, next, x3::get<ID>(next)); + } +}}} + +#endif diff --git a/boost/spirit/home/x3/support/numeric_utils/detail/extract_int.hpp b/boost/spirit/home/x3/support/numeric_utils/detail/extract_int.hpp new file mode 100644 index 0000000000..73770c87d0 --- /dev/null +++ b/boost/spirit/home/x3/support/numeric_utils/detail/extract_int.hpp @@ -0,0 +1,512 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + Copyright (c) 2011 Jan Frederick Eick + Copyright (c) 2011 Christopher Jefferson + Copyright (c) 2006 Stephen Nutt + + 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_X3_DETAIL_EXTRACT_INT_APRIL_17_2006_0816AM) +#define BOOST_SPIRIT_X3_DETAIL_EXTRACT_INT_APRIL_17_2006_0816AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/support/traits/attribute_type.hpp> +#include <boost/spirit/home/x3/support/traits/move_to.hpp> +#include <boost/spirit/home/x3/support/traits/numeric_traits.hpp> +#include <boost/spirit/home/support/char_encoding/ascii.hpp> + +#include <boost/preprocessor/repetition/repeat.hpp> +#include <boost/preprocessor/iteration/local.hpp> +#include <boost/preprocessor/comparison/less.hpp> +#include <boost/preprocessor/control/if.hpp> +#include <boost/preprocessor/seq/elem.hpp> + +#include <boost/detail/iterator.hpp> +#include <boost/utility/enable_if.hpp> + +#include <boost/type_traits/is_integral.hpp> +#include <boost/type_traits/is_signed.hpp> +#include <boost/type_traits/make_unsigned.hpp> + +#include <boost/mpl/bool.hpp> +#include <boost/mpl/and.hpp> +#include <boost/limits.hpp> + +#if !defined(SPIRIT_NUMERICS_LOOP_UNROLL) +# define SPIRIT_NUMERICS_LOOP_UNROLL 3 +#endif + +namespace boost { namespace spirit { namespace x3 { namespace detail +{ + /////////////////////////////////////////////////////////////////////////// + // + // The maximum radix digits that can be represented without + // overflow: + // + // template<typename T, unsigned Radix> + // struct digits_traits::value; + // + /////////////////////////////////////////////////////////////////////////// + template <typename T, unsigned Radix> + struct digits_traits; + +// lookup table for log2(x) : 2 <= x <= 36 +#define BOOST_SPIRIT_X3_LOG2 (#error)(#error) \ + (1000000)(1584960)(2000000)(2321920)(2584960)(2807350) \ + (3000000)(3169920)(3321920)(3459430)(3584960)(3700430) \ + (3807350)(3906890)(4000000)(4087460)(4169920)(4247920) \ + (4321920)(4392310)(4459430)(4523560)(4584960)(4643850) \ + (4700430)(4754880)(4807350)(4857980)(4906890)(4954190) \ + (5000000)(5044390)(5087460)(5129280)(5169925) \ + /***/ + +#define BOOST_PP_LOCAL_MACRO(Radix) \ + template <typename T> struct digits_traits<T, Radix> \ + { \ + typedef std::numeric_limits<T> numeric_limits_type; \ + BOOST_STATIC_CONSTANT(int, value = static_cast<int>( \ + (numeric_limits_type::digits * 1000000) / \ + BOOST_PP_SEQ_ELEM(Radix, BOOST_SPIRIT_X3_LOG2))); \ + }; \ + /***/ + +#define BOOST_PP_LOCAL_LIMITS (2, 36) +#include BOOST_PP_LOCAL_ITERATE() + +#undef BOOST_SPIRIT_X3_LOG2 + + /////////////////////////////////////////////////////////////////////////// + // + // Traits class for radix specific number conversion + // + // Test the validity of a single character: + // + // template<typename Char> static bool is_valid(Char ch); + // + // Convert a digit from character representation to binary + // representation: + // + // template<typename Char> static int digit(Char ch); + // + /////////////////////////////////////////////////////////////////////////// + template <unsigned Radix> + struct radix_traits + { + 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)); + } + + template <typename Char> + inline static unsigned digit(Char ch) + { + if (Radix <= 10 || (ch >= '0' && ch <= '9')) + return ch - '0'; + return char_encoding::ascii::tolower(ch) - 'a' + 10; + } + }; + + /////////////////////////////////////////////////////////////////////////// + // positive_accumulator/negative_accumulator: Accumulator policies for + // extracting integers. Use positive_accumulator if number is positive. + // Use negative_accumulator if number is negative. + /////////////////////////////////////////////////////////////////////////// + template <unsigned Radix> + struct positive_accumulator + { + template <typename T, typename Char> + inline static void add(T& n, Char ch, mpl::false_) // unchecked add + { + const int digit = radix_traits<Radix>::digit(ch); + n = n * T(Radix) + T(digit); + } + + template <typename T, typename Char> + inline static bool add(T& n, Char ch, mpl::true_) // checked add + { + // Ensure n *= Radix will not overflow + static T const max = (std::numeric_limits<T>::max)(); + static T const val = max / Radix; + if (n > val) + return false; + + n *= Radix; + + // Ensure n += digit will not overflow + const int digit = radix_traits<Radix>::digit(ch); + if (n > max - digit) + return false; + + n += static_cast<T>(digit); + return true; + } + }; + + template <unsigned Radix> + struct negative_accumulator + { + template <typename T, typename Char> + inline static void add(T& n, Char ch, mpl::false_) // unchecked subtract + { + const int digit = radix_traits<Radix>::digit(ch); + n = n * T(Radix) - T(digit); + } + + template <typename T, typename Char> + inline static bool add(T& n, Char ch, mpl::true_) // checked subtract + { + // Ensure n *= Radix will not underflow + static T const min = (std::numeric_limits<T>::min)(); + static T const val = (min + 1) / T(Radix); + if (n < val) + return false; + + n *= Radix; + + // Ensure n -= digit will not underflow + int const digit = radix_traits<Radix>::digit(ch); + if (n < min + digit) + return false; + + n -= static_cast<T>(digit); + return true; + } + }; + + /////////////////////////////////////////////////////////////////////////// + // Common code for extract_int::parse specializations + /////////////////////////////////////////////////////////////////////////// + template <unsigned Radix, typename Accumulator, int MaxDigits> + struct int_extractor + { + template <typename Char, typename T> + inline static bool + call(Char ch, std::size_t count, T& n, mpl::true_) + { + static std::size_t const + overflow_free = digits_traits<T, Radix>::value - 1; + + if (count < overflow_free) + { + Accumulator::add(n, ch, mpl::false_()); + } + else + { + if (!Accumulator::add(n, ch, mpl::true_())) + return false; // over/underflow! + } + return true; + } + + template <typename Char, typename T> + inline static bool + call(Char ch, std::size_t /*count*/, T& n, mpl::false_) + { + // no need to check for overflow + Accumulator::add(n, ch, mpl::false_()); + return true; + } + + template <typename Char> + inline static bool + call(Char /*ch*/, std::size_t /*count*/, unused_type, mpl::false_) + { + return true; + } + + template <typename Char, typename T> + inline static bool + call(Char ch, std::size_t count, T& n) + { + return call(ch, count, n + , mpl::bool_< + ( (MaxDigits < 0) + || (MaxDigits > digits_traits<T, Radix>::value) + ) + && traits::check_overflow<T>::value + >() + ); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // End of loop checking: check if the number of digits + // being parsed exceeds MaxDigits. Note: if MaxDigits == -1 + // we don't do any checking. + /////////////////////////////////////////////////////////////////////////// + template <int MaxDigits> + struct check_max_digits + { + inline static bool + call(std::size_t count) + { + return count < MaxDigits; // bounded + } + }; + + template <> + struct check_max_digits<-1> + { + inline static bool + call(std::size_t /*count*/) + { + return true; // unbounded + } + }; + + /////////////////////////////////////////////////////////////////////////// + // extract_int: main code for extracting integers + /////////////////////////////////////////////////////////////////////////// +#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) || !extractor::call(ch, count, val)) \ + break; \ + ++it; \ + ++count; \ + /**/ + + template < + typename T, unsigned Radix, unsigned MinDigits, int MaxDigits + , typename Accumulator = positive_accumulator<Radix> + , bool Accumulate = false + > + struct extract_int + { +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +#endif + template <typename Iterator, typename Attribute> + inline static bool + parse_main( + Iterator& first + , Iterator const& last + , Attribute& attr) + { + typedef radix_traits<Radix> radix_check; + typedef int_extractor<Radix, Accumulator, MaxDigits> extractor; + typedef typename + boost::detail::iterator_traits<Iterator>::value_type + char_type; + + Iterator it = first; + std::size_t leading_zeros = 0; + if (!Accumulate) + { + // skip leading zeros + while (it != last && *it == '0' && leading_zeros < MaxDigits) + { + ++it; + ++leading_zeros; + } + } + + typedef typename + traits::attribute_type<Attribute>::type + attribute_type; + + attribute_type val = Accumulate ? attr : attribute_type(0); + std::size_t count = 0; + char_type ch; + + while (true) + { + BOOST_PP_REPEAT( + SPIRIT_NUMERICS_LOOP_UNROLL + , SPIRIT_NUMERIC_INNER_LOOP, _) + } + + if (count + leading_zeros >= MinDigits) + { + traits::move_to(val, attr); + first = it; + return true; + } + return false; + } +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(pop) +#endif + + template <typename Iterator> + inline static bool + parse( + Iterator& first + , Iterator const& last + , unused_type) + { + T n = 0; // must calculate value to detect over/underflow + return parse_main(first, last, n); + } + + template <typename Iterator, typename Attribute> + inline static bool + parse( + Iterator& first + , Iterator const& last + , Attribute& attr) + { + return parse_main(first, last, attr); + } + }; +#undef SPIRIT_NUMERIC_INNER_LOOP + + /////////////////////////////////////////////////////////////////////////// + // extract_int: main code for extracting integers + // common case where MinDigits == 1 and MaxDigits = -1 + /////////////////////////////////////////////////////////////////////////// +#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)) \ + return false; \ + ++it; \ + ++count; \ + /**/ + + template <typename T, unsigned Radix, typename Accumulator, bool Accumulate> + struct extract_int<T, Radix, 1, -1, Accumulator, Accumulate> + { +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(push) +# pragma warning(disable: 4127) // conditional expression is constant +#endif + template <typename Iterator, typename Attribute> + inline static bool + parse_main( + Iterator& first + , Iterator const& last + , Attribute& attr) + { + typedef radix_traits<Radix> radix_check; + typedef int_extractor<Radix, Accumulator, -1> extractor; + typedef typename + boost::detail::iterator_traits<Iterator>::value_type + char_type; + + Iterator it = first; + std::size_t count = 0; + if (!Accumulate) + { + // skip leading zeros + while (it != last && *it == '0') + { + ++it; + ++count; + } + + if (it == last) + { + if (count == 0) // must have at least one digit + return false; + attr = 0; + first = it; + return true; + } + } + + typedef typename + traits::attribute_type<Attribute>::type + attribute_type; + + attribute_type val = Accumulate ? attr : attribute_type(0); + char_type ch = *it; + + if (!radix_check::is_valid(ch) || !extractor::call(ch, 0, val)) + { + if (count == 0) // must have at least one digit + return false; + traits::move_to(val, attr); + first = it; + return true; + } + + count = 0; + ++it; + while (true) + { + BOOST_PP_REPEAT( + SPIRIT_NUMERICS_LOOP_UNROLL + , SPIRIT_NUMERIC_INNER_LOOP, _) + } + + traits::move_to(val, attr); + first = it; + return true; + } +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(pop) +#endif + + template <typename Iterator> + inline static bool + parse( + Iterator& first + , Iterator const& last + , unused_type) + { + T n = 0; // must calculate value to detect over/underflow + return parse_main(first, last, n); + } + + template <typename Iterator, typename Attribute> + inline static bool + parse( + Iterator& first + , Iterator const& last + , Attribute& attr) + { + return parse_main(first, last, attr); + } + }; + +#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; + } + }; +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/numeric_utils/extract_int.hpp b/boost/spirit/home/x3/support/numeric_utils/extract_int.hpp new file mode 100644 index 0000000000..aa80cdd6ea --- /dev/null +++ b/boost/spirit/home/x3/support/numeric_utils/extract_int.hpp @@ -0,0 +1,147 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2011 Jan Frederick Eick + + 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_X3_EXTRACT_INT_APRIL_17_2006_0830AM) +#define BOOST_SPIRIT_X3_EXTRACT_INT_APRIL_17_2006_0830AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/traits/move_to.hpp> +#include <boost/spirit/home/x3/support/numeric_utils/detail/extract_int.hpp> +#include <boost/assert.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + /////////////////////////////////////////////////////////////////////////// + // Extract the prefix sign (- or +), return true if a '-' was found + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator> + inline bool + extract_sign(Iterator& first, Iterator const& last) + { + (void)last; // silence unused warnings + BOOST_ASSERT(first != last); // precondition + + // Extract the sign + bool neg = *first == '-'; + if (neg || (*first == '+')) + { + ++first; + return neg; + } + return false; + } + + /////////////////////////////////////////////////////////////////////////// + // Low level unsigned integer parser + /////////////////////////////////////////////////////////////////////////// + template <typename T, unsigned Radix, unsigned MinDigits, int MaxDigits + , bool Accumulate = false> + struct extract_uint + { + // check template parameter 'Radix' for validity + static_assert( + (Radix >= 2 && Radix <= 36), + "Error Unsupported Radix"); + + template <typename Iterator> + inline static bool call(Iterator& first, Iterator const& last, T& attr) + { + if (first == last) + return false; + + typedef detail::extract_int< + T + , Radix + , MinDigits + , MaxDigits + , detail::positive_accumulator<Radix> + , Accumulate> + extract_type; + + Iterator save = first; + if (!extract_type::parse(first, last, + detail::cast_unsigned<T>::call(attr))) + { + first = save; + return false; + } + return true; + } + + template <typename Iterator, typename Attribute> + inline static bool call(Iterator& first, Iterator const& last, Attribute& attr_) + { + // this case is called when Attribute is not T + T attr; + if (call(first, last, attr)) + { + traits::move_to(attr, attr_); + return true; + } + return false; + } + }; + + /////////////////////////////////////////////////////////////////////////// + // Low level signed integer parser + /////////////////////////////////////////////////////////////////////////// + template <typename T, unsigned Radix, unsigned MinDigits, int MaxDigits> + struct extract_int + { + // check template parameter 'Radix' for validity + static_assert( + (Radix == 2 || Radix == 8 || Radix == 10 || Radix == 16), + "Error Unsupported Radix"); + + template <typename Iterator> + inline static bool call(Iterator& first, Iterator const& last, T& attr) + { + if (first == last) + return false; + + typedef detail::extract_int< + T, Radix, MinDigits, MaxDigits> + extract_pos_type; + + typedef detail::extract_int< + T, Radix, MinDigits, MaxDigits, detail::negative_accumulator<Radix> > + extract_neg_type; + + Iterator save = first; + bool hit = extract_sign(first, last); + if (hit) + hit = extract_neg_type::parse(first, last, attr); + else + hit = extract_pos_type::parse(first, last, attr); + + if (!hit) + { + first = save; + return false; + } + return true; + } + + template <typename Iterator, typename Attribute> + inline static bool call(Iterator& first, Iterator const& last, Attribute& attr_) + { + // this case is called when Attribute is not T + T attr; + if (call(first, last, attr)) + { + traits::move_to(attr, attr_); + return true; + } + return false; + } + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/support/numeric_utils/extract_real.hpp b/boost/spirit/home/x3/support/numeric_utils/extract_real.hpp new file mode 100644 index 0000000000..fb30f02306 --- /dev/null +++ b/boost/spirit/home/x3/support/numeric_utils/extract_real.hpp @@ -0,0 +1,271 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + http://spirit.sourceforge.net/ + + 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_EXTRACT_REAL_APRIL_18_2006_0901AM) +#define SPIRIT_EXTRACT_REAL_APRIL_18_2006_0901AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <cmath> +#include <boost/limits.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/support/numeric_utils/pow10.hpp> +#include <boost/spirit/home/x3/support/numeric_utils/sign.hpp> +#include <boost/spirit/home/x3/support/traits/move_to.hpp> +#include <boost/assert.hpp> + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(push) +# pragma warning(disable: 4100) // 'p': unreferenced formal parameter +# pragma warning(disable: 4127) // conditional expression is constant +#endif + +namespace boost { namespace spirit { namespace x3 { namespace extension +{ + using x3::traits::pow10; + + template <typename T> + inline void + scale(int exp, T& n) + { + if (exp >= 0) + { + // $$$ Why is this failing for boost.math.concepts ? $$$ + //~ int nn = std::numeric_limits<T>::max_exponent10; + //~ BOOST_ASSERT(exp <= std::numeric_limits<T>::max_exponent10); + n *= pow10<T>(exp); + } + else + { + if (exp < std::numeric_limits<T>::min_exponent10) + { + n /= pow10<T>(-std::numeric_limits<T>::min_exponent10); + n /= pow10<T>(-exp + std::numeric_limits<T>::min_exponent10); + } + else + { + n /= pow10<T>(-exp); + } + } + } + + inline void + scale(int /*exp*/, unused_type /*n*/) + { + // no-op for unused_type + } + + template <typename T> + inline void + scale(int exp, int frac, T& n) + { + scale(exp - frac, n); + } + + inline void + scale(int /*exp*/, int /*frac*/, unused_type /*n*/) + { + // no-op for unused_type + } + + inline float + negate(bool neg, float n) + { + return neg ? x3::changesign(n) : n; + } + + inline double + negate(bool neg, double n) + { + return neg ? x3::changesign(n) : n; + } + + inline long double + negate(bool neg, long double n) + { + return neg ? x3::changesign(n) : n; + } + + template <typename T> + inline T + negate(bool neg, T const& n) + { + return neg ? -n : n; + } + + inline unused_type + negate(bool /*neg*/, unused_type n) + { + // no-op for unused_type + 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; + } +}}}} + +namespace boost { namespace spirit { namespace x3 +{ + template <typename T, typename RealPolicies> + struct extract_real + { + template <typename Iterator, typename Attribute> + static bool + parse(Iterator& first, Iterator const& last, Attribute& attr, + RealPolicies const& p) + { + if (first == last) + return false; + Iterator save = first; + + // Start by parsing the sign. neg will be true if + // we got a "-" sign, false otherwise. + bool neg = p.parse_sign(first, last); + + // Now attempt to parse an integer + T n = 0; + bool got_a_number = p.parse_n(first, last, n); + + // If we did not get a number it might be a NaN, Inf or a leading + // dot. + if (!got_a_number) + { + // 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::move_to(extension::negate(neg, n), attr); + return true; // got a NaN or Inf, return early + } + + // If we did not get a number and our policies do not + // allow a leading dot, fail and return early (no-match) + if (!p.allow_leading_dot) + { + first = save; + return false; + } + } + + bool e_hit = false; + int frac_digits = 0; + + // Try to parse the dot ('.' decimal point) + if (p.parse_dot(first, last)) + { + // We got the decimal point. Now we will try to parse + // the fraction if it is there. If not, it defaults + // to zero (0) only if we already got a number. + Iterator savef = first; + if (p.parse_frac_n(first, last, n)) + { + // Optimization note: don't compute frac_digits if T is + // an unused_type. This should be optimized away by the compiler. + if (!is_same<T, unused_type>::value) + frac_digits = + static_cast<int>(std::distance(savef, first)); + } + else if (!got_a_number || !p.allow_trailing_dot) + { + // We did not get a fraction. If we still haven't got a + // number and our policies do not allow a trailing dot, + // return no-match. + first = save; + return false; + } + + // Now, let's see if we can parse the exponent prefix + e_hit = p.parse_exp(first, last); + } + else + { + // No dot and no number! Return no-match. + if (!got_a_number) + { + first = save; + return false; + } + + // If we must expect a dot and we didn't see an exponent + // prefix, return no-match. + e_hit = p.parse_exp(first, last); + if (p.expect_dot && !e_hit) + { + first = save; + return false; + } + } + + if (e_hit) + { + // We got the exponent prefix. Now we will try to parse the + // actual exponent. It is an error if it is not there. + int exp = 0; + if (p.parse_exp_n(first, last, exp)) + { + // Got the exponent value. Scale the number by + // exp-frac_digits. + extension::scale(exp, frac_digits, n); + } + else + { + // Oops, no exponent, return no-match. + first = save; + return false; + } + } + else if (frac_digits) + { + // No exponent found. Scale the number by -frac_digits. + extension::scale(-frac_digits, n); + } + else if (extension::is_equal_to_one(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::move_to(extension::negate(neg, n), attr); + return true; // got a NaN or Inf, return immediately + } + } + + // If we got a negative sign, negate the number + traits::move_to(extension::negate(neg, n), attr); + + // Success!!! + return true; + } + }; + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(pop) +#endif + +}}} + +#endif diff --git a/boost/spirit/home/x3/support/numeric_utils/pow10.hpp b/boost/spirit/home/x3/support/numeric_utils/pow10.hpp new file mode 100644 index 0000000000..f51d29fba8 --- /dev/null +++ b/boost/spirit/home/x3/support/numeric_utils/pow10.hpp @@ -0,0 +1,116 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + http://spirit.sourceforge.net/ + + 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_X3_POW10_DECEMBER_26_2008_1118AM) +#define BOOST_SPIRIT_X3_POW10_DECEMBER_26_2008_1118AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/config/no_tr1/cmath.hpp> +#include <boost/limits.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/spirit/home/x3/support/traits/numeric_traits.hpp> + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(push) +# pragma warning(disable: 4244) // conversion from 'double' to 'float', possible loss of data +#endif + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + namespace detail + { + template <typename T, typename Enable = void> + struct pow10_helper + { + static T call(unsigned dim) + { + using namespace std; // allow for ADL to find the correct overload + return pow(T(10), T(dim)); + } + }; + + template <> + struct pow10_helper<unused_type> + { + static unused_type call(unused_type) + { + return unused; + } + }; + +#if (DBL_MAX_10_EXP == 308) // for IEEE-754 + template <> + struct pow10_helper<double> + { + static double call(unsigned dim) + { + static double const exponents[] = + { + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, + 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, + 1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29, + 1e30, 1e31, 1e32, 1e33, 1e34, 1e35, 1e36, 1e37, 1e38, 1e39, + 1e40, 1e41, 1e42, 1e43, 1e44, 1e45, 1e46, 1e47, 1e48, 1e49, + 1e50, 1e51, 1e52, 1e53, 1e54, 1e55, 1e56, 1e57, 1e58, 1e59, + 1e60, 1e61, 1e62, 1e63, 1e64, 1e65, 1e66, 1e67, 1e68, 1e69, + 1e70, 1e71, 1e72, 1e73, 1e74, 1e75, 1e76, 1e77, 1e78, 1e79, + 1e80, 1e81, 1e82, 1e83, 1e84, 1e85, 1e86, 1e87, 1e88, 1e89, + 1e90, 1e91, 1e92, 1e93, 1e94, 1e95, 1e96, 1e97, 1e98, 1e99, + 1e100, 1e101, 1e102, 1e103, 1e104, 1e105, 1e106, 1e107, 1e108, 1e109, + 1e110, 1e111, 1e112, 1e113, 1e114, 1e115, 1e116, 1e117, 1e118, 1e119, + 1e120, 1e121, 1e122, 1e123, 1e124, 1e125, 1e126, 1e127, 1e128, 1e129, + 1e130, 1e131, 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138, 1e139, + 1e140, 1e141, 1e142, 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149, + 1e150, 1e151, 1e152, 1e153, 1e154, 1e155, 1e156, 1e157, 1e158, 1e159, + 1e160, 1e161, 1e162, 1e163, 1e164, 1e165, 1e166, 1e167, 1e168, 1e169, + 1e170, 1e171, 1e172, 1e173, 1e174, 1e175, 1e176, 1e177, 1e178, 1e179, + 1e180, 1e181, 1e182, 1e183, 1e184, 1e185, 1e186, 1e187, 1e188, 1e189, + 1e190, 1e191, 1e192, 1e193, 1e194, 1e195, 1e196, 1e197, 1e198, 1e199, + 1e200, 1e201, 1e202, 1e203, 1e204, 1e205, 1e206, 1e207, 1e208, 1e209, + 1e210, 1e211, 1e212, 1e213, 1e214, 1e215, 1e216, 1e217, 1e218, 1e219, + 1e220, 1e221, 1e222, 1e223, 1e224, 1e225, 1e226, 1e227, 1e228, 1e229, + 1e230, 1e231, 1e232, 1e233, 1e234, 1e235, 1e236, 1e237, 1e238, 1e239, + 1e240, 1e241, 1e242, 1e243, 1e244, 1e245, 1e246, 1e247, 1e248, 1e249, + 1e250, 1e251, 1e252, 1e253, 1e254, 1e255, 1e256, 1e257, 1e258, 1e259, + 1e260, 1e261, 1e262, 1e263, 1e264, 1e265, 1e266, 1e267, 1e268, 1e269, + 1e270, 1e271, 1e272, 1e273, 1e274, 1e275, 1e276, 1e277, 1e278, 1e279, + 1e280, 1e281, 1e282, 1e283, 1e284, 1e285, 1e286, 1e287, 1e288, 1e289, + 1e290, 1e291, 1e292, 1e293, 1e294, 1e295, 1e296, 1e297, 1e298, 1e299, + 1e300, 1e301, 1e302, 1e303, 1e304, 1e305, 1e306, 1e307, 1e308, + }; + BOOST_ASSERT(dim < sizeof(exponents)/sizeof(double)); + return exponents[dim]; + } + }; + + template <> + struct pow10_helper<float> + { + static float call(unsigned dim) + { + return pow10_helper<double>::call(dim); + } + }; +#endif // for IEEE-754 + } + + template <typename T> + inline T pow10(unsigned dim) + { + return detail::pow10_helper<T>::call(dim); + } +}}}} + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(pop) +#endif + +#endif diff --git a/boost/spirit/home/x3/support/numeric_utils/sign.hpp b/boost/spirit/home/x3/support/numeric_utils/sign.hpp new file mode 100644 index 0000000000..fe2feceeed --- /dev/null +++ b/boost/spirit/home/x3/support/numeric_utils/sign.hpp @@ -0,0 +1,48 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + http://spirit.sourceforge.net/ + + 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_SIGN_MAR_11_2009_0734PM) +#define SPIRIT_SIGN_MAR_11_2009_0734PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/config/no_tr1/cmath.hpp> +#include <boost/math/special_functions/fpclassify.hpp> +#include <boost/math/special_functions/sign.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template<typename T> + inline bool (signbit)(T x) + { + return (boost::math::signbit)(x) ? true : false; + } + + // This routine has been taken and adapted from Johan Rade's fp_traits + // library + template<typename T> + inline T (changesign)(T x) + { +#if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && !defined(BOOST_MATH_DISABLE_STD_FPCLASSIFY) + return -x; +#else + typedef typename math::detail::fp_traits<T>::type traits_type; + + typename traits_type::bits a; + traits_type::get_bits(x, a); + a ^= traits_type::sign; + traits_type::set_bits(x, a); + return x; +#endif + } + +}}} + +#endif diff --git a/boost/spirit/home/x3/support/subcontext.hpp b/boost/spirit/home/x3/support/subcontext.hpp new file mode 100644 index 0000000000..7614fcbcae --- /dev/null +++ b/boost/spirit/home/x3/support/subcontext.hpp @@ -0,0 +1,89 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2013 Agustín Bergé + http://spirit.sourceforge.net/ + + 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_X3_SUBCONTEXT_APR_15_2013_0840AM) +#define BOOST_SPIRIT_X3_SUBCONTEXT_APR_15_2013_0840AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/fusion/support/pair.hpp> +#include <boost/spirit/home/x3/support/context.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + template <typename... T> + struct subcontext; + + template <> + struct subcontext<> + { + template <typename Context> + subcontext(Context const& /*context*/) + {} + + template <typename ID_, typename Unused = void> + struct get_result + { + typedef unused_type type; + }; + + template <typename ID_> + unused_type + get(ID_) const + { + return unused; + } + }; + + template <typename T> + struct subcontext<T> + : context<typename T::first_type, typename T::second_type> + { + typedef context< + typename T::first_type, typename T::second_type + > context_type; + + template <typename Context> + subcontext(Context const& context) + : context_type(x3::get<typename T::first_type>(context)) + {} + + using context_type::get; + }; + + template <typename T, typename... Tail> + struct subcontext<T, Tail...> + : subcontext<Tail...> + , context< + typename T::first_type, typename T::second_type + , subcontext<Tail...> + > + { + typedef subcontext<Tail...> base_type; + typedef context< + typename T::first_type, typename T::second_type + , base_type + > context_type; + + template <typename Context> + subcontext(Context const& context) + : base_type(context) + , context_type( + x3::get<typename T::first_type>(context) + , *static_cast<base_type*>(this)) + {} + + using context_type::get; + }; + +}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/attribute_category.hpp b/boost/spirit/home/x3/support/traits/attribute_category.hpp new file mode 100644 index 0000000000..a003327de2 --- /dev/null +++ b/boost/spirit/home/x3/support/traits/attribute_category.hpp @@ -0,0 +1,82 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + http://spirit.sourceforge.net/ + + 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_X3_ATTRIBUTE_CATEGORY_JAN_4_2012_1150AM) +#define BOOST_SPIRIT_X3_ATTRIBUTE_CATEGORY_JAN_4_2012_1150AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/mpl/identity.hpp> +#include <boost/mpl/logical.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/fusion/include/copy.hpp> +#include <boost/fusion/include/is_sequence.hpp> +#include <boost/fusion/support/category_of.hpp> +#include <boost/spirit/home/x3/support/traits/is_variant.hpp> +#include <boost/spirit/home/x3/support/traits/container_traits.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + struct unused_type; +}}} + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + struct unused_attribute {}; + struct plain_attribute {}; + struct container_attribute {}; + struct tuple_attribute {}; + struct associative_attribute {}; + struct variant_attribute {}; + struct optional_attribute {}; + + template <typename T, typename Enable = void> + struct attribute_category + : mpl::identity<plain_attribute> {}; + + template <> + struct attribute_category<unused_type> + : mpl::identity<unused_attribute> {}; + + template <> + struct attribute_category<unused_type const> + : mpl::identity<unused_attribute> {}; + + template <typename T> + struct attribute_category< T + , typename enable_if< + typename mpl::eval_if< + fusion::traits::is_sequence<T> + , fusion::traits::is_associative<T> + , mpl::false_ + >::type >::type > + : mpl::identity<associative_attribute> {}; + + template <typename T> + struct attribute_category< T + , typename enable_if< + mpl::and_< + fusion::traits::is_sequence<T> + , mpl::not_<fusion::traits::is_associative<T> > + > >::type > + : mpl::identity<tuple_attribute> {}; + + template <typename T> + struct attribute_category<T, + typename enable_if<traits::is_variant<T>>::type> + : mpl::identity<variant_attribute> {}; + + template <typename T> + struct attribute_category<T, + typename enable_if<traits::is_container<T>>::type> + : mpl::identity<container_attribute> {}; + +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/attribute_of.hpp b/boost/spirit/home/x3/support/traits/attribute_of.hpp new file mode 100644 index 0000000000..71f70b0273 --- /dev/null +++ b/boost/spirit/home/x3/support/traits/attribute_of.hpp @@ -0,0 +1,59 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2013 Agustin Berge + http://spirit.sourceforge.net/ + + 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_X3_ATTRIBUTE_OF_JAN_7_2012_0914AM) +#define BOOST_SPIRIT_X3_ATTRIBUTE_OF_JAN_7_2012_0914AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/utility/sfinae.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/utility/enable_if.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + /////////////////////////////////////////////////////////////////////////// + // Get the attribute type of a component. By default, this gets the + // Component's attribute_type typedef or instantiates a nested attribute + // metafunction. Components may specialize this if such an attribute_type + // is not readily available (e.g. expensive to compute at compile time). + /////////////////////////////////////////////////////////////////////////// + template <typename Component, typename Context, typename Enable = void> + struct attribute_of; + + namespace detail + { + template <typename Component, typename Context, typename Enable = void> + struct default_attribute_of; + + template <typename Component, typename Context> + struct default_attribute_of<Component, Context, + typename disable_if_substitution_failure< + typename Component::attribute_type>::type> + : mpl::identity<typename Component::attribute_type> {}; + + template <typename Component, typename Context> + struct default_attribute_of<Component, Context, + typename disable_if_substitution_failure< + typename Component::template attribute<Context>::type>::type> + : Component::template attribute<Context> {}; + + template <typename Component, typename Context> + struct default_attribute_of<Component, Context, + typename enable_if_c<Component::is_pass_through_unary>::type> + : attribute_of<typename Component::subject_type, Context>{}; + } + + template <typename Component, typename Context, typename Enable> + struct attribute_of : detail::default_attribute_of<Component, Context> {}; + +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/attribute_type.hpp b/boost/spirit/home/x3/support/traits/attribute_type.hpp new file mode 100644 index 0000000000..55e788b41c --- /dev/null +++ b/boost/spirit/home/x3/support/traits/attribute_type.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + http://spirit.sourceforge.net/ + + 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_X3_ATTRIBUTE_TYPE_JAN_5_2012_0358PM) +#define BOOST_SPIRIT_X3_ATTRIBUTE_TYPE_JAN_5_2012_0358PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/mpl/identity.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + /////////////////////////////////////////////////////////////////////////// + // Retrieve the attribute type to use from the given type + // + // This is needed to extract the correct attribute type from proxy classes + // as utilized in FUSION_ADAPT_ADT et. al. + /////////////////////////////////////////////////////////////////////////// + template <typename Attribute, typename Enable = void> + struct attribute_type : mpl::identity<Attribute> {}; + +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/container_traits.hpp b/boost/spirit/home/x3/support/traits/container_traits.hpp new file mode 100644 index 0000000000..c382b7bfaa --- /dev/null +++ b/boost/spirit/home/x3/support/traits/container_traits.hpp @@ -0,0 +1,333 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + http://spirit.sourceforge.net/ + + 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_X3_CONTAINER_FEBRUARY_06_2007_1001AM) +#define BOOST_SPIRIT_X3_CONTAINER_FEBRUARY_06_2007_1001AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/fusion/support/category_of.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/detail/iterator.hpp> +#include <boost/fusion/include/deque.hpp> +#include <boost/mpl/has_xxx.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/identity.hpp> +#include <vector> +#include <string> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + /////////////////////////////////////////////////////////////////////////// + // This file contains some container utils for stl containers. + /////////////////////////////////////////////////////////////////////////// + + namespace detail + { + BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type) + BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator) + BOOST_MPL_HAS_XXX_TRAIT_DEF(size_type) + BOOST_MPL_HAS_XXX_TRAIT_DEF(reference) + } + + template <typename T, typename Enable = void> + struct is_container + : mpl::bool_< + detail::has_value_type<T>::value && + detail::has_iterator<T>::value && + detail::has_size_type<T>::value && + detail::has_reference<T>::value> + {}; + + /////////////////////////////////////////////////////////////////////////// + namespace detail + { + template <typename T> + struct remove_value_const : mpl::identity<T> {}; + + template <typename T> + struct remove_value_const<T const> : remove_value_const<T> {}; + + template <typename F, typename S> + struct remove_value_const<std::pair<F, S>> + { + typedef typename remove_value_const<F>::type first_type; + typedef typename remove_value_const<S>::type second_type; + typedef std::pair<first_type, second_type> type; + }; + } + + /////////////////////////////////////////////////////////////////////// + template <typename Container, typename Enable = void> + struct container_value + : detail::remove_value_const<typename Container::value_type> + {}; + + template <typename Container> + struct container_value<Container const> : container_value<Container> {}; + + // There is no single container value for fusion maps, but because output + // of this metafunc is used to check wheter parser's attribute can be + // saved to container, we simply return whole fusion::map as is + // so that check can be done in traits::is_substitute specialisation + template <typename T> + struct container_value<T + , typename enable_if<typename mpl::eval_if < + fusion::traits::is_sequence<T> + , fusion::traits::is_associative<T> + , mpl::false_ >::type >::type> + : mpl::identity<T> {}; + + template <> + struct container_value<unused_type> : mpl::identity<unused_type> {}; + + /////////////////////////////////////////////////////////////////////////// + template <typename Container, typename Enable = void> + struct container_iterator + : mpl::identity<typename Container::iterator> {}; + + template <typename Container> + struct container_iterator<Container const> + : mpl::identity<typename Container::const_iterator> {}; + + template <> + struct container_iterator<unused_type> + : mpl::identity<unused_type const*> {}; + + template <> + struct container_iterator<unused_type const> + : mpl::identity<unused_type const*> {}; + + /////////////////////////////////////////////////////////////////////////// + template <typename Container, typename T> + bool push_back(Container& c, T&& val); + + template <typename Container, typename Enable = void> + struct push_back_container + { + template <typename T> + static bool call(Container& c, T&& val) + { + c.insert(c.end(), std::move(val)); + return true; + } + }; + + template <typename Container, typename T> + inline bool push_back(Container& c, T&& val) + { + return push_back_container<Container>::call(c, std::move(val)); + } + + template <typename Container> + inline bool push_back(Container&, unused_type) + { + return true; + } + + template <typename T> + inline bool push_back(unused_type, T const&) + { + return true; + } + + inline bool push_back(unused_type, unused_type) + { + return true; + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Container, typename Iterator> + bool append(Container& c, Iterator first, Iterator last); + + template <typename Container, typename Enable = void> + struct append_container + { + // Not all containers have "reserve" + template <typename Container_> + static void reserve(Container_& c, std::size_t size) {} + + template <typename T> + static void reserve(std::vector<T>& c, std::size_t size) + { + c.reserve(size); + } + + template <typename Iterator> + static bool call(Container& c, Iterator first, Iterator last) + { + reserve(c, c.size() + std::distance(first, last)); + c.insert(c.end(), first, last); + return true; + } + }; + + template <typename Container, typename Iterator> + inline bool append(Container& c, Iterator first, Iterator last) + { + return append_container<Container>::call(c, first, last); + } + + template <typename Iterator> + inline bool append(unused_type, Iterator first, Iterator last) + { + return true; + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Container, typename Enable = void> + struct is_empty_container + { + static bool call(Container const& c) + { + return c.empty(); + } + }; + + template <typename Container> + inline bool is_empty(Container const& c) + { + return is_empty_container<Container>::call(c); + } + + inline bool is_empty(unused_type) + { + return true; + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Container, typename Enable = void> + struct begin_container + { + static typename container_iterator<Container>::type call(Container& c) + { + return c.begin(); + } + }; + + template <typename Container> + inline typename container_iterator<Container>::type + begin(Container& c) + { + return begin_container<Container>::call(c); + } + + inline unused_type const* + begin(unused_type) + { + return &unused; + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Container, typename Enable = void> + struct end_container + { + static typename container_iterator<Container>::type call(Container& c) + { + return c.end(); + } + }; + + template <typename Container> + inline typename container_iterator<Container>::type + end(Container& c) + { + return end_container<Container>::call(c); + } + + inline unused_type const* + end(unused_type) + { + return &unused; + } + + + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Enable = void> + struct deref_iterator + { + typedef typename boost::detail::iterator_traits<Iterator>::reference type; + static type call(Iterator& it) + { + return *it; + } + }; + + template <typename Iterator> + typename deref_iterator<Iterator>::type + deref(Iterator& it) + { + return deref_iterator<Iterator>::call(it); + } + + inline unused_type + deref(unused_type const*) + { + return unused; + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Enable = void> + struct next_iterator + { + static void call(Iterator& it) + { + ++it; + } + }; + + template <typename Iterator> + void next(Iterator& it) + { + next_iterator<Iterator>::call(it); + } + + inline void next(unused_type const*) + { + // do nothing + } + + /////////////////////////////////////////////////////////////////////////// + template <typename Iterator, typename Enable = void> + struct compare_iterators + { + static bool call(Iterator const& it1, Iterator const& it2) + { + return it1 == it2; + } + }; + + template <typename Iterator> + bool compare(Iterator& it1, Iterator& it2) + { + return compare_iterators<Iterator>::call(it1, it2); + } + + inline bool compare(unused_type const*, unused_type const*) + { + return false; + } + + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct build_container : mpl::identity<std::vector<T>> {}; + + template <typename T> + struct build_container<boost::fusion::deque<T> > : build_container<T> {}; + + template <> + struct build_container<unused_type> : mpl::identity<unused_type> {}; + + template <> + struct build_container<char> : mpl::identity<std::string> {}; + +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/handles_container.hpp b/boost/spirit/home/x3/support/traits/handles_container.hpp new file mode 100644 index 0000000000..3fe05aef87 --- /dev/null +++ b/boost/spirit/home/x3/support/traits/handles_container.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + Copyright (c) 2001-2011 Hartmut Kaiser + Copyright (c) 2013 Agustin Berge + + 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_X3_HANDLES_CONTAINER_DEC_18_2010_0920AM) +#define BOOST_SPIRIT_X3_HANDLES_CONTAINER_DEC_18_2010_0920AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + /////////////////////////////////////////////////////////////////////////// + // Whether a component handles container attributes intrinsically + // (or whether container attributes need to be split up separately). + // By default, this gets the Component's handles_container nested value. + // Components may specialize this if such a handles_container is not + // readily available (e.g. expensive to compute at compile time). + /////////////////////////////////////////////////////////////////////////// + template <typename Component, typename Context, typename Enable = void> + struct handles_container : mpl::bool_<Component::handles_container> {}; + +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/has_attribute.hpp b/boost/spirit/home/x3/support/traits/has_attribute.hpp new file mode 100644 index 0000000000..c8b1f8a347 --- /dev/null +++ b/boost/spirit/home/x3/support/traits/has_attribute.hpp @@ -0,0 +1,63 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2013 Agustin Berge + http://spirit.sourceforge.net/ + + 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_X3_HAS_ATTRIBUTE_JUN_6_2012_1714PM) +#define BOOST_SPIRIT_X3_HAS_ATTRIBUTE_JUN_6_2012_1714PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/traits/attribute_of.hpp> +#include <boost/spirit/home/x3/support/utility/sfinae.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/not.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/utility/enable_if.hpp> + +namespace boost { namespace spirit { namespace x3 +{ + struct unused_type; +}}} + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + /////////////////////////////////////////////////////////////////////////// + // Whether a component has an attribute. By default, this compares the + // component attribute against unused_type. If the component provides a + // nested constant expression has_attribute as a hint, that value is used + // instead. Components may specialize this. + /////////////////////////////////////////////////////////////////////////// + template <typename Component, typename Context, typename Enable = void> + struct has_attribute; + + namespace detail + { + template <typename Component, typename Context, typename Enable = void> + struct default_has_attribute + : mpl::not_<is_same<unused_type, + typename attribute_of<Component, Context>::type>> {}; + + template <typename Component, typename Context> + struct default_has_attribute<Component, Context, + typename disable_if_substitution_failure< + mpl::bool_<Component::has_attribute>>::type> + : mpl::bool_<Component::has_attribute> {}; + + template <typename Component, typename Context> + struct default_has_attribute<Component, Context, + typename enable_if_c<Component::is_pass_through_unary>::type> + : has_attribute<typename Component::subject_type, Context> {}; + } + + template <typename Component, typename Context, typename Enable> + struct has_attribute : detail::default_has_attribute<Component, Context> {}; + +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/is_parser.hpp b/boost/spirit/home/x3/support/traits/is_parser.hpp new file mode 100644 index 0000000000..cfbe8f74b4 --- /dev/null +++ b/boost/spirit/home/x3/support/traits/is_parser.hpp @@ -0,0 +1,37 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2014 Agustin Berge + + 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_X3_IS_PARSER_MAY_20_2013_0235PM) +#define BOOST_SPIRIT_X3_IS_PARSER_MAY_20_2013_0235PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/mpl/bool.hpp> +#include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/support/utility/sfinae.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + /////////////////////////////////////////////////////////////////////////// + // is_parser<T>: metafunction that evaluates to mpl::true_ if a type T + // can be used as a parser, mpl::false_ otherwise + /////////////////////////////////////////////////////////////////////////// + template <typename T, typename Enable = void> + struct is_parser + : mpl::false_ + {}; + + template <typename T> + struct is_parser<T, typename disable_if_substitution_failure< + typename extension::as_parser<T>::type>::type> + : mpl::true_ + {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/is_substitute.hpp b/boost/spirit/home/x3/support/traits/is_substitute.hpp new file mode 100644 index 0000000000..9e023371ce --- /dev/null +++ b/boost/spirit/home/x3/support/traits/is_substitute.hpp @@ -0,0 +1,164 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + http://spirit.sourceforge.net/ + + 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_X3_IS_SUBSTITUTE_JAN_9_2012_1049PM) +#define BOOST_SPIRIT_X3_IS_SUBSTITUTE_JAN_9_2012_1049PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/traits/container_traits.hpp> +#include <boost/fusion/include/is_sequence.hpp> +#include <boost/fusion/include/map.hpp> +#include <boost/fusion/include/value_at_key.hpp> +#include <boost/fusion/adapted/mpl.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/apply.hpp> +#include <boost/mpl/filter_view.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/logical.hpp> +#include <boost/mpl/at.hpp> +#include <boost/mpl/count_if.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/optional/optional.hpp> +#include <boost/type_traits/is_same.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + /////////////////////////////////////////////////////////////////////////// + // Find out if T can be a (strong) substitute for Attribute + /////////////////////////////////////////////////////////////////////////// + template <typename T, typename Attribute, typename Enable = void> + struct is_substitute; + + template <typename Variant, typename Attribute> + struct variant_has_substitute; + + namespace detail + { + template <typename T, typename Attribute> + struct value_type_is_substitute + : is_substitute< + typename container_value<T>::type + , typename container_value<Attribute>::type> + {}; + + template <typename T, typename Attribute, typename Enable = void> + struct is_substitute_impl : is_same<T, Attribute> {}; + + template <typename T, typename Attribute> + struct is_substitute_impl<T, Attribute, + typename enable_if< + mpl::and_< + fusion::traits::is_sequence<T>, + fusion::traits::is_sequence<Attribute>, + mpl::equal<T, Attribute, is_substitute<mpl::_1, mpl::_2>> + > + >::type> + : mpl::true_ {}; + + template <typename T, typename Attribute> + struct is_substitute_impl<T, Attribute, + typename enable_if< + mpl::and_< + is_container<T>, + is_container<Attribute>, + value_type_is_substitute<T, Attribute> + > + >::type> + : mpl::true_ {}; + + template <typename T, typename Attribute> + struct is_substitute_impl<T, Attribute, + typename enable_if< + is_variant<Attribute> + >::type> + : mpl::or_< + is_same<T, Attribute> + , variant_has_substitute<Attribute, T> + > + {}; + } + + template <typename T, typename Attribute, typename Enable /*= void*/> + struct is_substitute + : detail::is_substitute_impl<T, Attribute> {}; + + // for reference T + template <typename T, typename Attribute, typename Enable> + struct is_substitute<T&, Attribute, Enable> + : is_substitute<T, Attribute, Enable> {}; + + // for reference Attribute + template <typename T, typename Attribute, typename Enable> + struct is_substitute<T, Attribute&, Enable> + : is_substitute<T, Attribute, Enable> {}; + + // 2 element mpl tuple is compatible with fusion::map if: + // - it's first element type is existing key in map + // - it second element type is compatible to type stored at the key in map + template <typename T, typename Attribute> + struct is_substitute<T, Attribute + , typename enable_if< + typename mpl::eval_if< + mpl::and_<fusion::traits::is_sequence<T> + , fusion::traits::is_sequence<Attribute>> + , mpl::and_<traits::has_size<T, 2> + , fusion::traits::is_associative<Attribute>> + , mpl::false_>::type>::type> + + { + // checking that "p_key >> p_value" parser can + // store it's result in fusion::map attribute + typedef typename mpl::at_c<T, 0>::type p_key; + typedef typename mpl::at_c<T, 1>::type p_value; + + // for simple p_key type we just check that + // such key can be found in attr and that value under that key + // matches p_value + template <typename Key, typename Value, typename Map> + struct has_kv_in_map + : mpl::eval_if< + fusion::result_of::has_key<Map, Key> + , mpl::apply< + is_substitute< + fusion::result_of::value_at_key<mpl::_1, Key> + , Value> + , Map> + , mpl::false_> + {}; + + // if p_key is variant over multiple types (as a result of + // "(key1|key2|key3) >> p_value" parser) check that all + // keys are found in fusion::map attribute and that values + // under these keys match p_value + template <typename Variant> + struct variant_kv + : mpl::equal_to< + mpl::size< typename Variant::types> + , mpl::size< mpl::filter_view<typename Variant::types + , has_kv_in_map<mpl::_1, p_value, Attribute>>> + > + {}; + + typedef typename + mpl::eval_if< + is_variant<p_key> + , variant_kv<p_key> + , has_kv_in_map<p_key, p_value, Attribute> + >::type + type; + }; + + template <typename T, typename Attribute> + struct is_substitute<optional<T>, optional<Attribute>> + : is_substitute<T, Attribute> {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/is_variant.hpp b/boost/spirit/home/x3/support/traits/is_variant.hpp new file mode 100644 index 0000000000..829a673c3f --- /dev/null +++ b/boost/spirit/home/x3/support/traits/is_variant.hpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + http://spirit.sourceforge.net/ + + 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_X3_IS_VARIANT_JAN_10_2012_0823AM) +#define BOOST_SPIRIT_X3_IS_VARIANT_JAN_10_2012_0823AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/variant.hpp> +#include <boost/mpl/has_xxx.hpp> +#include <boost/mpl/bool.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + namespace detail + { + // By declaring a nested struct in your class/struct, you tell + // spirit that it is regarded as a variant type. The minimum + // required interface for such a variant is that it has constructors + // for various types supported by your variant and a typedef 'types' + // which is an mpl sequence of the contained types. + // + // This is an intrusive interface. For a non-intrusive interface, + // use the is_variant trait. + BOOST_MPL_HAS_XXX_TRAIT_DEF(adapted_variant_tag) + } + + template <typename T, typename Enable = void> + struct is_variant + : detail::has_adapted_variant_tag<T> + {}; + + template <BOOST_VARIANT_ENUM_PARAMS(typename T)> + struct is_variant<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>> + : mpl::true_ + {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/make_attribute.hpp b/boost/spirit/home/x3/support/traits/make_attribute.hpp new file mode 100644 index 0000000000..cf3baeedaf --- /dev/null +++ b/boost/spirit/home/x3/support/traits/make_attribute.hpp @@ -0,0 +1,86 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2012 Hartmut Kaiser + http://spirit.sourceforge.net/ + + 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_X3_MAKE_ATTRIBUTE_JAN_8_2012_0721PM) +#define BOOST_SPIRIT_X3_MAKE_ATTRIBUTE_JAN_8_2012_0721PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/mpl/if.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/type_traits/add_reference.hpp> +#include <boost/spirit/home/x3/support/unused.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Attribute> + struct make_attribute_base + { + static Attribute call(unused_type) + { + // synthesize the attribute/parameter + return Attribute(); + } + + template <typename T> + static T& call(T& value) + { + return value; // just pass the one provided + } + }; + + template <typename Attribute, typename ActualAttribute> + struct make_attribute : make_attribute_base<Attribute> + { + typedef ActualAttribute& type; + typedef ActualAttribute value_type; + }; + + template <typename Attribute> + struct make_attribute<Attribute, unused_type> + : make_attribute_base<Attribute> + { + typedef typename remove_const<Attribute>::type attribute_type; + typedef attribute_type type; + typedef attribute_type value_type; + }; + + template <typename Attribute, typename ActualAttribute> + struct make_attribute<Attribute&, ActualAttribute> + : make_attribute<Attribute, ActualAttribute> {}; + + template <typename Attribute, typename ActualAttribute> + struct make_attribute<Attribute const&, ActualAttribute> + : make_attribute<Attribute const, ActualAttribute> {}; + + 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; + } + }; + + template <> + struct make_attribute<unused_type, unused_type> + { + typedef unused_type type; + typedef unused_type value_type; + static unused_type call(unused_type) + { + return unused; + } + }; +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/move_to.hpp b/boost/spirit/home/x3/support/traits/move_to.hpp new file mode 100644 index 0000000000..ecd7c6f202 --- /dev/null +++ b/boost/spirit/home/x3/support/traits/move_to.hpp @@ -0,0 +1,211 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2013 Agustin Berge + http://spirit.sourceforge.net/ + + 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_X3_MOVE_TO_JAN_17_2013_0859PM) +#define BOOST_SPIRIT_X3_MOVE_TO_JAN_17_2013_0859PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/traits/attribute_category.hpp> +#include <boost/spirit/home/x3/support/traits/tuple_traits.hpp> +#include <boost/spirit/home/x3/support/traits/variant_has_substitute.hpp> +#include <boost/fusion/include/is_sequence.hpp> +#include <boost/fusion/include/front.hpp> +#include <boost/fusion/include/size.hpp> +#include <boost/fusion/include/move.hpp> +#include <boost/fusion/include/is_sequence.hpp> +#include <boost/range/iterator_range.hpp> +#include <utility> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Source, typename Dest> + void move_to(Source&& src, Dest& dest); + + template <typename Dest> + inline void move_to(unused_type, Dest&) {} + + template <typename Source> + inline void move_to(Source&, unused_type) {} + + inline void move_to(unused_type, unused_type) {} + + template <typename Iterator, typename Dest> + void + move_to(Iterator first, Iterator last, Dest& dest); + + template <typename Iterator> + inline void + move_to(Iterator, Iterator, unused_type) {} + + namespace detail + { + template <typename Source, typename Dest> + inline void + move_to(Source&&, Dest&, unused_attribute) {} + + template <typename Source, typename Dest> + inline void + move_to_plain(Source&& src, Dest& dest, mpl::false_) // src is not a single-element tuple + { + dest = std::move(src); + } + + template <typename Source, typename Dest> + inline void + move_to_plain(Source&& src, Dest& dest, mpl::true_) // src is a single-element tuple + { + dest = std::move(fusion::front(src)); + } + + template <typename Source, typename Dest> + inline void + move_to(Source&& src, Dest& dest, plain_attribute) + { + typename mpl::and_< + fusion::traits::is_sequence<Source>, + is_size_one_sequence<Source> > + is_single_element_sequence; + + move_to_plain(std::move(src), dest, is_single_element_sequence); + } + + template <typename Source, typename Dest> + inline typename enable_if<is_container<Source>>::type + move_to(Source&& src, Dest& dest, container_attribute) + { + traits::move_to(src.begin(), src.end(), dest); + } + + template <typename Source, typename Dest> + inline typename enable_if< + mpl::and_< + is_same_size_sequence<Dest, Source>, + mpl::not_<is_size_one_sequence<Dest> > > + >::type + move_to(Source&& src, Dest& dest, tuple_attribute) + { + fusion::move(std::move(src), dest); + } + + template <typename Source, typename Dest> + inline typename enable_if< + is_size_one_sequence<Dest> + >::type + move_to(Source&& src, Dest& dest, tuple_attribute) + { + traits::move_to(src, fusion::front(dest)); + } + + template <typename Source, typename Dest> + inline void + move_to(Source&& src, Dest& dest, variant_attribute, mpl::false_) + { + dest = std::move(src); + } + + template <typename Source, typename Dest> + inline void + move_to_variant_from_single_element_sequence(Source&& src, Dest& dest, mpl::false_) + { + // dest is a variant, src is a single element fusion sequence that the variant + // cannot directly hold. We'll try to unwrap the single element fusion sequence. + + // Make sure that the Dest variant can really hold Source + static_assert(variant_has_substitute<Dest, typename fusion::result_of::front<Source>::type>::value, + "Error! The destination variant (Dest) cannot hold the source type (Source)"); + + dest = std::move(fusion::front(src)); + } + + template <typename Source, typename Dest> + inline void + move_to_variant_from_single_element_sequence(Source&& src, Dest& dest, mpl::true_) + { + // dest is a variant, src is a single element fusion sequence that the variant + // *can* directly hold. + dest = std::move(src); + } + + template <typename Source, typename Dest> + inline void + move_to(Source&& src, Dest& dest, variant_attribute, mpl::true_) + { + move_to_variant_from_single_element_sequence(src, dest, variant_has_substitute<Dest, Source>()); + } + + template <typename Source, typename Dest> + inline void + move_to(Source&& src, Dest& dest, variant_attribute tag) + { + move_to(src, dest, tag, is_size_one_sequence<Source>()); + } + + template <typename Iterator> + inline void + move_to(Iterator, Iterator, unused_type, unused_attribute) {} + + template <typename Iterator, typename Dest> + inline void + move_to(Iterator first, Iterator last, Dest& dest, container_attribute) + { + if (is_empty(dest)) + dest = Dest(first, last); + else + append(dest, first, last); + } + + template <typename Iterator> + inline void + move_to(Iterator first, Iterator last, boost::iterator_range<Iterator>& rng, container_attribute) + { + rng = {first, last}; + } + } + + template <typename Source, typename Dest> + inline void + move_to(Source&& src, Dest& dest) + { + detail::move_to(std::move(src), dest + , typename attribute_category<Dest>::type()); + } + + template <typename T> + inline void move_to(T& src, T& dest) + { + if (&src != &dest) + dest = std::move(src); + } + + template <typename T> + inline void move_to(T const& src, T& dest) + { + if (&src != &dest) + dest = std::move(src); + } + + template <typename T> + inline void move_to(T&& src, T& dest) + { + if (&src != &dest) + dest = std::move(src); + } + + template <typename Iterator, typename Dest> + inline void + move_to(Iterator first, Iterator last, Dest& dest) + { + // $$$ Use std::move_iterator when iterator is not a const-iterator $$$ + detail::move_to(first, last, dest, typename attribute_category<Dest>::type()); + } +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/numeric_traits.hpp b/boost/spirit/home/x3/support/traits/numeric_traits.hpp new file mode 100644 index 0000000000..3cdbdaec63 --- /dev/null +++ b/boost/spirit/home/x3/support/traits/numeric_traits.hpp @@ -0,0 +1,128 @@ +/*============================================================================= + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_X3_NUMERIC_TRAITS_JAN_07_2011_0722AM) +#define BOOST_SPIRIT_X3_NUMERIC_TRAITS_JAN_07_2011_0722AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/config.hpp> +#include <boost/integer_traits.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/utility/enable_if.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + /////////////////////////////////////////////////////////////////////////// + // Determine if T is a boolean type + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct is_bool : mpl::false_ {}; + + template <typename T> + struct is_bool<T const> : is_bool<T> {}; + + template <> + struct is_bool<bool> : mpl::true_ {}; + + /////////////////////////////////////////////////////////////////////////// + // Determine if T is a signed integer type + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct is_int : mpl::false_ {}; + + template <typename T> + struct is_int<T const> : is_int<T> {}; + + template <> + struct is_int<short> : mpl::true_ {}; + + template <> + struct is_int<int> : mpl::true_ {}; + + template <> + struct is_int<long> : mpl::true_ {}; + +#ifdef BOOST_HAS_LONG_LONG + template <> + struct is_int<boost::long_long_type> : mpl::true_ {}; +#endif + + /////////////////////////////////////////////////////////////////////////// + // Determine if T is an unsigned integer type + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct is_uint : mpl::false_ {}; + + template <typename T> + struct is_uint<T const> : is_uint<T> {}; + +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) + template <> + struct is_uint<unsigned short> : mpl::true_ {}; +#endif + + template <> + struct is_uint<unsigned int> : mpl::true_ {}; + + template <> + struct is_uint<unsigned long> : mpl::true_ {}; + +#ifdef BOOST_HAS_LONG_LONG + template <> + struct is_uint<boost::ulong_long_type> : mpl::true_ {}; +#endif + + /////////////////////////////////////////////////////////////////////////// + // Determine if T is a floating point type + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct is_real : mpl::false_ {}; + + template <typename T> + struct is_real<T const> : is_uint<T> {}; + + template <> + struct is_real<float> : mpl::true_ {}; + + template <> + struct is_real<double> : mpl::true_ {}; + + template <> + struct is_real<long double> : mpl::true_ {}; + + /////////////////////////////////////////////////////////////////////////// + // customization points for numeric operations + /////////////////////////////////////////////////////////////////////////// + template <typename T, typename Enable = void> + struct absolute_value; + + template <typename T, typename Enable = void> + struct is_negative; + + template <typename T, typename Enable = void> + struct is_zero; + + template <typename T, typename Enable = void> + struct pow10_helper; + + template <typename T, typename Enable = void> + struct is_nan; + + template <typename T, typename Enable = void> + struct is_infinite; + + template <typename T, typename Enable = void> + struct check_overflow : mpl::false_ {}; + + template <typename T> + struct check_overflow<T, typename enable_if_c<integer_traits<T>::is_integral>::type> + : mpl::true_ {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/optional_traits.hpp b/boost/spirit/home/x3/support/traits/optional_traits.hpp new file mode 100644 index 0000000000..65568b0265 --- /dev/null +++ b/boost/spirit/home/x3/support/traits/optional_traits.hpp @@ -0,0 +1,78 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + http://spirit.sourceforge.net/ + + 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_X3_OPTIONAL_TRAITS_FEBRUARY_06_2007_1001AM) +#define BOOST_SPIRIT_X3_OPTIONAL_TRAITS_FEBRUARY_06_2007_1001AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/unused.hpp> +#include <boost/optional/optional.hpp> +#include <boost/mpl/identity.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + /////////////////////////////////////////////////////////////////////////// + template <typename T, typename Enable = void> + struct is_optional + : mpl::false_ + {}; + + template <typename T> + struct is_optional<boost::optional<T>> + : mpl::true_ + {}; + + /////////////////////////////////////////////////////////////////////////// + // build_optional + // + // Build a boost::optional from T. Return unused_type if T is unused_type. + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct build_optional + { + typedef boost::optional<T> type; + }; + + template <typename T> + struct build_optional<boost::optional<T> > + { + typedef boost::optional<T> type; + }; + + template <> + struct build_optional<unused_type> + { + typedef unused_type type; + }; + + /////////////////////////////////////////////////////////////////////////// + // optional_value + // + // Get the optional's value_type. Handles unused_type as well. + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct optional_value : mpl::identity<T> {}; + + template <typename T> + struct optional_value<boost::optional<T> > + : mpl::identity<T> {}; + + template <> + struct optional_value<unused_type> + : mpl::identity<unused_type> {}; + + template <> + struct optional_value<unused_type const> + : mpl::identity<unused_type> {}; + +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/print_attribute.hpp b/boost/spirit/home/x3/support/traits/print_attribute.hpp new file mode 100644 index 0000000000..47bffce1a1 --- /dev/null +++ b/boost/spirit/home/x3/support/traits/print_attribute.hpp @@ -0,0 +1,150 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_X3_PRINT_ATTRIBUTE_JANUARY_20_2013_0814AM) +#define BOOST_SPIRIT_X3_PRINT_ATTRIBUTE_JANUARY_20_2013_0814AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/variant.hpp> +#include <boost/optional/optional.hpp> +#include <boost/fusion/include/is_sequence.hpp> +#include <boost/fusion/include/for_each.hpp> +#include <boost/spirit/home/x3/support/traits/attribute_category.hpp> +#include <boost/spirit/home/x3/support/traits/is_variant.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Out, typename T> + void print_attribute(Out& out, T const& val); + + template <typename Out> + inline void print_attribute(Out&, unused_type) {} + + /////////////////////////////////////////////////////////////////////////// + namespace detail + { + template <typename Out> + struct print_fusion_sequence + { + print_fusion_sequence(Out& out) + : out(out), is_first(true) {} + + typedef void result_type; + + template <typename T> + void operator()(T const& val) const + { + if (is_first) + is_first = false; + else + out << ", "; + x3::traits::print_attribute(out, val); + } + + Out& out; + mutable bool is_first; + }; + + // print elements in a variant + template <typename Out> + struct print_visitor : static_visitor<> + { + print_visitor(Out& out) : out(out) {} + + template <typename T> + void operator()(T const& val) const + { + x3::traits::print_attribute(out, val); + } + + Out& out; + }; + } + + template <typename Out, typename T, typename Enable = void> + struct print_attribute_debug + { + // for plain data types + template <typename T_> + static void call(Out& out, T_ const& val, unused_attribute) + { + out << "unused"; + } + + // for plain data types + template <typename T_> + static void call(Out& out, T_ const& val, plain_attribute) + { + out << val; + } + + // for fusion data types + template <typename T_> + static void call(Out& out, T_ const& val, tuple_attribute) + { + out << '['; + fusion::for_each(val, detail::print_fusion_sequence<Out>(out)); + out << ']'; + } + + // stl container + template <typename T_> + static void call(Out& out, T_ const& val, container_attribute) + { + out << '['; + if (!traits::is_empty(val)) + { + bool first = true; + typename container_iterator<T_ const>::type iend = traits::end(val); + for (typename container_iterator<T_ const>::type i = traits::begin(val); + !traits::compare(i, iend); traits::next(i)) + { + if (!first) + out << ", "; + first = false; + x3::traits::print_attribute(out, traits::deref(i)); + } + } + out << ']'; + } + + // for variant types + template <typename T_> + static void call(Out& out, T_ const& val, variant_attribute) + { + apply_visitor(detail::print_visitor<Out>(out), val); + } + + // for optional types + template <typename T_> + static void call(Out& out, T_ const& val, optional_attribute) + { + if (val) + x3::traits::print_attribute(out, *val); + else + out << "[empty]"; + } + + // main entry point + static void call(Out& out, T const& val) + { + call(out, val, typename attribute_category<T>::type()); + } + }; + + /////////////////////////////////////////////////////////////////////////// + template <typename Out, typename T> + inline void print_attribute(Out& out, T const& val) + { + print_attribute_debug<Out, T>::call(out, val); + } +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/print_token.hpp b/boost/spirit/home/x3/support/traits/print_token.hpp new file mode 100644 index 0000000000..f1429f4776 --- /dev/null +++ b/boost/spirit/home/x3/support/traits/print_token.hpp @@ -0,0 +1,79 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_X3_PRINT_TOKEN_JANUARY_20_2013_0814AM) +#define BOOST_SPIRIT_X3_PRINT_TOKEN_JANUARY_20_2013_0814AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/mpl/if.hpp> +#include <boost/mpl/and.hpp> +#include <boost/type_traits/is_convertible.hpp> +#include <cctype> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + /////////////////////////////////////////////////////////////////////////// + // generate debug output for lookahead token (character) stream + namespace detail + { + struct token_printer_debug_for_chars + { + template<typename Out, typename Char> + static void print(Out& o, Char c) + { + using namespace std; // allow for ADL to find the proper iscntrl + + switch (c) + { + case '\a': o << "\\a"; break; + case '\b': o << "\\b"; break; + case '\f': o << "\\f"; break; + case '\n': o << "\\n"; break; + case '\r': o << "\\r"; break; + case '\t': o << "\\t"; break; + case '\v': o << "\\v"; break; + default: + if (c >= 0 && c < 127 && iscntrl(c)) + o << "\\" << std::oct << int(c); + else + o << Char(c); + } + } + }; + + // for token types where the comparison with char constants wouldn't work + struct token_printer_debug + { + template<typename Out, typename T> + static void print(Out& o, T const& val) + { + o << val; + } + }; + } + + template <typename T, typename Enable = void> + struct token_printer_debug + : mpl::if_< + mpl::and_< + is_convertible<T, char>, is_convertible<char, T> > + , detail::token_printer_debug_for_chars + , detail::token_printer_debug>::type + {}; + + template <typename Out, typename T> + inline void print_token(Out& out, T const& val) + { + // allow to customize the token printer routine + token_printer_debug<T>::print(out, val); + } +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/string_traits.hpp b/boost/spirit/home/x3/support/traits/string_traits.hpp new file mode 100644 index 0000000000..46ee356cdc --- /dev/null +++ b/boost/spirit/home/x3/support/traits/string_traits.hpp @@ -0,0 +1,291 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + Copyright (c) 2010 Bryce Lelbach + + 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_X3_STRING_TRAITS_OCTOBER_2008_1252PM) +#define BOOST_SPIRIT_X3_STRING_TRAITS_OCTOBER_2008_1252PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <string> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/identity.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + /////////////////////////////////////////////////////////////////////////// + // Determine if T is a character type + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct is_char : mpl::false_ {}; + + template <typename T> + struct is_char<T const> : is_char<T> {}; + + template <> + struct is_char<char> : mpl::true_ {}; + + template <> + struct is_char<wchar_t> : mpl::true_ {}; + + /////////////////////////////////////////////////////////////////////////// + // Determine if T is a string + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct is_string : mpl::false_ {}; + + template <typename T> + struct is_string<T const> : is_string<T> {}; + + template <> + struct is_string<char const*> : mpl::true_ {}; + + template <> + struct is_string<wchar_t const*> : mpl::true_ {}; + + template <> + struct is_string<char*> : mpl::true_ {}; + + template <> + struct is_string<wchar_t*> : mpl::true_ {}; + + template <std::size_t N> + struct is_string<char[N]> : mpl::true_ {}; + + template <std::size_t N> + struct is_string<wchar_t[N]> : mpl::true_ {}; + + template <std::size_t N> + struct is_string<char const[N]> : mpl::true_ {}; + + template <std::size_t N> + struct is_string<wchar_t const[N]> : mpl::true_ {}; + + template <std::size_t N> + struct is_string<char(&)[N]> : mpl::true_ {}; + + template <std::size_t N> + struct is_string<wchar_t(&)[N]> : mpl::true_ {}; + + template <std::size_t N> + struct is_string<char const(&)[N]> : mpl::true_ {}; + + template <std::size_t N> + struct is_string<wchar_t const(&)[N]> : mpl::true_ {}; + + template <typename T, typename Traits, typename Allocator> + struct is_string<std::basic_string<T, Traits, Allocator> > : mpl::true_ {}; + + /////////////////////////////////////////////////////////////////////////// + // Get the underlying char type of a string + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct char_type_of; + + template <typename T> + struct char_type_of<T const> : char_type_of<T> {}; + + template <> + struct char_type_of<char> : mpl::identity<char> {}; + + template <> + struct char_type_of<wchar_t> : mpl::identity<wchar_t> {}; + + template <> + struct char_type_of<char const*> : mpl::identity<char const> {}; + + template <> + struct char_type_of<wchar_t const*> : mpl::identity<wchar_t const> {}; + + template <> + struct char_type_of<char*> : mpl::identity<char> {}; + + template <> + struct char_type_of<wchar_t*> : mpl::identity<wchar_t> {}; + + template <std::size_t N> + struct char_type_of<char[N]> : mpl::identity<char> {}; + + template <std::size_t N> + struct char_type_of<wchar_t[N]> : mpl::identity<wchar_t> {}; + + template <std::size_t N> + struct char_type_of<char const[N]> : mpl::identity<char const> {}; + + template <std::size_t N> + struct char_type_of<wchar_t const[N]> : mpl::identity<wchar_t const> {}; + + template <std::size_t N> + struct char_type_of<char(&)[N]> : mpl::identity<char> {}; + + template <std::size_t N> + struct char_type_of<wchar_t(&)[N]> : mpl::identity<wchar_t> {}; + + template <std::size_t N> + struct char_type_of<char const(&)[N]> : mpl::identity<char const> {}; + + template <std::size_t N> + struct char_type_of<wchar_t const(&)[N]> : mpl::identity<wchar_t const> {}; + + template <typename T, typename Traits, typename Allocator> + struct char_type_of<std::basic_string<T, Traits, Allocator> > + : mpl::identity<T> {}; + + /////////////////////////////////////////////////////////////////////////// + // Get the C string from a string + /////////////////////////////////////////////////////////////////////////// + template <typename String> + struct extract_c_string; + + template <typename String> + struct extract_c_string + { + typedef typename char_type_of<String>::type char_type; + + template <typename T> + static T const* call (T* str) + { + return (T const*)str; + } + + template <typename T> + static T const* call (T const* str) + { + return str; + } + }; + + // Forwarder that strips const + template <typename T> + struct extract_c_string<T const> + { + typedef typename extract_c_string<T>::char_type char_type; + + static typename extract_c_string<T>::char_type const* call (T const str) + { + return extract_c_string<T>::call(str); + } + }; + + // Forwarder that strips references + template <typename T> + struct extract_c_string<T&> + { + typedef typename extract_c_string<T>::char_type char_type; + + static typename extract_c_string<T>::char_type const* call (T& str) + { + return extract_c_string<T>::call(str); + } + }; + + // Forwarder that strips const references + template <typename T> + struct extract_c_string<T const&> + { + typedef typename extract_c_string<T>::char_type char_type; + + static typename extract_c_string<T>::char_type const* call (T const& str) + { + return extract_c_string<T>::call(str); + } + }; + + template <typename T, typename Traits, typename Allocator> + struct extract_c_string<std::basic_string<T, Traits, Allocator> > + { + typedef T char_type; + + typedef std::basic_string<T, Traits, Allocator> string; + + static T const* call (string const& str) + { + return str.c_str(); + } + }; + + template <typename T> + typename extract_c_string<T*>::char_type const* + get_c_string(T* str) + { + return extract_c_string<T*>::call(str); + } + + template <typename T> + typename extract_c_string<T const*>::char_type const* + get_c_string(T const* str) + { + return extract_c_string<T const*>::call(str); + } + + template <typename String> + typename extract_c_string<String>::char_type const* + get_c_string(String& str) + { + return extract_c_string<String>::call(str); + } + + template <typename String> + typename extract_c_string<String>::char_type const* + get_c_string(String const& str) + { + return extract_c_string<String>::call(str); + } + + /////////////////////////////////////////////////////////////////////////// + // Get the begin/end iterators from a string + /////////////////////////////////////////////////////////////////////////// + + // Implementation for C-style strings. + + template <typename T> + inline T const* get_string_begin(T const* str) { return str; } + + template <typename T> + inline T* get_string_begin(T* str) { return str; } + + template <typename T> + inline T const* get_string_end(T const* str) + { + T const* last = str; + while (*last) + last++; + return last; + } + + template <typename T> + inline T* get_string_end(T* str) + { + T* last = str; + while (*last) + last++; + return last; + } + + // Implementation for containers (includes basic_string). + template <typename T, typename Str> + inline typename Str::const_iterator get_string_begin(Str const& str) + { return str.begin(); } + + template <typename T, typename Str> + inline typename Str::iterator + get_string_begin(Str& str) + { return str.begin(); } + + template <typename T, typename Str> + inline typename Str::const_iterator get_string_end(Str const& str) + { return str.end(); } + + template <typename T, typename Str> + inline typename Str::iterator + get_string_end(Str& str) + { return str.end(); } +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/transform_attribute.hpp b/boost/spirit/home/x3/support/traits/transform_attribute.hpp new file mode 100644 index 0000000000..24268520d7 --- /dev/null +++ b/boost/spirit/home/x3/support/traits/transform_attribute.hpp @@ -0,0 +1,48 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2012 Hartmut Kaiser + http://spirit.sourceforge.net/ + + 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_X3_ATTRIBUTE_TRANSFORM_JAN_8_2012_0721PM) +#define BOOST_SPIRIT_X3_ATTRIBUTE_TRANSFORM_JAN_8_2012_0721PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/mpl/identity.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + /////////////////////////////////////////////////////////////////////////// + // transform_attribute + // + // Sometimes the user needs to transform the attribute types for certain + // attributes. This template can be used as a customization point, where + // the user is able specify specific transformation rules for any attribute + // type. + /////////////////////////////////////////////////////////////////////////// + template <typename Exposed, typename Transformed, typename Tag + , typename Enable = void> + struct transform_attribute; + + /////////////////////////////////////////////////////////////////////////// + template <typename Tag, typename Transformed, typename Exposed> + typename transform_attribute<Exposed, Transformed, Tag>::type + pre_transform(Exposed& attr) + { + return transform_attribute<Exposed, Transformed, Tag>::pre(attr); + } + + template <typename Tag, typename Transformed, typename Exposed> + typename transform_attribute<Exposed, Transformed, Tag>::type + pre_transform(Exposed const& attr) + { + return transform_attribute<Exposed const, Transformed, Tag>::pre(attr); + } +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/tuple_traits.hpp b/boost/spirit/home/x3/support/traits/tuple_traits.hpp new file mode 100644 index 0000000000..17bfd4e1cb --- /dev/null +++ b/boost/spirit/home/x3/support/traits/tuple_traits.hpp @@ -0,0 +1,52 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_TUPLE_TRAITS_JANUARY_2012_1132PM) +#define BOOST_SPIRIT_X3_TUPLE_TRAITS_JANUARY_2012_1132PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/fusion/include/is_sequence.hpp> +#include <boost/fusion/include/size.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/and.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename A, typename B> + struct has_same_size + : mpl::bool_<( + fusion::result_of::size<A>::value == + fusion::result_of::size<B>::value + )> + {}; + + template <typename T, std::size_t N> + struct has_size + : mpl::bool_<(fusion::result_of::size<T>::value == N)> + {}; + + template <typename A, typename B> + struct is_same_size_sequence + : mpl::and_< + fusion::traits::is_sequence<A> + , fusion::traits::is_sequence<B> + , has_same_size<A, B> + > + {}; + + template <typename Seq> + struct is_size_one_sequence + : mpl::and_< + fusion::traits::is_sequence<Seq> + , has_size<Seq, 1> + > + {}; +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/value_traits.hpp b/boost/spirit/home/x3/support/traits/value_traits.hpp new file mode 100644 index 0000000000..5f004c957c --- /dev/null +++ b/boost/spirit/home/x3/support/traits/value_traits.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + http://spirit.sourceforge.net/ + + 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_X3_VALUE_TRAITS_MAY_07_2013_0203PM) +#define BOOST_SPIRIT_X3_VALUE_TRAITS_MAY_07_2013_0203PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/utility/value_init.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename T, typename Enable = void> + struct value_initialize + { + static T call() + { + return boost::value_initialized<T>(); + } + }; +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/variant_find_substitute.hpp b/boost/spirit/home/x3/support/traits/variant_find_substitute.hpp new file mode 100644 index 0000000000..4de7b7d5e3 --- /dev/null +++ b/boost/spirit/home/x3/support/traits/variant_find_substitute.hpp @@ -0,0 +1,56 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + http://spirit.sourceforge.net/ + + 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_X3_VARIANT_FIND_SUBSTITUTE_APR_18_2014_930AM) +#define BOOST_SPIRIT_X3_VARIANT_FIND_SUBSTITUTE_APR_18_2014_930AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/traits/is_substitute.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Variant, typename Attribute> + struct variant_find_substitute + { + // Get the type from the variant that can be a substitute for Attribute. + // If none is found, just return Attribute + + 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, Attribute> >::type + iter_1; + + typedef typename + mpl::eval_if< + is_same<iter_1, end>, + mpl::find_if<types, traits::is_substitute<mpl::_1, Attribute> >, + mpl::identity<iter_1> + >::type + iter; + + typedef typename + mpl::eval_if< + is_same<iter, end>, + mpl::identity<Attribute>, + mpl::deref<iter> + >::type + type; + }; + + template <typename Variant> + struct variant_find_substitute<Variant, Variant> + : mpl::identity<Variant> {}; + +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/traits/variant_has_substitute.hpp b/boost/spirit/home/x3/support/traits/variant_has_substitute.hpp new file mode 100644 index 0000000000..d0dfb49b8d --- /dev/null +++ b/boost/spirit/home/x3/support/traits/variant_has_substitute.hpp @@ -0,0 +1,56 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + http://spirit.sourceforge.net/ + + 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_X3_VARIANT_HAS_SUBSTITUTE_APR_18_2014_925AM) +#define BOOST_SPIRIT_X3_VARIANT_HAS_SUBSTITUTE_APR_18_2014_925AM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/x3/support/traits/is_substitute.hpp> + +namespace boost { namespace spirit { namespace x3 { namespace traits +{ + template <typename Variant, typename Attribute> + struct variant_has_substitute_impl + { + // Find a type from the variant that can be a substitute for Attribute. + // return true_ if one is found, else false_ + + 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, Attribute>>::type + iter_1; + + typedef typename + mpl::eval_if< + is_same<iter_1, end>, + mpl::find_if<types, traits::is_substitute<mpl::_1, Attribute>>, + mpl::identity<iter_1> + >::type + iter; + + typedef mpl::not_<is_same<iter, end>> type; + }; + + template <typename Variant, typename Attribute> + struct variant_has_substitute + : variant_has_substitute_impl<Variant, Attribute>::type {}; + + template <typename Attribute> + struct variant_has_substitute<unused_type, Attribute> : mpl::true_ {}; + + template <typename Attribute> + struct variant_has_substitute<unused_type const, Attribute> : mpl::true_ {}; + +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/unused.hpp b/boost/spirit/home/x3/support/unused.hpp new file mode 100644 index 0000000000..cf42d13098 --- /dev/null +++ b/boost/spirit/home/x3/support/unused.hpp @@ -0,0 +1,93 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + + 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_X3_UNUSED_APRIL_16_2006_0616PM) +#define BOOST_SPIRIT_X3_UNUSED_APRIL_16_2006_0616PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <ostream> +#include <istream> +#include <boost/mpl/identity.hpp> + +#if defined(BOOST_MSVC) +# pragma warning(push) +# pragma warning(disable: 4522) // multiple assignment operators specified warning +#endif + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { namespace x3 +{ + struct unused_type + { + unused_type() + { + } + + template <typename T> + unused_type(T const&) + { + } + + template <typename T> + unused_type const& + operator=(T const&) const + { + return *this; + } + + template <typename T> + unused_type& + operator=(T const&) + { + return *this; + } + + unused_type const& + operator=(unused_type const&) const + { + return *this; + } + + unused_type& + operator=(unused_type const&) + { + return *this; + } + + // unused_type can also masquerade as an empty context (see context.hpp) + + template <typename ID> + struct get_result : mpl::identity<unused_type> {}; + + template <typename ID> + unused_type get(ID) const + { + return unused_type(); + } + }; + + unused_type const unused = unused_type(); + + inline std::ostream& operator<<(std::ostream& out, unused_type const&) + { + return out; + } + + inline std::istream& operator>>(std::istream& in, unused_type&) + { + return in; + } +}}} + +#if defined(BOOST_MSVC) +# pragma warning(pop) +#endif + +#endif diff --git a/boost/spirit/home/phoenix/fusion.hpp b/boost/spirit/home/x3/support/utility/detail/testing.hpp index 2d0d699672..1423d9fc7b 100644 --- a/boost/spirit/home/phoenix/fusion.hpp +++ b/boost/spirit/home/x3/support/utility/detail/testing.hpp @@ -1,12 +1,16 @@ /*============================================================================= - Copyright (c) 2007 Joel de Guzman + Copyright (c) 2014 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) ==============================================================================*/ -#ifndef PHOENIX_FUSION_HPP -#define PHOENIX_FUSION_HPP +#if !defined(BOOST_SPIRIT_X3_DETAIL_TESTING_JUNE_05_2014_00422PM) +#define BOOST_SPIRIT_X3_DETAIL_TESTING_JUNE_05_2014_00422PM -#include <boost/spirit/home/phoenix/fusion/at.hpp> +namespace boost { namespace spirit { namespace x3 { namespace testing +{ + + +}}}} #endif diff --git a/boost/spirit/home/x3/support/utility/error_reporting.hpp b/boost/spirit/home/x3/support/utility/error_reporting.hpp new file mode 100644 index 0000000000..9e65f2149b --- /dev/null +++ b/boost/spirit/home/x3/support/utility/error_reporting.hpp @@ -0,0 +1,241 @@ +/*============================================================================= + Copyright (c) 2014 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_X3_ERROR_REPORTING_MAY_19_2014_00405PM) +#define BOOST_SPIRIT_X3_ERROR_REPORTING_MAY_19_2014_00405PM + +#include <boost/filesystem/path.hpp> +#include <boost/spirit/home/x3/support/ast/position_tagged.hpp> +#include <ostream> + +// Clang-style error handling utilities + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Iterator> + class error_handler + { + public: + + typedef Iterator iterator_type; + + error_handler( + Iterator first, Iterator last, std::ostream& err_out + , std::string file = "", int tabs = 4) + : err_out(err_out) + , file(file) + , tabs(tabs) + , pos_cache(first, last) {} + + typedef void result_type; + + void operator()(Iterator err_pos, std::string const& error_message) const; + void operator()(Iterator err_first, Iterator err_last, std::string const& error_message) const; + void operator()(position_tagged pos, std::string const& message) const + { + auto where = pos_cache.position_of(pos); + (*this)( + where.begin() + , where.end() + , message + ); + } + + template <typename AST> + void tag(AST& ast, Iterator first, Iterator last) + { + return pos_cache.annotate(ast, first, last); + } +// +// void operator()( +// Iterator first +// , Iterator last +// , Iterator err_op +// , Iterator err_first +// , Iterator err_last +// , std::string const& error_message +// ) const; + + private: + + void print_file_line(std::size_t line) const; + void print_line(Iterator& line_start, Iterator last) const; + void print_indicator(Iterator& line_start, Iterator last, char ind) const; + void skip_whitespace(Iterator& err_pos, Iterator last) const; + void skip_non_whitespace(Iterator& err_pos, Iterator last) const; + Iterator get_line_start(Iterator first, Iterator pos) const; + std::size_t position(Iterator i) const; + + std::ostream& err_out; + std::string file; + int tabs; + position_cache<std::vector<Iterator>> pos_cache; + }; + + template <typename Iterator> + void error_handler<Iterator>::print_file_line(std::size_t line) const + { + namespace fs = boost::filesystem; + + if (file != "") + err_out << "In file " << fs::path(file).generic_string() << ", "; + else + err_out << "In "; + + err_out << "line " << line << ':' << std::endl; + } + + template <typename Iterator> + void error_handler<Iterator>::print_line(Iterator& start, Iterator last) const + { + for (; start != last; ++start) + { + auto c = *start; + if (c == '\r' || c == '\n') + break; + else + err_out << c; + } + err_out << std::endl; + } + + template <typename Iterator> + void error_handler<Iterator>::print_indicator(Iterator& start, Iterator last, char ind) const + { + for (; start != last; ++start) + { + auto c = *start; + if (c == '\r' || c == '\n') + break; + else if (c == '\t') + for (int i = 0; i < tabs; ++i) + err_out << ind; + else + err_out << ind; + } + } + + template <typename Iterator> + void error_handler<Iterator>::skip_whitespace(Iterator& err_pos, Iterator last) const + { + // make sure err_pos does not point to white space + while (err_pos != last) + { + char c = *err_pos; + if (std::isspace(c)) + ++err_pos; + else + break; + } + } + + template <typename Iterator> + void error_handler<Iterator>::skip_non_whitespace(Iterator& err_pos, Iterator last) const + { + // make sure err_pos does not point to white space + while (err_pos != last) + { + char c = *err_pos; + if (std::isspace(c)) + break; + else + ++err_pos; + } + } + + template <class Iterator> + inline Iterator error_handler<Iterator>::get_line_start(Iterator first, Iterator pos) const + { + Iterator latest = first; + for (Iterator i = first; i != pos; ++i) + if (*i == '\r' || *i == '\n') + latest = i; + return latest; + } + + template <typename Iterator> + std::size_t error_handler<Iterator>::position(Iterator i) const + { + // $$$ asumes iterator is similar to line_pos_iterator $$$ + return i.position(); + } + + template <typename Iterator> + void error_handler<Iterator>::operator()( + Iterator err_pos, std::string const& error_message) const + { + Iterator first = pos_cache.first(); + Iterator last = pos_cache.last(); + + // make sure err_pos does not point to white space + skip_whitespace(err_pos, last); + + print_file_line(position(err_pos)); + err_out << error_message << std::endl; + + Iterator start = get_line_start(first, err_pos); + if (start != first) + ++start; + Iterator i = start; + print_line(i, last); + print_indicator(start, err_pos, '_'); + err_out << "^_" << std::endl; + } + + template <typename Iterator> + void error_handler<Iterator>::operator()( + Iterator err_first, Iterator err_last, std::string const& error_message) const + { + Iterator first = pos_cache.first(); + Iterator last = pos_cache.last(); + + // make sure err_pos does not point to white space + skip_whitespace(err_first, last); + + print_file_line(position(err_first)); + err_out << error_message << std::endl; + + Iterator start = get_line_start(first, err_first); + if (start != first) + ++start; + Iterator i = start; + print_line(i, last); + print_indicator(start, err_first, ' '); + print_indicator(start, err_last, '~'); + err_out << " <<-- Here" << std::endl; + } +// +// template <typename Iterator> +// void error_handler<Iterator>::operator()( +// Iterator first +// , Iterator last +// , Iterator err_op +// , Iterator err_first +// , Iterator err_last +// , std::string const& error_message +// ) const +// { +// // make sure err_pos does not point to white space +// skip_whitespace(err_first, last); +// +// print_file_line(position(err_pos)); +// err_out << error_message << std::endl; +// +// Iterator start = get_line_start(first, err_first); +// if (start != first) +// ++start; +// Iterator i = start; +// print_line(i, last); +// print_indicator(start, err_first, ' '); +// print_indicator(start, err_op, '~'); +// err_out << '^'; +// print_indicator(++start, err_last, '~'); +// err_out << " <<-- Here" << std::endl; +// } + +}}} + +#endif diff --git a/boost/spirit/home/x3/support/utility/integer_sequence.hpp b/boost/spirit/home/x3/support/utility/integer_sequence.hpp new file mode 100644 index 0000000000..1f0bace72b --- /dev/null +++ b/boost/spirit/home/x3/support/utility/integer_sequence.hpp @@ -0,0 +1,94 @@ +/*////////////////////////////////////////////////////////////////////////////// + Copyright (c) 2014 Jamboree + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//////////////////////////////////////////////////////////////////////////////*/ +#ifndef BOOST_SPIRIT_X3_INTEGER_SEQUENCE_HPP_INCLUDED +#define BOOST_SPIRIT_X3_INTEGER_SEQUENCE_HPP_INCLUDED + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <cstddef> +#include <boost/type_traits/integral_constant.hpp> + +// This is a standard (c++1y) compatible integer_sequence implementation, +// it's needed for now, and it could be replaced with std::integer_sequence +// once the new standard is available everywhere. + +namespace boost { namespace spirit { namespace x3 +{ + template <typename T, T... Ns> + struct integer_sequence + { + typedef T value_type; + + static constexpr std::size_t size() noexcept + { + return sizeof...(Ns); + } + }; +}}} + +namespace boost { namespace spirit { namespace x3 { namespace detail +{ + template <typename T, typename S1, typename S2, T N> + struct accum_integer_sequence; + + template <typename T, T... N1, T... N2, T N> + struct accum_integer_sequence<T, integer_sequence<T, N1...>, integer_sequence<T, N2...>, N> + { + typedef integer_sequence<T, N1..., (N + N2)...> type; + }; + + template <typename N> + struct make_integer_sequence_impl + { + typedef typename N::value_type T; + static T const n = N::value; + static T const m = n / 2; + typedef typename + make_integer_sequence_impl<integral_constant<T, m>>::type + part1; + typedef typename + make_integer_sequence_impl<integral_constant<T, n - m>>::type + part2; + typedef typename + accum_integer_sequence<T, part1, part2, m>::type + type; + }; + + template <typename T> + struct make_integer_sequence_impl<integral_constant<T, 0>> + { + typedef integer_sequence<T> type; + }; + + template <typename T> + struct make_integer_sequence_impl<integral_constant<T, 1>> + { + typedef integer_sequence<T, 0> type; + }; +}}}} + +namespace boost { namespace spirit { namespace x3 +{ + template <std::size_t... Ns> + using index_sequence = integer_sequence<std::size_t, Ns...>; + + template <typename T, T N> + using make_integer_sequence = typename detail::make_integer_sequence_impl< + integral_constant<T, N>>::type; + + template <std::size_t N> + using make_index_sequence = make_integer_sequence<std::size_t, N>; + + template <typename... T> + using index_sequence_for = make_index_sequence<sizeof...(T)>; +}}} + + +#endif + diff --git a/boost/spirit/home/x3/support/utility/is_callable.hpp b/boost/spirit/home/x3/support/utility/is_callable.hpp new file mode 100644 index 0000000000..17f86822b8 --- /dev/null +++ b/boost/spirit/home/x3/support/utility/is_callable.hpp @@ -0,0 +1,45 @@ +/*////////////////////////////////////////////////////////////////////////////// + Copyright (c) 2014 Jamboree + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//////////////////////////////////////////////////////////////////////////////*/ +#ifndef BOOST_SPIRIT_X3_IS_CALLABLE_HPP_INCLUDED +#define BOOST_SPIRIT_X3_IS_CALLABLE_HPP_INCLUDED + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/utility/result_of.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/spirit/home/x3/support/utility/sfinae.hpp> + + +namespace boost { namespace spirit { namespace x3 { namespace detail +{ + template <typename Sig, typename Enable = void> + struct is_callable_impl + : mpl::false_ + {}; + + template <typename F, typename... A> + struct is_callable_impl<F(A...), typename disable_if_substitution_failure< + typename result_of<F(A...)>::type>::type> + : mpl::true_ + {}; +}}}} + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Sig> + struct is_callable; + + template <typename F, typename... A> + struct is_callable<F(A...)> + : detail::is_callable_impl<F(A...)> + {}; +}}} + + +#endif diff --git a/boost/spirit/home/x3/support/utility/lambda_visitor.hpp b/boost/spirit/home/x3/support/utility/lambda_visitor.hpp new file mode 100644 index 0000000000..83e1d2f046 --- /dev/null +++ b/boost/spirit/home/x3/support/utility/lambda_visitor.hpp @@ -0,0 +1,49 @@ +/*============================================================================= + Copyright (c) 2014 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_X3_LAMBDA_VISITOR_MAY_19_2014_1116AM) +#define BOOST_SPIRIT_X3_LAMBDA_VISITOR_MAY_19_2014_1116AM + +namespace boost { namespace spirit { namespace x3 +{ + template <typename RT, typename... Lambdas> + struct lambda_visitor; + + template <typename RT, typename F, typename... Lambdas> + struct lambda_visitor<RT, F, Lambdas...> : F, lambda_visitor<RT, Lambdas...> + { + typedef lambda_visitor<RT , Lambdas...> base_type; + using F::operator(); + using base_type::operator(); + lambda_visitor(F f, Lambdas... lambdas) + : F(f), base_type(lambdas...) + {} + }; + + template <typename RT, typename F> + struct lambda_visitor<RT, F> : F + { + typedef RT result_type; + using F::operator(); + lambda_visitor(F f) + : F(f) + {} + }; + + template <typename RT> + struct lambda_visitor<RT> + { + typedef RT result_type; + }; + + template <typename RT, typename... Lambdas> + lambda_visitor<RT, Lambdas...> make_lambda_visitor(Lambdas... lambdas) + { + return { lambdas... }; + } +}}} + +#endif diff --git a/boost/spirit/home/x3/support/utility/sfinae.hpp b/boost/spirit/home/x3/support/utility/sfinae.hpp new file mode 100644 index 0000000000..6cefa95961 --- /dev/null +++ b/boost/spirit/home/x3/support/utility/sfinae.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2001-2014 Joel de Guzman + Copyright (c) 2013 Agustin Berge + + 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_X3_SFINAE_MAY_20_2013_0840AM) +#define BOOST_SPIRIT_X3_SFINAE_MAY_20_2013_0840AM + +#if defined(_MSC_VER) +#pragma once +#endif + +namespace boost { namespace spirit { namespace x3 +{ + template <typename Expr, typename T = void> + struct disable_if_substitution_failure + { + typedef T type; + }; + template <typename Expr, typename T> + struct lazy_disable_if_substitution_failure + { + typedef typename T::type type; + }; +}}} + +#endif diff --git a/boost/spirit/home/x3/support/utility/testing.hpp b/boost/spirit/home/x3/support/utility/testing.hpp new file mode 100644 index 0000000000..fced46bef8 --- /dev/null +++ b/boost/spirit/home/x3/support/utility/testing.hpp @@ -0,0 +1,69 @@ +/*============================================================================= + Copyright (c) 2014 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_X3_TESTING_JUNE_05_2014_00422PM) +#define BOOST_SPIRIT_X3_TESTING_JUNE_05_2014_00422PM + +namespace boost { namespace spirit { namespace x3 { namespace testing +{ + //////////////////////////////////////////////////////////////////////////// + // + // Test utility + // + // The test function accepts a file loaded in memory. The 'test_file' + // range param points to the data contained in the file. This file + // contains two parts. + // + // 1) The source input for testing + // 2) The expected result. + // + // The first part of the file is sent to the generator function + // 'gen' which returns a string. This generated string is then compared + // to the contents of the second (expected result) part. + // + // The second part is demarcated by the string parameter 'demarcation' + // which defaults to "<**expected**>". The expected template may include + // embedded regular expressions marked-up within re_prefix and re_suffix + // parameter tags. For example, given the default RE markup ("<%" and + // "%>"), this template: + // + // <%[0-9]+%> + // + // will match any integer in the source input being tested. The function + // will return the first non-matching position. The flag full_match + // indicates a full match. It is possible for returned pos to be + // at the end of in (in.end()) while still returning full_match == + // false. In that case, we have a partial match. + // + // Here's an example of a test file: + // + // Hello World, I am Joel. This is a test. + // + // <**expected**> + // Hello World, I am <%[a-zA-Z]+%>. This is a test. + // + //////////////////////////////////////////////////////////////////////////// + + template <typename Iterator> + struct test_result + { + Iterator pos; + bool full_match; + }; + + template <typename Range, typename F> + test_result<typename Range::const_iterator> + test( + Range test_file + , F gen + , char const* demarcation = "<**expected**>" + , char const* re_prefix = "<%" + , char const* re_suffix = "%>" + ); + +}}}} + +#endif diff --git a/boost/spirit/home/x3/support/utility/unrefcv.hpp b/boost/spirit/home/x3/support/utility/unrefcv.hpp new file mode 100644 index 0000000000..fa4d448178 --- /dev/null +++ b/boost/spirit/home/x3/support/utility/unrefcv.hpp @@ -0,0 +1,29 @@ +/*////////////////////////////////////////////////////////////////////////////// + Copyright (c) 2014 Jamboree + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//////////////////////////////////////////////////////////////////////////////*/ +#ifndef BOOST_SPIRIT_X3_UNREFCV_HPP_INCLUDED +#define BOOST_SPIRIT_X3_UNREFCV_HPP_INCLUDED + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/type_traits/remove_cv.hpp> +#include <boost/type_traits/remove_reference.hpp> + + +namespace boost { namespace spirit { namespace x3 +{ + template <typename T> + struct unrefcv : remove_cv<typename remove_reference<T>::type> {}; + + template <typename T> + using unrefcv_t = typename unrefcv<T>::type; +}}} + + +#endif + diff --git a/boost/spirit/home/x3/support/utility/utf8.hpp b/boost/spirit/home/x3/support/utility/utf8.hpp new file mode 100644 index 0000000000..93b5a22077 --- /dev/null +++ b/boost/spirit/home/x3/support/utility/utf8.hpp @@ -0,0 +1,72 @@ +/*============================================================================= + Copyright (c) 2001-2014 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_X3_UC_TYPES_NOVEMBER_23_2008_0840PM) +#define BOOST_SPIRIT_X3_UC_TYPES_NOVEMBER_23_2008_0840PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/cstdint.hpp> +#include <boost/foreach.hpp> +#include <boost/regex/pending/unicode_iterator.hpp> +#include <boost/type_traits/make_unsigned.hpp> +#include <string> + +namespace boost { namespace spirit { namespace x3 +{ + typedef ::boost::uint32_t ucs4_char; + typedef char utf8_char; + typedef std::basic_string<ucs4_char> ucs4_string; + typedef std::basic_string<utf8_char> utf8_string; + + template <typename Char> + inline utf8_string to_utf8(Char value) + { + // always store as UTF8 + utf8_string result; + typedef std::back_insert_iterator<utf8_string> insert_iter; + insert_iter out_iter(result); + utf8_output_iterator<insert_iter> utf8_iter(out_iter); + typedef typename make_unsigned<Char>::type UChar; + *utf8_iter = (UChar)value; + return result; + } + + template <typename Char> + inline utf8_string to_utf8(Char const* str) + { + // always store as UTF8 + utf8_string result; + typedef std::back_insert_iterator<utf8_string> insert_iter; + insert_iter out_iter(result); + utf8_output_iterator<insert_iter> utf8_iter(out_iter); + typedef typename make_unsigned<Char>::type UChar; + while (*str) + *utf8_iter++ = (UChar)*str++; + return result; + } + + template <typename Char, typename Traits, typename Allocator> + inline utf8_string + to_utf8(std::basic_string<Char, Traits, Allocator> const& str) + { + // always store as UTF8 + utf8_string result; + typedef std::back_insert_iterator<utf8_string> insert_iter; + insert_iter out_iter(result); + utf8_output_iterator<insert_iter> utf8_iter(out_iter); + typedef typename make_unsigned<Char>::type UChar; + BOOST_FOREACH(Char ch, str) + { + *utf8_iter++ = (UChar)ch; + } + return result; + } +}}} + +#endif diff --git a/boost/spirit/include/phoenix.hpp b/boost/spirit/include/phoenix.hpp index f60958739a..7915d74d14 100644 --- a/boost/spirit/include/phoenix.hpp +++ b/boost/spirit/include/phoenix.hpp @@ -8,11 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX #define BOOST_SPIRIT_INCLUDE_PHOENIX - -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -#include <boost/spirit/home/phoenix.hpp> -#else #include <boost/phoenix.hpp> #endif - -#endif diff --git a/boost/spirit/include/phoenix_algorithm.hpp b/boost/spirit/include/phoenix_algorithm.hpp index 4b97d4cf4c..9b434e4c6a 100644 --- a/boost/spirit/include/phoenix_algorithm.hpp +++ b/boost/spirit/include/phoenix_algorithm.hpp @@ -8,11 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX_ALGORITHM #define BOOST_SPIRIT_INCLUDE_PHOENIX_ALGORITHM - -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -#include <boost/spirit/home/phoenix/algorithm.hpp> -#else #include <boost/phoenix/stl/algorithm.hpp> #endif - -#endif diff --git a/boost/spirit/include/phoenix_bind.hpp b/boost/spirit/include/phoenix_bind.hpp index f289ac02ca..1c8cd4ebf4 100644 --- a/boost/spirit/include/phoenix_bind.hpp +++ b/boost/spirit/include/phoenix_bind.hpp @@ -8,11 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX_BIND #define BOOST_SPIRIT_INCLUDE_PHOENIX_BIND - -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -#include <boost/spirit/home/phoenix/bind.hpp> -#else #include <boost/phoenix/bind.hpp> #endif - -#endif diff --git a/boost/spirit/include/phoenix_container.hpp b/boost/spirit/include/phoenix_container.hpp index 95b13a25aa..c78e28b0d3 100644 --- a/boost/spirit/include/phoenix_container.hpp +++ b/boost/spirit/include/phoenix_container.hpp @@ -8,11 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX_CONTAINER #define BOOST_SPIRIT_INCLUDE_PHOENIX_CONTAINER - -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -#include <boost/spirit/home/phoenix/container.hpp> -#else #include <boost/phoenix/stl/container.hpp> #endif - -#endif diff --git a/boost/spirit/include/phoenix_core.hpp b/boost/spirit/include/phoenix_core.hpp index 55b5010ec3..d08ed06687 100644 --- a/boost/spirit/include/phoenix_core.hpp +++ b/boost/spirit/include/phoenix_core.hpp @@ -8,12 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX_CORE #define BOOST_SPIRIT_INCLUDE_PHOENIX_CORE - -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -#define BOOST_PHOENIX_DEFINE_CUSTOM_TERMINAL(A,B,C,D) -#include <boost/spirit/home/phoenix/core.hpp> -#else #include <boost/phoenix/core.hpp> #endif - -#endif diff --git a/boost/spirit/include/phoenix_function.hpp b/boost/spirit/include/phoenix_function.hpp index 76c244d975..6ab828f53b 100644 --- a/boost/spirit/include/phoenix_function.hpp +++ b/boost/spirit/include/phoenix_function.hpp @@ -8,11 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX_FUNCTION #define BOOST_SPIRIT_INCLUDE_PHOENIX_FUNCTION - -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -#include <boost/spirit/home/phoenix/function.hpp> -#else #include <boost/phoenix/function.hpp> #endif - -#endif diff --git a/boost/spirit/include/phoenix_fusion.hpp b/boost/spirit/include/phoenix_fusion.hpp index 8ab422a5b0..4820ba8a53 100644 --- a/boost/spirit/include/phoenix_fusion.hpp +++ b/boost/spirit/include/phoenix_fusion.hpp @@ -8,11 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX_FUSION #define BOOST_SPIRIT_INCLUDE_PHOENIX_FUSION - -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -#include <boost/spirit/home/phoenix/fusion.hpp> -#else #include <boost/phoenix/fusion.hpp> #endif - -#endif diff --git a/boost/spirit/include/phoenix_limits.hpp b/boost/spirit/include/phoenix_limits.hpp index 3d9ed3a4ee..93a1e1ef90 100644 --- a/boost/spirit/include/phoenix_limits.hpp +++ b/boost/spirit/include/phoenix_limits.hpp @@ -8,9 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX_LIMITS #define BOOST_SPIRIT_INCLUDE_PHOENIX_LIMITS - -#ifdef BOOST_SPIRIT_USE_PHOENIX_V3 #include <boost/phoenix/core/limits.hpp> #endif - -#endif diff --git a/boost/spirit/include/phoenix_object.hpp b/boost/spirit/include/phoenix_object.hpp index 5bb6dd469c..43be44d2d4 100644 --- a/boost/spirit/include/phoenix_object.hpp +++ b/boost/spirit/include/phoenix_object.hpp @@ -8,11 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX_OBJECT #define BOOST_SPIRIT_INCLUDE_PHOENIX_OBJECT - -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -#include <boost/spirit/home/phoenix/object.hpp> -#else #include <boost/phoenix/object.hpp> #endif - -#endif diff --git a/boost/spirit/include/phoenix_operator.hpp b/boost/spirit/include/phoenix_operator.hpp index 03c66c9d12..5ba6921257 100644 --- a/boost/spirit/include/phoenix_operator.hpp +++ b/boost/spirit/include/phoenix_operator.hpp @@ -8,11 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX_OPERATOR #define BOOST_SPIRIT_INCLUDE_PHOENIX_OPERATOR - -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -#include <boost/spirit/home/phoenix/operator.hpp> -#else #include <boost/phoenix/operator.hpp> #endif - -#endif diff --git a/boost/spirit/include/phoenix_scope.hpp b/boost/spirit/include/phoenix_scope.hpp index c71533e90d..6ab3d954ee 100644 --- a/boost/spirit/include/phoenix_scope.hpp +++ b/boost/spirit/include/phoenix_scope.hpp @@ -8,11 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX_SCOPE #define BOOST_SPIRIT_INCLUDE_PHOENIX_SCOPE - -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -#include <boost/spirit/home/phoenix/scope.hpp> -#else #include <boost/phoenix/scope.hpp> #endif - -#endif diff --git a/boost/spirit/include/phoenix_statement.hpp b/boost/spirit/include/phoenix_statement.hpp index e6729b2ec5..498b70fa84 100644 --- a/boost/spirit/include/phoenix_statement.hpp +++ b/boost/spirit/include/phoenix_statement.hpp @@ -8,11 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX_STATEMENT #define BOOST_SPIRIT_INCLUDE_PHOENIX_STATEMENT - -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -#include <boost/spirit/home/phoenix/statement.hpp> -#else #include <boost/phoenix/statement.hpp> #endif - -#endif diff --git a/boost/spirit/include/phoenix_stl.hpp b/boost/spirit/include/phoenix_stl.hpp index 63656357cd..c60bfb4213 100644 --- a/boost/spirit/include/phoenix_stl.hpp +++ b/boost/spirit/include/phoenix_stl.hpp @@ -8,11 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX_STL #define BOOST_SPIRIT_INCLUDE_PHOENIX_STL - -#ifndef BOOST_SPIRIT_USE_PHOENIX_V3 -#include <boost/spirit/home/phoenix/stl.hpp> -#else #include <boost/phoenix/stl.hpp> #endif - -#endif diff --git a/boost/spirit/include/phoenix_version.hpp b/boost/spirit/include/phoenix_version.hpp index acc3fdf192..3d0327a1d2 100644 --- a/boost/spirit/include/phoenix_version.hpp +++ b/boost/spirit/include/phoenix_version.hpp @@ -8,5 +8,5 @@ =============================================================================*/ #ifndef BOOST_SPIRIT_INCLUDE_PHOENIX_VERSION #define BOOST_SPIRIT_INCLUDE_PHOENIX_VERSION -#include <boost/spirit/home/phoenix/version.hpp> +#include <boost/phoenix/version.hpp> #endif diff --git a/boost/spirit/home/phoenix/container.hpp b/boost/spirit/include/qi_copy.hpp index fb6ec3f9f9..6ad8c3f125 100644 --- a/boost/spirit/home/phoenix/container.hpp +++ b/boost/spirit/include/qi_copy.hpp @@ -1,12 +1,17 @@ /*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2001-2012 Joel de Guzman + http://spirit.sourceforge.net/ - Distributed under the Boost Software License, Version 1.0. (See accompanying + Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#ifndef PHOENIX_CONTAINER_HPP -#define PHOENIX_CONTAINER_HPP +=============================================================================*/ +#ifndef BOOST_SPIRIT_INCLUDE_SUPPORT_COPY +#define BOOST_SPIRIT_INCLUDE_SUPPORT_COPY -#include <boost/spirit/home/phoenix/stl/container/container.hpp> +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/qi/copy.hpp> #endif diff --git a/boost/spirit/home/phoenix/function.hpp b/boost/spirit/include/support_auto.hpp index 5309d9af3f..6021d84c5e 100644 --- a/boost/spirit/home/phoenix/function.hpp +++ b/boost/spirit/include/support_auto.hpp @@ -1,13 +1,17 @@ /*============================================================================= - Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2001-2012 Joel de Guzman + http://spirit.sourceforge.net/ - Distributed under the Boost Software License, Version 1.0. (See accompanying + Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#ifndef PHOENIX_FUNCTION_HPP -#define PHOENIX_FUNCTION_HPP +=============================================================================*/ +#ifndef BOOST_SPIRIT_INCLUDE_SUPPORT_AUTO +#define BOOST_SPIRIT_INCLUDE_SUPPORT_AUTO -#include <boost/spirit/home/phoenix/version.hpp> -#include <boost/spirit/home/phoenix/function/function.hpp> +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/support/auto.hpp> #endif diff --git a/boost/spirit/repository/home/karma/nonterminal/subrule.hpp b/boost/spirit/repository/home/karma/nonterminal/subrule.hpp index 29651a28e8..0c6fc6bfa8 100644 --- a/boost/spirit/repository/home/karma/nonterminal/subrule.hpp +++ b/boost/spirit/repository/home/karma/nonterminal/subrule.hpp @@ -207,7 +207,7 @@ namespace boost { namespace spirit { namespace repository { namespace karma // trying to use a subrule which has inherited attributes, // without passing values for them. context_type context(*this - , traits::pre_transform<karma::domain, subrule_attr_type>( + , traits::pre_transform<spirit::karma::domain, subrule_attr_type>( make_attribute::call(attr))); return def.binder(sink, context, delimiter); @@ -242,7 +242,7 @@ namespace boost { namespace spirit { namespace repository { namespace karma // trying to use a subrule which has inherited attributes, // passing values of incompatible types for them. context_type context(*this - , traits::pre_transform<karma::domain, subrule_attr_type>( + , traits::pre_transform<spirit::karma::domain, subrule_attr_type>( make_attribute::call(attr)), params, caller_context); return def.binder(sink, context, delimiter); @@ -503,7 +503,7 @@ namespace boost { namespace spirit { namespace repository { namespace karma { // If you are seeing a compilation error here, you are trying // to use a subrule as a generator outside of a subrule group. - BOOST_SPIRIT_ASSERT_MSG(false + BOOST_SPIRIT_ASSERT_FAIL(OutputIterator , subrule_used_outside_subrule_group, (id_type)); return false; @@ -532,7 +532,7 @@ namespace boost { namespace spirit { namespace repository { namespace karma { // If you are seeing a compilation error here, you are trying // to use a subrule as a generator outside of a subrule group. - BOOST_SPIRIT_ASSERT_MSG(false + BOOST_SPIRIT_ASSERT_FAIL(OutputIterator , subrule_used_outside_subrule_group, (id_type)); return false; diff --git a/boost/spirit/repository/home/qi/directive/kwd.hpp b/boost/spirit/repository/home/qi/directive/kwd.hpp index bba1a78448..18020804bd 100644 --- a/boost/spirit/repository/home/qi/directive/kwd.hpp +++ b/boost/spirit/repository/home/qi/directive/kwd.hpp @@ -30,25 +30,25 @@ namespace boost { namespace spirit /////////////////////////////////////////////////////////////////////////// // Enablers /////////////////////////////////////////////////////////////////////////// - + template < typename T> struct use_directive<qi::domain , terminal_ex<repository::tag::kwd // enables kwd(key)[p] , fusion::vector1<T > > > : mpl::true_ {}; - + template < typename T> struct use_directive<qi::domain , terminal_ex<repository::tag::ikwd // enables ikwd(key)[p] , fusion::vector1<T > > > : mpl::true_ {}; - + template < typename T> struct use_directive<qi::domain , terminal_ex<repository::tag::dkwd // enables dkwd(key)[p] , fusion::vector1<T > > > : mpl::true_ {}; - + template < typename T> struct use_directive<qi::domain , terminal_ex<repository::tag::idkwd // enables idkwd(key)[p] @@ -109,7 +109,7 @@ namespace boost { namespace spirit , terminal_ex<repository::tag::kwd // enables kwd(min, inf)[p] , fusion::vector3<T1, T2, inf_type > > > : mpl::true_ {}; - + template < typename T1, typename T2> struct use_directive<qi::domain , terminal_ex<repository::tag::ikwd // enables ikwd(min, inf)[p] @@ -164,7 +164,7 @@ template <typename T> flag=true; return true; } - + private: // silence MSVC warning C4512: assignment operator could not be generated @@ -193,7 +193,7 @@ template <typename T> } else return flag=false; - + } T const exact; @@ -254,42 +254,42 @@ template <typename T> kwd_infinite_iterator& operator= (kwd_infinite_iterator const&); }; - // This class enables the transportation of parameters needed to call + // This class enables the transportation of parameters needed to call // the occurence constraint checker from higher level calls - // It also serves to select the correct parse function call + // It also serves to select the correct parse function call // of the keyword parser. The implementation changes depending if it is // called form a keyword parsing loop or not. template <typename Skipper, typename NoCasePass> struct skipper_keyword_marker { typedef NoCasePass no_case_pass; - - skipper_keyword_marker(Skipper const &skipper,bool &flag,int &counter) : + + skipper_keyword_marker(Skipper const &skipper,bool &flag,int &counter) : skipper(skipper) , flag(flag) - , counter(counter) + , counter(counter) {} - + const Skipper &skipper; bool &flag; int &counter; }; - + template <typename Subject, typename KeywordType, typename LoopIter , typename NoCase, typename Distinct > struct kwd_parser : spirit::qi::unary_parser<kwd_parser<Subject, KeywordType, LoopIter , NoCase, Distinct > > { struct kwd_parser_id; - + typedef Subject subject_type; typedef NoCase no_case_keyword; typedef Distinct distinct; - + typedef typename remove_const<typename traits::char_type_of<KeywordType>::type>::type char_type; - + typedef std::basic_string<char_type> keyword_type; - + template <typename Context, typename Iterator> struct attribute { @@ -300,13 +300,13 @@ template <typename T> >::type type; }; - + kwd_parser(Subject const& subject , typename add_reference<KeywordType>::type keyword , LoopIter const& iter) - : subject(subject), iter(iter), keyword(keyword) {} - + : subject(subject), iter(iter), keyword(keyword) {} + template<typename CharEncoding> kwd_parser(Subject const& subject , typename add_reference<KeywordType>::type keyword @@ -323,15 +323,15 @@ template <typename T> { return subject.parse(first,last,context,skipper,attr); } - + // Call the subject parser on a container attribute template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse_impl(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper , Attribute& attr,mpl::true_) const - { - + { + // synthesized attribute needs to be default constructed typename traits::container_value<Attribute>::type val = typename traits::container_value<Attribute>::type(); @@ -347,23 +347,23 @@ template <typename T> } return r; } - + template <typename Iterator, typename Context , typename Skipper, typename Attribute,typename NoCasePass> bool parse(Iterator& first, Iterator const& last , Context& context, skipper_keyword_marker<Skipper,NoCasePass> const& skipper , Attribute &attr) const { - + typedef typename traits::attribute_of< Subject, Context, Iterator>::type subject_attribute; - + typedef typename mpl::and_< traits::is_container<Attribute> , mpl::not_< traits::is_weak_substitute< subject_attribute,Attribute > > >::type predicate; - + if((no_case_keyword::value && NoCasePass::value) || !NoCasePass::value) { if(parse_impl(first,last,context,skipper.skipper,attr, predicate())) @@ -371,7 +371,7 @@ template <typename T> } return false; } - + template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last @@ -381,12 +381,12 @@ template <typename T> typedef typename traits::attribute_of< Subject, Context, Iterator>::type subject_attribute; - + typedef typename mpl::and_< traits::is_container<Attribute> , mpl::not_< traits::is_weak_substitute< subject_attribute,Attribute > > >::type predicate; - + // Parse the keyword bool flag = iter.flag_init(); @@ -395,24 +395,24 @@ template <typename T> spirit::qi::skip_over(first, last, skipper); if(keyword.parse(first,last,context,skipper,unused)){ if((!distinct::value) || skipper.parse(first,last,unused,unused,unused)){ - // Followed by the subject parser - spirit::qi::skip_over(first, last, skipper); - if(parse_impl(first,last,context,skipper,attr, predicate())) - { - return iter.register_successful_parse(flag,counter); + // Followed by the subject parser + spirit::qi::skip_over(first, last, skipper); + if(parse_impl(first,last,context,skipper,attr, predicate())) + { + return iter.register_successful_parse(flag,counter); + } } } - } - first = save; - return flag; + first = save; + return flag; } - - + + template <typename Context> - info what(Context& context) const - { + info what(Context& context) const + { if(distinct::value){ - if(no_case_keyword::value) + if(no_case_keyword::value) return info("idkwd", subject.what(context)); else return info("dkwd", subject.what(context)); @@ -421,14 +421,14 @@ template <typename T> { if(no_case_keyword::value) return info("ikwd", subject.what(context)); - else + else return info("kwd", subject.what(context)); - } + } } Subject subject; - LoopIter iter; - + LoopIter iter; + typedef typename mpl::if_< no_case_keyword, spirit::qi::no_case_literal_string< KeywordType, true>, @@ -604,7 +604,7 @@ namespace boost { namespace spirit { namespace qi /////////////////////////////////////////////////////////////////////////// // Parser generators: make_xxx function (objects) /////////////////////////////////////////////////////////////////////////// - + template <typename T1, typename T2, typename Subject, typename Modifiers, typename Distinct, typename MakeDirectiveHelper> struct make_directive_internal_2_args { @@ -784,12 +784,12 @@ namespace boost { namespace spirit { namespace qi { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_pass_iterator<int> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::false_ > result_type; - + template <typename Terminal> result_type operator()( - Terminal const& term, Subject const& subject, unused_type) const + Terminal const& term, Subject const& subject, unused_type) const { typename spirit::detail::get_encoding<Modifiers, spirit::char_encoding::standard>::type encoding; @@ -801,14 +801,14 @@ namespace boost { namespace spirit { namespace qi ); } }; - + template <typename T1, typename Subject, typename Modifiers> struct make_directive< terminal_ex<repository::tag::idkwd, fusion::vector1<T1> >, Subject, Modifiers> { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_pass_iterator<int> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::true_ > result_type; template <typename Terminal> @@ -817,15 +817,15 @@ namespace boost { namespace spirit { namespace qi { typename spirit::detail::get_encoding<Modifiers, spirit::char_encoding::standard>::type encoding; - + return result_type(subject ,fusion::at_c<0>(term.args) - ,iterator_type() + ,iterator_type() ,encoding ); } }; - + // Directive kwd(key,exact)[p] template <typename T> struct make_exact_helper @@ -891,7 +891,7 @@ namespace boost { namespace spirit { namespace qi { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_exact_iterator<T2> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::false_ > result_type; template <typename Terminal> @@ -901,8 +901,8 @@ namespace boost { namespace spirit { namespace qi typename spirit::detail::get_encoding<Modifiers, spirit::char_encoding::standard>::type encoding; return result_type(subject - ,fusion::at_c<0>(term.args) - ,fusion::at_c<1>(term.args) + , fusion::at_c<0>(term.args) + , fusion::at_c<1>(term.args) , encoding ); } @@ -914,13 +914,13 @@ namespace boost { namespace spirit { namespace qi { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_exact_iterator<T2> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::true_ > result_type; - + template <typename Terminal> result_type operator()( Terminal const& term, Subject const& subject, Modifiers const& modifiers) const - { + { typename spirit::detail::get_encoding<Modifiers, spirit::char_encoding::standard>::type encoding; return result_type(subject @@ -930,7 +930,7 @@ namespace boost { namespace spirit { namespace qi ); } }; - + // Directive kwd(min, max)[p] @@ -946,9 +946,9 @@ namespace boost { namespace spirit { namespace qi }; - template <typename T1, typename T2, typename Subject, typename Modifiers> + template <typename T1, typename T2, typename Subject, typename Modifiers> struct make_directive< - terminal_ex<repository::tag::kwd, fusion::vector3< T1, T2, T2> >, Subject, Modifiers> + terminal_ex<repository::tag::kwd, fusion::vector3<T1,T2,T2> >, Subject, Modifiers> { typedef make_directive_internal_2_args< T1 , T2 @@ -1001,7 +1001,7 @@ namespace boost { namespace spirit { namespace qi { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_finite_iterator<T2> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::false_ > result_type; template <typename Terminal> @@ -1027,14 +1027,14 @@ namespace boost { namespace spirit { namespace qi { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_finite_iterator<T2> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::true_ > result_type; template <typename Terminal> result_type operator()( Terminal const& term, Subject const& subject, unused_type) const { - + typename spirit::detail::get_encoding<Modifiers, spirit::char_encoding::standard>::type encoding; return result_type(subject, fusion::at_c<0>(term.args), @@ -1046,7 +1046,7 @@ namespace boost { namespace spirit { namespace qi ); } }; - + // Directive kwd(min, inf)[p] @@ -1063,7 +1063,7 @@ namespace boost { namespace spirit { namespace qi }; - template <typename T1, typename T2, typename Subject, typename Modifiers> + template <typename T1, typename T2, typename Subject, typename Modifiers> struct make_directive< terminal_ex<repository::tag::kwd, fusion::vector3<T1,T2,inf_type> >, Subject, Modifiers> { @@ -1118,7 +1118,7 @@ namespace boost { namespace spirit { namespace qi { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_infinite_iterator<T2> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::false_ > result_type; template <typename Terminal> @@ -1135,15 +1135,15 @@ namespace boost { namespace spirit { namespace qi ); } }; - - template <typename T1, typename T2, typename Subject, typename Modifiers> + + template <typename T1, typename T2, typename Subject, typename Modifiers> struct make_directive< terminal_ex<repository::tag::idkwd , fusion::vector3<T1, T2, inf_type> >, Subject, Modifiers> { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_infinite_iterator<T2> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::true_ > result_type; template <typename Terminal> @@ -1152,7 +1152,7 @@ namespace boost { namespace spirit { namespace qi { typename spirit::detail::get_encoding<Modifiers, spirit::char_encoding::standard>::type encoding; - + return result_type(subject , fusion::at_c<0>(term.args) , fusion::at_c<1>(term.args) @@ -1160,15 +1160,15 @@ namespace boost { namespace spirit { namespace qi ); } }; - - + + }}} namespace boost { namespace spirit { namespace traits { template <typename Subject, typename KeywordType , typename LoopIter, typename NoCase , typename Distinct> - struct has_semantic_action< + struct has_semantic_action< repository::qi::kwd_parser< Subject, KeywordType, LoopIter, NoCase, Distinct > > : unary_has_semantic_action<Subject> {}; diff --git a/boost/spirit/repository/home/qi/nonterminal/subrule.hpp b/boost/spirit/repository/home/qi/nonterminal/subrule.hpp index a2db38496b..170367b71c 100644 --- a/boost/spirit/repository/home/qi/nonterminal/subrule.hpp +++ b/boost/spirit/repository/home/qi/nonterminal/subrule.hpp @@ -529,7 +529,7 @@ namespace boost { namespace spirit { namespace repository { namespace qi { // If you are seeing a compilation error here, you are trying // to use a subrule as a parser outside of a subrule group. - BOOST_SPIRIT_ASSERT_MSG(false + BOOST_SPIRIT_ASSERT_FAIL(Iterator , subrule_used_outside_subrule_group, (id_type)); return false; @@ -558,7 +558,7 @@ namespace boost { namespace spirit { namespace repository { namespace qi { // If you are seeing a compilation error here, you are trying // to use a subrule as a parser outside of a subrule group. - BOOST_SPIRIT_ASSERT_MSG(false + BOOST_SPIRIT_ASSERT_FAIL(Iterator , subrule_used_outside_subrule_group, (id_type)); return false; diff --git a/boost/spirit/repository/home/qi/operator/detail/keywords.hpp b/boost/spirit/repository/home/qi/operator/detail/keywords.hpp index 06836f7746..43aa133468 100644 --- a/boost/spirit/repository/home/qi/operator/detail/keywords.hpp +++ b/boost/spirit/repository/home/qi/operator/detail/keywords.hpp @@ -1,9 +1,9 @@ /*============================================================================= Copyright (c) 2011-2012 Thomas Bernard - 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) -=============================================================================*/ + 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_KEYWORDS_DETAIL_MARCH_13_2007_1145PM) #define SPIRIT_KEYWORDS_DETAIL_MARCH_13_2007_1145PM @@ -14,11 +14,11 @@ #include <boost/spirit/home/qi/string/lit.hpp> #include <boost/fusion/include/at.hpp> namespace boost { namespace spirit { namespace repository { namespace qi { namespace detail { - // Variant visitor class which handles dispatching the parsing to the selected parser - // This also handles passing the correct attributes and flags/counters to the subject parsers + // Variant visitor class which handles dispatching the parsing to the selected parser + // This also handles passing the correct attributes and flags/counters to the subject parsers template<typename T> struct is_distinct : T::distinct { }; - + template<typename T, typename Action> struct is_distinct< spirit::qi::action<T,Action> > : T::distinct { }; @@ -27,10 +27,10 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names - template < typename Elements, typename Iterator ,typename Context ,typename Skipper - ,typename Flags ,typename Counters ,typename Attribute, typename NoCasePass> + template < typename Elements, typename Iterator ,typename Context ,typename Skipper + ,typename Flags ,typename Counters ,typename Attribute, typename NoCasePass> struct parse_dispatcher - : public boost::static_visitor<bool> + : public boost::static_visitor<bool> { typedef Iterator iterator_type; @@ -38,60 +38,60 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names typedef Skipper skipper_type; typedef Elements elements_type; - typedef typename add_reference<Attribute>::type attr_reference; + typedef typename add_reference<Attribute>::type attr_reference; public: parse_dispatcher(const Elements &elements,Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper - , Flags &flags, Counters &counters, attr_reference attr) : - elements(elements), first(first), last(last) - , context(context), skipper(skipper) - , flags(flags),counters(counters), attr(attr) + , Context& context, Skipper const& skipper + , Flags &flags, Counters &counters, attr_reference attr) : + elements(elements), first(first), last(last) + , context(context), skipper(skipper) + , flags(flags),counters(counters), attr(attr) {} - + template<typename T> bool operator()(T& idx) const - { + { return call(idx,typename traits::not_is_unused<Attribute>::type()); } - - template <typename Subject,typename Index> - bool call_subject_unused( - Subject const &subject, Iterator &first, Iterator const &last - , Context& context, Skipper const& skipper - , Index& idx ) const - { - Iterator save = first; + + template <typename Subject,typename Index> + bool call_subject_unused( + Subject const &subject, Iterator &first, Iterator const &last + , Context& context, Skipper const& skipper + , Index& idx ) const + { + Iterator save = first; skipper_keyword_marker<Skipper,NoCasePass> marked_skipper(skipper,flags[Index::value],counters[Index::value]); - - if(subject.parse(first,last,context,marked_skipper,unused)) - { + + if(subject.parse(first,last,context,marked_skipper,unused)) + { return true; + } + save = save; + return false; } - save = save; - return false; - } - - - template <typename Subject,typename Index> - bool call_subject( - Subject const &subject, Iterator &first, Iterator const &last - , Context& context, Skipper const& skipper - , Index& idx ) const - { - - Iterator save = first; + + + template <typename Subject,typename Index> + bool call_subject( + Subject const &subject, Iterator &first, Iterator const &last + , Context& context, Skipper const& skipper + , Index& idx ) const + { + + Iterator save = first; skipper_keyword_marker<Skipper,NoCasePass> marked_skipper(skipper,flags[Index::value],counters[Index::value]); - if(subject.parse(first,last,context,marked_skipper,fusion::at_c<Index::value>(attr))) - { + if(subject.parse(first,last,context,marked_skipper,fusion::at_c<Index::value>(attr))) + { return true; + } + save = save; + return false; } - save = save; - return false; - } // Handle unused attributes - template <typename T> bool call(T &idx, mpl::false_) const{ + template <typename T> bool call(T &idx, mpl::false_) const{ typedef typename mpl::at<Elements,T>::type ElementType; if( @@ -99,8 +99,8 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names || skipper.parse(first,last,unused,unused,unused) ){ spirit::qi::skip_over(first, last, skipper); - return call_subject_unused(fusion::at_c<T::value>(elements), first, last, context, skipper, idx ); - } + return call_subject_unused(fusion::at_c<T::value>(elements), first, last, context, skipper, idx ); + } return false; } // Handle normal attributes @@ -110,11 +110,11 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names (!is_distinct<ElementType>::value) || skipper.parse(first,last,unused,unused,unused) ){ - return call_subject(fusion::at_c<T::value>(elements), first, last, context, skipper, idx); - } + return call_subject(fusion::at_c<T::value>(elements), first, last, context, skipper, idx); + } return false; } - + const Elements &elements; Iterator &first; const Iterator &last; @@ -132,7 +132,7 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names typedef typename spirit::detail::as_variant< IndexList >::type parser_index_type; - + /////////////////////////////////////////////////////////////////////////// // build_char_type_sequence // @@ -369,8 +369,8 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names // Make the keyword/parse index entry in the tst parser lookup->add( - traits::get_begin<char_type>(parser.subject.keyword.str), - traits::get_end<char_type>(parser.subject.keyword.str), + traits::get_begin<char_type>(get_string(parser.subject.keyword)), + traits::get_end<char_type>(get_string(parser.subject.keyword)), position ); // Get the initial state of the flags array and store it in the flags initializer @@ -397,8 +397,8 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names { // Make the keyword/parse index entry in the tst parser lookup->add( - traits::get_begin<char_type>(parser.subject.keyword.str), - traits::get_end<char_type>(parser.subject.keyword.str), + traits::get_begin<char_type>(get_string(parser.subject.keyword)), + traits::get_end<char_type>(get_string(parser.subject.keyword)), position ); // Get the initial state of the flags array and store it in the flags initializer @@ -406,19 +406,20 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names return 0; } + template <typename String, bool no_attribute> - const String & get_string(const boost::spirit::qi::literal_string<String,no_attribute> &parser) const + const String get_string(const boost::spirit::qi::literal_string<String,no_attribute> &parser) const { return parser.str; } - template <typename String, bool no_attribute> + template <typename String, bool no_attribute> const typename boost::spirit::qi::no_case_literal_string<String,no_attribute>::string_type & get_string(const boost::spirit::qi::no_case_literal_string<String,no_attribute> &parser) const { return parser.str_lo; } - + shared_ptr<keywords_type> lookup; diff --git a/boost/spirit/repository/home/qi/operator/keywords.hpp b/boost/spirit/repository/home/qi/operator/keywords.hpp index f0382371fa..4933f91104 100644 --- a/boost/spirit/repository/home/qi/operator/keywords.hpp +++ b/boost/spirit/repository/home/qi/operator/keywords.hpp @@ -66,12 +66,12 @@ namespace boost { namespace spirit { namespace repository { namespace qi // kwd directive parser type identification namespace detail { - BOOST_MPL_HAS_XXX_TRAIT_DEF(kwd_parser_id) + BOOST_MPL_HAS_XXX_TRAIT_DEF(kwd_parser_id) BOOST_MPL_HAS_XXX_TRAIT_DEF(complex_kwd_parser_id) - + } - + // kwd directive type query template <typename T> struct is_kwd_parser : detail::has_kwd_parser_id<T> {}; @@ -112,35 +112,35 @@ namespace boost { namespace spirit { namespace repository { namespace qi traits::build_fusion_vector<all_attributes>::type type; }; - + /// Make sure that all subjects are of the kwd type - typedef typename mpl::count_if< - Elements, - mpl::not_< + typedef typename mpl::count_if< + Elements, + mpl::not_< mpl::or_< - is_kwd_parser< - mpl::_1 + is_kwd_parser< + mpl::_1 > , is_complex_kwd_parser< mpl::_1 - > - > + > + > > > non_kwd_subject_count; - - /// If the assertion fails here then you probably forgot to wrap a + + /// If the assertion fails here then you probably forgot to wrap a /// subject of the / operator in a kwd directive BOOST_MPL_ASSERT_RELATION( non_kwd_subject_count::value, ==, 0 ); - + /////////////////////////////////////////////////////////////////////////// // build_parser_tags // - // Builds a boost::variant from an mpl::range_c in order to "mark" every + // Builds a boost::variant from an mpl::range_c in order to "mark" every // parser of the fusion sequence. The integer constant is used in the parser // dispatcher functor in order to use the parser corresponding to the recognised // keyword. /////////////////////////////////////////////////////////////////////////// - + template <typename Sequence> struct build_parser_tags { @@ -149,14 +149,14 @@ namespace boost { namespace spirit { namespace repository { namespace qi // Create an integer_c constant for every parser in the sequence typedef typename mpl::range_c<int, 0, sequence_size::value>::type int_range; - + // Transform the range_c to an mpl vector in order to be able to transform it into a variant typedef typename mpl::copy<int_range, mpl::back_inserter<mpl::vector<> > >::type type; - + }; // Build an index mpl vector typedef typename build_parser_tags< Elements >::type parser_index_vector; - + template <typename idx> struct is_complex_kwd_parser_filter : is_complex_kwd_parser< typename mpl::at<Elements, idx>::type > {}; @@ -166,8 +166,8 @@ namespace boost { namespace spirit { namespace repository { namespace qi {}; // filter out the string kwd directives - typedef typename mpl::filter_view< Elements, is_kwd_parser<mpl_::_> >::type string_keywords; - + typedef typename mpl::filter_view< Elements, is_kwd_parser<mpl::_> >::type string_keywords; + typedef typename mpl::filter_view< parser_index_vector , is_kwd_parser_filter< mpl::_ > >::type string_keyword_indexes; @@ -183,13 +183,13 @@ namespace boost { namespace spirit { namespace repository { namespace qi detail::empty_keywords_list, detail::complex_keywords< complex_keywords_indexes > >::type complex_keywords_type; - - // build a bool array and an integer array which will be used to - // check that the repetition constraints of the kwd parsers are + + // build a bool array and an integer array which will be used to + // check that the repetition constraints of the kwd parsers are // met and bail out a soon as possible typedef boost::array<bool, fusion::result_of::size<Elements>::value> flags_type; typedef boost::array<int, fusion::result_of::size<Elements>::value> counters_type; - + typedef typename mpl::if_< typename mpl::empty<string_keyword_indexes>::type, detail::empty_keywords_list, @@ -200,13 +200,13 @@ namespace boost { namespace spirit { namespace repository { namespace qi flags_type, Modifiers> >::type string_keywords_type; - + keywords(Elements const& elements_) : elements(elements_) , string_keywords_inst(elements,flags_init) , complex_keywords_inst(elements,flags_init) { - } + } template <typename Iterator, typename Context , typename Skipper, typename Attribute> @@ -214,30 +214,30 @@ namespace boost { namespace spirit { namespace repository { namespace qi , Context& context, Skipper const& skipper , Attribute& attr_) const { - // Select which parse function to call + // Select which parse function to call // We need to handle the case where kwd / ikwd directives have been mixed // This is where we decide which function should be called. return parse_impl(first, last, context, skipper, attr_, typename string_keywords_type::requires_one_pass() ); } - + template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse_impl(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper , Attribute& attr_,mpl::true_ /* one pass */) const { - + // wrap the attribute in a tuple if it is not a tuple typename traits::wrap_if_not_tuple<Attribute>::type attr(attr_); flags_type flags(flags_init); //flags.assign(false); - + counters_type counters; counters.assign(0); - + typedef repository::qi::detail::parse_dispatcher<Elements,Iterator, Context, Skipper , flags_type, counters_type , typename traits::wrap_if_not_tuple<Attribute>::type @@ -246,7 +246,7 @@ namespace boost { namespace spirit { namespace repository { namespace qi parser_visitor_type parse_visitor(elements, first, last , context, skipper, flags , counters, attr); - + typedef repository::qi::detail::complex_kwd_function< parser_visitor_type > complex_kwd_function_type; complex_kwd_function_type @@ -255,16 +255,16 @@ namespace boost { namespace spirit { namespace repository { namespace qi // We have a bool array 'flags' with one flag for each parser as well as a 'counter' // array. // The kwd directive sets and increments the counter when a successeful parse occured - // as well as the slot of the corresponding parser to true in the flags array as soon - // the minimum repetition requirement is met and keeps that value to true as long as - // the maximum repetition requirement is met. + // as well as the slot of the corresponding parser to true in the flags array as soon + // the minimum repetition requirement is met and keeps that value to true as long as + // the maximum repetition requirement is met. // The parsing takes place here in two steps: // 1) parse a keyword and fetch the parser index associated with that keyword // 2) call the associated parser and store the parsed value in the matching attribute. while(true) { - + spirit::qi::skip_over(first, last, skipper); Iterator save = first; if (string_keywords_inst.parse(first, last,parse_visitor,skipper)) @@ -272,28 +272,28 @@ namespace boost { namespace spirit { namespace repository { namespace qi save = first; } else { - // restore the position to the last successful keyword parse - first = save; - if(!complex_keywords_inst.parse(complex_function)) - { - first = save; + // restore the position to the last successful keyword parse + first = save; + if(!complex_keywords_inst.parse(complex_function)) + { + first = save; // Check that we are leaving the keywords parser in a successfull state BOOST_FOREACH(bool &valid,flags) { - if(!valid) - { - return false; - } + if(!valid) + { + return false; + } } return true; + } + else + save = first; } - else - save = first; - } } return false; - } - + } + // Handle the mixed kwd and ikwd case template <typename Iterator, typename Context , typename Skipper, typename Attribute> @@ -301,32 +301,32 @@ namespace boost { namespace spirit { namespace repository { namespace qi , Context& context, Skipper const& skipper , Attribute& attr_,mpl::false_ /* two passes */) const { - + // wrap the attribute in a tuple if it is not a tuple typename traits::wrap_if_not_tuple<Attribute>::type attr(attr_); flags_type flags(flags_init); //flags.assign(false); - + counters_type counters; counters.assign(0); - + typedef detail::parse_dispatcher<Elements, Iterator, Context, Skipper , flags_type, counters_type - , typename traits::wrap_if_not_tuple<Attribute>::type + , typename traits::wrap_if_not_tuple<Attribute>::type , mpl::false_> parser_visitor_type; - + typedef detail::parse_dispatcher<Elements, Iterator, Context, Skipper , flags_type, counters_type - , typename traits::wrap_if_not_tuple<Attribute>::type + , typename traits::wrap_if_not_tuple<Attribute>::type , mpl::true_> no_case_parser_visitor_type; - + parser_visitor_type parse_visitor(elements,first,last ,context,skipper,flags,counters,attr); no_case_parser_visitor_type no_case_parse_visitor(elements,first,last - ,context,skipper,flags,counters,attr); - + ,context,skipper,flags,counters,attr); + typedef repository::qi::detail::complex_kwd_function< parser_visitor_type > complex_kwd_function_type; complex_kwd_function_type @@ -336,9 +336,9 @@ namespace boost { namespace spirit { namespace repository { namespace qi // We have a bool array 'flags' with one flag for each parser as well as a 'counter' // array. // The kwd directive sets and increments the counter when a successeful parse occured - // as well as the slot of the corresponding parser to true in the flags array as soon - // the minimum repetition requirement is met and keeps that value to true as long as - // the maximum repetition requirement is met. + // as well as the slot of the corresponding parser to true in the flags array as soon + // the minimum repetition requirement is met and keeps that value to true as long as + // the maximum repetition requirement is met. // The parsing takes place here in two steps: // 1) parse a keyword and fetch the parser index associated with that keyword // 2) call the associated parser and store the parsed value in the matching attribute. @@ -353,29 +353,29 @@ namespace boost { namespace spirit { namespace repository { namespace qi save = first; } else { - first = save; + first = save; - if(!complex_keywords_inst.parse(complex_function)) - { - first = save; + if(!complex_keywords_inst.parse(complex_function)) + { + first = save; // Check that we are leaving the keywords parser in a successfull state BOOST_FOREACH(bool &valid,flags) { - if(!valid) - { - return false; - } + if(!valid) + { + return false; + } } return true; - } - else - { - save = first; - } + } + else + { + save = first; + } } } return false; - } + } template <typename Context> info what(Context& context) const @@ -389,7 +389,7 @@ namespace boost { namespace spirit { namespace repository { namespace qi Elements elements; string_keywords_type string_keywords_inst; complex_keywords_type complex_keywords_inst; - + }; }}}} @@ -406,8 +406,8 @@ namespace boost { namespace spirit { namespace qi { return result_type(ref); } }; - - + + }}} namespace boost { namespace spirit { namespace traits |