/*============================================================================= Copyright (c) 2001-2010 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_REAL_APRIL_18_2006_0850AM) #define BOOST_SPIRIT_REAL_APRIL_18_2006_0850AM #if defined(_MSC_VER) #pragma once #endif #include #include #include #include #include #include #include namespace boost { namespace spirit { /////////////////////////////////////////////////////////////////////////// // Enablers /////////////////////////////////////////////////////////////////////////// template <> struct use_terminal // enables float_ : mpl::true_ {}; template <> struct use_terminal // enables double_ : mpl::true_ {}; template <> struct use_terminal // enables long_double : mpl::true_ {}; }} namespace boost { namespace spirit { namespace qi { using spirit::float_; using spirit::float__type; using spirit::double_; using spirit::double__type; using spirit::long_double; using spirit::long_double_type; /////////////////////////////////////////////////////////////////////////// // This is the actual real number parser /////////////////////////////////////////////////////////////////////////// template < typename T = double, typename RealPolicies = real_policies > struct real_parser_impl : primitive_parser > { template struct attribute { typedef T type; }; template bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper , T& attr) const { qi::skip_over(first, last, skipper); return detail::real_impl:: parse(first, last, attr, RealPolicies()); } template bool parse(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper , Attribute& attr_) const { // this case is called when Attribute is not T T attr; if (parse(first, last, context, skipper, attr)) { traits::assign_to(attr, attr_); return true; } return false; } template info what(Context& /*context*/) const { return info("real-number"); } }; /////////////////////////////////////////////////////////////////////////// // This one is the class that the user can instantiate directly /////////////////////////////////////////////////////////////////////////// template < typename T, typename RealPolicies = real_policies > struct real_parser : proto::terminal >::type { }; /////////////////////////////////////////////////////////////////////////// // Parser generators: make_xxx function (objects) /////////////////////////////////////////////////////////////////////////// template struct make_real { typedef real_parser_impl > result_type; result_type operator()(unused_type, unused_type) const { return result_type(); } }; template struct make_primitive : make_real {}; template struct make_primitive : make_real {}; template struct make_primitive : make_real {}; }}} #endif