]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/classic/test/mix_and_match_trees.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / spirit / classic / test / mix_and_match_trees.cpp
1 //
2 // Copyright (c) 2006 Joao Abecasis
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8
9 ////////////////////////////////////////////////////////////////////////////////
10 //
11 // As reported by Jascha Wetzel, in
12 // http://article.gmane.org/gmane.comp.parsers.spirit.general/9013, the
13 // directives gen_ast_node_d and gen_pt_node_d were not working for lack of
14 // appropriate conversion constructors in the underlying tree match policies.
15 //
16 ////////////////////////////////////////////////////////////////////////////////
17
18 #include <boost/spirit/include/classic_core.hpp>
19 #include <boost/spirit/include/classic_ast.hpp>
20 #include <boost/spirit/include/classic_parse_tree.hpp>
21
22 using namespace BOOST_SPIRIT_CLASSIC_NS;
23
24 struct my_grammar : grammar<my_grammar>
25 {
26 template <class Scanner>
27 struct definition
28 {
29 typedef
30 scanner<
31 typename Scanner::iterator_t,
32 scanner_policies<
33 typename Scanner::iteration_policy_t,
34 ast_match_policy<
35 typename Scanner::match_policy_t::iterator_t,
36 typename Scanner::match_policy_t::factory_t
37 >,
38 typename Scanner::action_policy_t
39 >
40 > ast_scanner;
41
42 typedef
43 scanner<
44 typename Scanner::iterator_t,
45 scanner_policies<
46 typename Scanner::iteration_policy_t,
47 pt_match_policy<
48 typename Scanner::match_policy_t::iterator_t,
49 typename Scanner::match_policy_t::factory_t
50 >,
51 typename Scanner::action_policy_t
52 >
53 > pt_scanner;
54
55 typedef rule<ast_scanner> ast_rule;
56 typedef rule<pt_scanner> pt_rule;
57 typedef rule<Scanner> rule_;
58
59 definition(my_grammar const & /* self */)
60 {
61 start_ = gen_ast_node_d[ ast_rule_ ];
62 start_ = gen_pt_node_d[ pt_rule_ ];
63 }
64
65 rule_ const & start() const
66 {
67 return start_;
68 }
69
70 rule_ start_;
71 ast_rule ast_rule_;
72 pt_rule pt_rule_;
73 };
74 };
75
76 int main()
77 {
78 const char * begin = NULL, * end = NULL;
79
80 pt_parse(begin, end, my_grammar());
81 ast_parse(begin, end, my_grammar());
82 }