6 template <class P1, class P2, /* ... */, class Pn>
9 This is a [link parser_combinator parser combinator].
13 [[`P1` .. `Pn`] [[link parser parser]s]]
18 It accepts an input when any of the `P1`, ... `Pn` parsers accept it. The result
19 of parsing is the result of applying the first parser that accepts the input.
20 The parsers are tried in order, therefore in case of ambiguous grammars the
21 result of parsing depends on the order of the `P1` ... `Pn` parsers.
23 The maximum number of accepted parsers is defined by the
24 `BOOST_METAPARSE_LIMIT_ONE_OF_SIZE` macro. Its default value is `20`.
28 #include <boost/metaparse/one_of.hpp>
30 [h1 Expression semantics]
32 For any `p1`, ..., `pn` parsers, `s` compile-time string and `pos` source
35 one_of<p1, ..., pn>::apply<s, pos>
41 when there is a `k`, that `pi::apply<s, pos>::type` returns an error for every
42 `i` in the range `[1..k)` and `pk::apply<s, pos>::type` doesn't return an error.
44 The parser combinator returns an error when there is no such `k`.
48 #include <boost/metaparse/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 #include <boost/metaparse/is_error.hpp>
55 using namespace boost::metaparse;
58 one_of<lit_c<' '>, lit_c<'\n'>, lit_c<'\r'>, lit_c<'\t'>, lit_c<'\v'>>;
62 whitespace::apply<BOOST_METAPARSE_STRING(" "), start>
63 >::type::value == ' ',
64 "the result of parsing should be the first character of the input"
68 is_error<whitespace::apply<BOOST_METAPARSE_STRING("x"), start>>::type::value,
69 "it should return an error when the input does not begin with a whitespace"