File indexing completed on 2025-01-31 10:01:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #if !defined(BOOST_SPIRIT_PARSER_TRAITS_HPP)
0011 #define BOOST_SPIRIT_PARSER_TRAITS_HPP
0012
0013 #include <boost/type_traits/is_base_and_derived.hpp>
0014 #include <boost/static_assert.hpp>
0015
0016 #include <boost/spirit/home/classic/namespace.hpp>
0017 #include <boost/spirit/home/classic/core/parser.hpp>
0018 #include <boost/spirit/home/classic/meta/impl/parser_traits.ipp>
0019
0020
0021 namespace boost { namespace spirit {
0022
0023 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 template <typename T>
0041 struct is_parser
0042 {
0043 BOOST_STATIC_CONSTANT(bool, value =
0044 (::boost::is_base_and_derived<parser<T>, T>::value));
0045
0046
0047
0048 };
0049
0050
0051
0052
0053
0054
0055
0056 template <typename UnaryT>
0057 struct is_unary_composite {
0058
0059 BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible<
0060 typename UnaryT::parser_category_t, unary_parser_category>::value));
0061 };
0062
0063
0064
0065
0066
0067
0068
0069
0070 template <typename ActionT>
0071 struct is_action_parser {
0072
0073 BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible<
0074 typename ActionT::parser_category_t, action_parser_category>::value));
0075 };
0076
0077
0078
0079
0080
0081
0082
0083 template <typename BinaryT>
0084 struct is_binary_composite {
0085
0086 BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible<
0087 typename BinaryT::parser_category_t, binary_parser_category>::value));
0088 };
0089
0090
0091
0092
0093
0094
0095
0096 template <typename CompositeT>
0097 struct is_composite_parser {
0098
0099 BOOST_STATIC_CONSTANT(bool, value = (
0100 ::BOOST_SPIRIT_CLASSIC_NS::is_unary_composite<CompositeT>::value ||
0101 ::BOOST_SPIRIT_CLASSIC_NS::is_binary_composite<CompositeT>::value));
0102 };
0103
0104
0105 template <typename ParserT>
0106 struct is_alternative {
0107
0108 BOOST_STATIC_CONSTANT(bool, value = (
0109 ::BOOST_SPIRIT_CLASSIC_NS::impl::parser_type_traits<ParserT>::is_alternative));
0110 };
0111
0112 template <typename ParserT>
0113 struct is_sequence {
0114
0115 BOOST_STATIC_CONSTANT(bool, value = (
0116 ::BOOST_SPIRIT_CLASSIC_NS::impl::parser_type_traits<ParserT>::is_sequence));
0117 };
0118
0119 template <typename ParserT>
0120 struct is_sequential_or {
0121
0122 BOOST_STATIC_CONSTANT(bool, value = (
0123 ::BOOST_SPIRIT_CLASSIC_NS::impl::parser_type_traits<ParserT>::is_sequential_or));
0124 };
0125
0126 template <typename ParserT>
0127 struct is_intersection {
0128
0129 BOOST_STATIC_CONSTANT(bool, value = (
0130 ::BOOST_SPIRIT_CLASSIC_NS::impl::parser_type_traits<ParserT>::is_intersection));
0131 };
0132
0133 template <typename ParserT>
0134 struct is_difference {
0135
0136 BOOST_STATIC_CONSTANT(bool, value = (
0137 ::BOOST_SPIRIT_CLASSIC_NS::impl::parser_type_traits<ParserT>::is_difference));
0138 };
0139
0140 template <typename ParserT>
0141 struct is_exclusive_or {
0142
0143 BOOST_STATIC_CONSTANT(bool, value = (
0144 ::BOOST_SPIRIT_CLASSIC_NS::impl::parser_type_traits<ParserT>::is_exclusive_or));
0145 };
0146
0147 template <typename ParserT>
0148 struct is_optional {
0149
0150 BOOST_STATIC_CONSTANT(bool, value = (
0151 ::BOOST_SPIRIT_CLASSIC_NS::impl::parser_type_traits<ParserT>::is_optional));
0152 };
0153
0154 template <typename ParserT>
0155 struct is_kleene_star {
0156
0157 BOOST_STATIC_CONSTANT(bool, value = (
0158 ::BOOST_SPIRIT_CLASSIC_NS::impl::parser_type_traits<ParserT>::is_kleene_star));
0159 };
0160
0161 template <typename ParserT>
0162 struct is_positive {
0163
0164 BOOST_STATIC_CONSTANT(bool, value = (
0165 ::BOOST_SPIRIT_CLASSIC_NS::impl::parser_type_traits<ParserT>::is_positive));
0166 };
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182 template <typename UnaryT>
0183 struct unary_subject {
0184
0185 BOOST_STATIC_ASSERT(BOOST_SPIRIT_CLASSIC_NS::is_unary_composite<UnaryT>::value);
0186 typedef typename UnaryT::subject_t type;
0187 };
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197 template <typename UnaryT>
0198 inline typename unary_subject<UnaryT>::type const &
0199 get_unary_subject(UnaryT const &unary_)
0200 {
0201 BOOST_STATIC_ASSERT(::BOOST_SPIRIT_CLASSIC_NS::is_unary_composite<UnaryT>::value);
0202 return unary_.subject();
0203 }
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214 template <typename BinaryT>
0215 struct binary_left_subject {
0216
0217 BOOST_STATIC_ASSERT(::BOOST_SPIRIT_CLASSIC_NS::is_binary_composite<BinaryT>::value);
0218 typedef typename BinaryT::left_t type;
0219 };
0220
0221 template <typename BinaryT>
0222 struct binary_right_subject {
0223
0224 BOOST_STATIC_ASSERT(::BOOST_SPIRIT_CLASSIC_NS::is_binary_composite<BinaryT>::value);
0225 typedef typename BinaryT::right_t type;
0226 };
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237 template <typename BinaryT>
0238 inline typename binary_left_subject<BinaryT>::type const &
0239 get_binary_left_subject(BinaryT const &binary_)
0240 {
0241 BOOST_STATIC_ASSERT(::BOOST_SPIRIT_CLASSIC_NS::is_binary_composite<BinaryT>::value);
0242 return binary_.left();
0243 }
0244
0245 template <typename BinaryT>
0246 inline typename binary_right_subject<BinaryT>::type const &
0247 get_binary_right_subject(BinaryT const &binary_)
0248 {
0249 BOOST_STATIC_ASSERT(::BOOST_SPIRIT_CLASSIC_NS::is_binary_composite<BinaryT>::value);
0250 return binary_.right();
0251 }
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261 template <typename ActionT>
0262 struct action_subject {
0263
0264 BOOST_STATIC_ASSERT(::BOOST_SPIRIT_CLASSIC_NS::is_action_parser<ActionT>::value);
0265 typedef typename ActionT::subject_t type;
0266 };
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276 template <typename ActionT>
0277 inline typename action_subject<ActionT>::type const &
0278 get_action_subject(ActionT const &action_)
0279 {
0280 BOOST_STATIC_ASSERT(::BOOST_SPIRIT_CLASSIC_NS::is_action_parser<ActionT>::value);
0281 return action_.subject();
0282 }
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292 template <typename ActionT>
0293 struct semantic_action {
0294
0295 BOOST_STATIC_ASSERT(::BOOST_SPIRIT_CLASSIC_NS::is_action_parser<ActionT>::value);
0296 typedef typename ActionT::predicate_t type;
0297 };
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307 template <typename ActionT>
0308 inline typename semantic_action<ActionT>::type const &
0309 get_semantic_action(ActionT const &action_)
0310 {
0311 BOOST_STATIC_ASSERT(::BOOST_SPIRIT_CLASSIC_NS::is_action_parser<ActionT>::value);
0312 return action_.predicate();
0313 }
0314
0315
0316 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0317
0318 }}
0319
0320 #endif