Simplify structural_parser.start()
This commit is contained in:
parent
70c2a1c9f9
commit
fa81068ea8
|
@ -34,11 +34,8 @@ public:
|
||||||
return parser.len - *current_structural;
|
return parser.len - *current_structural;
|
||||||
}
|
}
|
||||||
|
|
||||||
really_inline bool past_end(uint32_t n_structural_indexes) {
|
really_inline bool at_end() {
|
||||||
return current_structural >= &parser.structural_indexes[n_structural_indexes];
|
return current_structural == &parser.structural_indexes[parser.n_structural_indexes];
|
||||||
}
|
|
||||||
really_inline bool at_end(uint32_t n_structural_indexes) {
|
|
||||||
return current_structural == &parser.structural_indexes[n_structural_indexes];
|
|
||||||
}
|
}
|
||||||
really_inline bool at_beginning() {
|
really_inline bool at_beginning() {
|
||||||
return current_structural == parser.structural_indexes.get();
|
return current_structural == parser.structural_indexes.get();
|
||||||
|
|
|
@ -223,6 +223,16 @@ struct structural_parser : structural_iterator {
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WARN_UNUSED really_inline error_code start() {
|
||||||
|
logger::log_start();
|
||||||
|
|
||||||
|
// If there are no structurals left, return EMPTY
|
||||||
|
if (at_end()) { return EMPTY; }
|
||||||
|
|
||||||
|
// Push the root scope (there is always at least one scope)
|
||||||
|
return start_document();
|
||||||
|
}
|
||||||
|
|
||||||
WARN_UNUSED really_inline error_code finish() {
|
WARN_UNUSED really_inline error_code finish() {
|
||||||
end_document();
|
end_document();
|
||||||
parser.next_structural_index = uint32_t(current_structural + 1 - &parser.structural_indexes[0]);
|
parser.next_structural_index = uint32_t(current_structural + 1 - &parser.structural_indexes[0]);
|
||||||
|
@ -235,29 +245,10 @@ struct structural_parser : structural_iterator {
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
really_inline void init() {
|
|
||||||
log_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
WARN_UNUSED really_inline error_code start() {
|
|
||||||
// If there are no structurals left, return EMPTY
|
|
||||||
if (at_end(parser.n_structural_indexes)) {
|
|
||||||
return EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
init();
|
|
||||||
// Push the root scope (there is always at least one scope)
|
|
||||||
return start_document();
|
|
||||||
}
|
|
||||||
|
|
||||||
really_inline void log_value(const char *type) {
|
really_inline void log_value(const char *type) {
|
||||||
logger::log_line(*this, "", type, "");
|
logger::log_line(*this, "", type, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static really_inline void log_start() {
|
|
||||||
logger::log_start();
|
|
||||||
}
|
|
||||||
|
|
||||||
really_inline void log_start_value(const char *type) {
|
really_inline void log_start_value(const char *type) {
|
||||||
logger::log_line(*this, "+", type, "");
|
logger::log_line(*this, "+", type, "");
|
||||||
if (logger::LOG_ENABLED) { logger::log_depth++; }
|
if (logger::LOG_ENABLED) { logger::log_depth++; }
|
||||||
|
|
Loading…
Reference in New Issue