⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regex.hpp

📁 著名的Parser库Spirit在VC6上的Port
💻 HPP
字号:
/*=============================================================================
    Regular expression parser primitives

    Spirit V1.2
    Copyright (c) 2001, Hartmut Kaiser

    This software is provided 'as-is', without any express or implied
    warranty. In no event will the copyright holder be held liable for
    any damages arising from the use of this software.

    Permission is granted to anyone to use this software for any purpose,
    including commercial applications, and to alter it and redistribute
    it freely, subject to the following restrictions:

    1.  The origin of this software must not be misrepresented; you must
        not claim that you wrote the original software. If you use this
        software in a product, an acknowledgment in the product documentation
        would be appreciated but is not required.

    2.  Altered source versions must be plainly marked as such, and must
        not be misrepresented as being the original software.

    3.  This notice may not be removed or altered from any source
        distribution.

    Acknowledgements:

        Special thanks to Dan Nuffer, John (EBo) David, Chris Uzdavinis,
        and Doug Gregor. These people are most instrumental in steering
        Spirit in the right direction.

        Special thanks also to people who have contributed to the code base
        and sample code, ported Spirit to various platforms and compilers,
        gave suggestions, reported and provided bug fixes. Alexander
        Hirner, Andy Elvey, Bogdan Kushnir, Brett Calcott, Bruce Florman,
        Changzhe Han, Colin McPhail, Hakki Dogusan, Jan Bares, Joseph
        Smith, Martijn W. van der Lee, Raghavendra Satish, Remi Delcos, Tom
        Spilman, Vladimir Prus, W. Scott Dillman, David A. Greene, Bob
        Bailey, Hartmut Kaiser.

        Finally special thanks also to people who gave feedback and
        valuable comments, particularly members of Spirit's Source Forge
        mailing list and boost.org.

    URL: http://spirit.sourceforge.net/

=============================================================================*/
#ifndef SPIRIT_REGEX_HPP
#define SPIRIT_REGEX_HPP

///////////////////////////////////////////////////////////////////////////////
// include the regular expression library of boost
#define BOOST_REGEX_NO_LIB
#define BOOST_REGEX_STATIC_LINK
#include <boost/regex.hpp>
#include <boost/regex/src.cpp>

namespace spirit {

///////////////////////////////////////////////////////////////////////////////
// rxlit class
template <typename CharT = char, typename StringT = cstring<CharT> >
struct rxlit : 
    public parser<rxlit<CharT, StringT> > 
{
    rxlit(StringT str);
    rxlit(CharT const *str);

// Due to limitations in the boost::regex library the iterator should be at
// least a bidirectional iterator. Plain forward iterators do not work here.
    template <typename IteratorT>
    match
    parse(IteratorT& first, IteratorT const& last) const;

    template <typename IteratorT>
    ast_match<IteratorT>
    ast_parse(IteratorT& first, IteratorT const& last, 
            MatchTraitsT const&) const;

    boost::reg_expression<CharT> str;    // regular expression to match
};

namespace impl {

///////////////////////////////////////////////////////////////////////////////
// A static regular expression literal template, which allows regular 
// expressions to be used as a type (template parameter).
    template<typename CharT, CharT const *Lit>
    struct static_rxlit :
        public rxlit<CharT>
    {
        static_rxlit() : rxlit<CharT>(Lit) {}
    };

} // namespace impl

///////////////////////////////////////////////////////////////////////////////
// Implementation of static regular expression literals of type char and wchar_t
template<const char *Lit>
struct s_rxlit :
    public impl::static_rxlit<char, Lit>,
    public impl::static_operator_base<>
{
};

template<const wchar_t *Lit>
struct s_wrxlit :
    public impl::static_rxlit<wchar_t, Lit>,
    public impl::static_operator_base<>
{
};

///////////////////////////////////////////////////////////////////////////////
// Generator functions
template <typename CharT>
inline rxlit<CharT>
regex_p(CharT const* str);

}   //  namespace Spirit

#include <boost/spirit/impl/regex.ipp>

#endif // SPIRIT_REGEX_HPP

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -