]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/example/getting_started/5_2_3.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / metaparse / example / getting_started / 5_2_3.hpp
1 #ifndef BOOST_METAPARSE_GETTING_STARTED_5_2_3_HPP
2 #define BOOST_METAPARSE_GETTING_STARTED_5_2_3_HPP
3
4 // Automatically generated header file
5
6 // Definitions before section 5.2.2
7 #include "5_2_2.hpp"
8
9 // Definitions of section 5.2.2
10 using exp_parser8 =
11 build_parser<
12 sequence<
13 int_token, /* parse the first <number> */
14 transform<
15 repeated<sequence<plus_token, int_token>>, /* parse the "+ <number>" elements */
16 /* lambda expression summarising the "+ <number>" elements using fold */
17 boost::mpl::lambda<
18 /* The folding expression we have just created */
19 boost::mpl::fold<
20 boost::mpl::_1, /* the argument of the lambda expression, the result */
21 /* of the repeated<...> parser */
22 boost::mpl::int_<0>,
23 boost::mpl::quote2<sum_items>
24 >
25 >::type
26 >
27 >
28 >;
29
30 // query:
31 // exp_parser8::apply<BOOST_METAPARSE_STRING("1 + 2 + 3 + 4")>::type
32
33 using exp_parser9 =
34 build_parser<
35 transform<
36 /* What we had so far */
37 sequence<
38 int_token,
39 transform<
40 repeated<sequence<plus_token, int_token>>,
41 boost::mpl::lambda<
42 boost::mpl::fold<
43 boost::mpl::_1,
44 boost::mpl::int_<0>,
45 boost::mpl::quote2<sum_items>
46 >
47 >::type
48 >
49 >,
50 boost::mpl::quote1<sum_vector> /* summarise the vector of numbers */
51 >
52 >;
53
54 // query:
55 // exp_parser9::apply<BOOST_METAPARSE_STRING("1 + 2 + 3 + 4")>::type
56
57 #endif
58