/*============================================================================= Copyright (c) 2001-2011 Joel de Guzman Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #if !defined(BOOST_SPIRIT_META_COMPILER_OCTOBER_16_2008_0347PM) #define BOOST_SPIRIT_META_COMPILER_OCTOBER_16_2008_0347PM #if defined(_MSC_VER) #pragma once #endif #include #include #include #include #include #include #include #include namespace boost { namespace spirit { template struct use_terminal >::type> // enables parsers : mpl::true_ {}; namespace qi { template struct make_primitive // by default, return it as-is { typedef T result_type; template T_& operator()(T_& val, unused_type) const { return val; } template T_ const& operator()(T_ const& val, unused_type) const { return val; } }; template struct make_composite; template struct make_directive { typedef Body result_type; result_type operator()(unused_type, Body const& body, unused_type) const { return body; // By default, a directive simply returns its subject } }; } // Qi primitive meta-compiler template <> struct make_component { template struct result; template struct result { typedef typename qi::make_primitive< typename remove_const::type, typename remove_reference::type>::result_type type; }; template typename result::type operator()(Elements const& elements, Modifiers const& modifiers) const { typedef typename remove_const::type term; return qi::make_primitive()(elements.car, modifiers); } }; // Qi composite meta-compiler template struct make_component { template struct result; template struct result { typedef typename qi::make_composite::type>::result_type type; }; template typename result::type operator()(Elements const& elements, Modifiers const& modifiers) const { return qi::make_composite()( elements, modifiers); } }; // Qi function meta-compiler template <> struct make_component { template struct result; template struct result { typedef typename qi::make_composite< typename remove_const::type, typename Elements::cdr_type, typename remove_reference::type >::result_type type; }; template typename result::type operator()(Elements const& elements, Modifiers const& modifiers) const { return qi::make_composite< typename remove_const::type, typename Elements::cdr_type, Modifiers>()(elements.cdr, modifiers); } }; // Qi directive meta-compiler template <> struct make_component { template struct result; template struct result { typedef typename qi::make_directive< typename remove_const::type, typename remove_const::type, typename remove_reference::type >::result_type type; }; template typename result::type operator()(Elements const& elements, Modifiers const& modifiers) const { return qi::make_directive< typename remove_const::type, typename remove_const::type, Modifiers>()(elements.car, elements.cdr.car, modifiers); } }; }} #endif