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

📄 primitives.hpp

📁 著名的Parser库Spirit在VC6上的Port
💻 HPP
📖 第 1 页 / 共 2 页
字号:
#ifndef iscntrl
inline bool iscntrl(int c)     { return std::iscntrl(c); }
#endif
#ifndef isdigit
inline bool isdigit(int c)     { return std::isdigit(c); }
#endif
#ifndef isgraph
inline bool isgraph(int c)     { return std::isgraph(c); }
#endif
#ifndef islower
inline bool islower(int c)     { return std::islower(c); }
#endif
#ifndef isprint
inline bool isprint(int c)     { return std::isprint(c); }
#endif
#ifndef ispunct
inline bool ispunct(int c)     { return std::ispunct(c); }
#endif
#ifndef isspace
inline bool isspace(int c)     { return std::isspace(c); }
#endif
#ifndef isupper
inline bool isupper(int c)     { return std::isupper(c); }
#endif
#ifndef isxdigit
inline bool isxdigit(int c)    { return std::isxdigit(c); }
#endif
#ifndef isalnum
inline bool isalnum(wchar_t c)  { return std::iswalnum(c); }
#endif
#ifndef isalpha
inline bool isalpha(wchar_t c)  { return std::iswalpha(c); }
#endif
#ifndef iscntrl
inline bool iscntrl(wchar_t c)  { return std::iswcntrl(c); }
#endif
#ifndef isdigit
inline bool isdigit(wchar_t c)  { return std::iswdigit(c); }
#endif
#ifndef isgraph
inline bool isgraph(wchar_t c)  { return std::iswgraph(c); }
#endif
#ifndef islower
inline bool islower(wchar_t c)  { return std::iswlower(c); }
#endif
#ifndef isprint
inline bool isprint(wchar_t c)  { return std::iswprint(c); }
#endif
#ifndef ispunct
inline bool ispunct(wchar_t c)  { return std::iswpunct(c); }
#endif
#ifndef isspace
inline bool isspace(wchar_t c)  { return std::iswspace(c); }
#endif
#ifndef isupper
inline bool isupper(wchar_t c)  { return std::iswupper(c); }
#endif
#ifndef isxdigit
inline bool isxdigit(wchar_t c) { return std::iswxdigit(c); }
#endif
#endif // !defined(_MSC_VER)

///////////////////////////////////////////////////////////////////////////////
//
//  Predefined parser primitives
//
///////////////////////////////////////////////////////////////////////////////
struct anychar_ : public char_parser<anychar_> {

    template <typename CharT>
    bool
    test(CharT ch) const { return true; }
};

///////////////////////////////////////////////////////////////////////////////
struct nothing_ : public parser<nothing_> {

    template <typename IteratorT>
    match
    parse(IteratorT& first, IteratorT const& last) const
    {
       return match();
    } 
};

///////////////////////////////////////////////////////////////////////////////
struct epsilon_ : public parser<epsilon_> {

    template <typename IteratorT>
    match
    parse(IteratorT& first, IteratorT const& last) const
    {
       return match(0);
    }    

};

///////////////////////////////////////////////////////////////////////////////
struct alnum_ : public char_parser<alnum_> {

    template <typename CharT>
    bool
    test(CharT ch) const
    {
       return isalnum(ch) ? true : false;
    }  
};

struct alpha_ : public char_parser<alpha_> {
   
    template <typename CharT>
    bool
    test(CharT ch) const 
    {
       return isalpha(ch) ? true : false;
    }    
};

//////////////////////////////////
struct cntrl_ : public char_parser<cntrl_> {

    template <typename CharT>
    bool
    test(CharT ch) const
    {
       return iscntrl(ch) ? true : false;
    }    
};

//////////////////////////////////
struct digit_ : public char_parser<digit_> {

    template <typename CharT>
    bool
    test(CharT ch) const
    {
       return isdigit(ch) ? true : false;
    }    
};

//////////////////////////////////
struct graph_ : public char_parser<graph_> {

    template <typename CharT>
    bool
    test(CharT ch) const
    {
      return isgraph(ch) ? true : false;
    }   

};

//////////////////////////////////
struct lower_ : public char_parser<lower_> {

    template <typename CharT>
    bool
    test(CharT ch) const
    {
       return islower(ch) ? true : false;
    }    
};

//////////////////////////////////
struct print_ : public char_parser<print_> {

    template <typename CharT>
    bool
    test(CharT ch) const
    {
      return isprint(ch) ? true : false;
    }   
};

//////////////////////////////////
struct punct_ : public char_parser<punct_> {

    template <typename CharT>
    bool
    test(CharT ch) const
    {
      return ispunct(ch) ? true : false;
    }   

};

//////////////////////////////////
struct blank_ : public char_parser<blank_> {

    template <typename CharT>
    bool
    test(CharT ch) const
    {
      // some systems have isblank(), but some don't, so just do it manually.
      return ch == ' ' || ch == '\t';
    }
       
};

//////////////////////////////////
struct space_ : public char_parser<space_> {

    template <typename CharT>
    bool
    test(CharT ch) const
    {
      return isspace(ch) ? true : false;
    }   
};

//////////////////////////////////
struct upper_ : public char_parser<upper_> {

    template <typename CharT>
    bool
    test(CharT ch) const
    {
      return isupper(ch) ? true : false;
    }   
};

//////////////////////////////////
struct xdigit_ : public char_parser<xdigit_> {

    template <typename CharT>
    bool
    test(CharT ch) const
    {
      return isxdigit(ch) ? true : false;
    }

};

///////////////////////////////////////////////////////////////////////////////
//
//  Generator functions
//
///////////////////////////////////////////////////////////////////////////////

//  Forward declaration
template <typename T> class reference_wrapper;

//////////////////////////////////
template <typename ParamT>
chlit<ParamT>
ch_p(ParamT param)
{
    return chlit<ParamT>(param);
     
}

//////////////////////////////////
template <typename ParamAT, typename ParamBT>
range<ParamAT, ParamBT>
range_p(ParamAT first, ParamBT last)
{
   return range<ParamAT, ParamBT>(first, last);
}

   

//////////////////////////////////
template <typename CharT>
strlit<cstring<CharT> >
str_p(CharT const* str)
{
    return strlit<cstring<CharT> >(str);
}
   

//////////////////////////////////
template <typename StringT>
strlit<reference_wrapper<StringT> > //RAGAV why was this changed ??
str_p(reference_wrapper<StringT> const& ref)
{
   return strlit<reference_wrapper<StringT> >(ref);
}


///////////////////////////////////////////////////////////////////////////////
//
//  Generator objects
//
///////////////////////////////////////////////////////////////////////////////
const anychar_  anychar = anychar_();
const nothing_  nothing = nothing_();
const epsilon_  epsilon = epsilon_();
const epsilon_  eps     = epsilon_();

const alnum_    alnum   = alnum_();
const alpha_    alpha   = alpha_();
const cntrl_    cntrl   = cntrl_();
const digit_    digit   = digit_();
const graph_    graph   = graph_();
const lower_    lower   = lower_();
const print_    print   = print_();
const punct_    punct   = punct_();
const blank_    blank   = blank_();
const space_    space   = space_();
const upper_    upper   = upper_();
const xdigit_   xdigit  = xdigit_();

///////////////////////////////////////////////////////////////////////////////
}   //  namespace Spirit

//BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(spirit::cstring<char>);
//BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(spirit::cstring<wchar_t>);
#endif

⌨️ 快捷键说明

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