annotate DEPENDENCIES/generic/include/boost/spirit/home/classic/utility/impl/regex.ipp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*=============================================================================
Chris@16 2 Copyright (c) 2002-2003 Hartmut Kaiser
Chris@16 3 http://spirit.sourceforge.net/
Chris@16 4
Chris@16 5 Use, modification and distribution is subject to the Boost Software
Chris@16 6 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 =============================================================================*/
Chris@16 9 #ifndef BOOST_SPIRIT_REGEX_IPP
Chris@16 10 #define BOOST_SPIRIT_REGEX_IPP
Chris@16 11
Chris@16 12 ///////////////////////////////////////////////////////////////////////////////
Chris@16 13 #include <boost/spirit/home/classic/core/primitives/impl/primitives.ipp>
Chris@16 14
Chris@16 15 ///////////////////////////////////////////////////////////////////////////////
Chris@16 16 namespace boost { namespace spirit {
Chris@16 17
Chris@16 18 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
Chris@16 19
Chris@16 20 namespace impl {
Chris@16 21
Chris@16 22 ///////////////////////////////////////////////////////////////////////////////
Chris@16 23 //
Chris@16 24 inline const char* rx_prefix(char) { return "\\A"; }
Chris@16 25 inline const wchar_t* rx_prefix(wchar_t) { return L"\\A"; }
Chris@16 26
Chris@16 27 ///////////////////////////////////////////////////////////////////////////////
Chris@16 28 //
Chris@16 29 // rx_parser class
Chris@16 30 //
Chris@16 31 ///////////////////////////////////////////////////////////////////////////////
Chris@16 32 template <typename CharT = char>
Chris@16 33 class rx_parser : public parser<rx_parser<CharT> > {
Chris@16 34
Chris@16 35 public:
Chris@16 36 typedef std::basic_string<CharT> string_t;
Chris@16 37 typedef rx_parser<CharT> self_t;
Chris@16 38
Chris@16 39 rx_parser(CharT const *first, CharT const *last)
Chris@16 40 {
Chris@16 41 rxstr = string_t(rx_prefix(CharT())) + string_t(first, last);
Chris@16 42 }
Chris@16 43
Chris@16 44 rx_parser(CharT const *first)
Chris@16 45 {
Chris@16 46 rxstr = string_t(rx_prefix(CharT())) +
Chris@16 47 string_t(first, impl::get_last(first));
Chris@16 48 }
Chris@16 49
Chris@16 50 template <typename ScannerT>
Chris@16 51 typename parser_result<self_t, ScannerT>::type
Chris@16 52 parse(ScannerT const& scan) const
Chris@16 53 {
Chris@16 54 boost::match_results<typename ScannerT::iterator_t> what;
Chris@16 55 boost::regex_search(scan.first, scan.last, what, rxstr,
Chris@16 56 boost::match_default);
Chris@16 57
Chris@16 58 if (!what[0].matched)
Chris@16 59 return scan.no_match();
Chris@16 60
Chris@16 61 scan.first = what[0].second;
Chris@16 62 return scan.create_match(what[0].length(), nil_t(),
Chris@16 63 what[0].first, scan.first);
Chris@16 64 }
Chris@16 65
Chris@16 66 private:
Chris@16 67 #if BOOST_VERSION >= 013300
Chris@16 68 boost::basic_regex<CharT> rxstr; // regular expression to match
Chris@16 69 #else
Chris@16 70 boost::reg_expression<CharT> rxstr; // regular expression to match
Chris@16 71 #endif
Chris@16 72 };
Chris@16 73
Chris@16 74 } // namespace impl
Chris@16 75
Chris@16 76 ///////////////////////////////////////////////////////////////////////////////
Chris@16 77 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
Chris@16 78
Chris@16 79 }} // namespace boost::spirit
Chris@16 80
Chris@16 81 #endif // BOOST_SPIRIT_REGEX_IPP