9
3

fundamental.hpp 2.1 KB

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