• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/detail/lightweight_test.hpp>
8 #include <boost/spirit/include/qi_directive.hpp>
9 #include <boost/spirit/include/qi_char.hpp>
10 #include <boost/spirit/include/qi_operator.hpp>
11 #include <boost/spirit/include/qi_nonterminal.hpp>
12 
13 #include <iostream>
14 #include "test.hpp"
15 
16 int
main()17 main()
18 {
19     using spirit_test::test_attr;
20     using boost::spirit::qi::no_skip;
21     using boost::spirit::qi::lexeme;
22     using boost::spirit::qi::char_;
23     using boost::spirit::qi::space;
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             str == "  abc "));
30     }
31     {
32         std::string str;
33         BOOST_TEST((test_attr("'  abc '", '\'' >> lexeme[+~char_('\'')] >> '\'', str) &&
34             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             str == "  abc "));
42     }
43     {
44         std::string str;
45         BOOST_TEST((test_attr("'  abc '", '\'' >> lexeme[+~char_('\'')] >> '\'', str, space) &&
46             str == "abc "));
47     }
48 
49     return boost::report_errors();
50 }
51