]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/classic/test/mix_and_match_trees.cpp
2 // Copyright (c) 2006 Joao Abecasis
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)
9 ////////////////////////////////////////////////////////////////////////////////
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.
16 ////////////////////////////////////////////////////////////////////////////////
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>
22 using namespace BOOST_SPIRIT_CLASSIC_NS
;
24 struct my_grammar
: grammar
<my_grammar
>
26 template <class Scanner
>
31 typename
Scanner::iterator_t
,
33 typename
Scanner::iteration_policy_t
,
35 typename
Scanner::match_policy_t::iterator_t
,
36 typename
Scanner::match_policy_t::factory_t
38 typename
Scanner::action_policy_t
44 typename
Scanner::iterator_t
,
46 typename
Scanner::iteration_policy_t
,
48 typename
Scanner::match_policy_t::iterator_t
,
49 typename
Scanner::match_policy_t::factory_t
51 typename
Scanner::action_policy_t
55 typedef rule
<ast_scanner
> ast_rule
;
56 typedef rule
<pt_scanner
> pt_rule
;
57 typedef rule
<Scanner
> rule_
;
59 definition(my_grammar
const & /* self */)
61 start_
= gen_ast_node_d
[ ast_rule_
];
62 start_
= gen_pt_node_d
[ pt_rule_
];
65 rule_
const & start() const
78 const char * begin
= NULL
, * end
= NULL
;
80 pt_parse(begin
, end
, my_grammar());
81 ast_parse(begin
, end
, my_grammar());