]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2002 2004 2006Joel de Guzman | |
3 | Copyright (c) 2004 Eric Niebler | |
4 | http://spirit.sourceforge.net/ | |
5 | ||
6 | Use, modification and distribution is subject to the Boost Software | |
7 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
8 | http://www.boost.org/LICENSE_1_0.txt) | |
9 | =============================================================================*/ | |
10 | #if !defined(BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP) | |
11 | #define BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP | |
12 | ||
13 | #include <boost/spirit/include/classic_core.hpp> | |
14 | #include "fwd.hpp" | |
b32b8144 | 15 | #include "iterator.hpp" |
7c673cae FG |
16 | |
17 | namespace quickbook | |
18 | { | |
19 | namespace cl = boost::spirit::classic; | |
20 | ||
21 | // The spirit scanner for explicitly instantiating grammars. This is a | |
22 | // spirit implementation detail, but since classic is no longer under | |
23 | // development, it won't change. And spirit 2 won't require such a hack. | |
24 | ||
25 | typedef cl::scanner<parse_iterator, cl::scanner_policies < | |
26 | cl::iteration_policy, cl::match_policy, cl::action_policy> > scanner; | |
27 | ||
28 | template <typename Scanner> | |
29 | struct Scanner_must_be_the_quickbook_scanner_typedef; | |
30 | template <> | |
31 | struct Scanner_must_be_the_quickbook_scanner_typedef<scanner> {}; | |
32 | ||
33 | struct grammar | |
34 | : public cl::grammar<grammar> | |
35 | { | |
b32b8144 FG |
36 | grammar(cl::rule<scanner> const& start_rule_, char const* /* name */) |
37 | : start_rule(start_rule_) {} | |
7c673cae FG |
38 | |
39 | template <typename Scanner> | |
40 | struct definition : | |
41 | Scanner_must_be_the_quickbook_scanner_typedef<Scanner> | |
42 | { | |
43 | definition(grammar const& self) : start_rule(self.start_rule) {} | |
44 | cl::rule<scanner> const& start() const { return start_rule; } | |
45 | cl::rule<scanner> const& start_rule; | |
46 | }; | |
47 | ||
48 | cl::rule<scanner> const& start_rule; | |
49 | }; | |
50 | ||
51 | struct quickbook_grammar | |
52 | { | |
53 | public: | |
54 | struct impl; | |
55 | ||
56 | private: | |
57 | boost::scoped_ptr<impl> impl_; | |
58 | ||
59 | public: | |
60 | grammar command_line_macro; | |
61 | grammar inline_phrase; | |
62 | grammar phrase_start; | |
63 | grammar block_start; | |
64 | grammar attribute_template_body; | |
65 | grammar doc_info; | |
66 | ||
67 | quickbook_grammar(quickbook::state&); | |
68 | ~quickbook_grammar(); | |
69 | }; | |
70 | } | |
71 | ||
72 | #endif |