closure.hpp 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083
  1. /*=============================================================================
  2. Copyright (c) 2001-2003 Joel de Guzman
  3. Copyright (c) 2002-2003 Hartmut Kaiser
  4. http://spirit.sourceforge.net/
  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_SPIRIT_CLOSURE_HPP
  9. #define BOOST_SPIRIT_CLOSURE_HPP
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #include <boost/spirit/home/classic/namespace.hpp>
  12. #include <boost/spirit/home/classic/core/parser.hpp>
  13. #include <boost/spirit/home/classic/core/composite/composite.hpp>
  14. #include <boost/spirit/home/classic/core/non_terminal/parser_context.hpp>
  15. #include <boost/spirit/home/classic/attribute/parametric.hpp>
  16. #include <boost/spirit/home/classic/attribute/closure_context.hpp>
  17. #include <boost/spirit/home/classic/attribute/closure_fwd.hpp>
  18. #include <boost/spirit/home/classic/phoenix/closures.hpp>
  19. #include <boost/spirit/home/classic/phoenix/primitives.hpp>
  20. #include <boost/spirit/home/classic/phoenix/casts.hpp>
  21. #include <boost/spirit/home/classic/phoenix/operators.hpp>
  22. #include <boost/spirit/home/classic/phoenix/tuple_helpers.hpp>
  23. #include <boost/static_assert.hpp>
  24. ///////////////////////////////////////////////////////////////////////////////
  25. //
  26. // Spirit predefined maximum closure limit. This limit defines the maximum
  27. // number of elements a closure can hold. This number defaults to 3. The
  28. // actual maximum is rounded up in multiples of 3. Thus, if this value
  29. // is 4, the actual limit is 6. The ultimate maximum limit in this
  30. // implementation is 15.
  31. //
  32. // It should NOT be greater than PHOENIX_LIMIT!
  33. //
  34. ///////////////////////////////////////////////////////////////////////////////
  35. #if !defined(BOOST_SPIRIT_CLOSURE_LIMIT)
  36. #define BOOST_SPIRIT_CLOSURE_LIMIT PHOENIX_LIMIT
  37. #endif
  38. ///////////////////////////////////////////////////////////////////////////////
  39. //
  40. // ensure BOOST_SPIRIT_CLOSURE_LIMIT <= PHOENIX_LIMIT and SPIRIT_CLOSURE_LIMIT <= 15
  41. //
  42. ///////////////////////////////////////////////////////////////////////////////
  43. BOOST_STATIC_ASSERT(BOOST_SPIRIT_CLOSURE_LIMIT <= PHOENIX_LIMIT);
  44. BOOST_STATIC_ASSERT(BOOST_SPIRIT_CLOSURE_LIMIT <= 15);
  45. ///////////////////////////////////////////////////////////////////////////////
  46. namespace boost { namespace spirit {
  47. BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
  48. ///////////////////////////////////////////////////////////////////////////
  49. //
  50. // closure_context class
  51. //
  52. ///////////////////////////////////////////////////////////////////////////
  53. template <typename ClosureT>
  54. class closure_context : public parser_context_base
  55. {
  56. public:
  57. typedef typename ::phoenix::tuple_element<0,
  58. typename ClosureT::tuple_t>::type attr_t;
  59. typedef ClosureT base_t;
  60. typedef closure_context_linker<closure_context<ClosureT> >
  61. context_linker_t;
  62. closure_context(ClosureT const& clos)
  63. : frame(clos) {}
  64. ~closure_context() {}
  65. template <typename ParserT, typename ScannerT>
  66. void pre_parse(ParserT const&, ScannerT const&) {}
  67. template <typename ResultT, typename ParserT, typename ScannerT>
  68. ResultT& post_parse(ResultT& hit, ParserT const&, ScannerT const&)
  69. { hit.value(frame[::phoenix::tuple_index<0>()]); return hit; }
  70. private:
  71. ::phoenix::closure_frame<typename ClosureT::phoenix_closure_t> frame;
  72. };
  73. ///////////////////////////////////////////////////////////////////////////
  74. //
  75. // init_closure_context class
  76. //
  77. // The init_closure_context class is a special parser context type
  78. // which additionally initializes a closure contained in the derived
  79. // parser with values from a given tuple. Please note, that this
  80. // given tuple does not contain the required values directly, it
  81. // contains phoenix::actor objects. These actors have to be
  82. // dereferenced to gain the values to be used for initialization
  83. // (this is done by the help of the phoenix::convert_actors<>
  84. // template).
  85. //
  86. ///////////////////////////////////////////////////////////////////////////
  87. template <typename ClosureT>
  88. class init_closure_context : public parser_context_base
  89. {
  90. typedef typename ClosureT::tuple_t tuple_t;
  91. typedef typename ClosureT::closure_t closure_t;
  92. public:
  93. init_closure_context(ClosureT const& clos)
  94. : frame(clos.subject(), ::phoenix::convert_actors<tuple_t>(clos.init)) {}
  95. ~init_closure_context() {}
  96. template <typename ParserT, typename ScannerT>
  97. void pre_parse(ParserT const& /*p*/, ScannerT const&) {}
  98. template <typename ResultT, typename ParserT, typename ScannerT>
  99. ResultT& post_parse(ResultT& hit, ParserT const&, ScannerT const&)
  100. { hit.value(frame[::phoenix::tuple_index<0>()]); return hit; }
  101. private:
  102. ::phoenix::closure_frame<closure_t> frame;
  103. };
  104. ///////////////////////////////////////////////////////////////////////////
  105. //
  106. // init_closure_parser class
  107. //
  108. ///////////////////////////////////////////////////////////////////////////
  109. template <typename ParserT, typename ActorTupleT>
  110. struct init_closure_parser
  111. : public unary<ParserT, parser<init_closure_parser<ParserT, ActorTupleT> > >
  112. {
  113. typedef init_closure_parser<ParserT, ActorTupleT> self_t;
  114. typedef unary<ParserT, parser<self_t> > base_t;
  115. typedef typename ParserT::phoenix_closure_t closure_t;
  116. typedef typename ParserT::tuple_t tuple_t;
  117. typedef typename ::phoenix::tuple_element<0, tuple_t>::type attr_t;
  118. template <typename ScannerT>
  119. struct result
  120. {
  121. typedef typename match_result<ScannerT, attr_t>::type type;
  122. };
  123. init_closure_parser(ParserT const& p, ActorTupleT const& init_)
  124. : base_t(p), init(init_) {}
  125. template <typename ScannerT>
  126. typename parser_result<self_t, ScannerT>::type
  127. parse_main(ScannerT const& scan) const
  128. {
  129. return this->subject().parse_main(scan);
  130. }
  131. template <typename ScannerT>
  132. typename parser_result<self_t, ScannerT>::type
  133. parse(ScannerT const& scan) const
  134. {
  135. typedef init_closure_context<self_t> init_context_t;
  136. typedef parser_scanner_linker<ScannerT> scanner_t;
  137. typedef closure_context_linker<init_context_t> context_t;
  138. typedef typename parser_result<self_t, ScannerT>::type result_t;
  139. BOOST_SPIRIT_CONTEXT_PARSE(
  140. scan, *this, scanner_t, context_t, result_t);
  141. }
  142. ActorTupleT init;
  143. };
  144. ///////////////////////////////////////////////////////////////////////////
  145. //
  146. // closure class
  147. //
  148. ///////////////////////////////////////////////////////////////////////////
  149. template <
  150. typename DerivedT
  151. , typename T0
  152. , typename T1
  153. , typename T2
  154. #if BOOST_SPIRIT_CLOSURE_LIMIT > 3
  155. , typename T3
  156. , typename T4
  157. , typename T5
  158. #if BOOST_SPIRIT_CLOSURE_LIMIT > 6
  159. , typename T6
  160. , typename T7
  161. , typename T8
  162. #if BOOST_SPIRIT_CLOSURE_LIMIT > 9
  163. , typename T9
  164. , typename T10
  165. , typename T11
  166. #if BOOST_SPIRIT_CLOSURE_LIMIT > 12
  167. , typename T12
  168. , typename T13
  169. , typename T14
  170. #endif
  171. #endif
  172. #endif
  173. #endif
  174. >
  175. struct closure :
  176. public ::phoenix::closure<
  177. T0, T1, T2
  178. #if BOOST_SPIRIT_CLOSURE_LIMIT > 3
  179. , T3, T4, T5
  180. #if BOOST_SPIRIT_CLOSURE_LIMIT > 6
  181. , T6, T7, T8
  182. #if BOOST_SPIRIT_CLOSURE_LIMIT > 9
  183. , T9, T10, T11
  184. #if BOOST_SPIRIT_CLOSURE_LIMIT > 12
  185. , T12, T13, T14
  186. #endif
  187. #endif
  188. #endif
  189. #endif
  190. >
  191. {
  192. typedef ::phoenix::closure<
  193. T0, T1, T2
  194. #if BOOST_SPIRIT_CLOSURE_LIMIT > 3
  195. , T3, T4, T5
  196. #if BOOST_SPIRIT_CLOSURE_LIMIT > 6
  197. , T6, T7, T8
  198. #if BOOST_SPIRIT_CLOSURE_LIMIT > 9
  199. , T9, T10, T11
  200. #if BOOST_SPIRIT_CLOSURE_LIMIT > 12
  201. , T12, T13, T14
  202. #endif
  203. #endif
  204. #endif
  205. #endif
  206. > phoenix_closure_t;
  207. typedef closure_context<DerivedT> context_t;
  208. template <typename DerivedT2>
  209. struct aux
  210. {
  211. DerivedT2& aux_derived()
  212. { return *static_cast<DerivedT2*>(this); }
  213. DerivedT2 const& aux_derived() const
  214. { return *static_cast<DerivedT2 const*>(this); }
  215. // initialization functions
  216. template <typename A>
  217. init_closure_parser<
  218. DerivedT2,
  219. ::phoenix::tuple<
  220. typename ::phoenix::as_actor<A>::type
  221. >
  222. >
  223. operator()(A const &a) const
  224. {
  225. typedef typename ::phoenix::as_actor<A>::type a_t;
  226. typedef ::phoenix::tuple<a_t> actor_tuple_t;
  227. return init_closure_parser<DerivedT2, actor_tuple_t>(
  228. aux_derived(),
  229. actor_tuple_t(
  230. ::phoenix::as_actor<A>::convert(a)
  231. )
  232. );
  233. }
  234. template <typename A, typename B>
  235. init_closure_parser<
  236. DerivedT2,
  237. ::phoenix::tuple<
  238. typename ::phoenix::as_actor<A>::type,
  239. typename ::phoenix::as_actor<B>::type
  240. >
  241. >
  242. operator()(A const &a, B const &b) const
  243. {
  244. typedef typename ::phoenix::as_actor<A>::type a_t;
  245. typedef typename ::phoenix::as_actor<B>::type b_t;
  246. typedef ::phoenix::tuple<a_t, b_t> actor_tuple_t;
  247. return init_closure_parser<DerivedT2, actor_tuple_t>(
  248. aux_derived(),
  249. actor_tuple_t(
  250. ::phoenix::as_actor<A>::convert(a),
  251. ::phoenix::as_actor<B>::convert(b)
  252. )
  253. );
  254. }
  255. template <typename A, typename B, typename C>
  256. init_closure_parser<
  257. DerivedT2,
  258. ::phoenix::tuple<
  259. typename ::phoenix::as_actor<A>::type,
  260. typename ::phoenix::as_actor<B>::type,
  261. typename ::phoenix::as_actor<C>::type
  262. >
  263. >
  264. operator()(A const &a, B const &b, C const &c) const
  265. {
  266. typedef typename ::phoenix::as_actor<A>::type a_t;
  267. typedef typename ::phoenix::as_actor<B>::type b_t;
  268. typedef typename ::phoenix::as_actor<C>::type c_t;
  269. typedef ::phoenix::tuple<a_t, b_t, c_t> actor_tuple_t;
  270. return init_closure_parser<DerivedT2, actor_tuple_t>(
  271. aux_derived(),
  272. actor_tuple_t(
  273. ::phoenix::as_actor<A>::convert(a),
  274. ::phoenix::as_actor<B>::convert(b),
  275. ::phoenix::as_actor<C>::convert(c)
  276. )
  277. );
  278. }
  279. #if BOOST_SPIRIT_CLOSURE_LIMIT > 3
  280. template <
  281. typename A, typename B, typename C, typename D
  282. >
  283. init_closure_parser<
  284. DerivedT2,
  285. ::phoenix::tuple<
  286. typename ::phoenix::as_actor<A>::type,
  287. typename ::phoenix::as_actor<B>::type,
  288. typename ::phoenix::as_actor<C>::type,
  289. typename ::phoenix::as_actor<D>::type
  290. >
  291. >
  292. operator()(
  293. A const &a, B const &b, C const &c, D const &d
  294. ) const
  295. {
  296. typedef typename ::phoenix::as_actor<A>::type a_t;
  297. typedef typename ::phoenix::as_actor<B>::type b_t;
  298. typedef typename ::phoenix::as_actor<C>::type c_t;
  299. typedef typename ::phoenix::as_actor<D>::type d_t;
  300. typedef ::phoenix::tuple<
  301. a_t, b_t, c_t, d_t
  302. > actor_tuple_t;
  303. return init_closure_parser<DerivedT2, actor_tuple_t>(
  304. aux_derived(),
  305. actor_tuple_t(
  306. ::phoenix::as_actor<A>::convert(a),
  307. ::phoenix::as_actor<B>::convert(b),
  308. ::phoenix::as_actor<C>::convert(c),
  309. ::phoenix::as_actor<D>::convert(d)
  310. )
  311. );
  312. }
  313. template <
  314. typename A, typename B, typename C, typename D, typename E
  315. >
  316. init_closure_parser<
  317. DerivedT2,
  318. ::phoenix::tuple<
  319. typename ::phoenix::as_actor<A>::type,
  320. typename ::phoenix::as_actor<B>::type,
  321. typename ::phoenix::as_actor<C>::type,
  322. typename ::phoenix::as_actor<D>::type,
  323. typename ::phoenix::as_actor<E>::type
  324. >
  325. >
  326. operator()(
  327. A const &a, B const &b, C const &c, D const &d, E const &e
  328. ) const
  329. {
  330. typedef typename ::phoenix::as_actor<A>::type a_t;
  331. typedef typename ::phoenix::as_actor<B>::type b_t;
  332. typedef typename ::phoenix::as_actor<C>::type c_t;
  333. typedef typename ::phoenix::as_actor<D>::type d_t;
  334. typedef typename ::phoenix::as_actor<E>::type e_t;
  335. typedef ::phoenix::tuple<
  336. a_t, b_t, c_t, d_t, e_t
  337. > actor_tuple_t;
  338. return init_closure_parser<DerivedT2, actor_tuple_t>(
  339. aux_derived(),
  340. actor_tuple_t(
  341. ::phoenix::as_actor<A>::convert(a),
  342. ::phoenix::as_actor<B>::convert(b),
  343. ::phoenix::as_actor<C>::convert(c),
  344. ::phoenix::as_actor<D>::convert(d),
  345. ::phoenix::as_actor<E>::convert(e)
  346. )
  347. );
  348. }
  349. template <
  350. typename A, typename B, typename C, typename D, typename E,
  351. typename F
  352. >
  353. init_closure_parser<
  354. DerivedT2,
  355. ::phoenix::tuple<
  356. typename ::phoenix::as_actor<A>::type,
  357. typename ::phoenix::as_actor<B>::type,
  358. typename ::phoenix::as_actor<C>::type,
  359. typename ::phoenix::as_actor<D>::type,
  360. typename ::phoenix::as_actor<E>::type,
  361. typename ::phoenix::as_actor<F>::type
  362. >
  363. >
  364. operator()(
  365. A const &a, B const &b, C const &c, D const &d, E const &e,
  366. F const &f
  367. ) const
  368. {
  369. typedef typename ::phoenix::as_actor<A>::type a_t;
  370. typedef typename ::phoenix::as_actor<B>::type b_t;
  371. typedef typename ::phoenix::as_actor<C>::type c_t;
  372. typedef typename ::phoenix::as_actor<D>::type d_t;
  373. typedef typename ::phoenix::as_actor<E>::type e_t;
  374. typedef typename ::phoenix::as_actor<F>::type f_t;
  375. typedef ::phoenix::tuple<
  376. a_t, b_t, c_t, d_t, e_t, f_t
  377. > actor_tuple_t;
  378. return init_closure_parser<DerivedT2, actor_tuple_t>(
  379. aux_derived(),
  380. actor_tuple_t(
  381. ::phoenix::as_actor<A>::convert(a),
  382. ::phoenix::as_actor<B>::convert(b),
  383. ::phoenix::as_actor<C>::convert(c),
  384. ::phoenix::as_actor<D>::convert(d),
  385. ::phoenix::as_actor<E>::convert(e),
  386. ::phoenix::as_actor<F>::convert(f)
  387. )
  388. );
  389. }
  390. #if BOOST_SPIRIT_CLOSURE_LIMIT > 6
  391. template <
  392. typename A, typename B, typename C, typename D, typename E,
  393. typename F, typename G
  394. >
  395. init_closure_parser<
  396. DerivedT2,
  397. ::phoenix::tuple<
  398. typename ::phoenix::as_actor<A>::type,
  399. typename ::phoenix::as_actor<B>::type,
  400. typename ::phoenix::as_actor<C>::type,
  401. typename ::phoenix::as_actor<D>::type,
  402. typename ::phoenix::as_actor<E>::type,
  403. typename ::phoenix::as_actor<F>::type,
  404. typename ::phoenix::as_actor<G>::type
  405. >
  406. >
  407. operator()(
  408. A const &a, B const &b, C const &c, D const &d, E const &e,
  409. F const &f, G const &g
  410. ) const
  411. {
  412. typedef typename ::phoenix::as_actor<A>::type a_t;
  413. typedef typename ::phoenix::as_actor<B>::type b_t;
  414. typedef typename ::phoenix::as_actor<C>::type c_t;
  415. typedef typename ::phoenix::as_actor<D>::type d_t;
  416. typedef typename ::phoenix::as_actor<E>::type e_t;
  417. typedef typename ::phoenix::as_actor<F>::type f_t;
  418. typedef typename ::phoenix::as_actor<G>::type g_t;
  419. typedef ::phoenix::tuple<
  420. a_t, b_t, c_t, d_t, e_t, f_t, g_t
  421. > actor_tuple_t;
  422. return init_closure_parser<DerivedT2, actor_tuple_t>(
  423. aux_derived(),
  424. actor_tuple_t(
  425. ::phoenix::as_actor<A>::convert(a),
  426. ::phoenix::as_actor<B>::convert(b),
  427. ::phoenix::as_actor<C>::convert(c),
  428. ::phoenix::as_actor<D>::convert(d),
  429. ::phoenix::as_actor<E>::convert(e),
  430. ::phoenix::as_actor<F>::convert(f),
  431. ::phoenix::as_actor<G>::convert(g)
  432. )
  433. );
  434. }
  435. template <
  436. typename A, typename B, typename C, typename D, typename E,
  437. typename F, typename G, typename H
  438. >
  439. init_closure_parser<
  440. DerivedT2,
  441. ::phoenix::tuple<
  442. typename ::phoenix::as_actor<A>::type,
  443. typename ::phoenix::as_actor<B>::type,
  444. typename ::phoenix::as_actor<C>::type,
  445. typename ::phoenix::as_actor<D>::type,
  446. typename ::phoenix::as_actor<E>::type,
  447. typename ::phoenix::as_actor<F>::type,
  448. typename ::phoenix::as_actor<G>::type,
  449. typename ::phoenix::as_actor<H>::type
  450. >
  451. >
  452. operator()(
  453. A const &a, B const &b, C const &c, D const &d, E const &e,
  454. F const &f, G const &g, H const &h
  455. ) const
  456. {
  457. typedef typename ::phoenix::as_actor<A>::type a_t;
  458. typedef typename ::phoenix::as_actor<B>::type b_t;
  459. typedef typename ::phoenix::as_actor<C>::type c_t;
  460. typedef typename ::phoenix::as_actor<D>::type d_t;
  461. typedef typename ::phoenix::as_actor<E>::type e_t;
  462. typedef typename ::phoenix::as_actor<F>::type f_t;
  463. typedef typename ::phoenix::as_actor<G>::type g_t;
  464. typedef typename ::phoenix::as_actor<H>::type h_t;
  465. typedef ::phoenix::tuple<
  466. a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t
  467. > actor_tuple_t;
  468. return init_closure_parser<DerivedT2, actor_tuple_t>(
  469. aux_derived(),
  470. actor_tuple_t(
  471. ::phoenix::as_actor<A>::convert(a),
  472. ::phoenix::as_actor<B>::convert(b),
  473. ::phoenix::as_actor<C>::convert(c),
  474. ::phoenix::as_actor<D>::convert(d),
  475. ::phoenix::as_actor<E>::convert(e),
  476. ::phoenix::as_actor<F>::convert(f),
  477. ::phoenix::as_actor<G>::convert(g),
  478. ::phoenix::as_actor<H>::convert(h)
  479. )
  480. );
  481. }
  482. template <
  483. typename A, typename B, typename C, typename D, typename E,
  484. typename F, typename G, typename H, typename I
  485. >
  486. init_closure_parser<
  487. DerivedT2,
  488. ::phoenix::tuple<
  489. typename ::phoenix::as_actor<A>::type,
  490. typename ::phoenix::as_actor<B>::type,
  491. typename ::phoenix::as_actor<C>::type,
  492. typename ::phoenix::as_actor<D>::type,
  493. typename ::phoenix::as_actor<E>::type,
  494. typename ::phoenix::as_actor<F>::type,
  495. typename ::phoenix::as_actor<G>::type,
  496. typename ::phoenix::as_actor<H>::type,
  497. typename ::phoenix::as_actor<I>::type
  498. >
  499. >
  500. operator()(
  501. A const &a, B const &b, C const &c, D const &d, E const &e,
  502. F const &f, G const &g, H const &h, I const &i
  503. ) const
  504. {
  505. typedef typename ::phoenix::as_actor<A>::type a_t;
  506. typedef typename ::phoenix::as_actor<B>::type b_t;
  507. typedef typename ::phoenix::as_actor<C>::type c_t;
  508. typedef typename ::phoenix::as_actor<D>::type d_t;
  509. typedef typename ::phoenix::as_actor<E>::type e_t;
  510. typedef typename ::phoenix::as_actor<F>::type f_t;
  511. typedef typename ::phoenix::as_actor<G>::type g_t;
  512. typedef typename ::phoenix::as_actor<H>::type h_t;
  513. typedef typename ::phoenix::as_actor<I>::type i_t;
  514. typedef ::phoenix::tuple<
  515. a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t
  516. > actor_tuple_t;
  517. return init_closure_parser<DerivedT2, actor_tuple_t>(
  518. aux_derived(),
  519. actor_tuple_t(
  520. ::phoenix::as_actor<A>::convert(a),
  521. ::phoenix::as_actor<B>::convert(b),
  522. ::phoenix::as_actor<C>::convert(c),
  523. ::phoenix::as_actor<D>::convert(d),
  524. ::phoenix::as_actor<E>::convert(e),
  525. ::phoenix::as_actor<F>::convert(f),
  526. ::phoenix::as_actor<G>::convert(g),
  527. ::phoenix::as_actor<H>::convert(h),
  528. ::phoenix::as_actor<I>::convert(i)
  529. )
  530. );
  531. }
  532. #if BOOST_SPIRIT_CLOSURE_LIMIT > 9
  533. template <
  534. typename A, typename B, typename C, typename D, typename E,
  535. typename F, typename G, typename H, typename I, typename J
  536. >
  537. init_closure_parser<
  538. DerivedT2,
  539. ::phoenix::tuple<
  540. typename ::phoenix::as_actor<A>::type,
  541. typename ::phoenix::as_actor<B>::type,
  542. typename ::phoenix::as_actor<C>::type,
  543. typename ::phoenix::as_actor<D>::type,
  544. typename ::phoenix::as_actor<E>::type,
  545. typename ::phoenix::as_actor<F>::type,
  546. typename ::phoenix::as_actor<G>::type,
  547. typename ::phoenix::as_actor<H>::type,
  548. typename ::phoenix::as_actor<I>::type,
  549. typename ::phoenix::as_actor<J>::type
  550. >
  551. >
  552. operator()(
  553. A const &a, B const &b, C const &c, D const &d, E const &e,
  554. F const &f, G const &g, H const &h, I const &i, J const &j
  555. ) const
  556. {
  557. typedef typename ::phoenix::as_actor<A>::type a_t;
  558. typedef typename ::phoenix::as_actor<B>::type b_t;
  559. typedef typename ::phoenix::as_actor<C>::type c_t;
  560. typedef typename ::phoenix::as_actor<D>::type d_t;
  561. typedef typename ::phoenix::as_actor<E>::type e_t;
  562. typedef typename ::phoenix::as_actor<F>::type f_t;
  563. typedef typename ::phoenix::as_actor<G>::type g_t;
  564. typedef typename ::phoenix::as_actor<H>::type h_t;
  565. typedef typename ::phoenix::as_actor<I>::type i_t;
  566. typedef typename ::phoenix::as_actor<J>::type j_t;
  567. typedef ::phoenix::tuple<
  568. a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t, j_t
  569. > actor_tuple_t;
  570. return init_closure_parser<DerivedT2, actor_tuple_t>(
  571. aux_derived(),
  572. actor_tuple_t(
  573. ::phoenix::as_actor<A>::convert(a),
  574. ::phoenix::as_actor<B>::convert(b),
  575. ::phoenix::as_actor<C>::convert(c),
  576. ::phoenix::as_actor<D>::convert(d),
  577. ::phoenix::as_actor<E>::convert(e),
  578. ::phoenix::as_actor<F>::convert(f),
  579. ::phoenix::as_actor<G>::convert(g),
  580. ::phoenix::as_actor<H>::convert(h),
  581. ::phoenix::as_actor<I>::convert(i),
  582. ::phoenix::as_actor<J>::convert(j)
  583. )
  584. );
  585. }
  586. template <
  587. typename A, typename B, typename C, typename D, typename E,
  588. typename F, typename G, typename H, typename I, typename J,
  589. typename K
  590. >
  591. init_closure_parser<
  592. DerivedT2,
  593. ::phoenix::tuple<
  594. typename ::phoenix::as_actor<A>::type,
  595. typename ::phoenix::as_actor<B>::type,
  596. typename ::phoenix::as_actor<C>::type,
  597. typename ::phoenix::as_actor<D>::type,
  598. typename ::phoenix::as_actor<E>::type,
  599. typename ::phoenix::as_actor<F>::type,
  600. typename ::phoenix::as_actor<G>::type,
  601. typename ::phoenix::as_actor<H>::type,
  602. typename ::phoenix::as_actor<I>::type,
  603. typename ::phoenix::as_actor<J>::type,
  604. typename ::phoenix::as_actor<K>::type
  605. >
  606. >
  607. operator()(
  608. A const &a, B const &b, C const &c, D const &d, E const &e,
  609. F const &f, G const &g, H const &h, I const &i, J const &j,
  610. K const &k
  611. ) const
  612. {
  613. typedef typename ::phoenix::as_actor<A>::type a_t;
  614. typedef typename ::phoenix::as_actor<B>::type b_t;
  615. typedef typename ::phoenix::as_actor<C>::type c_t;
  616. typedef typename ::phoenix::as_actor<D>::type d_t;
  617. typedef typename ::phoenix::as_actor<E>::type e_t;
  618. typedef typename ::phoenix::as_actor<F>::type f_t;
  619. typedef typename ::phoenix::as_actor<G>::type g_t;
  620. typedef typename ::phoenix::as_actor<H>::type h_t;
  621. typedef typename ::phoenix::as_actor<I>::type i_t;
  622. typedef typename ::phoenix::as_actor<J>::type j_t;
  623. typedef typename ::phoenix::as_actor<K>::type k_t;
  624. typedef ::phoenix::tuple<
  625. a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t, j_t,
  626. k_t
  627. > actor_tuple_t;
  628. return init_closure_parser<DerivedT2, actor_tuple_t>(
  629. aux_derived(),
  630. actor_tuple_t(
  631. ::phoenix::as_actor<A>::convert(a),
  632. ::phoenix::as_actor<B>::convert(b),
  633. ::phoenix::as_actor<C>::convert(c),
  634. ::phoenix::as_actor<D>::convert(d),
  635. ::phoenix::as_actor<E>::convert(e),
  636. ::phoenix::as_actor<F>::convert(f),
  637. ::phoenix::as_actor<G>::convert(g),
  638. ::phoenix::as_actor<H>::convert(h),
  639. ::phoenix::as_actor<I>::convert(i),
  640. ::phoenix::as_actor<J>::convert(j),
  641. ::phoenix::as_actor<K>::convert(k)
  642. )
  643. );
  644. }
  645. template <
  646. typename A, typename B, typename C, typename D, typename E,
  647. typename F, typename G, typename H, typename I, typename J,
  648. typename K, typename L
  649. >
  650. init_closure_parser<
  651. DerivedT2,
  652. ::phoenix::tuple<
  653. typename ::phoenix::as_actor<A>::type,
  654. typename ::phoenix::as_actor<B>::type,
  655. typename ::phoenix::as_actor<C>::type,
  656. typename ::phoenix::as_actor<D>::type,
  657. typename ::phoenix::as_actor<E>::type,
  658. typename ::phoenix::as_actor<F>::type,
  659. typename ::phoenix::as_actor<G>::type,
  660. typename ::phoenix::as_actor<H>::type,
  661. typename ::phoenix::as_actor<I>::type,
  662. typename ::phoenix::as_actor<J>::type,
  663. typename ::phoenix::as_actor<K>::type,
  664. typename ::phoenix::as_actor<L>::type
  665. >
  666. >
  667. operator()(
  668. A const &a, B const &b, C const &c, D const &d, E const &e,
  669. F const &f, G const &g, H const &h, I const &i, J const &j,
  670. K const &k, L const &l
  671. ) const
  672. {
  673. typedef typename ::phoenix::as_actor<A>::type a_t;
  674. typedef typename ::phoenix::as_actor<B>::type b_t;
  675. typedef typename ::phoenix::as_actor<C>::type c_t;
  676. typedef typename ::phoenix::as_actor<D>::type d_t;
  677. typedef typename ::phoenix::as_actor<E>::type e_t;
  678. typedef typename ::phoenix::as_actor<F>::type f_t;
  679. typedef typename ::phoenix::as_actor<G>::type g_t;
  680. typedef typename ::phoenix::as_actor<H>::type h_t;
  681. typedef typename ::phoenix::as_actor<I>::type i_t;
  682. typedef typename ::phoenix::as_actor<J>::type j_t;
  683. typedef typename ::phoenix::as_actor<K>::type k_t;
  684. typedef typename ::phoenix::as_actor<L>::type l_t;
  685. typedef ::phoenix::tuple<
  686. a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t, j_t,
  687. k_t, l_t
  688. > actor_tuple_t;
  689. return init_closure_parser<DerivedT2, actor_tuple_t>(
  690. aux_derived(),
  691. actor_tuple_t(
  692. ::phoenix::as_actor<A>::convert(a),
  693. ::phoenix::as_actor<B>::convert(b),
  694. ::phoenix::as_actor<C>::convert(c),
  695. ::phoenix::as_actor<D>::convert(d),
  696. ::phoenix::as_actor<E>::convert(e),
  697. ::phoenix::as_actor<F>::convert(f),
  698. ::phoenix::as_actor<G>::convert(g),
  699. ::phoenix::as_actor<H>::convert(h),
  700. ::phoenix::as_actor<I>::convert(i),
  701. ::phoenix::as_actor<J>::convert(j),
  702. ::phoenix::as_actor<K>::convert(k),
  703. ::phoenix::as_actor<L>::convert(l)
  704. )
  705. );
  706. }
  707. #if BOOST_SPIRIT_CLOSURE_LIMIT > 12
  708. template <
  709. typename A, typename B, typename C, typename D, typename E,
  710. typename F, typename G, typename H, typename I, typename J,
  711. typename K, typename L, typename M
  712. >
  713. init_closure_parser<
  714. DerivedT2,
  715. ::phoenix::tuple<
  716. typename ::phoenix::as_actor<A>::type,
  717. typename ::phoenix::as_actor<B>::type,
  718. typename ::phoenix::as_actor<C>::type,
  719. typename ::phoenix::as_actor<D>::type,
  720. typename ::phoenix::as_actor<E>::type,
  721. typename ::phoenix::as_actor<F>::type,
  722. typename ::phoenix::as_actor<G>::type,
  723. typename ::phoenix::as_actor<H>::type,
  724. typename ::phoenix::as_actor<I>::type,
  725. typename ::phoenix::as_actor<J>::type,
  726. typename ::phoenix::as_actor<K>::type,
  727. typename ::phoenix::as_actor<L>::type,
  728. typename ::phoenix::as_actor<M>::type
  729. >
  730. >
  731. operator()(
  732. A const &a, B const &b, C const &c, D const &d, E const &e,
  733. F const &f, G const &g, H const &h, I const &i, J const &j,
  734. K const &k, L const &l, M const &m
  735. ) const
  736. {
  737. typedef typename ::phoenix::as_actor<A>::type a_t;
  738. typedef typename ::phoenix::as_actor<B>::type b_t;
  739. typedef typename ::phoenix::as_actor<C>::type c_t;
  740. typedef typename ::phoenix::as_actor<D>::type d_t;
  741. typedef typename ::phoenix::as_actor<E>::type e_t;
  742. typedef typename ::phoenix::as_actor<F>::type f_t;
  743. typedef typename ::phoenix::as_actor<G>::type g_t;
  744. typedef typename ::phoenix::as_actor<H>::type h_t;
  745. typedef typename ::phoenix::as_actor<I>::type i_t;
  746. typedef typename ::phoenix::as_actor<J>::type j_t;
  747. typedef typename ::phoenix::as_actor<K>::type k_t;
  748. typedef typename ::phoenix::as_actor<L>::type l_t;
  749. typedef typename ::phoenix::as_actor<M>::type m_t;
  750. typedef ::phoenix::tuple<
  751. a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t, j_t,
  752. k_t, l_t, m_t
  753. > actor_tuple_t;
  754. return init_closure_parser<DerivedT2, actor_tuple_t>(
  755. aux_derived(),
  756. actor_tuple_t(
  757. ::phoenix::as_actor<A>::convert(a),
  758. ::phoenix::as_actor<B>::convert(b),
  759. ::phoenix::as_actor<C>::convert(c),
  760. ::phoenix::as_actor<D>::convert(d),
  761. ::phoenix::as_actor<E>::convert(e),
  762. ::phoenix::as_actor<F>::convert(f),
  763. ::phoenix::as_actor<G>::convert(g),
  764. ::phoenix::as_actor<H>::convert(h),
  765. ::phoenix::as_actor<I>::convert(i),
  766. ::phoenix::as_actor<J>::convert(j),
  767. ::phoenix::as_actor<K>::convert(k),
  768. ::phoenix::as_actor<L>::convert(l),
  769. ::phoenix::as_actor<M>::convert(m)
  770. )
  771. );
  772. }
  773. template <
  774. typename A, typename B, typename C, typename D, typename E,
  775. typename F, typename G, typename H, typename I, typename J,
  776. typename K, typename L, typename M, typename N
  777. >
  778. init_closure_parser<
  779. DerivedT2,
  780. ::phoenix::tuple<
  781. typename ::phoenix::as_actor<A>::type,
  782. typename ::phoenix::as_actor<B>::type,
  783. typename ::phoenix::as_actor<C>::type,
  784. typename ::phoenix::as_actor<D>::type,
  785. typename ::phoenix::as_actor<E>::type,
  786. typename ::phoenix::as_actor<F>::type,
  787. typename ::phoenix::as_actor<G>::type,
  788. typename ::phoenix::as_actor<H>::type,
  789. typename ::phoenix::as_actor<I>::type,
  790. typename ::phoenix::as_actor<J>::type,
  791. typename ::phoenix::as_actor<K>::type,
  792. typename ::phoenix::as_actor<L>::type,
  793. typename ::phoenix::as_actor<M>::type,
  794. typename ::phoenix::as_actor<N>::type
  795. >
  796. >
  797. operator()(
  798. A const &a, B const &b, C const &c, D const &d, E const &e,
  799. F const &f, G const &g, H const &h, I const &i, J const &j,
  800. K const &k, L const &l, M const &m, N const &n
  801. ) const
  802. {
  803. typedef typename ::phoenix::as_actor<A>::type a_t;
  804. typedef typename ::phoenix::as_actor<B>::type b_t;
  805. typedef typename ::phoenix::as_actor<C>::type c_t;
  806. typedef typename ::phoenix::as_actor<D>::type d_t;
  807. typedef typename ::phoenix::as_actor<E>::type e_t;
  808. typedef typename ::phoenix::as_actor<F>::type f_t;
  809. typedef typename ::phoenix::as_actor<G>::type g_t;
  810. typedef typename ::phoenix::as_actor<H>::type h_t;
  811. typedef typename ::phoenix::as_actor<I>::type i_t;
  812. typedef typename ::phoenix::as_actor<J>::type j_t;
  813. typedef typename ::phoenix::as_actor<K>::type k_t;
  814. typedef typename ::phoenix::as_actor<L>::type l_t;
  815. typedef typename ::phoenix::as_actor<M>::type m_t;
  816. typedef typename ::phoenix::as_actor<N>::type n_t;
  817. typedef ::phoenix::tuple<
  818. a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t, j_t,
  819. k_t, l_t, m_t, n_t
  820. > actor_tuple_t;
  821. return init_closure_parser<DerivedT2, actor_tuple_t>(
  822. aux_derived(),
  823. actor_tuple_t(
  824. ::phoenix::as_actor<A>::convert(a),
  825. ::phoenix::as_actor<B>::convert(b),
  826. ::phoenix::as_actor<C>::convert(c),
  827. ::phoenix::as_actor<D>::convert(d),
  828. ::phoenix::as_actor<E>::convert(e),
  829. ::phoenix::as_actor<F>::convert(f),
  830. ::phoenix::as_actor<G>::convert(g),
  831. ::phoenix::as_actor<H>::convert(h),
  832. ::phoenix::as_actor<I>::convert(i),
  833. ::phoenix::as_actor<J>::convert(j),
  834. ::phoenix::as_actor<K>::convert(k),
  835. ::phoenix::as_actor<L>::convert(l),
  836. ::phoenix::as_actor<M>::convert(m),
  837. ::phoenix::as_actor<N>::convert(n)
  838. )
  839. );
  840. }
  841. template <
  842. typename A, typename B, typename C, typename D, typename E,
  843. typename F, typename G, typename H, typename I, typename J,
  844. typename K, typename L, typename M, typename N, typename O
  845. >
  846. init_closure_parser<
  847. DerivedT2,
  848. ::phoenix::tuple<
  849. typename ::phoenix::as_actor<A>::type,
  850. typename ::phoenix::as_actor<B>::type,
  851. typename ::phoenix::as_actor<C>::type,
  852. typename ::phoenix::as_actor<D>::type,
  853. typename ::phoenix::as_actor<E>::type,
  854. typename ::phoenix::as_actor<F>::type,
  855. typename ::phoenix::as_actor<G>::type,
  856. typename ::phoenix::as_actor<H>::type,
  857. typename ::phoenix::as_actor<I>::type,
  858. typename ::phoenix::as_actor<J>::type,
  859. typename ::phoenix::as_actor<K>::type,
  860. typename ::phoenix::as_actor<L>::type,
  861. typename ::phoenix::as_actor<M>::type,
  862. typename ::phoenix::as_actor<N>::type,
  863. typename ::phoenix::as_actor<O>::type
  864. >
  865. >
  866. operator()(
  867. A const &a, B const &b, C const &c, D const &d, E const &e,
  868. F const &f, G const &g, H const &h, I const &i, J const &j,
  869. K const &k, L const &l, M const &m, N const &n, O const &o
  870. ) const
  871. {
  872. typedef typename ::phoenix::as_actor<A>::type a_t;
  873. typedef typename ::phoenix::as_actor<B>::type b_t;
  874. typedef typename ::phoenix::as_actor<C>::type c_t;
  875. typedef typename ::phoenix::as_actor<D>::type d_t;
  876. typedef typename ::phoenix::as_actor<E>::type e_t;
  877. typedef typename ::phoenix::as_actor<F>::type f_t;
  878. typedef typename ::phoenix::as_actor<G>::type g_t;
  879. typedef typename ::phoenix::as_actor<H>::type h_t;
  880. typedef typename ::phoenix::as_actor<I>::type i_t;
  881. typedef typename ::phoenix::as_actor<J>::type j_t;
  882. typedef typename ::phoenix::as_actor<K>::type k_t;
  883. typedef typename ::phoenix::as_actor<L>::type l_t;
  884. typedef typename ::phoenix::as_actor<M>::type m_t;
  885. typedef typename ::phoenix::as_actor<N>::type n_t;
  886. typedef typename ::phoenix::as_actor<O>::type o_t;
  887. typedef ::phoenix::tuple<
  888. a_t, b_t, c_t, d_t, e_t, f_t, g_t, h_t, i_t, j_t,
  889. k_t, l_t, m_t, n_t, o_t
  890. > actor_tuple_t;
  891. return init_closure_parser<DerivedT2, actor_tuple_t>(
  892. aux_derived(),
  893. actor_tuple_t(
  894. ::phoenix::as_actor<A>::convert(a),
  895. ::phoenix::as_actor<B>::convert(b),
  896. ::phoenix::as_actor<C>::convert(c),
  897. ::phoenix::as_actor<D>::convert(d),
  898. ::phoenix::as_actor<E>::convert(e),
  899. ::phoenix::as_actor<F>::convert(f),
  900. ::phoenix::as_actor<G>::convert(g),
  901. ::phoenix::as_actor<H>::convert(h),
  902. ::phoenix::as_actor<I>::convert(i),
  903. ::phoenix::as_actor<J>::convert(j),
  904. ::phoenix::as_actor<K>::convert(k),
  905. ::phoenix::as_actor<L>::convert(l),
  906. ::phoenix::as_actor<M>::convert(m),
  907. ::phoenix::as_actor<N>::convert(n),
  908. ::phoenix::as_actor<O>::convert(o)
  909. )
  910. );
  911. }
  912. #endif
  913. #endif
  914. #endif
  915. #endif
  916. };
  917. ~closure() {}
  918. };
  919. ///////////////////////////////////////////////////////////////////////////
  920. //
  921. // overloads for chseq_p and str_p taking in phoenix actors
  922. //
  923. ///////////////////////////////////////////////////////////////////////////
  924. template <typename ActorT>
  925. struct container_begin
  926. {
  927. typedef container_begin<ActorT> self_t;
  928. template <typename TupleT>
  929. struct result
  930. {
  931. typedef typename ::phoenix::actor_result<ActorT, TupleT>
  932. ::plain_type::iterator type;
  933. };
  934. container_begin(ActorT actor_)
  935. : actor(actor_) {}
  936. template <typename TupleT>
  937. typename ::phoenix::actor_result<self_t, TupleT>::type
  938. eval(TupleT const& /*args*/) const
  939. { return actor().begin(); }
  940. ActorT actor;
  941. };
  942. template <typename ActorT>
  943. struct container_end
  944. {
  945. typedef container_begin<ActorT> self_t;
  946. template <typename TupleT>
  947. struct result
  948. {
  949. typedef typename ::phoenix::actor_result<ActorT, TupleT>
  950. ::plain_type::iterator type;
  951. };
  952. container_end(ActorT actor_)
  953. : actor(actor_) {}
  954. template <typename TupleT>
  955. typename ::phoenix::actor_result<self_t, TupleT>::type
  956. eval(TupleT const& /*args*/) const
  957. { return actor().end(); }
  958. ActorT actor;
  959. };
  960. template <typename BaseT>
  961. inline f_chseq<
  962. ::phoenix::actor<container_begin< ::phoenix::actor<BaseT> > >,
  963. ::phoenix::actor<container_end< ::phoenix::actor<BaseT> > >
  964. >
  965. f_chseq_p(::phoenix::actor<BaseT> const& a)
  966. {
  967. typedef ::phoenix::actor<container_begin< ::phoenix::actor<BaseT> > >
  968. container_begin_t;
  969. typedef ::phoenix::actor<container_end< ::phoenix::actor<BaseT> > >
  970. container_end_t;
  971. typedef f_chseq<container_begin_t, container_end_t> result_t;
  972. return result_t(container_begin_t(a), container_end_t(a));
  973. }
  974. template <typename BaseT>
  975. inline f_strlit<
  976. ::phoenix::actor<container_begin< ::phoenix::actor<BaseT> > >,
  977. ::phoenix::actor<container_end< ::phoenix::actor<BaseT> > >
  978. >
  979. f_str_p(::phoenix::actor<BaseT> const& a)
  980. {
  981. typedef ::phoenix::actor<container_begin< ::phoenix::actor<BaseT> > >
  982. container_begin_t;
  983. typedef ::phoenix::actor<container_end< ::phoenix::actor<BaseT> > >
  984. container_end_t;
  985. typedef f_strlit<container_begin_t, container_end_t> result_t;
  986. return result_t(container_begin_t(a), container_end_t(a));
  987. }
  988. BOOST_SPIRIT_CLASSIC_NAMESPACE_END
  989. }} // namespace BOOST_SPIRIT_CLASSIC_NS
  990. #endif