6 template <class P1, class P2, class P3>
9 This is a [link parser_combinator parser combinator].
13 [[`P1`] [[link parser parser]]]
14 [[`P2`] [[link parser parser]]]
15 [[`P3`] [[link parser parser]]]
20 `middle_of` applies `P1`, `P2` and `P3` in sequence. It accepts an input when
21 all of these three parsers accept it. The result of parsing is the result of
26 #include <boost/metaparse/middle_of.hpp>
28 [h1 Expression semantics]
30 For any `p1`, `p2` and `p3` parsers
40 #include <boost/metaparse/middle_of.hpp>
41 #include <boost/metaparse/int_.hpp>
42 #include <boost/metaparse/lit_c.hpp>
43 #include <boost/metaparse/token.hpp>
44 #include <boost/metaparse/start.hpp>
45 #include <boost/metaparse/string.hpp>
46 #include <boost/metaparse/is_error.hpp>
47 #include <boost/metaparse/get_result.hpp>
49 using namespace boost::metaparse;
51 using int_token = token<int_>;
52 using left_paren_token = token<lit_c<'('>>;
53 using right_paren_token = token<lit_c<')'>>;
55 using int_in_parens = middle_of<left_paren_token, int_token, right_paren_token>;
59 int_in_parens::apply<BOOST_METAPARSE_STRING("(13)"), start>
61 "it should return the result of the middle parser"
66 int_in_parens::apply<BOOST_METAPARSE_STRING("13"), start>
68 "it should reject the input when there are no parens"
73 int_in_parens::apply<BOOST_METAPARSE_STRING("(13"), start>
75 "it should reject the input when there is no closing paren"