1[#repeated_one_of1] 2[section repeated_one_of1] 3 4[h1 Synopsis] 5 6 template <class... Ps> 7 struct repeated_one_of1; 8 9This is a [link parser_combinator parser combinator]. 10 11[table Arguments 12 [[Name] [Type]] 13 [[`Ps`] [[link parser parser]s]] 14] 15 16[h1 Description] 17 18It applies the `Ps...` parsers repeatedly as long as any of them accepts the 19input. 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 `Ps...` parsers. The result of parsing 22with this [link parser_combinator parser combinator] is a sequence of the 23individual parsing results. 24 25When none of the `Ps...` parsers accept the input in the first iteration, 26`repeated_one_of1` rejects the input. 27 28On compilers, which are not C++11-compliant, the maximum number of accepted 29parsers is defined by the `BOOST_METAPARSE_LIMIT_ONE_OF_SIZE` macro. Its default 30value is 20. 31 32[h1 Header] 33 34 #include <boost/metaparse/repeated_one_of1.hpp> 35 36[h1 Expression semantics] 37 38For any `p1`, ..., `pn` parsers 39 40 repeated_one_of1<p1, /* ... */, pn> 41 42is equivalent to 43 44 repeated1<one_of<p1, /* ... */, pn>> 45 46[h1 Example] 47 48 #include <boost/metaparse/repeated_one_of1.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> 54 55 #include <boost/mpl/equal.hpp> 56 #include <boost/mpl/vector.hpp> 57 #include <boost/mpl/char.hpp> 58 59 using namespace boost::metaparse; 60 61 using as_and_bs = repeated_one_of1<lit_c<'a'>, lit_c<'b'>>; 62 63 static_assert( 64 boost::mpl::equal< 65 get_result<as_and_bs::apply<BOOST_METAPARSE_STRING("abaab"), start>>::type, 66 boost::mpl::vector< 67 boost::mpl::char_<'a'>, 68 boost::mpl::char_<'b'>, 69 boost::mpl::char_<'a'>, 70 boost::mpl::char_<'a'>, 71 boost::mpl::char_<'b'> 72 > 73 >::type::value, 74 "the result of parsing should be the list of results" 75 ); 76 77 static_assert( 78 is_error<as_and_bs::apply<BOOST_METAPARSE_STRING("x"), start>>::type::value, 79 "repeated_one_of1 should reject the input when it" 80 " can't parse anything with digit_val" 81 ); 82 83[endsect] 84 85