]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/metaparse/doc/repeated1.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / metaparse / doc / repeated1.qbk
1 [#repeated1]
2 [section repeated1]
3
4 [h1 Synopsis]
5
6 template <class P>
7 struct repeated1;
8
9 This is a [link parser_combinator parser combinator].
10
11 [table Arguments
12 [[Name] [Type]]
13 [[`P`] [[link parser parser]]]
14 ]
15
16 [h1 Description]
17
18 It applies `P` on the input string repeatedly as long as the parser accepts the
19 input. The result of parsing is a sequence of the results of the individual
20 applications of `P`.
21
22 When `P` rejects the input for the first time, `repeated1` rejects it as well.
23 At least one successful application of `P` is required for `repeated1` to accept
24 the input.
25
26 [h1 Header]
27
28 #include <boost/metaparse/repeated1.hpp>
29
30 [h1 Expression semantics]
31
32 For any `p` parser the following are equivalent:
33
34 repeated1<p>
35
36 last_of<look_ahead<p>, repeated<p>>
37
38 [h1 Example]
39
40 #include <boost/metaparse/repeated1.hpp>
41 #include <boost/metaparse/digit_val.hpp>
42 #include <boost/metaparse/start.hpp>
43 #include <boost/metaparse/string.hpp>
44 #include <boost/metaparse/get_result.hpp>
45 #include <boost/metaparse/is_error.hpp>
46
47 #include <boost/mpl/equal.hpp>
48 #include <boost/mpl/vector.hpp>
49 #include <boost/mpl/int.hpp>
50
51 using namespace boost::metaparse;
52
53 using digits = repeated1<digit_val>;
54
55 static_assert(
56 boost::mpl::equal<
57 get_result<digits::apply<BOOST_METAPARSE_STRING("1234"), start>>::type,
58 boost::mpl::vector<
59 boost::mpl::int_<1>,
60 boost::mpl::int_<2>,
61 boost::mpl::int_<3>,
62 boost::mpl::int_<4>
63 >
64 >::type::value,
65 "the result of parsing should be the list of digit values"
66 );
67
68 static_assert(
69 is_error<digits::apply<BOOST_METAPARSE_STRING("x"), start>>::type::value,
70 "repeated1 should reject the input when it can't parse anything with digit_val"
71 );
72
73 [endsect]
74