// Copyright (c) 2001-2007 Joel de Guzman // Copyright (c) 2001-2008 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_KARMA_NONTERMINAL_MAR_06_2007_0750AM) #define BOOST_SPIRIT_KARMA_NONTERMINAL_MAR_06_2007_0750AM #if defined(_MSC_VER) && (_MSC_VER >= 1020) #pragma once // MS compatible compilers support #pragma once #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace spirit { namespace karma { /////////////////////////////////////////////////////////////////////////// template struct nonterminal : proto::extends< typename make_nonterminal_holder< Derived const*, Derived >::type, Derived > { typedef Sig sig_type; typedef typename function_types::result_type::type result_type_; // This is the nonterminal return type typedef typename mpl::if_< is_same, unused_type, result_type_ >::type attribute_type; // param_types is a sequence of types passed as parameters to the // nonterminal typedef typename function_types::parameter_types::type param_types; // the parameter tuple has the attribute value pre-pended typedef typename fusion::result_of::as_vector< fusion::joint_view< fusion::single_view, param_types > >::type retval_param_types; // locals_type is a sequence of types to be used as local variables typedef typename fusion::result_of::as_vector::type locals_type; // The overall context_type consists of a tuple with: // 1) a tuple of the return value and parameters // 2) the locals typedef fusion::vector context_type; typedef nonterminal self_type; typedef nonterminal_holder nonterminal_holder_; typedef typename proto::terminal::type nonterminal_tag; typedef proto::extends base_type; explicit nonterminal() : base_type(make_tag()) { } // bring in the operator() overloads #include private: nonterminal_tag make_tag() const { nonterminal_tag xpr = {{static_cast(this)}}; return xpr; } }; /////////////////////////////////////////////////////////////////////////// template struct make_nonterminal { typedef mpl::vector types; typedef function_types::is_function is_function; typedef spirit::detail::is_locals is_locals; typedef spirit::traits::is_component is_delimiter; typedef typename mpl::find_if::type sig_; typedef typename mpl::find_if::type locals_; typedef typename mpl::find_if::type delimiter_; typedef typename mpl::eval_if< is_same::type>, mpl::identity, mpl::deref >::type sig_type; typedef typename mpl::eval_if< is_same::type>, mpl::identity >, mpl::deref >::type locals_type; typedef typename mpl::eval_if< is_same::type>, mpl::identity, mpl::deref >::type delimiter_type; typedef nonterminal type; }; }}} #endif