]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/metaparse/doc/repeated_one_of.qbk
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / metaparse / doc / repeated_one_of.qbk
CommitLineData
7c673cae
FG
1[#repeated_one_of]
2[section repeated_one_of]
3
4[h1 Synopsis]
5
6 template <class P1, class P2, /* ... */, class Pn>
7 struct repeated_one_of1;
8
9[table Arguments
10 [[Name] [Type]]
11 [[`P1` .. `Pn`][[link parser parser]s]]
12]
13
14This is a [link parser_combinator parser combinator].
15
16[h1 Description]
17
18It applies the `P1` ... `Pn` parsers repeatedly as long as any of them accepts
19the input. In each iteration the parsers are tried in order and the first one
20accepting the input is used, therefore in case of ambiguous grammars the result
21of parsing depends on the order of the `P1` ... `Pn` parsers. The result of
22parsing with this [link parser_combinator parser combinator] is a sequence of
23the individual parsing results.
24
25When none of the `P1` ... `Pn` parsers accept the input in the first iteration,
26`repeated_one_of` accepts the input and the result of parsing is an empty
27sequence.
28
29The maximum number of accepted parsers is defined by the
30`BOOST_METAPARSE_LIMIT_ONE_OF_SIZE` macro. Its default value is 20.
31
32[h1 Header]
33
34 #include <boost/metaparse/repeated_one_of.hpp>
35
36[h1 Expression semantics]
37
38For any `p1`, ..., `pn` parsers
39
40 repeated_one_of<p1, /* ... */, pn>
41
42is equivalent to
43
44 repeated<one_of<p1, /* ... */, pn>>
45
46[h1 Example]
47
48 #include <boost/metaparse/repeated_one_of.hpp>
49 #include <boost/metaparse/lit_c.hpp>
50 #include <boost/metaparse/start.hpp>
51 #include <boost/metaparse/string.hpp>
52 #include <boost/metaparse/get_result.hpp>
53
54 #include <boost/mpl/equal.hpp>
55 #include <boost/mpl/vector.hpp>
56 #include <boost/mpl/char.hpp>
57
58 using namespace boost::metaparse;
59
60 using as_and_bs = repeated_one_of<lit_c<'a'>, lit_c<'b'>>;
61
62 static_assert(
63 boost::mpl::equal<
64 get_result<as_and_bs::apply<BOOST_METAPARSE_STRING("abaab"), start>>::type,
65 boost::mpl::vector<
66 boost::mpl::char_<'a'>,
67 boost::mpl::char_<'b'>,
68 boost::mpl::char_<'a'>,
69 boost::mpl::char_<'a'>,
70 boost::mpl::char_<'b'>
71 >
72 >::type::value,
73 "the result of parsing should be the list of results"
74 );
75
76 static_assert(
77 boost::mpl::equal<
78 get_result<as_and_bs::apply<BOOST_METAPARSE_STRING("x"), start>>::type,
79 boost::mpl::vector<>
80 >::type::value,
81 "repeated_one_of should accept the input when it"
82 " can't parse anything with digit_val"
83 );
84
85[endsect]
86