/** * @file recursivedescent.h * @brief Declaration of a recursive descent IMAP command parser. * @author Andreas Aardal Hanssen, Jannis M. Hoffmann * @date 2002-2023 */ #ifndef expectcommand_h_inluded #define expectcommand_h_inluded #include "imapparser.h" #include "session.h" #include #include namespace Binc { class Parser { std::stack inputBuffer; int charnr; Session &session; public: Parser(Session &session) : charnr(0), session(session){}; Parser(const Parser &) = delete; int readChar(); void unReadChar(int c_in); void unReadChar(const std::string &s_in); enum class ParseResult { ACCEPT, REJECT, ERROR, TIMEOUT }; ParseResult expectTag(std::string &s_in); ParseResult expectTagChar(int &c_in); ParseResult expectSPACE(); ParseResult expectFlag(std::vector &v_in); ParseResult expectListMailbox(std::string &s_in); ParseResult expectListWildcards(int &c_in); ParseResult expectDateTime(std::string &s_in); ParseResult expectTime(std::string &s_in); ParseResult expectZone(std::string &s_in); ParseResult expectMailbox(std::string &s_in); ParseResult expectAstring(std::string &s_in); ParseResult expectAtom(std::string &s_in); ParseResult expectAtomChar(int &i_in); ParseResult expectString(std::string &s_in); ParseResult expectDate(std::string &s_in); ParseResult expectNumber(unsigned int &i_in); ParseResult expectDigit(unsigned int &i_in); ParseResult expectDigitNZ(unsigned int &i_in); ParseResult expectLiteral(std::string &s_in); ParseResult expectQuoted(std::string &s_in); ParseResult expectQuotedChar(int &c_in); ParseResult expectSet(SequenceSet &s_in); ParseResult expectSequenceNum(unsigned int &i_in); ParseResult expectNZNumber(unsigned int &i_in); ParseResult expectCRLF(); ParseResult expectCR(); ParseResult expectLF(); ParseResult expectThisString(const std::string &s_in); }; } #endif