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/config/warning_disable.hpp>
8 #include <boost/spirit/include/qi.hpp>
9 #include <boost/typeof/typeof.hpp>
13 ///////////////////////////////////////////////////////////////////////////////
15 ///////////////////////////////////////////////////////////////////////////////
17 #define BOOST_SPIRIT_AUTO(domain_, name, expr) \
18 typedef boost::proto::result_of:: \
19 deep_copy<BOOST_TYPEOF(expr)>::type name##_expr_type; \
20 BOOST_SPIRIT_ASSERT_MATCH( \
21 boost::spirit::domain_::domain, name##_expr_type); \
22 BOOST_AUTO(name, boost::proto::deep_copy(expr)); \
27 using boost::spirit::ascii::space;
28 using boost::spirit::ascii::char_;
29 using boost::spirit::qi::parse;
30 typedef std::string::const_iterator iterator_type;
32 BOOST_SPIRIT_AUTO(qi, comment, "/*" >> *(char_ - "*/") >> "*/");
34 std::string str = "/*This is a comment*/";
35 std::string::const_iterator iter = str.begin();
36 std::string::const_iterator end = str.end();
37 bool r = parse(iter, end, comment);
41 std::cout << "-------------------------\n";
42 std::cout << "Parsing succeeded\n";
43 std::cout << "-------------------------\n";
47 std::string rest(iter, end);
48 std::cout << "-------------------------\n";
49 std::cout << "Parsing failed\n";
50 std::cout << "stopped at: \": " << rest << "\"\n";
51 std::cout << "-------------------------\n";