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