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