Remove on_error function
Solely here to make the next patch smaller and more isolatable
This commit is contained in:
parent
6a71b24495
commit
db2cb061cb
|
@ -12,7 +12,7 @@ struct streaming_structural_parser: structural_parser {
|
|||
advance_char();
|
||||
// Push the root scope (there is always at least one scope)
|
||||
if (start_document(finish_parser)) {
|
||||
return on_error(DEPTH_ERROR);
|
||||
return parser.error = DEPTH_ERROR;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@ -21,16 +21,16 @@ struct streaming_structural_parser: structural_parser {
|
|||
WARN_UNUSED really_inline error_code finish() {
|
||||
if ( structurals.past_end(parser.n_structural_indexes) ) {
|
||||
log_error("IMPOSSIBLE: past the end of the JSON!");
|
||||
return on_error(TAPE_ERROR);
|
||||
return parser.error = TAPE_ERROR;
|
||||
}
|
||||
end_document();
|
||||
if (depth != 0) {
|
||||
log_error("Unclosed objects or arrays!");
|
||||
return on_error(TAPE_ERROR);
|
||||
return parser.error = TAPE_ERROR;
|
||||
}
|
||||
if (parser.containing_scope[depth].tape_index != 0) {
|
||||
log_error("IMPOSSIBLE: root scope tape index did not start at 0!");
|
||||
return on_error(TAPE_ERROR);
|
||||
return parser.error = TAPE_ERROR;
|
||||
}
|
||||
bool finished = structurals.at_end(parser.n_structural_indexes);
|
||||
if (!finished) { log_value("(and has more)"); }
|
||||
|
|
|
@ -274,25 +274,21 @@ struct structural_parser {
|
|||
// the string might not be NULL terminated.
|
||||
if ( !structurals.at_end(parser.n_structural_indexes) ) {
|
||||
log_error("More than one JSON value at the root of the document, or extra characters at the end of the JSON!");
|
||||
return on_error(TAPE_ERROR);
|
||||
return parser.error = TAPE_ERROR;
|
||||
}
|
||||
end_document();
|
||||
if (depth != 0) {
|
||||
log_error("Unclosed objects or arrays!");
|
||||
return on_error(TAPE_ERROR);
|
||||
return parser.error = TAPE_ERROR;
|
||||
}
|
||||
if (parser.containing_scope[depth].tape_index != 0) {
|
||||
log_error("IMPOSSIBLE: root scope tape index did not start at 0!");
|
||||
return on_error(TAPE_ERROR);
|
||||
return parser.error = TAPE_ERROR;
|
||||
}
|
||||
|
||||
return on_success(SUCCESS);
|
||||
}
|
||||
|
||||
really_inline error_code on_error(error_code new_error_code) noexcept {
|
||||
parser.error = new_error_code;
|
||||
return new_error_code;
|
||||
}
|
||||
really_inline error_code on_success(error_code success_code) noexcept {
|
||||
parser.error = success_code;
|
||||
parser.valid = true;
|
||||
|
@ -311,11 +307,11 @@ struct structural_parser {
|
|||
* carefully,
|
||||
* all without any added cost. */
|
||||
if (depth >= parser.max_depth()) {
|
||||
return on_error(DEPTH_ERROR);
|
||||
return parser.error = DEPTH_ERROR;
|
||||
}
|
||||
switch (structurals.current_char()) {
|
||||
case '"':
|
||||
return on_error(STRING_ERROR);
|
||||
return parser.error = STRING_ERROR;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
|
@ -327,15 +323,15 @@ struct structural_parser {
|
|||
case '8':
|
||||
case '9':
|
||||
case '-':
|
||||
return on_error(NUMBER_ERROR);
|
||||
return parser.error = NUMBER_ERROR;
|
||||
case 't':
|
||||
return on_error(T_ATOM_ERROR);
|
||||
return parser.error = T_ATOM_ERROR;
|
||||
case 'n':
|
||||
return on_error(N_ATOM_ERROR);
|
||||
return parser.error = N_ATOM_ERROR;
|
||||
case 'f':
|
||||
return on_error(F_ATOM_ERROR);
|
||||
return parser.error = F_ATOM_ERROR;
|
||||
default:
|
||||
return on_error(TAPE_ERROR);
|
||||
return parser.error = TAPE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,7 +352,7 @@ struct structural_parser {
|
|||
structurals.advance_char();
|
||||
// Push the root scope (there is always at least one scope)
|
||||
if (start_document(finish_state)) {
|
||||
return on_error(DEPTH_ERROR);
|
||||
return parser.error = DEPTH_ERROR;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue