• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2011 Thomas Heller
3     Copyright (c) 2001-2011 Hartmut Kaiser
4     Copyright (c)      2011 Thomas Heller
5 
6     Distributed under the Boost Software License, Version 1.0. (See accompanying
7     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 ==============================================================================*/
9 #if !defined(BOOST_SPIRIT_ARGUMENT_MARCH_22_2011_0939PM)
10 #define BOOST_SPIRIT_ARGUMENT_MARCH_22_2011_0939PM
11 
12 #include <boost/phoenix/core/terminal.hpp>
13 #include <boost/phoenix/core/v2_eval.hpp>
14 #include <boost/proto/proto_fwd.hpp> // for transform placeholders
15 
16 namespace boost { namespace spirit
17 {
18     template <int N>
19     struct argument;
20 
21     template <typename Dummy>
22     struct attribute_context;
23 
24     namespace expression
25     {
26         template <int N>
27         struct argument
28           : phoenix::expression::terminal<spirit::argument<N> >
29         {
30             typedef typename phoenix::expression::terminal<
31                 spirit::argument<N>
32             >::type type;
33 
makeboost::spirit::expression::argument34             static type make()
35             {
36                 type const e = {{{}}};
37                 return e;
38             }
39         };
40 
41         template <typename Dummy>
42         struct attribute_context
43           : phoenix::expression::terminal<spirit::attribute_context<Dummy> >
44         {
45             typedef typename phoenix::expression::terminal<
46                 spirit::attribute_context<Dummy>
47             >::type type;
48 
makeboost::spirit::expression::attribute_context49             static type make()
50             {
51                 type const e = {{{}}};
52                 return e;
53             }
54         };
55     }
56 }}
57 
58 namespace boost { namespace phoenix
59 {
60     namespace result_of
61     {
62         template <typename Dummy>
63         struct is_nullary<custom_terminal<spirit::attribute_context<Dummy> > >
64           : mpl::false_
65         {};
66 
67         template <int N>
68         struct is_nullary<custom_terminal<spirit::argument<N> > >
69           : mpl::false_
70         {};
71     }
72 
73     template <typename Dummy>
74     struct is_custom_terminal<spirit::attribute_context<Dummy> >
75       : mpl::true_
76     {};
77 
78     template <int N>
79     struct is_custom_terminal<spirit::argument<N> >
80       : mpl::true_
81     {};
82 
83     template <typename Dummy>
84     struct custom_terminal<spirit::attribute_context<Dummy> >
85       : proto::call<
86             v2_eval(
87                 proto::make<spirit::attribute_context<Dummy>()>
88               , proto::call<
89                     functional::env(proto::_state)
90                 >
91             )
92         >
93     {};
94 
95     template <int N>
96     struct custom_terminal<spirit::argument<N> >
97       : proto::call<
98             v2_eval(
99                 proto::make<spirit::argument<N>()>
100               , proto::call<
101                     functional::env(proto::_state)
102                 >
103             )
104         >
105     {};
106 }}
107 
108 #endif
109