File indexing completed on 2025-01-31 10:01:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #if !defined(BOOST_SPIRIT_KLEENE_STAR_HPP)
0011 #define BOOST_SPIRIT_KLEENE_STAR_HPP
0012
0013 #include <boost/spirit/home/classic/namespace.hpp>
0014 #include <boost/spirit/home/classic/core/parser.hpp>
0015 #include <boost/spirit/home/classic/core/primitives/primitives.hpp>
0016 #include <boost/spirit/home/classic/core/composite/composite.hpp>
0017 #include <boost/spirit/home/classic/meta/as_parser.hpp>
0018
0019 namespace boost { namespace spirit {
0020
0021 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 struct kleene_star_parser_gen;
0036
0037 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
0038 #pragma warning(push)
0039 #pragma warning(disable:4512)
0040 #endif
0041
0042 template <typename S>
0043 struct kleene_star
0044 : public unary<S, parser<kleene_star<S> > >
0045 {
0046 typedef kleene_star<S> self_t;
0047 typedef unary_parser_category parser_category_t;
0048 typedef kleene_star_parser_gen parser_generator_t;
0049 typedef unary<S, parser<self_t> > base_t;
0050
0051 kleene_star(S const& a)
0052 : base_t(a) {}
0053
0054 template <typename ScannerT>
0055 typename parser_result<self_t, ScannerT>::type
0056 parse(ScannerT const& scan) const
0057 {
0058 typedef typename parser_result<self_t, ScannerT>::type result_t;
0059 typedef typename ScannerT::iterator_t iterator_t;
0060 result_t hit = scan.empty_match();
0061
0062 for (;;)
0063 {
0064 iterator_t save = scan.first;
0065 if (result_t next = this->subject().parse(scan))
0066 {
0067 scan.concat_match(hit, next);
0068 }
0069 else
0070 {
0071 scan.first = save;
0072 return hit;
0073 }
0074 }
0075 }
0076 };
0077
0078 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
0079 #pragma warning(pop)
0080 #endif
0081
0082 struct kleene_star_parser_gen
0083 {
0084 template <typename S>
0085 struct result
0086 {
0087 typedef kleene_star<S> type;
0088 };
0089
0090 template <typename S>
0091 static kleene_star<S>
0092 generate(parser<S> const& a)
0093 {
0094 return kleene_star<S>(a.derived());
0095 }
0096 };
0097
0098
0099 template <typename S>
0100 kleene_star<S>
0101 operator*(parser<S> const& a);
0102
0103 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0104
0105 }}
0106
0107 #endif
0108
0109 #include <boost/spirit/home/classic/core/composite/impl/kleene_star.ipp>