diff options
Diffstat (limited to '3rdParty/Boost/src/boost/spirit/home/classic/core/primitives')
5 files changed, 1985 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/impl/numerics.ipp b/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/impl/numerics.ipp new file mode 100644 index 0000000..19586f1 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/impl/numerics.ipp @@ -0,0 +1,478 @@ +/*============================================================================= + Copyright (c) 1998-2003 Joel de Guzman + Copyright (c) 2001-2003 Hartmut Kaiser + http://spirit.sourceforge.net/ + + 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_SPIRIT_NUMERICS_IPP +#define BOOST_SPIRIT_NUMERICS_IPP + +#include <boost/config/no_tr1/cmath.hpp> +#include <limits> + +namespace boost { namespace spirit { + +BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN + + struct sign_parser; // forward declaration only + + namespace impl + { + /////////////////////////////////////////////////////////////////////// + // + // Extract the prefix sign (- or +) + // + /////////////////////////////////////////////////////////////////////// + template <typename ScannerT> + bool + extract_sign(ScannerT const& scan, std::size_t& count) + { + // Extract the sign + count = 0; + bool neg = *scan == '-'; + if (neg || (*scan == '+')) + { + ++scan; + ++count; + return neg; + } + + return false; + } + + /////////////////////////////////////////////////////////////////////// + // + // Traits class for radix specific number conversion + // + // Convert a digit from character representation, ch, to binary + // representation, returned in val. + // Returns whether the conversion was successful. + // + // template<typename CharT> static bool digit(CharT ch, T& val); + // + /////////////////////////////////////////////////////////////////////// + template<const int Radix> + struct radix_traits; + + ////////////////////////////////// Binary + template<> + struct radix_traits<2> + { + template<typename CharT, typename T> + static bool digit(CharT ch, T& val) + { + val = ch - '0'; + return ('0' == ch || '1' == ch); + } + }; + + ////////////////////////////////// Octal + template<> + struct radix_traits<8> + { + template<typename CharT, typename T> + static bool digit(CharT ch, T& val) + { + val = ch - '0'; + return ('0' <= ch && ch <= '7'); + } + }; + + ////////////////////////////////// Decimal + template<> + struct radix_traits<10> + { + template<typename CharT, typename T> + static bool digit(CharT ch, T& val) + { + val = ch - '0'; + return impl::isdigit_(ch); + } + }; + + ////////////////////////////////// Hexadecimal + template<> + struct radix_traits<16> + { + template<typename CharT, typename T> + static bool digit(CharT ch, T& val) + { + if (radix_traits<10>::digit(ch, val)) + return true; + + CharT lc = impl::tolower_(ch); + if ('a' <= lc && lc <= 'f') + { + val = lc - 'a' + 10; + return true; + } + return false; + } + }; + + /////////////////////////////////////////////////////////////////////// + // + // Helper templates for encapsulation of radix specific + // conversion of an input string to an integral value. + // + // main entry point: + // + // extract_int<Radix, MinDigits, MaxDigits, Accumulate> + // ::f(first, last, n, count); + // + // The template parameter Radix represents the radix of the + // number contained in the parsed string. The template + // parameter MinDigits specifies the minimum digits to + // accept. The template parameter MaxDigits specifies the + // maximum digits to parse. A -1 value for MaxDigits will + // make it parse an arbitrarilly large number as long as the + // numeric type can hold it. Accumulate is either + // positive_accumulate<Radix> (default) for parsing positive + // numbers or negative_accumulate<Radix> otherwise. + // Checking is only performed when std::numeric_limits<T>:: + // is_specialized is true. Otherwise, there's no way to + // do the check. + // + // scan.first and scan.last are iterators as usual (i.e. + // first is mutable and is moved forward when a match is + // found), n is a variable that holds the number (passed by + // reference). The number of parsed characters is added to + // count (also passed by reference) + // + // NOTE: + // Returns a non-match, if the number to parse + // overflows (or underflows) the used type. + // + // BEWARE: + // the parameters 'n' and 'count' should be properly + // initialized before calling this function. + // + /////////////////////////////////////////////////////////////////////// +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:4127) //conditional expression is constant +#endif + + template <typename T, int Radix> + struct positive_accumulate + { + // Use this accumulator if number is positive + static bool add(T& n, T digit) + { + if (std::numeric_limits<T>::is_specialized) + { + static T const max = (std::numeric_limits<T>::max)(); + static T const max_div_radix = max/Radix; + + if (n > max_div_radix) + return false; + n *= Radix; + + if (n > max - digit) + return false; + n += digit; + + return true; + } + else + { + n *= Radix; + n += digit; + return true; + } + } + }; + + template <typename T, int Radix> + struct negative_accumulate + { + // Use this accumulator if number is negative + static bool add(T& n, T digit) + { + if (std::numeric_limits<T>::is_specialized) + { + typedef std::numeric_limits<T> num_limits; + static T const min = + (!num_limits::is_integer && num_limits::is_signed && num_limits::has_denorm) ? + -(num_limits::max)() : (num_limits::min)(); + static T const min_div_radix = min/Radix; + + if (n < min_div_radix) + return false; + n *= Radix; + + if (n < min + digit) + return false; + n -= digit; + + return true; + } + else + { + n *= Radix; + n -= digit; + return true; + } + } + }; + + template <int MaxDigits> + inline bool allow_more_digits(std::size_t i) + { + return i < MaxDigits; + } + + template <> + inline bool allow_more_digits<-1>(std::size_t) + { + return true; + } + + ////////////////////////////////// + template < + int Radix, unsigned MinDigits, int MaxDigits, + typename Accumulate + > + struct extract_int + { + template <typename ScannerT, typename T> + static bool + f(ScannerT& scan, T& n, std::size_t& count) + { + std::size_t i = 0; + T digit; + while( allow_more_digits<MaxDigits>(i) && !scan.at_end() && + radix_traits<Radix>::digit(*scan, digit) ) + { + if (!Accumulate::add(n, digit)) + return false; // Overflow + ++i, ++scan, ++count; + } + return i >= MinDigits; + } + }; + + /////////////////////////////////////////////////////////////////////// + // + // uint_parser_impl class + // + /////////////////////////////////////////////////////////////////////// + template < + typename T = unsigned, + int Radix = 10, + unsigned MinDigits = 1, + int MaxDigits = -1 + > + struct uint_parser_impl + : parser<uint_parser_impl<T, Radix, MinDigits, MaxDigits> > + { + typedef uint_parser_impl<T, Radix, MinDigits, MaxDigits> self_t; + + template <typename ScannerT> + struct result + { + typedef typename match_result<ScannerT, T>::type type; + }; + + template <typename ScannerT> + typename parser_result<self_t, ScannerT>::type + parse(ScannerT const& scan) const + { + if (!scan.at_end()) + { + T n = 0; + std::size_t count = 0; + typename ScannerT::iterator_t save = scan.first; + if (extract_int<Radix, MinDigits, MaxDigits, + positive_accumulate<T, Radix> >::f(scan, n, count)) + { + return scan.create_match(count, n, save, scan.first); + } + // return no-match if number overflows + } + return scan.no_match(); + } + }; + + /////////////////////////////////////////////////////////////////////// + // + // int_parser_impl class + // + /////////////////////////////////////////////////////////////////////// + template < + typename T = unsigned, + int Radix = 10, + unsigned MinDigits = 1, + int MaxDigits = -1 + > + struct int_parser_impl + : parser<int_parser_impl<T, Radix, MinDigits, MaxDigits> > + { + typedef int_parser_impl<T, Radix, MinDigits, MaxDigits> self_t; + + template <typename ScannerT> + struct result + { + typedef typename match_result<ScannerT, T>::type type; + }; + + template <typename ScannerT> + typename parser_result<self_t, ScannerT>::type + parse(ScannerT const& scan) const + { + typedef extract_int<Radix, MinDigits, MaxDigits, + negative_accumulate<T, Radix> > extract_int_neg_t; + typedef extract_int<Radix, MinDigits, MaxDigits, + positive_accumulate<T, Radix> > extract_int_pos_t; + + if (!scan.at_end()) + { + T n = 0; + std::size_t count = 0; + typename ScannerT::iterator_t save = scan.first; + + bool hit = impl::extract_sign(scan, count); + + if (hit) + hit = extract_int_neg_t::f(scan, n, count); + else + hit = extract_int_pos_t::f(scan, n, count); + + if (hit) + return scan.create_match(count, n, save, scan.first); + else + scan.first = save; + // return no-match if number overflows or underflows + } + return scan.no_match(); + } + }; + + /////////////////////////////////////////////////////////////////////// + // + // real_parser_impl class + // + /////////////////////////////////////////////////////////////////////// + template <typename RT, typename T, typename RealPoliciesT> + struct real_parser_impl + { + typedef real_parser_impl<RT, T, RealPoliciesT> self_t; + + template <typename ScannerT> + RT parse_main(ScannerT const& scan) const + { + if (scan.at_end()) + return scan.no_match(); + typename ScannerT::iterator_t save = scan.first; + + typedef typename parser_result<sign_parser, ScannerT>::type + sign_match_t; + typedef typename parser_result<chlit<>, ScannerT>::type + exp_match_t; + + sign_match_t sign_match = RealPoliciesT::parse_sign(scan); + std::size_t count = sign_match ? sign_match.length() : 0; + bool neg = sign_match.has_valid_attribute() ? + sign_match.value() : false; + + RT n_match = RealPoliciesT::parse_n(scan); + T n = n_match.has_valid_attribute() ? + n_match.value() : T(0); + bool got_a_number = n_match; + exp_match_t e_hit; + + if (!got_a_number && !RealPoliciesT::allow_leading_dot) + return scan.no_match(); + else + count += n_match.length(); + + if (neg) + n = -n; + + if (RealPoliciesT::parse_dot(scan)) + { + // 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. + + if (RT hit = RealPoliciesT::parse_frac_n(scan)) + { +#if !defined(BOOST_NO_STDC_NAMESPACE) + using namespace std; // allow for ADL to find pow() +#endif + hit.value(hit.value() + * pow(T(10), T(-hit.length()))); + if (neg) + n -= hit.value(); + else + n += hit.value(); + count += hit.length() + 1; + + } + + else if (!got_a_number || + !RealPoliciesT::allow_trailing_dot) + return scan.no_match(); + + e_hit = RealPoliciesT::parse_exp(scan); + } + else + { + // We have reached a point where we + // still haven't seen a number at all. + // We return early with a no-match. + if (!got_a_number) + return scan.no_match(); + + // If we must expect a dot and we didn't see + // an exponent, return early with a no-match. + e_hit = RealPoliciesT::parse_exp(scan); + if (RealPoliciesT::expect_dot && !e_hit) + return scan.no_match(); + } + + 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. + if (RT e_n_hit = RealPoliciesT::parse_exp_n(scan)) + { +#if !defined(BOOST_NO_STDC_NAMESPACE) + using namespace std; // allow for ADL to find pow() +#endif + n *= pow(T(10), T(e_n_hit.value())); + count += e_n_hit.length() + e_hit.length(); + } + else + { + // Oops, no exponent, return a no-match + return scan.no_match(); + } + } + + return scan.create_match(count, n, save, scan.first); + } + + template <typename ScannerT> + static RT parse(ScannerT const& scan) + { + static self_t this_; + return impl::implicit_lexeme_parse<RT>(this_, scan, scan); + } + }; + +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + + } // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +BOOST_SPIRIT_CLASSIC_NAMESPACE_END + +}} // namespace boost::spirit + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/impl/primitives.ipp b/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/impl/primitives.ipp new file mode 100644 index 0000000..152e5b1 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/impl/primitives.ipp @@ -0,0 +1,476 @@ +/*============================================================================= + Copyright (c) 1998-2003 Joel de Guzman + Copyright (c) 2003 Martin Wille + http://spirit.sourceforge.net/ + + 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) +=============================================================================*/ +#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 + +#if defined(BOOST_MSVC) +# pragma warning (push) +# pragma warning(disable:4800) +#endif + +namespace boost { namespace spirit { + +BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN + + template <typename DrivedT> struct char_parser; + + namespace impl + { + template <typename IteratorT> + inline IteratorT + get_last(IteratorT first) + { + while (*first) + first++; + return first; + } + + template< + typename RT, + typename IteratorT, + typename ScannerT> + inline RT + string_parser_parse( + IteratorT str_first, + IteratorT str_last, + ScannerT& scan) + { + typedef typename ScannerT::iterator_t iterator_t; + iterator_t saved = scan.first; + std::size_t slen = str_last - str_first; + + while (str_first != str_last) + { + if (scan.at_end() || (*str_first != *scan)) + return scan.no_match(); + ++str_first; + ++scan; + } + + return scan.create_match(slen, nil_t(), saved, scan.first); + } + + /////////////////////////////////////////////////////////////////////////// + // + // Conversion from char_type to int_type + // + /////////////////////////////////////////////////////////////////////////// + +#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. + // + // For UDT, one may override: + // + // isalnum + // isalpha + // iscntrl + // isdigit + // isgraph + // islower + // isprint + // ispunct + // isspace + // isupper + // isxdigit + // isblank + // isupper + // tolower + // toupper + // + // in a namespace suitable for Argument Dependent lookup or in + // namespace std (disallowed by the standard). + + template <typename CharT> + struct char_type_char_traits_helper + { + typedef CharT char_type; + typedef typename BOOST_SPIRIT_CHAR_TRAITS_NAMESPACE + ::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); + } + + static char_type to_char_type(int_type i) + { + return BOOST_SPIRIT_CHAR_TRAITS_NAMESPACE + ::char_traits<CharT>::to_char_type(i); + } + }; + + template <typename CharT> + struct char_traits_helper + { + typedef CharT char_type; + typedef CharT int_type; + + static CharT & to_int_type(CharT & c) + { + return c; + } + + static CharT & to_char_type(CharT & c) + { + return c; + } + }; + + template <> + struct char_traits_helper<char> + : char_type_char_traits_helper<char> + { + }; + +#if !defined(BOOST_NO_CWCTYPE) + + template <> + struct char_traits_helper<wchar_t> + : char_type_char_traits_helper<wchar_t> + { + }; + +#endif + + template <typename CharT> + inline typename char_traits_helper<CharT>::int_type + to_int_type(CharT c) + { + return char_traits_helper<CharT>::to_int_type(c); + } + + template <typename CharT> + inline CharT + to_char_type(typename char_traits_helper<CharT>::int_type c) + { + return char_traits_helper<CharT>::to_char_type(c); + } + + /////////////////////////////////////////////////////////////////////// + // + // Convenience functions + // + /////////////////////////////////////////////////////////////////////// + + template <typename CharT> + inline bool + isalnum_(CharT c) + { + using namespace std; + return isalnum(to_int_type(c)) ? true : false; + } + + template <typename CharT> + inline bool + isalpha_(CharT c) + { + using namespace std; + return isalpha(to_int_type(c)) ? true : false; + } + + template <typename CharT> + inline bool + iscntrl_(CharT c) + { + using namespace std; + return iscntrl(to_int_type(c)) ? true : false; + } + + template <typename CharT> + inline bool + isdigit_(CharT c) + { + using namespace std; + return isdigit(to_int_type(c)) ? true : false; + } + + template <typename CharT> + inline bool + isgraph_(CharT c) + { + using namespace std; + return isgraph(to_int_type(c)) ? true : false; + } + + template <typename CharT> + inline bool + islower_(CharT c) + { + using namespace std; + return islower(to_int_type(c)) ? true : false; + } + + template <typename CharT> + inline bool + isprint_(CharT c) + { + using namespace std; + return isprint(to_int_type(c)) ? true : false; + } + + template <typename CharT> + inline bool + ispunct_(CharT c) + { + using namespace std; + return ispunct(to_int_type(c)) ? true : false; + } + + template <typename CharT> + inline bool + isspace_(CharT c) + { + using namespace std; + return isspace(to_int_type(c)) ? true : false; + } + + template <typename CharT> + inline bool + isupper_(CharT c) + { + using namespace std; + return isupper(to_int_type(c)) ? true : false; + } + + template <typename CharT> + inline bool + isxdigit_(CharT c) + { + using namespace std; + return isxdigit(to_int_type(c)) ? true : false; + } + + template <typename CharT> + inline bool + isblank_(CharT c) + { + return (c == ' ' || c == '\t'); + } + + template <typename CharT> + inline CharT + tolower_(CharT c) + { + using namespace std; + return to_char_type<CharT>(tolower(to_int_type(c))); + } + + template <typename CharT> + inline CharT + toupper_(CharT c) + { + using namespace std; + return to_char_type<CharT>(toupper(to_int_type(c))); + } + +#if !defined(BOOST_NO_CWCTYPE) + + inline bool + isalnum_(wchar_t c) + { + using namespace std; + return iswalnum(to_int_type(c)) ? true : false; + } + + inline bool + isalpha_(wchar_t c) + { + using namespace std; + return iswalpha(to_int_type(c)) ? true : false; + } + + inline bool + iscntrl_(wchar_t c) + { + using namespace std; + return iswcntrl(to_int_type(c)) ? true : false; + } + + inline bool + isdigit_(wchar_t c) + { + using namespace std; + return iswdigit(to_int_type(c)) ? true : false; + } + + inline bool + isgraph_(wchar_t c) + { + using namespace std; + return iswgraph(to_int_type(c)) ? true : false; + } + + inline bool + islower_(wchar_t c) + { + using namespace std; + return iswlower(to_int_type(c)) ? true : false; + } + + inline bool + isprint_(wchar_t c) + { + using namespace std; + return iswprint(to_int_type(c)) ? true : false; + } + + inline bool + ispunct_(wchar_t c) + { + using namespace std; + return iswpunct(to_int_type(c)) ? true : false; + } + + inline bool + isspace_(wchar_t c) + { + using namespace std; + return iswspace(to_int_type(c)) ? true : false; + } + + inline bool + isupper_(wchar_t c) + { + using namespace std; + return iswupper(to_int_type(c)) ? true : false; + } + + inline bool + isxdigit_(wchar_t c) + { + using namespace std; + return iswxdigit(to_int_type(c)) ? true : false; + } + + inline bool + isblank_(wchar_t c) + { + return (c == L' ' || c == L'\t'); + } + + inline wchar_t + tolower_(wchar_t c) + { + using namespace std; + return to_char_type<wchar_t>(towlower(to_int_type(c))); + } + + inline wchar_t + toupper_(wchar_t c) + { + using namespace std; + return to_char_type<wchar_t>(towupper(to_int_type(c))); + } + +#endif // !defined(BOOST_NO_CWCTYPE) + +} + +BOOST_SPIRIT_CLASSIC_NAMESPACE_END + +}} // namespace boost::spirit::impl + +#ifdef BOOST_MSVC +#pragma warning (pop) +#endif + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/numerics.hpp b/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/numerics.hpp new file mode 100644 index 0000000..20ea091 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/numerics.hpp @@ -0,0 +1,289 @@ +/*============================================================================= + Copyright (c) 1998-2003 Joel de Guzman + Copyright (c) 2001-2003 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) +=============================================================================*/ +#ifndef BOOST_SPIRIT_NUMERICS_HPP +#define BOOST_SPIRIT_NUMERICS_HPP + +#include <boost/config.hpp> +#include <boost/spirit/home/classic/namespace.hpp> +#include <boost/spirit/home/classic/core/parser.hpp> +#include <boost/spirit/home/classic/core/composite/directives.hpp> + +#include <boost/spirit/home/classic/core/primitives/numerics_fwd.hpp> +#include <boost/spirit/home/classic/core/primitives/impl/numerics.ipp> + +namespace boost { namespace spirit { + +BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN + + /////////////////////////////////////////////////////////////////////////// + // + // uint_parser class + // + /////////////////////////////////////////////////////////////////////////// + template < + typename T, + int Radix, + unsigned MinDigits, + int MaxDigits + > + struct uint_parser : parser<uint_parser<T, Radix, MinDigits, MaxDigits> > + { + typedef uint_parser<T, Radix, MinDigits, MaxDigits> self_t; + + template <typename ScannerT> + struct result + { + typedef typename match_result<ScannerT, T>::type type; + }; + + template <typename ScannerT> + typename parser_result<self_t, ScannerT>::type + parse(ScannerT const& scan) const + { + typedef impl::uint_parser_impl<T, Radix, MinDigits, MaxDigits> impl_t; + typedef typename parser_result<impl_t, ScannerT>::type result_t; + return impl::contiguous_parser_parse<result_t>(impl_t(), scan, scan); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // int_parser class + // + /////////////////////////////////////////////////////////////////////////// + template < + typename T, + int Radix, + unsigned MinDigits, + int MaxDigits + > + struct int_parser : parser<int_parser<T, Radix, MinDigits, MaxDigits> > + { + typedef int_parser<T, Radix, MinDigits, MaxDigits> self_t; + + template <typename ScannerT> + struct result + { + typedef typename match_result<ScannerT, T>::type type; + }; + + template <typename ScannerT> + typename parser_result<self_t, ScannerT>::type + parse(ScannerT const& scan) const + { + typedef impl::int_parser_impl<T, Radix, MinDigits, MaxDigits> impl_t; + typedef typename parser_result<impl_t, ScannerT>::type result_t; + return impl::contiguous_parser_parse<result_t>(impl_t(), scan, scan); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // uint_parser/int_parser instantiations + // + /////////////////////////////////////////////////////////////////////////// + int_parser<int> const + int_p = int_parser<int>(); + + uint_parser<unsigned> const + uint_p = uint_parser<unsigned>(); + + uint_parser<unsigned, 2> const + bin_p = uint_parser<unsigned, 2>(); + + uint_parser<unsigned, 8> const + oct_p = uint_parser<unsigned, 8>(); + + uint_parser<unsigned, 16> const + hex_p = uint_parser<unsigned, 16>(); + + /////////////////////////////////////////////////////////////////////////// + // + // sign_parser class + // + /////////////////////////////////////////////////////////////////////////// + namespace impl + { + // Utility to extract the prefix sign ('-' | '+') + template <typename ScannerT> + bool extract_sign(ScannerT const& scan, std::size_t& count); + } + + struct sign_parser : public parser<sign_parser> + { + typedef sign_parser self_t; + + template <typename ScannerT> + struct result + { + typedef typename match_result<ScannerT, bool>::type type; + }; + + sign_parser() {} + + template <typename ScannerT> + typename parser_result<self_t, ScannerT>::type + parse(ScannerT const& scan) const + { + if (!scan.at_end()) + { + std::size_t length; + typename ScannerT::iterator_t save(scan.first); + bool neg = impl::extract_sign(scan, length); + if (length) + return scan.create_match(1, neg, save, scan.first); + } + return scan.no_match(); + } + }; + + sign_parser const sign_p = sign_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // default real number policies + // + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct ureal_parser_policies + { + // trailing dot policy suggested suggested by Gustavo Guerra + BOOST_STATIC_CONSTANT(bool, allow_leading_dot = true); + BOOST_STATIC_CONSTANT(bool, allow_trailing_dot = true); + BOOST_STATIC_CONSTANT(bool, expect_dot = false); + + typedef uint_parser<T, 10, 1, -1> uint_parser_t; + typedef int_parser<T, 10, 1, -1> int_parser_t; + + template <typename ScannerT> + static typename match_result<ScannerT, nil_t>::type + parse_sign(ScannerT& scan) + { + return scan.no_match(); + } + + template <typename ScannerT> + static typename parser_result<uint_parser_t, ScannerT>::type + parse_n(ScannerT& scan) + { + return uint_parser_t().parse(scan); + } + + template <typename ScannerT> + static typename parser_result<chlit<>, ScannerT>::type + parse_dot(ScannerT& scan) + { + return ch_p('.').parse(scan); + } + + template <typename ScannerT> + static typename parser_result<uint_parser_t, ScannerT>::type + parse_frac_n(ScannerT& scan) + { + return uint_parser_t().parse(scan); + } + + template <typename ScannerT> + static typename parser_result<chlit<>, ScannerT>::type + parse_exp(ScannerT& scan) + { + return as_lower_d['e'].parse(scan); + } + + template <typename ScannerT> + static typename parser_result<int_parser_t, ScannerT>::type + parse_exp_n(ScannerT& scan) + { + return int_parser_t().parse(scan); + } + }; + + template <typename T> + struct real_parser_policies : public ureal_parser_policies<T> + { + template <typename ScannerT> + static typename parser_result<sign_parser, ScannerT>::type + parse_sign(ScannerT& scan) + { + return sign_p.parse(scan); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // real_parser class + // + /////////////////////////////////////////////////////////////////////////// + template < + typename T, + typename RealPoliciesT + > + struct real_parser + : public parser<real_parser<T, RealPoliciesT> > + { + typedef real_parser<T, RealPoliciesT> self_t; + + template <typename ScannerT> + struct result + { + typedef typename match_result<ScannerT, T>::type type; + }; + + real_parser() {} + + template <typename ScannerT> + typename parser_result<self_t, ScannerT>::type + parse(ScannerT const& scan) const + { + typedef typename parser_result<self_t, ScannerT>::type result_t; + return impl::real_parser_impl<result_t, T, RealPoliciesT>::parse(scan); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // real_parser instantiations + // + /////////////////////////////////////////////////////////////////////////// + real_parser<double, ureal_parser_policies<double> > const + ureal_p = real_parser<double, ureal_parser_policies<double> >(); + + real_parser<double, real_parser_policies<double> > const + real_p = real_parser<double, real_parser_policies<double> >(); + + /////////////////////////////////////////////////////////////////////////// + // + // strict reals (do not allow plain integers (no decimal point)) + // + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct strict_ureal_parser_policies : public ureal_parser_policies<T> + { + BOOST_STATIC_CONSTANT(bool, expect_dot = true); + }; + + template <typename T> + struct strict_real_parser_policies : public real_parser_policies<T> + { + BOOST_STATIC_CONSTANT(bool, expect_dot = true); + }; + + real_parser<double, strict_ureal_parser_policies<double> > const + strict_ureal_p + = real_parser<double, strict_ureal_parser_policies<double> >(); + + real_parser<double, strict_real_parser_policies<double> > const + strict_real_p + = real_parser<double, strict_real_parser_policies<double> >(); + +BOOST_SPIRIT_CLASSIC_NAMESPACE_END + +}} // namespace BOOST_SPIRIT_CLASSIC_NS + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/numerics_fwd.hpp b/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/numerics_fwd.hpp new file mode 100644 index 0000000..b0f20d9 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/numerics_fwd.hpp @@ -0,0 +1,88 @@ +/*============================================================================= + Copyright (C) 2006 Tobias Schwinger + 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_NUMERICS_FWD_HPP) +# define BOOST_SPIRIT_NUMERICS_FWD_HPP + +#include <boost/spirit/home/classic/namespace.hpp> + +namespace boost { namespace spirit { + +BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN + + /////////////////////////////////////////////////////////////////////////// + // + // uint_parser class + // + /////////////////////////////////////////////////////////////////////////// + template < + typename T = unsigned, + int Radix = 10, + unsigned MinDigits = 1, + int MaxDigits = -1 + > + struct uint_parser; + + /////////////////////////////////////////////////////////////////////////// + // + // int_parser class + // + /////////////////////////////////////////////////////////////////////////// + template < + typename T = unsigned, + int Radix = 10, + unsigned MinDigits = 1, + int MaxDigits = -1 + > + struct int_parser; + + /////////////////////////////////////////////////////////////////////////// + // + // sign_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct sign_parser; + + /////////////////////////////////////////////////////////////////////////// + // + // default real number policies + // + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct ureal_parser_policies; + + template <typename T> + struct real_parser_policies; + + /////////////////////////////////////////////////////////////////////////// + // + // real_parser class + // + /////////////////////////////////////////////////////////////////////////// + template < + typename T = double, + typename RealPoliciesT = ureal_parser_policies<T> + > + struct real_parser; + + /////////////////////////////////////////////////////////////////////////// + // + // strict reals (do not allow plain integers (no decimal point)) + // + /////////////////////////////////////////////////////////////////////////// + template <typename T> + struct strict_ureal_parser_policies; + + template <typename T> + struct strict_real_parser_policies; + +BOOST_SPIRIT_CLASSIC_NAMESPACE_END + +}} // namespace BOOST_SPIRIT_CLASSIC_NS + +#endif + diff --git a/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/primitives.hpp b/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/primitives.hpp new file mode 100644 index 0000000..d89585b --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/classic/core/primitives/primitives.hpp @@ -0,0 +1,654 @@ +/*============================================================================= + Copyright (c) 1998-2003 Joel de Guzman + Copyright (c) 2003 Martin Wille + 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_PRIMITIVES_HPP) +#define BOOST_SPIRIT_PRIMITIVES_HPP + +#include <boost/ref.hpp> +#include <boost/spirit/home/classic/namespace.hpp> +#include <boost/spirit/home/classic/core/assert.hpp> +#include <boost/spirit/home/classic/core/parser.hpp> +#include <boost/spirit/home/classic/core/composite/impl/directives.ipp> +#include <boost/spirit/home/classic/core/primitives/impl/primitives.ipp> + +#ifdef BOOST_MSVC +#pragma warning (push) +#pragma warning(disable : 4512) +#endif + +namespace boost { namespace spirit { + +BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN + + /////////////////////////////////////////////////////////////////////////// + // + // char_parser class + // + /////////////////////////////////////////////////////////////////////////// + template <typename DerivedT> + struct char_parser : public parser<DerivedT> + { + typedef DerivedT self_t; + template <typename ScannerT> + struct result + { + typedef typename match_result< + ScannerT, + typename ScannerT::value_t + >::type type; + }; + + template <typename ScannerT> + typename parser_result<self_t, ScannerT>::type + parse(ScannerT const& scan) const + { + typedef typename parser_result<self_t, ScannerT>::type result_t; + typedef typename ScannerT::value_t value_t; + typedef typename ScannerT::iterator_t iterator_t; + + if (!scan.at_end()) + { + value_t ch = *scan; + if (this->derived().test(ch)) + { + iterator_t save(scan.first); + ++scan.first; + return scan.create_match(1, ch, save, scan.first); + } + } + return scan.no_match(); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // negation of char_parsers + // + /////////////////////////////////////////////////////////////////////////// + template <typename PositiveT> + struct negated_char_parser + : public char_parser<negated_char_parser<PositiveT> > + { + typedef negated_char_parser<PositiveT> self_t; + typedef PositiveT positive_t; + + negated_char_parser(positive_t const& p) + : positive(p.derived()) {} + + template <typename T> + bool test(T ch) const + { + return !positive.test(ch); + } + + positive_t const positive; + }; + + template <typename ParserT> + inline negated_char_parser<ParserT> + operator~(char_parser<ParserT> const& p) + { + return negated_char_parser<ParserT>(p.derived()); + } + + template <typename ParserT> + inline ParserT + operator~(negated_char_parser<ParserT> const& n) + { + return n.positive; + } + + /////////////////////////////////////////////////////////////////////////// + // + // chlit class + // + /////////////////////////////////////////////////////////////////////////// + template <typename CharT = char> + struct chlit : public char_parser<chlit<CharT> > + { + chlit(CharT ch_) + : ch(ch_) {} + + template <typename T> + bool test(T ch_) const + { + return ch_ == ch; + } + + CharT ch; + }; + + template <typename CharT> + inline chlit<CharT> + ch_p(CharT ch) + { + return chlit<CharT>(ch); + } + + // This should take care of ch_p("a") "bugs" + template <typename CharT, std::size_t N> + inline chlit<CharT> + ch_p(CharT const (& str)[N]) + { + // ch_p's argument should be a single character or a null-terminated + // string with a single character + BOOST_STATIC_ASSERT(N < 3); + return chlit<CharT>(str[0]); + } + + /////////////////////////////////////////////////////////////////////////// + // + // range class + // + /////////////////////////////////////////////////////////////////////////// + template <typename CharT = char> + struct range : public char_parser<range<CharT> > + { + range(CharT first_, CharT last_) + : first(first_), last(last_) + { + BOOST_SPIRIT_ASSERT(!(last < first)); + } + + template <typename T> + bool test(T ch) const + { + return !(CharT(ch) < first) && !(last < CharT(ch)); + } + + CharT first; + CharT last; + }; + + template <typename CharT> + inline range<CharT> + range_p(CharT first, CharT last) + { + return range<CharT>(first, last); + } + + /////////////////////////////////////////////////////////////////////////// + // + // chseq class + // + /////////////////////////////////////////////////////////////////////////// + template <typename IteratorT = char const*> + class chseq : public parser<chseq<IteratorT> > + { + public: + + typedef chseq<IteratorT> self_t; + + chseq(IteratorT first_, IteratorT last_) + : first(first_), last(last_) {} + + chseq(IteratorT first_) + : first(first_), last(impl::get_last(first_)) {} + + template <typename ScannerT> + typename parser_result<self_t, ScannerT>::type + parse(ScannerT const& scan) const + { + typedef typename boost::unwrap_reference<IteratorT>::type striter_t; + typedef typename parser_result<self_t, ScannerT>::type result_t; + return impl::string_parser_parse<result_t>( + striter_t(first), + striter_t(last), + scan); + } + + private: + + IteratorT first; + IteratorT last; + }; + + template <typename CharT> + inline chseq<CharT const*> + chseq_p(CharT const* str) + { + return chseq<CharT const*>(str); + } + + template <typename IteratorT> + inline chseq<IteratorT> + chseq_p(IteratorT first, IteratorT last) + { + return chseq<IteratorT>(first, last); + } + + /////////////////////////////////////////////////////////////////////////// + // + // strlit class + // + /////////////////////////////////////////////////////////////////////////// + template <typename IteratorT = char const*> + class strlit : public parser<strlit<IteratorT> > + { + public: + + typedef strlit<IteratorT> self_t; + + strlit(IteratorT first, IteratorT last) + : seq(first, last) {} + + strlit(IteratorT first) + : seq(first) {} + + template <typename ScannerT> + typename parser_result<self_t, ScannerT>::type + parse(ScannerT const& scan) const + { + typedef typename parser_result<self_t, ScannerT>::type result_t; + return impl::contiguous_parser_parse<result_t> + (seq, scan, scan); + } + + private: + + chseq<IteratorT> seq; + }; + + template <typename CharT> + inline strlit<CharT const*> + str_p(CharT const* str) + { + return strlit<CharT const*>(str); + } + + template <typename CharT> + inline strlit<CharT *> + str_p(CharT * str) + { + return strlit<CharT *>(str); + } + + template <typename IteratorT> + inline strlit<IteratorT> + str_p(IteratorT first, IteratorT last) + { + return strlit<IteratorT>(first, last); + } + + // This should take care of str_p('a') "bugs" + template <typename CharT> + inline chlit<CharT> + str_p(CharT ch) + { + return chlit<CharT>(ch); + } + + /////////////////////////////////////////////////////////////////////////// + // + // nothing_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct nothing_parser : public parser<nothing_parser> + { + typedef nothing_parser self_t; + + nothing_parser() {} + + template <typename ScannerT> + typename parser_result<self_t, ScannerT>::type + parse(ScannerT const& scan) const + { + return scan.no_match(); + } + }; + + nothing_parser const nothing_p = nothing_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // anychar_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct anychar_parser : public char_parser<anychar_parser> + { + typedef anychar_parser self_t; + + anychar_parser() {} + + template <typename CharT> + bool test(CharT) const + { + return true; + } + }; + + anychar_parser const anychar_p = anychar_parser(); + + inline nothing_parser + operator~(anychar_parser) + { + return nothing_p; + } + + /////////////////////////////////////////////////////////////////////////// + // + // alnum_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct alnum_parser : public char_parser<alnum_parser> + { + typedef alnum_parser self_t; + + alnum_parser() {} + + template <typename CharT> + bool test(CharT ch) const + { + return impl::isalnum_(ch); + } + }; + + alnum_parser const alnum_p = alnum_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // alpha_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct alpha_parser : public char_parser<alpha_parser> + { + typedef alpha_parser self_t; + + alpha_parser() {} + + template <typename CharT> + bool test(CharT ch) const + { + return impl::isalpha_(ch); + } + }; + + alpha_parser const alpha_p = alpha_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // cntrl_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct cntrl_parser : public char_parser<cntrl_parser> + { + typedef cntrl_parser self_t; + + cntrl_parser() {} + + template <typename CharT> + bool test(CharT ch) const + { + return impl::iscntrl_(ch); + } + }; + + cntrl_parser const cntrl_p = cntrl_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // digit_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct digit_parser : public char_parser<digit_parser> + { + typedef digit_parser self_t; + + digit_parser() {} + + template <typename CharT> + bool test(CharT ch) const + { + return impl::isdigit_(ch); + } + }; + + digit_parser const digit_p = digit_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // graph_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct graph_parser : public char_parser<graph_parser> + { + typedef graph_parser self_t; + + graph_parser() {} + + template <typename CharT> + bool test(CharT ch) const + { + return impl::isgraph_(ch); + } + }; + + graph_parser const graph_p = graph_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // lower_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct lower_parser : public char_parser<lower_parser> + { + typedef lower_parser self_t; + + lower_parser() {} + + template <typename CharT> + bool test(CharT ch) const + { + return impl::islower_(ch); + } + }; + + lower_parser const lower_p = lower_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // print_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct print_parser : public char_parser<print_parser> + { + typedef print_parser self_t; + + print_parser() {} + + template <typename CharT> + bool test(CharT ch) const + { + return impl::isprint_(ch); + } + }; + + print_parser const print_p = print_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // punct_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct punct_parser : public char_parser<punct_parser> + { + typedef punct_parser self_t; + + punct_parser() {} + + template <typename CharT> + bool test(CharT ch) const + { + return impl::ispunct_(ch); + } + }; + + punct_parser const punct_p = punct_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // blank_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct blank_parser : public char_parser<blank_parser> + { + typedef blank_parser self_t; + + blank_parser() {} + + template <typename CharT> + bool test(CharT ch) const + { + return impl::isblank_(ch); + } + }; + + blank_parser const blank_p = blank_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // space_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct space_parser : public char_parser<space_parser> + { + typedef space_parser self_t; + + space_parser() {} + + template <typename CharT> + bool test(CharT ch) const + { + return impl::isspace_(ch); + } + }; + + space_parser const space_p = space_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // upper_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct upper_parser : public char_parser<upper_parser> + { + typedef upper_parser self_t; + + upper_parser() {} + + template <typename CharT> + bool test(CharT ch) const + { + return impl::isupper_(ch); + } + }; + + upper_parser const upper_p = upper_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // xdigit_parser class + // + /////////////////////////////////////////////////////////////////////////// + struct xdigit_parser : public char_parser<xdigit_parser> + { + typedef xdigit_parser self_t; + + xdigit_parser() {} + + template <typename CharT> + bool test(CharT ch) const + { + return impl::isxdigit_(ch); + } + }; + + xdigit_parser const xdigit_p = xdigit_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // eol_parser class (contributed by Martin Wille) + // + /////////////////////////////////////////////////////////////////////////// + struct eol_parser : public parser<eol_parser> + { + typedef eol_parser self_t; + + eol_parser() {} + + template <typename ScannerT> + typename parser_result<self_t, ScannerT>::type + parse(ScannerT const& scan) const + { + typename ScannerT::iterator_t save = scan.first; + std::size_t len = 0; + + if (!scan.at_end() && *scan == '\r') // CR + { + ++scan.first; + ++len; + } + + // Don't call skipper here + if (scan.first != scan.last && *scan == '\n') // LF + { + ++scan.first; + ++len; + } + + if (len) + return scan.create_match(len, nil_t(), save, scan.first); + return scan.no_match(); + } + }; + + eol_parser const eol_p = eol_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // end_parser class (suggested by Markus Schoepflin) + // + /////////////////////////////////////////////////////////////////////////// + struct end_parser : public parser<end_parser> + { + typedef end_parser self_t; + + end_parser() {} + + template <typename ScannerT> + typename parser_result<self_t, ScannerT>::type + parse(ScannerT const& scan) const + { + if (scan.at_end()) + return scan.empty_match(); + return scan.no_match(); + } + }; + + end_parser const end_p = end_parser(); + + /////////////////////////////////////////////////////////////////////////// + // + // the pizza_p parser :-) + // + /////////////////////////////////////////////////////////////////////////// + inline strlit<char const*> const + pizza_p(char const* your_favorite_pizza) + { + return your_favorite_pizza; + } + +BOOST_SPIRIT_CLASSIC_NAMESPACE_END + +}} // namespace BOOST_SPIRIT_CLASSIC_NS + +#ifdef BOOST_MSVC +#pragma warning (pop) +#endif + +#endif |