1 /*==============================================================================
2 Copyright (c) 2005-2010 Joel de Guzman
3 Copyright (c) 2010 Thomas Heller
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #ifndef BOOST_PHOENIX_CORE_TERMINAL_HPP
9 #define BOOST_PHOENIX_CORE_TERMINAL_HPP
11 #include <boost/phoenix/core/limits.hpp>
12 #include <boost/call_traits.hpp>
13 #include <boost/is_placeholder.hpp>
14 #include <boost/phoenix/core/actor.hpp>
15 #include <boost/phoenix/core/meta_grammar.hpp>
16 #include <boost/phoenix/core/terminal_fwd.hpp>
17 #include <boost/proto/matches.hpp>
18 #include <boost/proto/transform/lazy.hpp>
19 #include <boost/proto/functional/fusion/at.hpp>
20 #include <boost/type_traits/remove_pointer.hpp>
22 #define BOOST_PHOENIX_DEFINE_CUSTOM_TERMINAL(Template, Terminal, IsNullary, EvalFun)\
23 namespace boost { namespace phoenix \
37 struct is_custom_terminal<Terminal >: mpl::true_ {}; \
40 struct custom_terminal<Terminal > : proto::call<EvalFun > {}; \
44 namespace boost { namespace phoenix
46 template <typename T, typename Dummy>
47 struct is_custom_terminal
50 template <typename T, typename Dummy>
51 struct custom_terminal;
54 struct terminal /*: public proto::tag::terminal */ {};
59 template <typename T, template <typename> class Actor = actor>
62 T//typename call_traits<T>::value_type
68 // tag::terminal //cannot change to use phoenix tag - breaks code.
73 typedef Actor<base_type> type;
75 static const type make(typename call_traits<T>::param_type t)
77 // ?? Should the next line be Actor not actor which is the default?
78 actor<base_type> const e = {base_type::make(t)};
79 //Actor<base_type> const e = {base_type::make(t)};
88 : proto::if_<boost::is_placeholder<proto::_value>()>
91 struct custom_terminal
92 : proto::if_<boost::phoenix::is_custom_terminal<proto::_value>()>
96 : proto::terminal<proto::_>
100 template <typename Dummy>
101 struct meta_grammar::case_<proto::tag::terminal, Dummy>
103 enable_rule<rule::argument , Dummy>
104 , enable_rule<rule::custom_terminal, Dummy>
105 , enable_rule<rule::terminal , Dummy>
109 template <typename Dummy>
110 struct default_actions::when<rule::custom_terminal, Dummy>
112 custom_terminal<proto::_value>(
121 template <typename N>
122 struct placeholder_idx
123 : mpl::int_<N::value>
127 template <typename Grammar>
128 struct default_actions::when<rule::argument, Grammar>
130 proto::functional::at(
133 detail::placeholder_idx<
135 boost::is_placeholder<proto::_value>()