Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/spirit/home/classic/meta/impl/fundamental.ipp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 /*============================================================================= | |
2 Copyright (c) 2002-2003 Hartmut Kaiser | |
3 http://spirit.sourceforge.net/ | |
4 | |
5 Use, modification and distribution is subject to the Boost Software | |
6 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
7 http://www.boost.org/LICENSE_1_0.txt) | |
8 =============================================================================*/ | |
9 #if !defined(BOOST_SPIRIT_FUNDAMENTAL_IPP) | |
10 #define BOOST_SPIRIT_FUNDAMENTAL_IPP | |
11 | |
12 #include <boost/mpl/int.hpp> | |
13 | |
14 namespace boost { namespace spirit { | |
15 | |
16 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN | |
17 | |
18 #if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) | |
19 BOOST_SPIRIT_DEPENDENT_TEMPLATE_WRAPPER2(count_wrapper, count); | |
20 #endif // defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) | |
21 | |
22 namespace impl | |
23 { | |
24 /////////////////////////////////////////////////////////////////////////// | |
25 // | |
26 // Helper template for counting the number of nodes contained in a | |
27 // given parser type. | |
28 // All parser_category type parsers are counted as nodes. | |
29 // | |
30 /////////////////////////////////////////////////////////////////////////// | |
31 template <typename CategoryT> | |
32 struct nodes; | |
33 | |
34 template <> | |
35 struct nodes<plain_parser_category> { | |
36 | |
37 template <typename ParserT, typename LeafCountT> | |
38 struct count { | |
39 | |
40 // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT | |
41 enum { value = (LeafCountT::value + 1) }; | |
42 }; | |
43 }; | |
44 | |
45 #if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) | |
46 | |
47 template <> | |
48 struct nodes<unary_parser_category> { | |
49 | |
50 template <typename ParserT, typename LeafCountT> | |
51 struct count { | |
52 | |
53 typedef typename ParserT::subject_t subject_t; | |
54 typedef typename subject_t::parser_category_t subject_category_t; | |
55 | |
56 typedef nodes<subject_category_t> nodes_t; | |
57 typedef typename count_wrapper<nodes_t> | |
58 ::template result_<subject_t, LeafCountT> count_t; | |
59 | |
60 BOOST_STATIC_CONSTANT(int, value = count_t::value + 1); | |
61 }; | |
62 }; | |
63 | |
64 template <> | |
65 struct nodes<action_parser_category> { | |
66 | |
67 template <typename ParserT, typename LeafCountT> | |
68 struct count { | |
69 | |
70 typedef typename ParserT::subject_t subject_t; | |
71 typedef typename subject_t::parser_category_t subject_category_t; | |
72 | |
73 typedef nodes<subject_category_t> nodes_t; | |
74 typedef typename count_wrapper<nodes_t> | |
75 ::template result_<subject_t, LeafCountT> count_t; | |
76 | |
77 BOOST_STATIC_CONSTANT(int, value = count_t::value + 1); | |
78 }; | |
79 }; | |
80 | |
81 template <> | |
82 struct nodes<binary_parser_category> { | |
83 | |
84 template <typename ParserT, typename LeafCountT> | |
85 struct count { | |
86 | |
87 typedef typename ParserT::left_t left_t; | |
88 typedef typename ParserT::right_t right_t; | |
89 typedef typename left_t::parser_category_t left_category_t; | |
90 typedef typename right_t::parser_category_t right_category_t; | |
91 | |
92 typedef nodes<left_category_t> left_nodes_t; | |
93 typedef typename count_wrapper<left_nodes_t> | |
94 ::template result_<left_t, LeafCountT> left_count_t; | |
95 | |
96 typedef nodes<right_category_t> right_nodes_t; | |
97 typedef typename count_wrapper<right_nodes_t> | |
98 ::template result_<right_t, LeafCountT> right_count_t; | |
99 | |
100 BOOST_STATIC_CONSTANT(int, | |
101 value = (left_count_t::value + right_count_t::value + 1)); | |
102 }; | |
103 }; | |
104 | |
105 #else | |
106 | |
107 template <> | |
108 struct nodes<unary_parser_category> { | |
109 | |
110 template <typename ParserT, typename LeafCountT> | |
111 struct count { | |
112 | |
113 typedef typename ParserT::subject_t subject_t; | |
114 typedef typename subject_t::parser_category_t subject_category_t; | |
115 | |
116 // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT | |
117 enum { value = (nodes<subject_category_t> | |
118 ::template count<subject_t, LeafCountT>::value + 1) }; | |
119 }; | |
120 }; | |
121 | |
122 template <> | |
123 struct nodes<action_parser_category> { | |
124 | |
125 template <typename ParserT, typename LeafCountT> | |
126 struct count { | |
127 | |
128 typedef typename ParserT::subject_t subject_t; | |
129 typedef typename subject_t::parser_category_t subject_category_t; | |
130 | |
131 // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT | |
132 enum { value = (nodes<subject_category_t> | |
133 ::template count<subject_t, LeafCountT>::value + 1) }; | |
134 }; | |
135 }; | |
136 | |
137 template <> | |
138 struct nodes<binary_parser_category> { | |
139 | |
140 template <typename ParserT, typename LeafCountT> | |
141 struct count { | |
142 | |
143 typedef typename ParserT::left_t left_t; | |
144 typedef typename ParserT::right_t right_t; | |
145 typedef typename left_t::parser_category_t left_category_t; | |
146 typedef typename right_t::parser_category_t right_category_t; | |
147 | |
148 typedef count self_t; | |
149 | |
150 // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT | |
151 enum { | |
152 leftcount = (nodes<left_category_t> | |
153 ::template count<left_t, LeafCountT>::value), | |
154 rightcount = (nodes<right_category_t> | |
155 ::template count<right_t, LeafCountT>::value), | |
156 value = ((self_t::leftcount) + (self_t::rightcount) + 1) | |
157 }; | |
158 }; | |
159 }; | |
160 | |
161 #endif | |
162 | |
163 /////////////////////////////////////////////////////////////////////////// | |
164 // | |
165 // Helper template for counting the number of leaf nodes contained in a | |
166 // given parser type. | |
167 // Only plain_parser_category type parsers are counted as leaf nodes. | |
168 // | |
169 /////////////////////////////////////////////////////////////////////////// | |
170 template <typename CategoryT> | |
171 struct leafs; | |
172 | |
173 template <> | |
174 struct leafs<plain_parser_category> { | |
175 | |
176 template <typename ParserT, typename LeafCountT> | |
177 struct count { | |
178 | |
179 // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT | |
180 enum { value = (LeafCountT::value + 1) }; | |
181 }; | |
182 }; | |
183 | |
184 #if defined(BOOST_MSVC) && (BOOST_MSVC <= 1300) | |
185 | |
186 template <> | |
187 struct leafs<unary_parser_category> { | |
188 | |
189 template <typename ParserT, typename LeafCountT> | |
190 struct count { | |
191 | |
192 typedef typename ParserT::subject_t subject_t; | |
193 typedef typename subject_t::parser_category_t subject_category_t; | |
194 | |
195 typedef leafs<subject_category_t> nodes_t; | |
196 typedef typename count_wrapper<nodes_t> | |
197 ::template result_<subject_t, LeafCountT> count_t; | |
198 | |
199 BOOST_STATIC_CONSTANT(int, value = count_t::value); | |
200 }; | |
201 }; | |
202 | |
203 template <> | |
204 struct leafs<action_parser_category> { | |
205 | |
206 template <typename ParserT, typename LeafCountT> | |
207 struct count { | |
208 | |
209 typedef typename ParserT::subject_t subject_t; | |
210 typedef typename subject_t::parser_category_t subject_category_t; | |
211 | |
212 typedef leafs<subject_category_t> nodes_t; | |
213 typedef typename count_wrapper<nodes_t> | |
214 ::template result_<subject_t, LeafCountT> count_t; | |
215 | |
216 BOOST_STATIC_CONSTANT(int, value = count_t::value); | |
217 }; | |
218 }; | |
219 | |
220 template <> | |
221 struct leafs<binary_parser_category> { | |
222 | |
223 template <typename ParserT, typename LeafCountT> | |
224 struct count { | |
225 | |
226 typedef typename ParserT::left_t left_t; | |
227 typedef typename ParserT::right_t right_t; | |
228 typedef typename left_t::parser_category_t left_category_t; | |
229 typedef typename right_t::parser_category_t right_category_t; | |
230 | |
231 typedef leafs<left_category_t> left_nodes_t; | |
232 typedef typename count_wrapper<left_nodes_t> | |
233 ::template result_<left_t, LeafCountT> left_count_t; | |
234 | |
235 typedef leafs<right_category_t> right_nodes_t; | |
236 typedef typename count_wrapper<right_nodes_t> | |
237 ::template result_<right_t, LeafCountT> right_count_t; | |
238 | |
239 BOOST_STATIC_CONSTANT(int, | |
240 value = (left_count_t::value + right_count_t::value)); | |
241 }; | |
242 }; | |
243 | |
244 #else | |
245 | |
246 template <> | |
247 struct leafs<unary_parser_category> { | |
248 | |
249 template <typename ParserT, typename LeafCountT> | |
250 struct count { | |
251 | |
252 typedef typename ParserT::subject_t subject_t; | |
253 typedef typename subject_t::parser_category_t subject_category_t; | |
254 | |
255 // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT | |
256 enum { value = (leafs<subject_category_t> | |
257 ::template count<subject_t, LeafCountT>::value) }; | |
258 }; | |
259 }; | |
260 | |
261 template <> | |
262 struct leafs<action_parser_category> { | |
263 | |
264 template <typename ParserT, typename LeafCountT> | |
265 struct count { | |
266 | |
267 typedef typename ParserT::subject_t subject_t; | |
268 typedef typename subject_t::parser_category_t subject_category_t; | |
269 | |
270 // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT | |
271 enum { value = (leafs<subject_category_t> | |
272 ::template count<subject_t, LeafCountT>::value) }; | |
273 }; | |
274 }; | |
275 | |
276 template <> | |
277 struct leafs<binary_parser_category> { | |
278 | |
279 template <typename ParserT, typename LeafCountT> | |
280 struct count { | |
281 | |
282 typedef typename ParserT::left_t left_t; | |
283 typedef typename ParserT::right_t right_t; | |
284 typedef typename left_t::parser_category_t left_category_t; | |
285 typedef typename right_t::parser_category_t right_category_t; | |
286 | |
287 typedef count self_t; | |
288 | |
289 // __BORLANDC__ == 0x0561 isn't happy with BOOST_STATIC_CONSTANT | |
290 enum { | |
291 leftcount = (leafs<left_category_t> | |
292 ::template count<left_t, LeafCountT>::value), | |
293 rightcount = (leafs<right_category_t> | |
294 ::template count<right_t, LeafCountT>::value), | |
295 value = (self_t::leftcount + self_t::rightcount) | |
296 }; | |
297 }; | |
298 }; | |
299 | |
300 #endif | |
301 | |
302 } // namespace impl | |
303 | |
304 /////////////////////////////////////////////////////////////////////////////// | |
305 BOOST_SPIRIT_CLASSIC_NAMESPACE_END | |
306 | |
307 }} // namespace boost::spirit | |
308 | |
309 #endif // !defined(BOOST_SPIRIT_FUNDAMENTAL_IPP) |