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