File indexing completed on 2025-01-31 10:01:56
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_SPIRIT_CONDITIONS_IPP
0010 #define BOOST_SPIRIT_CONDITIONS_IPP
0011
0012
0013 #include <boost/spirit/home/classic/meta/parser_traits.hpp>
0014 #include <boost/spirit/home/classic/core/composite/epsilon.hpp>
0015
0016
0017 namespace boost { namespace spirit {
0018
0019 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0020
0021 namespace impl {
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 template <typename T> struct embed_t_accessor
0035 {
0036 typedef typename T::embed_t type;
0037 };
0038
0039 template <typename ConditionT>
0040 struct condition_parser_selector
0041 {
0042 typedef
0043 typename mpl::if_<
0044 is_parser<ConditionT>,
0045 ConditionT,
0046 condition_parser<ConditionT>
0047 >::type
0048 type;
0049
0050 typedef typename embed_t_accessor<type>::type embed_t;
0051 };
0052
0053
0054
0055
0056
0057
0058
0059 template <typename ConditionT>
0060 struct condition_evaluator
0061 {
0062 typedef condition_parser_selector<ConditionT> selector_t;
0063 typedef typename selector_t::type selected_t;
0064 typedef typename selector_t::embed_t cond_embed_t;
0065
0066 typedef typename boost::call_traits<cond_embed_t>::param_type
0067 param_t;
0068
0069 condition_evaluator(param_t s) : cond(s) {}
0070
0071
0072
0073
0074 template <typename ScannerT>
0075 std::ptrdiff_t
0076 evaluate(ScannerT const &scan) const
0077 {
0078 typedef typename ScannerT::iterator_t iterator_t;
0079 typedef typename parser_result<selected_t, ScannerT>::type cres_t;
0080 iterator_t save(scan.first);
0081 cres_t result = cond.parse(scan);
0082 if (!result)
0083 scan.first = save;
0084 return result.length();
0085 }
0086
0087 cond_embed_t cond;
0088 };
0089
0090
0091 }
0092
0093 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0094
0095 }}
0096
0097 #endif