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/spirit/include/qi.hpp> |
9 | |
10 | #include <boost/fusion/include/adapt_struct.hpp> |
11 | #include <boost/variant.hpp> |
12 | |
13 | #include <string> |
14 | #include <vector> |
15 | #include "test.hpp" |
16 | |
17 | using namespace spirit_test; |
18 | |
19 | ////////////////////////////////////////////////////////////////////////////// |
20 | struct ast; // Forward declaration |
21 | |
22 | typedef boost::variant< |
23 | double, char, int, std::string, boost::recursive_wrapper<ast> |
24 | > ast_element; |
25 | |
26 | struct ast |
27 | { |
28 | int op; |
29 | std::vector<ast_element> children; |
30 | ast() {} |
31 | }; |
32 | |
33 | BOOST_FUSION_ADAPT_STRUCT( |
34 | ast, |
35 | (int, op) |
36 | (std::vector<ast_element>, children) |
37 | ) |
38 | |
39 | /////////////////////////////////////////////////////////////////////////////// |
40 | int main() |
41 | { |
42 | namespace qi = boost::spirit::qi; |
43 | |
44 | { |
45 | qi::rule<char const*, ast()> num_expr; |
46 | num_expr = (*(qi::char_ >> num_expr))[ qi::_1 ]; |
47 | } |
48 | |
49 | // doesn't currently work |
50 | // { |
51 | // qi::rule<char const*, std::string()> str = "abc"; |
52 | // qi::rule<char const*, std::string()> r = |
53 | // '"' >> *('\\' >> qi::char_ | str) >> "'"; |
54 | // |
55 | // std::string s; |
56 | // BOOST_TEST(test_attr("\"abc\\a\"", r, s) && s == "abca"); |
57 | // } |
58 | |
59 | return boost::report_errors(); |
60 | } |
61 | |
62 | |