/*============================================================================= Copyright (c) 2002-2003 Hartmut Kaiser http://spirit.sourceforge.net/ Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef BOOST_SPIRIT_XPRESSIVE_IPP #define BOOST_SPIRIT_XPRESSIVE_IPP /////////////////////////////////////////////////////////////////////////////// #include /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace impl { /////////////////////////////////////////////////////////////////////////////// // // xpressive_parser class // /////////////////////////////////////////////////////////////////////////////// template class xpressive_parser : public parser > { private: typedef typename std::iterator_traits::value_type char_t; typedef std::basic_string string_t; public: typedef xpressive_parser self_t; template struct result { typedef xpressive::basic_match_results result_t; typedef typename match_result::type type; }; xpressive_parser(IteratorT first, IteratorT last) { pattern = xpressive::begin >> string_t(first, last); } xpressive_parser(IteratorT first) { pattern = xpressive::begin >> string_t(first, impl::get_last(first)); } xpressive_parser(xpressive::basic_regex const &pattern_) : pattern(pattern_) {} template typename parser_result::type parse(ScannerT const& scan) const { xpressive::basic_match_results result; bool matched = xpressive::match(pattern, scan.first, scan.last, result); if (!matched) return scan.no_match(); scan.first = result[0].second; return scan.create_match(result[0].length(), result, result[0].first, scan.first); } private: xpressive::basic_regex pattern; }; } // namespace impl /////////////////////////////////////////////////////////////////////////////// }} // namespace boost::spirit #endif // BOOST_SPIRIT_XPRESSIVE_IPP