1 /*=============================================================================
2 Copyright (c) 2001-2010 Joel de Guzman
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.hpp>
8 #include <boost/spirit/include/qi_copy.hpp>
9 #include <boost/spirit/include/support_auto.hpp>
13 ///////////////////////////////////////////////////////////////////////////////
15 ///////////////////////////////////////////////////////////////////////////////
20 using boost::spirit::ascii::space
;
21 using boost::spirit::ascii::char_
;
22 using boost::spirit::qi::parse
;
23 typedef std::string::const_iterator iterator_type
;
25 ///////////////////////////////////////////////////////////////////////////////
26 // this works for non-c++11 compilers
27 #ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS
29 BOOST_SPIRIT_AUTO(qi
, comment
, "/*" >> *(char_
- "*/") >> "*/");
31 ///////////////////////////////////////////////////////////////////////////////
32 // but this is better for c++11 compilers with auto
35 using boost::spirit::qi::copy
;
37 auto comment
= copy("/*" >> *(char_
- "*/") >> "*/");
41 std::string str
= "/*This is a comment*/";
42 std::string::const_iterator iter
= str
.begin();
43 std::string::const_iterator end
= str
.end();
44 bool r
= parse(iter
, end
, comment
);
48 std::cout
<< "-------------------------\n";
49 std::cout
<< "Parsing succeeded\n";
50 std::cout
<< "-------------------------\n";
54 std::string
rest(iter
, end
);
55 std::cout
<< "-------------------------\n";
56 std::cout
<< "Parsing failed\n";
57 std::cout
<< "stopped at: \": " << rest
<< "\"\n";
58 std::cout
<< "-------------------------\n";