diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-10-11 21:49:37 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-10-11 21:49:37 +0200 |
commit | bc946633e0bcae5fe63528ad743bcc67de7e347d (patch) | |
tree | 7a3d127148c13d84e92f38c319fb5aad1e88a6cb /src/include/recursivedescent.h | |
parent | 3ea7edf8c9bf7583c426178d4aaff4fb5b736bd2 (diff) |
created a Parser class
Diffstat (limited to 'src/include/recursivedescent.h')
-rw-r--r-- | src/include/recursivedescent.h | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/src/include/recursivedescent.h b/src/include/recursivedescent.h index 1200211..bf1fee4 100644 --- a/src/include/recursivedescent.h +++ b/src/include/recursivedescent.h @@ -9,63 +9,67 @@ #define expectcommand_h_inluded #include "imapparser.h" +#include "session.h" #include <stack> #include <string> namespace Binc { - extern std::stack<int> inputBuffer; - extern int charnr; + class Parser { + std::stack<int> inputBuffer; + int charnr; + Session &session; - int readChar(); - void unReadChar(int c_in); - void unReadChar(const std::string &s_in); + public: + Parser(Session &session) : charnr(0), session(session){}; + Parser(const Parser &) = delete; - namespace Parser { - enum class ParseResult { ACCEPT, REJECT, ERROR, TIMEOUT }; - } + int readChar(); + void unReadChar(int c_in); + void unReadChar(const std::string &s_in); - using ParseResult = Parser::ParseResult; + enum class ParseResult { ACCEPT, REJECT, ERROR, TIMEOUT }; - ParseResult expectTag(std::string &s_in); - ParseResult expectTagChar(int &c_in); - ParseResult expectSPACE(); + ParseResult expectTag(std::string &s_in); + ParseResult expectTagChar(int &c_in); + ParseResult expectSPACE(); - ParseResult expectFlag(std::vector<std::string> &v_in); + ParseResult expectFlag(std::vector<std::string> &v_in); - ParseResult expectListMailbox(std::string &s_in); - ParseResult expectListWildcards(int &c_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 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 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 expectDate(std::string &s_in); - ParseResult expectNumber(unsigned int &i_in); - ParseResult expectDigit(unsigned int &i_in); - ParseResult expectDigitNZ(unsigned int &i_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 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 expectSet(SequenceSet &s_in); + ParseResult expectSequenceNum(unsigned int &i_in); + ParseResult expectNZNumber(unsigned int &i_in); - ParseResult expectCRLF(); - ParseResult expectCR(); - ParseResult expectLF(); + ParseResult expectCRLF(); + ParseResult expectCR(); + ParseResult expectLF(); - ParseResult expectThisString(const std::string &s_in); + ParseResult expectThisString(const std::string &s_in); + }; } #endif |