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