• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*==============================================================================
2     Copyright (c) 2001-2010 Joel de Guzman
3     Copyright (c) 2010 Thomas Heller
4 
5     Distributed under the Boost Software License, Version 1.0. (See accompanying
6     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #ifndef BOOST_PHOENIX_STATEMENT_DO_WHILE_HPP
9 #define BOOST_PHOENIX_STATEMENT_DO_WHILE_HPP
10 
11 #include <boost/phoenix/core/limits.hpp>
12 #include <boost/phoenix/core/call.hpp>
13 #include <boost/phoenix/core/expression.hpp>
14 #include <boost/phoenix/core/meta_grammar.hpp>
15 
16 BOOST_PHOENIX_DEFINE_EXPRESSION(
17     (boost)(phoenix)(do_while)
18   , (meta_grammar) // Cond
19     (meta_grammar) // Do
20 )
21 
22 namespace boost { namespace phoenix
23 {
24     struct do_while_eval
25     {
26         typedef void result_type;
27 
28         template <typename Cond, typename Do, typename Context>
29         result_type
operator ()boost::phoenix::do_while_eval30         operator()(Cond const& cond, Do const& do_it, Context const & ctx) const
31         {
32             do
33                 boost::phoenix::eval(do_it, ctx);
34             while (boost::phoenix::eval(cond, ctx));
35         }
36     };
37 
38     template <typename Dummy>
39     struct default_actions::when<rule::do_while, Dummy>
40         : call<do_while_eval, Dummy>
41     {};
42 
43     template <typename Do>
44     struct do_while_gen
45     {
do_while_genboost::phoenix::do_while_gen46         do_while_gen(Do const& do_it)
47             : do_(do_it) {}
48 
49         template <typename Cond>
50         typename expression::do_while<Cond, Do>::type const
while_boost::phoenix::do_while_gen51         while_(Cond const& cond) const
52         {
53             return expression::do_while<Cond, Do>::make(cond, do_);
54         }
55 
56         Do const& do_;
57     };
58 
59     struct do_gen
60     {
61         template <typename Do>
62         do_while_gen<Do> const
operator []boost::phoenix::do_gen63         operator[](Do const& do_) const
64         {
65             return do_while_gen<Do>(do_);
66         }
67     };
68 
69 #ifndef BOOST_PHOENIX_NO_PREDEFINED_TERMINALS
70     do_gen const do_ = {};
71 #endif
72 
73 }}
74 
75 #endif
76