| 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/spirit/home/x3.hpp> |
| 9 | |
| 10 | #include <iostream> |
| 11 | #include "test.hpp" |
| 12 | |
| 13 | int |
| 14 | main() |
| 15 | { |
| 16 | using spirit_test::test; |
| 17 | using spirit_test::test_attr; |
| 18 | using boost::spirit::x3::ascii::space; |
| 19 | using boost::spirit::x3::ascii::space_type; |
| 20 | using boost::spirit::x3::ascii::char_; |
| 21 | using boost::spirit::x3::lexeme; |
| 22 | using boost::spirit::x3::no_skip; |
| 23 | |
| 24 | BOOST_SPIRIT_ASSERT_CONSTEXPR_CTORS(no_skip['x']); |
| 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 | BOOST_TEST(str == " abc " ); |
| 31 | } |
| 32 | { |
| 33 | std::string str; |
| 34 | BOOST_TEST((test_attr("' abc '" , '\'' >> lexeme[+~char_('\'')] >> '\'', str))); |
| 35 | BOOST_TEST(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 | BOOST_TEST(str == " abc " ); |
| 43 | } |
| 44 | { |
| 45 | std::string str; |
| 46 | BOOST_TEST((test_attr("' abc '" , '\'' >> lexeme[+~char_('\'')] >> '\'', str, space))); |
| 47 | BOOST_TEST(str == "abc " ); |
| 48 | } |
| 49 | |
| 50 | return boost::report_errors(); |
| 51 | } |
| 52 | |