File indexing completed on 2025-01-31 10:02:07
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_SPIRIT_REGEX_IPP
0010 #define BOOST_SPIRIT_REGEX_IPP
0011
0012
0013 #include <boost/spirit/home/classic/core/primitives/impl/primitives.ipp>
0014
0015
0016 namespace boost { namespace spirit {
0017
0018 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0019
0020 namespace impl {
0021
0022
0023
0024 inline const char* rx_prefix(char) { return "\\A"; }
0025 inline const wchar_t* rx_prefix(wchar_t) { return L"\\A"; }
0026
0027
0028
0029
0030
0031
0032 template <typename CharT = char>
0033 class rx_parser : public parser<rx_parser<CharT> > {
0034
0035 public:
0036 typedef std::basic_string<CharT> string_t;
0037 typedef rx_parser<CharT> self_t;
0038
0039 rx_parser(CharT const *first, CharT const *last)
0040 {
0041 rxstr = string_t(rx_prefix(CharT())) + string_t(first, last);
0042 }
0043
0044 rx_parser(CharT const *first)
0045 {
0046 rxstr = string_t(rx_prefix(CharT())) +
0047 string_t(first, impl::get_last(first));
0048 }
0049
0050 template <typename ScannerT>
0051 typename parser_result<self_t, ScannerT>::type
0052 parse(ScannerT const& scan) const
0053 {
0054 boost::match_results<typename ScannerT::iterator_t> what;
0055 boost::regex_search(scan.first, scan.last, what, rxstr,
0056 boost::match_default);
0057
0058 if (!what[0].matched)
0059 return scan.no_match();
0060
0061 scan.first = what[0].second;
0062 return scan.create_match(what[0].length(), nil_t(),
0063 what[0].first, scan.first);
0064 }
0065
0066 private:
0067 #if BOOST_VERSION >= 013300
0068 boost::basic_regex<CharT> rxstr;
0069 #else
0070 boost::reg_expression<CharT> rxstr;
0071 #endif
0072 };
0073
0074 }
0075
0076
0077 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0078
0079 }}
0080
0081 #endif