]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/spirit/test/karma/debug.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / spirit / test / karma / debug.cpp
CommitLineData
7c673cae
FG
1// Copyright (c) 2001-2011 Hartmut Kaiser
2// Copyright (c) 2001-2011 Joel de Guzman
3//
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#define BOOST_SPIRIT_KARMA_DEBUG
8
7c673cae
FG
9#include <boost/spirit/include/karma_operator.hpp>
10#include <boost/spirit/include/karma_char.hpp>
11#include <boost/spirit/include/karma_string.hpp>
12#include <boost/spirit/include/karma_numeric.hpp>
13#include <boost/spirit/include/karma_auxiliary.hpp>
14#include <boost/spirit/include/karma_nonterminal.hpp>
15#include <boost/spirit/include/karma_action.hpp>
1e59de90
TL
16#include <boost/phoenix/core.hpp>
17#include <boost/phoenix/operator.hpp>
7c673cae
FG
18#include <boost/fusion/include/std_pair.hpp>
19
20#include <string>
21#include <cstring>
22#include <iostream>
23#include "test.hpp"
24
25int main()
26{
27 using spirit_test::test;
28 using spirit_test::test_delimited;
29
30 using namespace boost::spirit::ascii;
31 using namespace boost::spirit::karma::labels;
32 using boost::spirit::karma::locals;
33 using boost::spirit::karma::rule;
34 using boost::spirit::karma::char_;
35 using boost::spirit::karma::debug;
36 using boost::spirit::karma::space;
37 using boost::spirit::karma::eps;
38
7c673cae
FG
39 typedef spirit_test::output_iterator<char>::type outiter_type;
40
41 { // basic tests
42 rule<outiter_type, char()> a, b, c;
43 rule<outiter_type, std::vector<char>()> start;
44
45 std::vector<char> v;
46 v.push_back('a');
47 v.push_back('b');
48 v.push_back('a');
49 v.push_back('c');
50 v.push_back('a');
51 v.push_back('b');
52 v.push_back('b');
53 v.push_back('a');
54
55 a = char_('a');
56 b = char_('b');
57 c = char_('c');
58 BOOST_SPIRIT_DEBUG_NODE(a);
59 BOOST_SPIRIT_DEBUG_NODE(b);
60 BOOST_SPIRIT_DEBUG_NODE(c);
61
62 start = *(a | b | c);
63 BOOST_SPIRIT_DEBUG_NODE(start);
64 BOOST_TEST(test("abacabba", start, v));
65
66 // ignore the delimiter
67 BOOST_TEST(test_delimited("abacabba ", start, v, space));
68
69 std::vector<char> v1;
70 v1.push_back('b');
71 v1.push_back('c');
72
73 start = (a | b) << c;
74 BOOST_SPIRIT_DEBUG_NODE(start);
75 BOOST_TEST(test("bc", start, v1));
76 }
77
78 { // tests with locals
79 rule<outiter_type, char()> a, b, c;
80 rule<outiter_type, std::vector<char>(), locals<int, double> > start;
81
82 std::vector<char> v;
83 v.push_back('a');
84 v.push_back('b');
85 v.push_back('a');
86 v.push_back('c');
87 v.push_back('a');
88 v.push_back('b');
89 v.push_back('b');
90 v.push_back('a');
91
92 a = char_('a');
93 b = char_('b');
94 c = char_('c');
95 BOOST_SPIRIT_DEBUG_NODE(a);
96 BOOST_SPIRIT_DEBUG_NODE(b);
97 BOOST_SPIRIT_DEBUG_NODE(c);
98
20effc67 99 start %= eps[(_a = 0, _b = 2.0)] << *(a[++_a] | b | c);
7c673cae
FG
100 BOOST_SPIRIT_DEBUG_NODE(start);
101 BOOST_TEST(test("abacabba", start, v));
102 }
103
104 return boost::report_errors();
105}
106