Skip N_OBJECT and N_ARRAY
This commit is contained in:
@@ -22,10 +22,8 @@ typedef WeaselJsonStatus (*Continuation)(struct Parser3 *);
|
||||
// automata
|
||||
enum Symbol : uint8_t {
|
||||
N_VALUE,
|
||||
N_OBJECT,
|
||||
N_OBJECT2,
|
||||
N_OBJECT3,
|
||||
N_ARRAY,
|
||||
N_ARRAY2,
|
||||
N_ARRAY3,
|
||||
N_STRING,
|
||||
@@ -162,14 +160,18 @@ inline WeaselJsonStatus n_value(Parser3 *self) {
|
||||
}
|
||||
switch (*self->buf) {
|
||||
case '{':
|
||||
self->callbacks->on_begin_object(self->data);
|
||||
++self->buf;
|
||||
self->pop();
|
||||
if (auto s = self->push({N_OBJECT})) {
|
||||
if (auto s = self->push({N_OBJECT2})) {
|
||||
return s;
|
||||
}
|
||||
break;
|
||||
case '[':
|
||||
self->callbacks->on_begin_array(self->data);
|
||||
++self->buf;
|
||||
self->pop();
|
||||
if (auto s = self->push({N_ARRAY})) {
|
||||
if (auto s = self->push({N_ARRAY2})) {
|
||||
return s;
|
||||
}
|
||||
break;
|
||||
@@ -226,19 +228,6 @@ inline WeaselJsonStatus n_value(Parser3 *self) {
|
||||
MUSTTAIL return Parser3::keepGoing(self);
|
||||
}
|
||||
|
||||
inline WeaselJsonStatus n_object(Parser3 *self) {
|
||||
if (*self->buf != '{') {
|
||||
return WeaselJson_REJECT;
|
||||
}
|
||||
self->callbacks->on_begin_object(self->data);
|
||||
++self->buf;
|
||||
self->pop();
|
||||
if (auto s = self->push({N_OBJECT2})) {
|
||||
return s;
|
||||
}
|
||||
MUSTTAIL return Parser3::keepGoing(self);
|
||||
}
|
||||
|
||||
inline WeaselJsonStatus n_object2(Parser3 *self) {
|
||||
assert(self->len() != 0);
|
||||
while (tables.whitespace[uint8_t(*self->buf)]) {
|
||||
@@ -293,19 +282,6 @@ inline WeaselJsonStatus n_object3(Parser3 *self) {
|
||||
}
|
||||
}
|
||||
|
||||
inline WeaselJsonStatus n_array(Parser3 *self) {
|
||||
if (*self->buf != '[') {
|
||||
return WeaselJson_REJECT;
|
||||
}
|
||||
self->callbacks->on_begin_array(self->data);
|
||||
++self->buf;
|
||||
self->pop();
|
||||
if (auto s = self->push({N_ARRAY2})) {
|
||||
return s;
|
||||
}
|
||||
MUSTTAIL return Parser3::keepGoing(self);
|
||||
}
|
||||
|
||||
inline WeaselJsonStatus n_array2(Parser3 *self) {
|
||||
assert(self->len() != 0);
|
||||
while (tables.whitespace[uint8_t(*self->buf)]) {
|
||||
@@ -896,10 +872,8 @@ constexpr inline struct ContinuationTable {
|
||||
};
|
||||
}
|
||||
continuations[N_VALUE] = n_value;
|
||||
continuations[N_OBJECT] = n_object;
|
||||
continuations[N_OBJECT2] = n_object2;
|
||||
continuations[N_OBJECT3] = n_object3;
|
||||
continuations[N_ARRAY] = n_array;
|
||||
continuations[N_ARRAY2] = n_array2;
|
||||
continuations[N_ARRAY3] = n_array3;
|
||||
continuations[N_STRING] = n_string;
|
||||
@@ -936,10 +910,8 @@ constexpr inline struct ContinuationTable {
|
||||
continuations[T_BACKSLASH] = singleChar<'\\'>;
|
||||
|
||||
symbolNames[N_VALUE] = "n_value";
|
||||
symbolNames[N_OBJECT] = "n_object";
|
||||
symbolNames[N_OBJECT2] = "n_object2";
|
||||
symbolNames[N_OBJECT3] = "n_object3";
|
||||
symbolNames[N_ARRAY] = "n_array";
|
||||
symbolNames[N_ARRAY2] = "n_array2";
|
||||
symbolNames[N_ARRAY3] = "n_array3";
|
||||
symbolNames[N_STRING] = "n_string";
|
||||
@@ -1017,10 +989,8 @@ inline WeaselJsonStatus Parser3::keepGoing(Parser3 *self) {
|
||||
self->flushString();
|
||||
break;
|
||||
case N_VALUE:
|
||||
case N_OBJECT:
|
||||
case N_OBJECT2:
|
||||
case N_OBJECT3:
|
||||
case N_ARRAY:
|
||||
case N_ARRAY2:
|
||||
case N_ARRAY3:
|
||||
case N_WHITESPACE:
|
||||
|
||||
Reference in New Issue
Block a user