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