File indexing completed on 2024-11-15 09:31:45
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_SPIRIT_LEX_ARGUMENT_PHEONIX_MARCH_25_2011_1841PM)
0008 #define BOOST_SPIRIT_LEX_ARGUMENT_PHEONIX_MARCH_25_2011_1841PM
0009
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013
0014 #include <boost/phoenix/core/actor.hpp>
0015 #include <boost/phoenix/core/as_actor.hpp>
0016 #include <boost/phoenix/core/expression.hpp>
0017 #include <boost/phoenix/core/v2_eval.hpp>
0018 #include <boost/phoenix/core/value.hpp> // includes as_actor specialization
0019 #include <boost/proto/traits.hpp>
0020 #include <boost/proto/proto_fwd.hpp> // for transform placeholders
0021
0022 namespace boost { namespace spirit { namespace lex
0023 {
0024
0025
0026
0027
0028
0029
0030
0031
0032 struct value_context
0033 {
0034 typedef mpl::true_ no_nullary;
0035
0036 typedef unused_type result_type;
0037
0038 template <typename Env>
0039 struct result
0040 {
0041 typedef unused_type type;
0042 };
0043
0044 template <typename Env>
0045 unused_type
0046 eval(Env const&) const
0047 {
0048 return unused;
0049 }
0050 };
0051
0052
0053 struct value_getter;
0054 template <typename> struct value_setter;
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 struct state_context
0065 {
0066 typedef mpl::true_ no_nullary;
0067
0068 typedef unused_type result_type;
0069
0070 template <typename Env>
0071 struct result
0072 {
0073 typedef unused_type type;
0074 };
0075
0076 template <typename Env>
0077 unused_type
0078 eval(Env const&) const
0079 {
0080 return unused;
0081 }
0082 };
0083
0084
0085 struct state_getter;
0086 template <typename> struct state_setter;
0087 struct eoi_getter;
0088 }}}
0089
0090
0091
0092 BOOST_PHOENIX_DEFINE_EXPRESSION(
0093 (boost)(spirit)(lex)(value_setter)
0094 , (boost::phoenix::meta_grammar)
0095 )
0096
0097 BOOST_PHOENIX_DEFINE_EXPRESSION(
0098 (boost)(spirit)(lex)(state_setter)
0099 , (boost::phoenix::meta_grammar)
0100 )
0101
0102 namespace boost { namespace phoenix
0103 {
0104 namespace result_of
0105 {
0106 template <>
0107 struct is_nullary<custom_terminal<boost::spirit::lex::value_context> >
0108 : mpl::false_
0109 {};
0110 }
0111
0112 template <typename Dummy>
0113 struct is_custom_terminal<boost::spirit::lex::value_context, Dummy>: mpl::true_ {};
0114
0115 template <typename Dummy>
0116 struct custom_terminal<boost::spirit::lex::value_context, Dummy>
0117 : proto::call<
0118 v2_eval(
0119 proto::make<boost::spirit::lex::value_getter()>
0120 , proto::call<functional::env(proto::_state)>
0121 )
0122 >
0123 {};
0124
0125 template <typename Dummy>
0126 struct is_nullary::when<spirit::lex::rule::value_setter, Dummy>
0127 : proto::make<mpl::false_()>
0128 {};
0129
0130 template <typename Dummy>
0131 struct default_actions::when<spirit::lex::rule::value_setter, Dummy>
0132 : proto::call<
0133 v2_eval(
0134 proto::make<
0135 spirit::lex::value_setter<proto::_child0>(
0136 proto::_child0
0137 )
0138 >
0139 , _env
0140 )
0141 >
0142 {};
0143
0144 template <>
0145 struct actor<spirit::lex::value_context>
0146 : boost::phoenix::actor<proto::terminal<spirit::lex::value_context>::type>
0147 {
0148 typedef boost::phoenix::actor<
0149 proto::terminal<spirit::lex::value_context>::type
0150 > base_type;
0151
0152 actor(base_type const & base = base_type())
0153 : base_type(base)
0154 {}
0155
0156 template <typename Expr>
0157 typename spirit::lex::expression::value_setter<
0158 typename phoenix::as_actor<Expr>::type>::type const
0159 operator=(Expr const & expr) const
0160 {
0161 return
0162 spirit::lex::expression::value_setter<
0163 typename phoenix::as_actor<Expr>::type
0164 >::make(phoenix::as_actor<Expr>::convert(expr));
0165 }
0166 };
0167
0168 namespace result_of
0169 {
0170 template <>
0171 struct is_nullary<custom_terminal<boost::spirit::lex::state_context> >
0172 : mpl::false_
0173 {};
0174 }
0175
0176 template <typename Dummy>
0177 struct is_custom_terminal<boost::spirit::lex::state_context, Dummy>: mpl::true_ {};
0178
0179 template <typename Dummy>
0180 struct custom_terminal<boost::spirit::lex::state_context, Dummy>
0181 : proto::call<
0182 v2_eval(
0183 proto::make<boost::spirit::lex::state_getter()>
0184 , proto::call<functional::env(proto::_state)>
0185 )
0186 >
0187 {};
0188
0189 template <typename Dummy>
0190 struct is_nullary::when<spirit::lex::rule::state_setter, Dummy>
0191 : proto::make<mpl::false_()>
0192 {};
0193
0194 template <typename Dummy>
0195 struct default_actions::when<spirit::lex::rule::state_setter, Dummy>
0196 : proto::call<
0197 v2_eval(
0198 proto::make<
0199 spirit::lex::state_setter<proto::_child0>(
0200 proto::_child0
0201 )
0202 >
0203 , _env
0204 )
0205 >
0206 {};
0207
0208 template <>
0209 struct actor<spirit::lex::state_context>
0210 : boost::phoenix::actor<proto::terminal<spirit::lex::state_context>::type>
0211 {
0212 typedef boost::phoenix::actor<
0213 proto::terminal<spirit::lex::state_context>::type
0214 > base_type;
0215
0216 actor(base_type const & base = base_type())
0217 : base_type(base)
0218 {}
0219
0220 template <typename Expr>
0221 typename spirit::lex::expression::state_setter<
0222 typename phoenix::as_actor<Expr>::type>::type const
0223 operator=(Expr const & expr) const
0224 {
0225 return
0226 spirit::lex::expression::state_setter<
0227 typename phoenix::as_actor<Expr>::type
0228 >::make(phoenix::as_actor<Expr>::convert(expr));
0229 }
0230 };
0231
0232 namespace result_of
0233 {
0234 template <>
0235 struct is_nullary<custom_terminal<boost::spirit::lex::eoi_getter> >
0236 : mpl::false_
0237 {};
0238 }
0239
0240 template <typename Dummy>
0241 struct is_custom_terminal<boost::spirit::lex::eoi_getter, Dummy>: mpl::true_ {};
0242
0243 template <typename Dummy>
0244 struct custom_terminal<boost::spirit::lex::eoi_getter, Dummy>
0245 : proto::call<
0246 v2_eval(
0247 proto::make<boost::spirit::lex::eoi_getter()>
0248 , proto::call<functional::env(proto::_state)>
0249 )
0250 >
0251 {};
0252 }}
0253
0254 #endif