1 [#repeated_reject_incomplete1]
2 [section repeated_reject_incomplete1]
7 struct repeated_reject_incomplete1;
9 This is a [link parser_combinator parser combinator].
13 [[`P`] [[link parser parser]]]
18 The same as [link repeated1 `repeated1`], but once `P` rejects the input,
19 `repeated_reject_incomplete1` checks if `P` consumes any characters before
20 rejecting the input. If so, `repeated_reject_incomplete1` rejects the input with
21 the 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`].
27 #include <boost/metaparse/repeated_reject_incomplete1.hpp>
29 [h1 Expression semantics]
31 For any `p` parser, `s` compile-time string and `pos` source position
33 repeated_reject_incomplete1<p>::apply<s, pos>
37 first_of<repeated1<p>, fail_at_first_char_expected<p> >::apply<s, pos>
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>
51 #include <boost/mpl/equal.hpp>
52 #include <boost/mpl/vector_c.hpp>
54 using namespace boost::metaparse;
56 using int_token = token<int_>;
57 using plus_token = token<lit_c<'+'>>;
58 using plus_int = last_of<plus_token, int_token>;
60 using ints = repeated_reject_incomplete1<plus_int>;
64 boost::mpl::vector_c<int, 13, 3, 21>,
66 ints::apply<BOOST_METAPARSE_STRING("+ 13 + 3 + 21"), start>
69 "ints should parse the numbers"
74 ints::apply<BOOST_METAPARSE_STRING("+ 13 + 3 +"), start>
76 "when the last number is missing, it should be an error"
80 is_error<ints::apply<BOOST_METAPARSE_STRING(""), start>>::type::value,
81 "when no numbers are provided, it should be an error"