1[#repeated_reject_incomplete1] 2[section repeated_reject_incomplete1] 3 4[h1 Synopsis] 5 6 template <class P> 7 struct repeated_reject_incomplete1; 8 9This 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 18The same as [link repeated1 `repeated1`], but once `P` rejects the input, 19`repeated_reject_incomplete1` checks if `P` consumes any characters before 20rejecting the input. If so, `repeated_reject_incomplete1` rejects the input with 21the same error message this last application of `P` returned. Otherwise 22_reject_incomplete`repeated1` accepts the input and gives the same result as 23[link repeated1 `repeated1`]. 24 25[h1 Header] 26 27 #include <boost/metaparse/repeated_reject_incomplete1.hpp> 28 29[h1 Expression semantics] 30 31For any `p` parser, `s` compile-time string and `pos` source position 32 33 repeated_reject_incomplete1<p>::apply<s, pos> 34 35is equivalent to 36 37 first_of<repeated1<p>, fail_at_first_char_expected<p> >::apply<s, pos> 38 39[h1 Example] 40 41 #include <boost/metaparse/repeated_reject_incomplete1.hpp> 42 #include <boost/metaparse/lit_c.hpp> 43 #include <boost/metaparse/last_of.hpp> 44 #include <boost/metaparse/token.hpp> 45 #include <boost/metaparse/int_.hpp> 46 #include <boost/metaparse/string.hpp> 47 #include <boost/metaparse/start.hpp> 48 #include <boost/metaparse/get_result.hpp> 49 #include <boost/metaparse/is_error.hpp> 50 51 #include <boost/mpl/equal.hpp> 52 #include <boost/mpl/vector_c.hpp> 53 54 using namespace boost::metaparse; 55 56 using int_token = token<int_>; 57 using plus_token = token<lit_c<'+'>>; 58 using plus_int = last_of<plus_token, int_token>; 59 60 using ints = repeated_reject_incomplete1<plus_int>; 61 62 static_assert( 63 boost::mpl::equal< 64 boost::mpl::vector_c<int, 13, 3, 21>, 65 get_result< 66 ints::apply<BOOST_METAPARSE_STRING("+ 13 + 3 + 21"), start> 67 >::type 68 >::type::value, 69 "ints should parse the numbers" 70 ); 71 72 static_assert( 73 is_error< 74 ints::apply<BOOST_METAPARSE_STRING("+ 13 + 3 +"), start> 75 >::type::value, 76 "when the last number is missing, it should be an error" 77 ); 78 79 static_assert( 80 is_error<ints::apply<BOOST_METAPARSE_STRING(""), start>>::type::value, 81 "when no numbers are provided, it should be an error" 82 ); 83 84[endsect] 85 86