9 This is a [link parser_combinator parser combinator].
13 [[`P`] [[link parser parser]]]
18 `token` parses the input using `P` when it succeeds, `token` consumes all
19 whitespaces afterwards. The result of parsing is the result of `P`.
23 #include <boost/metaparse/token.hpp>
25 [h1 Expression semantics]
27 For any `p` parser the following are equivalent:
35 #include <boost/metaparse/token.hpp>
36 #include <boost/metaparse/int_.hpp>
37 #include <boost/metaparse/start.hpp>
38 #include <boost/metaparse/get_result.hpp>
39 #include <boost/metaparse/get_remaining.hpp>
40 #include <boost/metaparse/is_error.hpp>
41 #include <boost/metaparse/string.hpp>
43 #include <type_traits>
45 using namespace boost::metaparse;
47 using int_token = token<int_>;
51 int_token::apply<BOOST_METAPARSE_STRING("13 "), start>
53 "the result of int_token is the number"
58 BOOST_METAPARSE_STRING(""),
59 get_remaining<int_token::apply<BOOST_METAPARSE_STRING("13 "), start>>::type
61 "token consumes whitespaces after the number"
66 int_token::apply<BOOST_METAPARSE_STRING("13"), start>
68 "whitespaces after the number are optional"
72 is_error<int_token::apply<BOOST_METAPARSE_STRING("foo"), start>>::type::value,
73 "when there is no number, token fails"