1 /*=============================================================================
2 Copyright (c) 2001-2015 Joel de Guzman
3 Copyright (c) 2013 Agustin Berge
4
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8 #include <boost/detail/lightweight_test.hpp>
9 #include <boost/spirit/home/x3.hpp>
10
11 #include <iostream>
12 #include "test.hpp"
13
14 int
main()15 main()
16 {
17 using spirit_test::test;
18 using spirit_test::test_attr;
19 using boost::spirit::x3::ascii::space;
20 using boost::spirit::x3::ascii::space_type;
21 using boost::spirit::x3::ascii::char_;
22 using boost::spirit::x3::lexeme;
23 using boost::spirit::x3::no_skip;
24
25 // without skipping no_skip is equivalent to lexeme
26 {
27 std::string str;
28 BOOST_TEST((test_attr("' abc '", '\'' >> no_skip[+~char_('\'')] >> '\'', str)));
29 BOOST_TEST(str == " abc ");
30 }
31 {
32 std::string str;
33 BOOST_TEST((test_attr("' abc '", '\'' >> lexeme[+~char_('\'')] >> '\'', str)));
34 BOOST_TEST(str == " abc ");
35 }
36
37 // with skipping, no_skip allows to match a leading skipper
38 {
39 std::string str;
40 BOOST_TEST((test_attr("' abc '", '\'' >> no_skip[+~char_('\'')] >> '\'', str, space)));
41 BOOST_TEST(str == " abc ");
42 }
43 {
44 std::string str;
45 BOOST_TEST((test_attr("' abc '", '\'' >> lexeme[+~char_('\'')] >> '\'', str, space)));
46 BOOST_TEST(str == "abc ");
47 }
48
49 return boost::report_errors();
50 }
51