Organize members, tweak eof
This commit is contained in:
27
src/parser.h
27
src/parser.h
@@ -99,7 +99,6 @@ struct Parser2 {
|
||||
static constexpr int kMaxStackSize = 1 << 10;
|
||||
|
||||
private:
|
||||
bool complete = false;
|
||||
// Helpers
|
||||
void maybeSkipWs() {
|
||||
while (buf != bufEnd && tables.whitespace[*buf]) {
|
||||
@@ -389,10 +388,10 @@ private:
|
||||
MUSTTAIL return keepGoing(self);
|
||||
}
|
||||
static Status eof(Parser2 *self) {
|
||||
if (self->complete) {
|
||||
return S_OK;
|
||||
if (self->len() > 0) {
|
||||
return S_REJECT;
|
||||
}
|
||||
return S_REJECT;
|
||||
return self->complete ? S_OK : S_AGAIN;
|
||||
}
|
||||
|
||||
static constexpr continuation table[] = {
|
||||
@@ -420,13 +419,6 @@ private:
|
||||
|
||||
static_assert(sizeof(table) / sizeof(table[0]) == N_PAST_END);
|
||||
|
||||
char *buf = nullptr;
|
||||
char *bufEnd = nullptr;
|
||||
int len() const { return bufEnd - buf; }
|
||||
const Callbacks *const callbacks;
|
||||
void *const data;
|
||||
Symbol stack[kMaxStackSize];
|
||||
Symbol *stackPtr = stack;
|
||||
bool empty() const { return stackPtr == stack; }
|
||||
void pop() {
|
||||
assert(!empty());
|
||||
@@ -441,4 +433,17 @@ private:
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
int len() const {
|
||||
auto result = bufEnd - buf;
|
||||
assert(result >= 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
char *buf = nullptr;
|
||||
char *bufEnd = nullptr;
|
||||
const Callbacks *const callbacks;
|
||||
void *const data;
|
||||
Symbol stack[kMaxStackSize];
|
||||
Symbol *stackPtr = stack;
|
||||
bool complete = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user