File indexing completed on 2025-01-31 10:01:58
0001
0002
0003
0004
0005
0006
0007
0008
0009 #if !defined(BOOST_SPIRIT_FUNDAMENTAL_IPP)
0010 #define BOOST_SPIRIT_FUNDAMENTAL_IPP
0011
0012 #include <boost/mpl/int.hpp>
0013
0014 namespace boost { namespace spirit {
0015
0016 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0017
0018 namespace impl
0019 {
0020
0021
0022
0023
0024
0025
0026
0027 template <typename CategoryT>
0028 struct nodes;
0029
0030 template <>
0031 struct nodes<plain_parser_category> {
0032
0033 template <typename ParserT, typename LeafCountT>
0034 struct count {
0035
0036 BOOST_STATIC_CONSTANT(int, value = (LeafCountT::value + 1));
0037 };
0038 };
0039
0040 template <>
0041 struct nodes<unary_parser_category> {
0042
0043 template <typename ParserT, typename LeafCountT>
0044 struct count {
0045
0046 typedef typename ParserT::subject_t subject_t;
0047 typedef typename subject_t::parser_category_t subject_category_t;
0048
0049 BOOST_STATIC_CONSTANT(int, value = (nodes<subject_category_t>
0050 ::template count<subject_t, LeafCountT>::value + 1));
0051 };
0052 };
0053
0054 template <>
0055 struct nodes<action_parser_category> {
0056
0057 template <typename ParserT, typename LeafCountT>
0058 struct count {
0059
0060 typedef typename ParserT::subject_t subject_t;
0061 typedef typename subject_t::parser_category_t subject_category_t;
0062
0063 BOOST_STATIC_CONSTANT(int, value = (nodes<subject_category_t>
0064 ::template count<subject_t, LeafCountT>::value + 1));
0065 };
0066 };
0067
0068 template <>
0069 struct nodes<binary_parser_category> {
0070
0071 template <typename ParserT, typename LeafCountT>
0072 struct count {
0073
0074 typedef typename ParserT::left_t left_t;
0075 typedef typename ParserT::right_t right_t;
0076 typedef typename left_t::parser_category_t left_category_t;
0077 typedef typename right_t::parser_category_t right_category_t;
0078
0079 typedef count self_t;
0080
0081 BOOST_STATIC_CONSTANT(int,
0082 leftcount = (nodes<left_category_t>
0083 ::template count<left_t, LeafCountT>::value));
0084 BOOST_STATIC_CONSTANT(int,
0085 rightcount = (nodes<right_category_t>
0086 ::template count<right_t, LeafCountT>::value));
0087 BOOST_STATIC_CONSTANT(int,
0088 value = ((self_t::leftcount) + (self_t::rightcount) + 1));
0089 };
0090 };
0091
0092
0093
0094
0095
0096
0097
0098
0099 template <typename CategoryT>
0100 struct leafs;
0101
0102 template <>
0103 struct leafs<plain_parser_category> {
0104
0105 template <typename ParserT, typename LeafCountT>
0106 struct count {
0107
0108 BOOST_STATIC_CONSTANT(int, value = (LeafCountT::value + 1));
0109 };
0110 };
0111
0112 template <>
0113 struct leafs<unary_parser_category> {
0114
0115 template <typename ParserT, typename LeafCountT>
0116 struct count {
0117
0118 typedef typename ParserT::subject_t subject_t;
0119 typedef typename subject_t::parser_category_t subject_category_t;
0120
0121 BOOST_STATIC_CONSTANT(int, value = (leafs<subject_category_t>
0122 ::template count<subject_t, LeafCountT>::value));
0123 };
0124 };
0125
0126 template <>
0127 struct leafs<action_parser_category> {
0128
0129 template <typename ParserT, typename LeafCountT>
0130 struct count {
0131
0132 typedef typename ParserT::subject_t subject_t;
0133 typedef typename subject_t::parser_category_t subject_category_t;
0134
0135 BOOST_STATIC_CONSTANT(int, value = (leafs<subject_category_t>
0136 ::template count<subject_t, LeafCountT>::value));
0137 };
0138 };
0139
0140 template <>
0141 struct leafs<binary_parser_category> {
0142
0143 template <typename ParserT, typename LeafCountT>
0144 struct count {
0145
0146 typedef typename ParserT::left_t left_t;
0147 typedef typename ParserT::right_t right_t;
0148 typedef typename left_t::parser_category_t left_category_t;
0149 typedef typename right_t::parser_category_t right_category_t;
0150
0151 typedef count self_t;
0152
0153 BOOST_STATIC_CONSTANT(int,
0154 leftcount = (leafs<left_category_t>
0155 ::template count<left_t, LeafCountT>::value));
0156 BOOST_STATIC_CONSTANT(int,
0157 rightcount = (leafs<right_category_t>
0158 ::template count<right_t, LeafCountT>::value));
0159 BOOST_STATIC_CONSTANT(int,
0160 value = (self_t::leftcount + self_t::rightcount));
0161 };
0162 };
0163
0164 }
0165
0166
0167 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0168
0169 }}
0170
0171 #endif