• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     BOOST_SPIRIT_ASSERT_CONSTEXPR_CTORS(no_skip['x']);
26 
27     // without skipping no_skip is equivalent to lexeme
28     {
29         std::string str;
30         BOOST_TEST((test_attr("'  abc '", '\'' >> no_skip[+~char_('\'')] >> '\'', str)));
31         BOOST_TEST(str == "  abc ");
32     }
33     {
34         std::string str;
35         BOOST_TEST((test_attr("'  abc '", '\'' >> lexeme[+~char_('\'')] >> '\'', str)));
36         BOOST_TEST(str == "  abc ");
37     }
38 
39     // with skipping, no_skip allows to match a leading skipper
40     {
41         std::string str;
42         BOOST_TEST((test_attr("'  abc '", '\'' >> no_skip[+~char_('\'')] >> '\'', str, space)));
43         BOOST_TEST(str == "  abc ");
44     }
45     {
46         std::string str;
47         BOOST_TEST((test_attr("'  abc '", '\'' >> lexeme[+~char_('\'')] >> '\'', str, space)));
48         BOOST_TEST(str == "abc ");
49     }
50 
51     return boost::report_errors();
52 }
53