1 | /*============================================================================= |
2 | Copyright (c) 2001-2010 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 | #include <boost/spirit/include/qi_no_skip.hpp> |
8 | |
9 | #include <boost/spirit/include/qi_lexeme.hpp> |
10 | #include <boost/spirit/include/qi_char.hpp> |
11 | #include <boost/spirit/include/qi_operator.hpp> |
12 | #include <boost/spirit/include/qi_nonterminal.hpp> |
13 | |
14 | #include <iostream> |
15 | #include "test.hpp" |
16 | |
17 | int |
18 | main() |
19 | { |
20 | using spirit_test::test_attr; |
21 | using boost::spirit::qi::no_skip; |
22 | using boost::spirit::qi::lexeme; |
23 | using boost::spirit::qi::char_; |
24 | using boost::spirit::qi::space; |
25 | |
26 | // without skipping no_skip is equivalent to lexeme |
27 | { |
28 | std::string str; |
29 | BOOST_TEST((test_attr("' abc '" , '\'' >> no_skip[+~char_('\'')] >> '\'', str) && |
30 | str == " abc " )); |
31 | } |
32 | { |
33 | std::string str; |
34 | BOOST_TEST((test_attr("' abc '" , '\'' >> lexeme[+~char_('\'')] >> '\'', str) && |
35 | str == " abc " )); |
36 | } |
37 | |
38 | // with skipping, no_skip allows to match a leading skipper |
39 | { |
40 | std::string str; |
41 | BOOST_TEST((test_attr("' abc '" , '\'' >> no_skip[+~char_('\'')] >> '\'', str, space) && |
42 | str == " abc " )); |
43 | } |
44 | { |
45 | std::string str; |
46 | BOOST_TEST((test_attr("' abc '" , '\'' >> lexeme[+~char_('\'')] >> '\'', str, space) && |
47 | str == "abc " )); |
48 | } |
49 | |
50 | return boost::report_errors(); |
51 | } |
52 | |