Add some comments
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
namespace parser3 {
|
||||
|
||||
// Calling a continuation with buf == bufEnd means end of input
|
||||
typedef PRESERVE_NONE WeaselJsonStatus (*Continuation)(struct Parser3 *,
|
||||
char *buf, char *bufEnd);
|
||||
|
||||
@@ -92,6 +93,9 @@ struct Parser3 {
|
||||
assert(!empty());
|
||||
--stackPtr;
|
||||
}
|
||||
|
||||
// Pushing symbols onto the stack roughly corresponds with "parse these
|
||||
// nonterminals/terminals in order"
|
||||
[[nodiscard]] WeaselJsonStatus push(std::initializer_list<Symbol> symbols) {
|
||||
if (stackEnd - stackPtr < ptrdiff_t(symbols.size())) [[unlikely]] {
|
||||
return WeaselJson_OVERFLOW;
|
||||
@@ -101,6 +105,7 @@ struct Parser3 {
|
||||
}
|
||||
return WeaselJson_OK;
|
||||
}
|
||||
|
||||
[[nodiscard]] Symbol top() const {
|
||||
assert(!empty());
|
||||
return *(stackPtr - 1);
|
||||
@@ -165,11 +170,12 @@ inline PRESERVE_NONE WeaselJsonStatus n_whitespace(Parser3 *self, char *buf,
|
||||
|
||||
inline PRESERVE_NONE WeaselJsonStatus n_number(Parser3 *self, char *buf,
|
||||
char *bufEnd) {
|
||||
bool complete = buf == bufEnd;
|
||||
buf = (char *)self->numDfa.scan(buf, bufEnd);
|
||||
if (buf == bufEnd && !complete) {
|
||||
self->flushNumber(false, buf);
|
||||
return WeaselJson_AGAIN;
|
||||
if (buf != bufEnd) {
|
||||
buf = (char *)self->numDfa.scan(buf, bufEnd);
|
||||
if (buf == bufEnd) {
|
||||
self->flushNumber(false, buf);
|
||||
return WeaselJson_AGAIN;
|
||||
}
|
||||
}
|
||||
if (!self->numDfa.accept()) [[unlikely]] {
|
||||
return WeaselJson_REJECT;
|
||||
|
||||
Reference in New Issue
Block a user