1 //  Copyright (c) 2001-2011 Hartmut Kaiser
2 //
3 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 // compilation test only
7 
8 #include <boost/config/warning_disable.hpp>
9 #include <boost/detail/lightweight_test.hpp>
10 
11 #include <string>
12 #include <vector>
13 
14 #include <boost/spirit/include/qi.hpp>
15 #include <boost/fusion/include/adapt_struct.hpp>
16 
17 #include <boost/variant.hpp>
18 
19 #include "test.hpp"
20 
21 using namespace spirit_test;
22 
23 //////////////////////////////////////////////////////////////////////////////
24 struct ast; // Forward declaration
25 
26 typedef boost::variant<
27     double, char, int, std::string, boost::recursive_wrapper<ast>
28 > ast_element;
29 
30 struct ast
31 {
32     int op;
33     std::vector<ast_element> children;
astast34     ast() {}
35 };
36 
37 BOOST_FUSION_ADAPT_STRUCT(
38     ast,
39     (int, op)
40     (std::vector<ast_element>, children)
41 )
42 
43 ///////////////////////////////////////////////////////////////////////////////
main()44 int main()
45 {
46     namespace qi = boost::spirit::qi;
47 
48     {
49         qi::rule<char const*, ast()> num_expr;
50         num_expr = (*(qi::char_ >> num_expr))[ qi::_1 ];
51     }
52 
53 // doesn't currently work
54 //     {
55 //         qi::rule<char const*, std::string()> str = "abc";
56 //         qi::rule<char const*, std::string()> r =
57 //             '"' >> *('\\' >> qi::char_ | str) >> "'";
58 //
59 //         std::string s;
60 //         BOOST_TEST(test_attr("\"abc\\a\"", r, s) && s == "abca");
61 //     }
62 
63     return boost::report_errors();
64 }
65 
66