Continued work on Parser.

This commit is contained in:
Brad Arant 2025-12-16 16:51:44 -08:00
parent d54aec1f06
commit 0243468d44
4 changed files with 38 additions and 8 deletions

View File

@ -5,7 +5,26 @@
namespace coreutils {
IMFBoundary(StreamReader &reader, ZString boundary) : boundary(boundary) {
if(reader.unparsed().getLength()
}
int IMFBoundary::parse() {
switch(state) {
case PREFIX:
if(buffer.remaining() > 3)
if(reader.nextIf("\r\n--"))
state = BOUNDARY;
case BOUNDARY:
while(buffer.getTokenInclude(""));
if(buffer.eod())
return 2;
else if(buffer.remaining() > 1)
if(buffer.ifNext("--"))
state = LAST_BOUNDARY;
case LAST_BOUNDARY:
return 0;
}
}
}

View File

@ -10,6 +10,8 @@ namespace coreutils {
public:
IMFBoundary(StreamReader &reader, ZString boundary);
virtual int parse();
private:
ZString boundary;

View File

@ -1,9 +1,11 @@
#include "StreamReader.h"
#include "Parser.h"
namespace coreutils {
StreamReader::StreamReader(int fd) {}
Parser::Parser(StreamReader &reader) : parser(parser) {}
StreamReader::~StreamReader() {}
Parser::~Parser() {}
int Parser::parse() {}
}

View File

@ -15,11 +15,18 @@ namespace coreutils {
class Parser {
public:
Parser(int fd);
Parser(StreamReader &reader, Parser *parser);
virtual ~Parser();
int doParse(); <--- copy the buffer available in read to here and call parse();
bool checkParse(Parser &parser); <--- can be called in parse to see if the parsing should branch
virtual int parse();
private:
vector<MString> buffer;
MString buffer;
Parser *parser;
vector<Parser *> chain;
};