@@ -110,6 +110,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::walk_docum
110
110
// Start the document
111
111
//
112
112
if (at_eof ()) { return EMPTY; }
113
+ log_start_value (" document" );
113
114
SIMDJSON_TRY ( visitor.visit_document_start (*this ) );
114
115
115
116
//
@@ -122,22 +123,14 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::walk_docum
122
123
// could get into memory corruption. See https://github.com/simdjson/simdjson/issues/906
123
124
if (!STREAMING) {
124
125
switch (*value) {
125
- case ' {' :
126
- if (last_structural () != ' }' ) {
127
- return TAPE_ERROR;
128
- }
129
- break ;
130
- case ' [' :
131
- if (last_structural () != ' ]' ) {
132
- return TAPE_ERROR;
133
- }
134
- break ;
126
+ case ' {' : if (last_structural () != ' }' ) { return TAPE_ERROR; }; break ;
127
+ case ' [' : if (last_structural () != ' ]' ) { return TAPE_ERROR; }; break ;
135
128
}
136
129
}
137
130
138
131
switch (*value) {
139
- case ' {' : if (*peek () == ' }' ) { advance (); SIMDJSON_TRY ( visitor.visit_empty_object (*this ) ); break ; } goto object_begin;
140
- case ' [' : if (*peek () == ' ]' ) { advance (); SIMDJSON_TRY ( visitor.visit_empty_array (*this ) ); break ; } goto array_begin;
132
+ case ' {' : if (*peek () == ' }' ) { advance (); log_value ( " empty object " ); SIMDJSON_TRY ( visitor.visit_empty_object (*this ) ); break ; } goto object_begin;
133
+ case ' [' : if (*peek () == ' ]' ) { advance (); log_value ( " empty array " ); SIMDJSON_TRY ( visitor.visit_empty_array (*this ) ); break ; } goto array_begin;
141
134
default : SIMDJSON_TRY ( visitor.visit_root_primitive (*this , value) ); break ;
142
135
}
143
136
}
@@ -147,6 +140,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::walk_docum
147
140
// Object parser states
148
141
//
149
142
object_begin:
143
+ log_start_value (" object" );
150
144
depth++;
151
145
if (depth >= dom_parser.max_depth ()) { log_error (" Exceeded max depth!" ); return DEPTH_ERROR; }
152
146
SIMDJSON_TRY ( visitor.visit_object_start (*this ) );
@@ -164,8 +158,8 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::walk_docum
164
158
{
165
159
auto value = advance ();
166
160
switch (*value) {
167
- case ' {' : if (*peek () == ' }' ) { advance (); SIMDJSON_TRY ( visitor.visit_empty_object (*this ) ); break ; } goto object_begin;
168
- case ' [' : if (*peek () == ' ]' ) { advance (); SIMDJSON_TRY ( visitor.visit_empty_array (*this ) ); break ; } goto array_begin;
161
+ case ' {' : if (*peek () == ' }' ) { advance (); log_value ( " empty object " ); SIMDJSON_TRY ( visitor.visit_empty_object (*this ) ); break ; } goto object_begin;
162
+ case ' [' : if (*peek () == ' ]' ) { advance (); log_value ( " empty array " ); SIMDJSON_TRY ( visitor.visit_empty_array (*this ) ); break ; } goto array_begin;
169
163
default : SIMDJSON_TRY ( visitor.visit_primitive (*this , value) ); break ;
170
164
}
171
165
}
@@ -180,7 +174,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::walk_docum
180
174
SIMDJSON_TRY ( visitor.visit_key (*this , key) );
181
175
}
182
176
goto object_field;
183
- case ' }' : SIMDJSON_TRY ( visitor.visit_object_end (*this ) ); goto scope_end;
177
+ case ' }' : log_end_value ( " object " ); SIMDJSON_TRY ( visitor.visit_object_end (*this ) ); goto scope_end;
184
178
default : log_error (" No comma between object fields" ); return TAPE_ERROR;
185
179
}
186
180
@@ -194,6 +188,7 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::walk_docum
194
188
// Array parser states
195
189
//
196
190
array_begin:
191
+ log_start_value (" array" );
197
192
depth++;
198
193
if (depth >= dom_parser.max_depth ()) { log_error (" Exceeded max depth!" ); return DEPTH_ERROR; }
199
194
SIMDJSON_TRY ( visitor.visit_array_start (*this ) );
@@ -204,20 +199,21 @@ SIMDJSON_WARN_UNUSED simdjson_really_inline error_code json_iterator::walk_docum
204
199
{
205
200
auto value = advance ();
206
201
switch (*value) {
207
- case ' {' : if (*peek () == ' }' ) { advance (); SIMDJSON_TRY ( visitor.visit_empty_object (*this ) ); break ; } goto object_begin;
208
- case ' [' : if (*peek () == ' ]' ) { advance (); SIMDJSON_TRY ( visitor.visit_empty_array (*this ) ); break ; } goto array_begin;
202
+ case ' {' : if (*peek () == ' }' ) { advance (); log_value ( " empty object " ); SIMDJSON_TRY ( visitor.visit_empty_object (*this ) ); break ; } goto object_begin;
203
+ case ' [' : if (*peek () == ' ]' ) { advance (); log_value ( " empty array " ); SIMDJSON_TRY ( visitor.visit_empty_array (*this ) ); break ; } goto array_begin;
209
204
default : SIMDJSON_TRY ( visitor.visit_primitive (*this , value) ); break ;
210
205
}
211
206
}
212
207
213
208
array_continue:
214
209
switch (*advance ()) {
215
210
case ' ,' : SIMDJSON_TRY ( visitor.increment_count (*this ) ); goto array_value;
216
- case ' ]' : SIMDJSON_TRY ( visitor.visit_array_end (*this ) ); goto scope_end;
211
+ case ' ]' : log_end_value ( " array " ); SIMDJSON_TRY ( visitor.visit_array_end (*this ) ); goto scope_end;
217
212
default : log_error (" Missing comma between array values" ); return TAPE_ERROR;
218
213
}
219
214
220
215
document_end:
216
+ log_end_value (" document" );
221
217
SIMDJSON_TRY ( visitor.visit_document_end (*this ) );
222
218
223
219
dom_parser.next_structural_index = uint32_t (next_structural - &dom_parser.structural_indexes [0 ]);
0 commit comments