]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/x3/actions.cpp
1 /*=============================================================================
2 Copyright (c) 2001-2015 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 =============================================================================*/
7 #include <boost/detail/lightweight_test.hpp>
8 #include <boost/spirit/home/x3.hpp>
12 namespace x3
= boost::spirit::x3
;
25 template <typename Context
>
26 void operator()(Context
const& ctx
) const
35 x3::_pass(ctx
) = false;
41 setnext(char& next
) : next(next
) {}
43 template <typename Context
>
44 void operator()(Context
const& ctx
) const
46 next
= x3::_attr(ctx
);
57 char const *s1
= "{42}", *e1
= s1
+ std::strlen(s1
);
58 x3::parse(s1
, e1
, '{' >> int_
[fun1
] >> '}');
63 char const *s1
= "{42}", *e1
= s1
+ std::strlen(s1
);
64 x3::parse(s1
, e1
, '{' >> int_
[fun_action()] >> '}');
68 using namespace std::placeholders
;
69 char const *s1
= "{42}", *e1
= s1
+ std::strlen(s1
);
70 x3::parse(s1
, e1
, '{' >> int_
[std::bind(fun_action(), _1
)] >> '}');
73 BOOST_TEST(x
== (42*3));
76 std::string
input("1234 6543");
78 BOOST_TEST(x3::phrase_parse(input
.begin(), input
.end(),
79 x3::int_
[fail
] | x3::digit
[setnext(next
)], x3::space
));
80 BOOST_TEST(next
== '1');
83 return boost::report_errors();