1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*=============================================================================
Copyright (c) 2001-2010 Hartmut Kaiser
Copyright (c) 2001-2010 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#include "match_manip.hpp"
int
main()
{
using boost::spirit::qi::_1;
using boost::spirit::qi::_2;
using boost::spirit::qi::match;
using boost::spirit::qi::phrase_match;
using boost::spirit::qi::typed_stream;
using boost::spirit::qi::stream;
using boost::spirit::qi::int_;
using namespace boost::spirit::ascii;
namespace fusion = boost::fusion;
namespace phx = boost::phoenix;
{
char a = '\0', b = '\0';
BOOST_TEST(test( "ab",
char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1]
) && a == 'a' && b == 'b');
a = '\0', b = '\0';
BOOST_TEST(test( "ab",
match(char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1])
) && a == 'a' && b == 'b');
a = '\0', b = '\0';
BOOST_TEST(test( " a b",
phrase_match(char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1], space)
) && a == 'a' && b == 'b');
fusion::vector<char, char> t;
BOOST_TEST(test( "ab",
match(char_ >> char_, t)
) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b');
t = fusion::vector<char, char>();
BOOST_TEST(test( " a b",
phrase_match(char_ >> char_, space, t)
) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b');
}
{
char a = '\0', b = '\0', c = '\0';
BOOST_TEST(test( "abc",
char_[phx::ref(a) = _1] >> char_[phx::ref(b) = _1] >> char_[phx::ref(c) = _1]
) && a == 'a' && b == 'b' && c == 'c');
BOOST_TEST(test( "abc",
match(char_('a') >> char_('b') >> char_('c'))
));
BOOST_TEST(test( " a b c",
phrase_match(char_('a') >> char_('b') >> char_('c'), space)
));
BOOST_TEST(!test( "abc",
match(char_('a') >> char_('b') >> char_('d'))
));
BOOST_TEST(!test( " a b c",
phrase_match(char_('a') >> char_('b') >> char_('d'), space)
));
fusion::vector<char, char, char> t;
BOOST_TEST(test( "abc",
match(char_ >> char_ >> char_, t)
) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
t = fusion::vector<char, char, char>();
BOOST_TEST(test( " a b c",
phrase_match(char_ >> char_ >> char_, space, t)
) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
t = fusion::vector<char, char, char>();
BOOST_TEST(test( "abc",
match(t)
) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
t = fusion::vector<char, char, char>();
BOOST_TEST(test( " a b c",
phrase_match(t, space)
) && fusion::at_c<0>(t) == 'a' && fusion::at_c<1>(t) == 'b' && fusion::at_c<2>(t) == 'c');
}
return boost::report_errors();
}
|