Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2002-2003 Hartmut Kaiser
|
Chris@16
|
3 http://spirit.sourceforge.net/
|
Chris@16
|
4
|
Chris@16
|
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 =============================================================================*/
|
Chris@16
|
8 #if !defined(BOOST_SPIRIT_FUNDAMENTAL_HPP)
|
Chris@16
|
9 #define BOOST_SPIRIT_FUNDAMENTAL_HPP
|
Chris@16
|
10
|
Chris@16
|
11 #include <boost/spirit/home/classic/namespace.hpp>
|
Chris@16
|
12 #include <boost/spirit/home/classic/meta/impl/fundamental.ipp>
|
Chris@16
|
13
|
Chris@16
|
14 namespace boost { namespace spirit {
|
Chris@16
|
15
|
Chris@16
|
16 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
|
Chris@16
|
17
|
Chris@16
|
18 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
19 //
|
Chris@16
|
20 // Helper template for counting the number of nodes contained in a
|
Chris@16
|
21 // given parser type.
|
Chris@16
|
22 // All parser_category type parsers are counted as nodes.
|
Chris@16
|
23 //
|
Chris@16
|
24 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
25 template <typename ParserT>
|
Chris@16
|
26 struct node_count {
|
Chris@16
|
27
|
Chris@16
|
28 typedef typename ParserT::parser_category_t parser_category_t;
|
Chris@16
|
29 typedef typename impl::nodes<parser_category_t>
|
Chris@16
|
30 ::template count<ParserT, mpl::int_<0> > count_t;
|
Chris@16
|
31
|
Chris@16
|
32 BOOST_STATIC_CONSTANT(int, value = count_t::value);
|
Chris@16
|
33 };
|
Chris@16
|
34
|
Chris@16
|
35 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
36 //
|
Chris@16
|
37 // Helper template for counting the number of leaf nodes contained in a
|
Chris@16
|
38 // given parser type.
|
Chris@16
|
39 // Only plain_parser_category type parsers are counted as leaf nodes.
|
Chris@16
|
40 //
|
Chris@16
|
41 ///////////////////////////////////////////////////////////////////////////
|
Chris@16
|
42 template <typename ParserT>
|
Chris@16
|
43 struct leaf_count {
|
Chris@16
|
44
|
Chris@16
|
45 typedef typename ParserT::parser_category_t parser_category_t;
|
Chris@16
|
46 typedef typename impl::leafs<parser_category_t>
|
Chris@16
|
47 ::template count<ParserT, mpl::int_<0> > count_t;
|
Chris@16
|
48
|
Chris@16
|
49 BOOST_STATIC_CONSTANT(int, value = count_t::value);
|
Chris@16
|
50 };
|
Chris@16
|
51
|
Chris@16
|
52 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
|
Chris@16
|
53
|
Chris@16
|
54 }} // namespace BOOST_SPIRIT_CLASSIC_NS
|
Chris@16
|
55
|
Chris@16
|
56 #endif // !defined(BOOST_SPIRIT_FUNDAMENTAL_HPP)
|