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;
|
static constexpr int kMaxStackSize = 1 << 10;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool complete = false;
|
|
||||||
// Helpers
|
// Helpers
|
||||||
void maybeSkipWs() {
|
void maybeSkipWs() {
|
||||||
while (buf != bufEnd && tables.whitespace[*buf]) {
|
while (buf != bufEnd && tables.whitespace[*buf]) {
|
||||||
@@ -389,10 +388,10 @@ private:
|
|||||||
MUSTTAIL return keepGoing(self);
|
MUSTTAIL return keepGoing(self);
|
||||||
}
|
}
|
||||||
static Status eof(Parser2 *self) {
|
static Status eof(Parser2 *self) {
|
||||||
if (self->complete) {
|
if (self->len() > 0) {
|
||||||
return S_OK;
|
return S_REJECT;
|
||||||
}
|
}
|
||||||
return S_REJECT;
|
return self->complete ? S_OK : S_AGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr continuation table[] = {
|
static constexpr continuation table[] = {
|
||||||
@@ -420,13 +419,6 @@ private:
|
|||||||
|
|
||||||
static_assert(sizeof(table) / sizeof(table[0]) == N_PAST_END);
|
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; }
|
bool empty() const { return stackPtr == stack; }
|
||||||
void pop() {
|
void pop() {
|
||||||
assert(!empty());
|
assert(!empty());
|
||||||
@@ -441,4 +433,17 @@ private:
|
|||||||
}
|
}
|
||||||
return S_OK;
|
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