]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/karma/debug.cpp
1 // Copyright (c) 2001-2011 Hartmut Kaiser
2 // Copyright (c) 2001-2011 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)
7 #define BOOST_SPIRIT_KARMA_DEBUG
9 #include <boost/detail/lightweight_test.hpp>
10 #include <boost/spirit/include/karma_operator.hpp>
11 #include <boost/spirit/include/karma_char.hpp>
12 #include <boost/spirit/include/karma_string.hpp>
13 #include <boost/spirit/include/karma_numeric.hpp>
14 #include <boost/spirit/include/karma_auxiliary.hpp>
15 #include <boost/spirit/include/karma_nonterminal.hpp>
16 #include <boost/spirit/include/karma_action.hpp>
17 #include <boost/spirit/include/phoenix_core.hpp>
18 #include <boost/spirit/include/phoenix_operator.hpp>
19 #include <boost/fusion/include/std_pair.hpp>
28 using spirit_test::test
;
29 using spirit_test::test_delimited
;
31 using namespace boost::spirit::ascii
;
32 using namespace boost::spirit::karma::labels
;
33 using boost::spirit::karma::locals
;
34 using boost::spirit::karma::rule
;
35 using boost::spirit::karma::char_
;
36 using boost::spirit::karma::debug
;
37 using boost::spirit::karma::space
;
38 using boost::spirit::karma::eps
;
40 typedef spirit_test::output_iterator
<char>::type outiter_type
;
43 rule
<outiter_type
, char()> a
, b
, c
;
44 rule
<outiter_type
, std::vector
<char>()> start
;
59 BOOST_SPIRIT_DEBUG_NODE(a
);
60 BOOST_SPIRIT_DEBUG_NODE(b
);
61 BOOST_SPIRIT_DEBUG_NODE(c
);
64 BOOST_SPIRIT_DEBUG_NODE(start
);
65 BOOST_TEST(test("abacabba", start
, v
));
67 // ignore the delimiter
68 BOOST_TEST(test_delimited("abacabba ", start
, v
, space
));
75 BOOST_SPIRIT_DEBUG_NODE(start
);
76 BOOST_TEST(test("bc", start
, v1
));
79 { // tests with locals
80 rule
<outiter_type
, char()> a
, b
, c
;
81 rule
<outiter_type
, std::vector
<char>(), locals
<int, double> > start
;
96 BOOST_SPIRIT_DEBUG_NODE(a
);
97 BOOST_SPIRIT_DEBUG_NODE(b
);
98 BOOST_SPIRIT_DEBUG_NODE(c
);
100 start
%= eps
[(_a
= 0, _b
= 2.0)] << *(a
[++_a
] | b
| c
);
101 BOOST_SPIRIT_DEBUG_NODE(start
);
102 BOOST_TEST(test("abacabba", start
, v
));
105 return boost::report_errors();