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/operator-store.cc | |
parent | 3ea7edf8c9bf7583c426178d4aaff4fb5b736bd2 (diff) |
created a Parser class
Diffstat (limited to 'src/operator-store.cc')
-rw-r--r-- | src/operator-store.cc | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/operator-store.cc b/src/operator-store.cc index 23d97e2..06e0e3a 100644 --- a/src/operator-store.cc +++ b/src/operator-store.cc @@ -120,58 +120,58 @@ Operator::ProcessResult StoreOperator::process(Depot &depot, Request &command) return ProcessResult::OK; } -Parser::ParseResult StoreOperator::parse(Request &c_in) +Parser::ParseResult StoreOperator::parse(Request &c_in, Parser &p) { constexpr auto ACCEPT = Parser::ParseResult::ACCEPT; Session &session = Session::getInstance(); Parser::ParseResult res; - if ((res = expectSPACE()) != ACCEPT) { + if ((res = p.expectSPACE()) != ACCEPT) { session.setLastError("Expected SPACE"); return res; } - if ((res = expectSet(c_in.getSet())) != ACCEPT) { + if ((res = p.expectSet(c_in.getSet())) != ACCEPT) { session.setLastError("Expected Set"); return res; } - if ((res = expectSPACE()) != ACCEPT) { + if ((res = p.expectSPACE()) != ACCEPT) { session.setLastError("Expected SPACE"); return res; } string mode; - if ((res = expectThisString("+")) == ACCEPT) + if ((res = p.expectThisString("+")) == ACCEPT) mode = "+"; - else if ((res = expectThisString("-")) == ACCEPT) + else if ((res = p.expectThisString("-")) == ACCEPT) mode = "-"; - if ((res = expectThisString("FLAGS")) != ACCEPT) { + if ((res = p.expectThisString("FLAGS")) != ACCEPT) { session.setLastError("Expected FLAGS"); return res; } else { mode += "FLAGS"; } - if ((res = expectThisString(".SILENT")) == ACCEPT) mode += ".SILENT"; + if ((res = p.expectThisString(".SILENT")) == ACCEPT) mode += ".SILENT"; c_in.setMode(mode); - if ((res = expectSPACE()) != ACCEPT) { + if ((res = p.expectSPACE()) != ACCEPT) { session.setLastError("Expected SPACE"); return res; } bool paren = false; - if ((res = expectThisString("(")) == ACCEPT) paren = true; + if ((res = p.expectThisString("(")) == ACCEPT) paren = true; - if ((res = expectFlag(c_in.getFlags())) == ACCEPT) { + if ((res = p.expectFlag(c_in.getFlags())) == ACCEPT) { while (1) { - if ((res = expectSPACE()) != ACCEPT) break; + if ((res = p.expectSPACE()) != ACCEPT) break; - if ((res = expectFlag(c_in.getFlags())) != ACCEPT) { + if ((res = p.expectFlag(c_in.getFlags())) != ACCEPT) { session.setLastError("Expected flag after SPACE"); return res; } @@ -179,13 +179,13 @@ Parser::ParseResult StoreOperator::parse(Request &c_in) } if (paren) { - if ((res = expectThisString(")")) != ACCEPT) { + if ((res = p.expectThisString(")")) != ACCEPT) { session.setLastError("Expected )"); return res; } } - if ((res = expectCRLF()) != ACCEPT) { + if ((res = p.expectCRLF()) != ACCEPT) { session.setLastError("Expected CRLF"); return res; } |