/*============================================================================= Copyright (c) 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_HPP #define BOOST_SPIRIT_XPRESSIVE_HPP #include /////////////////////////////////////////////////////////////////////////////// // // Include the Xpressive regular expression library // // Note though, that this library is not distributed with Spirit. You have to // obtain a separate copy from the Boost Sandbox CVS. // /////////////////////////////////////////////////////////////////////////////// #include /////////////////////////////////////////////////////////////////////////////// #include #include #include /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { /////////////////////////////////////////////////////////////////////////////// // xpressive_strlit class template class xpressive_strlit : public parser > { public: typedef xpressive_strlit self_t; template struct result { typedef xpressive::basic_match_results result_t; typedef typename match_result::type type; }; xpressive_strlit(IteratorT first, IteratorT last) : xp(first, last) {} xpressive_strlit(IteratorT first) : xp(first) {} xpressive_strlit(xpressive::basic_regex const &pattern) : xp(pattern) {} template typename parser_result::type parse(ScannerT const& scan) const { // Due to the nature of the Xpressive regex implementation the iterators // wrapped in the ScannerT object should be at least bidirectional // iterators. Plain forward iterators do not work here. typedef typename ScannerT::iterator_t iterator_t; typedef typename std::iterator_traits::iterator_category iterator_category; BOOST_STATIC_ASSERT(( boost::is_convertible::value )); typedef typename parser_result::type result_t; return impl::contiguous_parser_parse(xp, scan, scan); } private: impl::xpressive_parser xp; }; /////////////////////////////////////////////////////////////////////////////// // Generator functions template inline xpressive_strlit xpressive_p(CharT const *first) { return xpressive_strlit(first); } ////////////////////////////////// template inline xpressive_strlit xpressive_p(CharT const *first, CharT const *last) { return xpressive_strlit(first, last); } ////////////////////////////////// template inline xpressive_strlit xpressive_p(xpressive::basic_regex const &pattern) { return xpressive_strlit(pattern); } /////////////////////////////////////////////////////////////////////////////// }} // namespace boost::spirit #endif // BOOST_SPIRIT_XPRESSIVE_HPP