Make parse part of structural_parser
This commit is contained in:
parent
03d54f8f6e
commit
ee6647ce40
|
@ -112,6 +112,7 @@ really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t> prev2, c
|
|||
#include "arm64/stringparsing.h"
|
||||
#include "arm64/numberparsing.h"
|
||||
#include "generic/stage2/structural_parser.h"
|
||||
#include "generic/stage2/tape_builder.h"
|
||||
|
||||
//
|
||||
// Implementation-specific overrides
|
||||
|
@ -144,7 +145,7 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
|
|||
}
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
|
||||
if (auto error = stage2::parse_structurals<false>(*this, _doc)) { return error; }
|
||||
if (auto error = stage2::structural_parser<stage2::tape_builder>::parse<false>(*this, _doc)) { return error; }
|
||||
|
||||
// If we didn't make it to the end, it's an error
|
||||
if ( next_structural_index != n_structural_indexes ) {
|
||||
|
@ -156,7 +157,7 @@ WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) no
|
|||
}
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
|
||||
return stage2::parse_structurals<true>(*this, _doc);
|
||||
return stage2::structural_parser<stage2::tape_builder>::parse<true>(*this, _doc);
|
||||
}
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
|
||||
|
|
|
@ -316,12 +316,13 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
|
|||
#include "fallback/stringparsing.h"
|
||||
#include "fallback/numberparsing.h"
|
||||
#include "generic/stage2/structural_parser.h"
|
||||
#include "generic/stage2/tape_builder.h"
|
||||
|
||||
namespace {
|
||||
namespace SIMDJSON_IMPLEMENTATION {
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
|
||||
if (auto error = stage2::parse_structurals<false>(*this, _doc)) { return error; }
|
||||
if (auto error = stage2::structural_parser<stage2::tape_builder>::parse<false>(*this, _doc)) { return error; }
|
||||
|
||||
// If we didn't make it to the end, it's an error
|
||||
if ( next_structural_index != n_structural_indexes ) {
|
||||
|
@ -333,7 +334,7 @@ WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) no
|
|||
}
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
|
||||
return stage2::parse_structurals<true>(*this, _doc);
|
||||
return stage2::structural_parser<stage2::tape_builder>::parse<true>(*this, _doc);
|
||||
}
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
|
||||
|
|
|
@ -19,6 +19,9 @@ struct structural_parser : structural_iterator {
|
|||
/** Current depth (nested objects and arrays) */
|
||||
uint32_t depth{0};
|
||||
|
||||
template<bool STREAMING>
|
||||
WARN_UNUSED static really_inline error_code parse(dom_parser_implementation &dom_parser, dom::document &doc) noexcept;
|
||||
|
||||
// For non-streaming, to pass an explicit 0 as next_structural, which enables optimizations
|
||||
really_inline structural_parser(dom_parser_implementation &_parser, uint32_t start_structural_index)
|
||||
: structural_iterator(_parser, start_structural_index),
|
||||
|
@ -149,20 +152,11 @@ struct structural_parser : structural_iterator {
|
|||
}
|
||||
}; // struct structural_parser
|
||||
|
||||
} // namespace stage2
|
||||
} // namespace SIMDJSON_IMPLEMENTATION
|
||||
} // unnamed namespace
|
||||
|
||||
#include "generic/stage2/tape_builder.h"
|
||||
|
||||
namespace { // Make everything here private
|
||||
namespace SIMDJSON_IMPLEMENTATION {
|
||||
namespace stage2 {
|
||||
|
||||
template<typename T>
|
||||
template<bool STREAMING>
|
||||
WARN_UNUSED static really_inline error_code parse_structurals(dom_parser_implementation &dom_parser, dom::document &doc) noexcept {
|
||||
WARN_UNUSED really_inline error_code structural_parser<T>::parse(dom_parser_implementation &dom_parser, dom::document &doc) noexcept {
|
||||
dom_parser.doc = &doc;
|
||||
stage2::structural_parser<stage2::tape_builder> parser(dom_parser, STREAMING ? dom_parser.next_structural_index : 0);
|
||||
stage2::structural_parser<T> parser(dom_parser, STREAMING ? dom_parser.next_structural_index : 0);
|
||||
SIMDJSON_TRY( parser.start() );
|
||||
|
||||
//
|
||||
|
|
|
@ -77,6 +77,7 @@ really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t> prev2, c
|
|||
#include "haswell/stringparsing.h"
|
||||
#include "haswell/numberparsing.h"
|
||||
#include "generic/stage2/structural_parser.h"
|
||||
#include "generic/stage2/tape_builder.h"
|
||||
|
||||
//
|
||||
// Implementation-specific overrides
|
||||
|
@ -107,7 +108,7 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
|
|||
}
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
|
||||
if (auto error = stage2::parse_structurals<false>(*this, _doc)) { return error; }
|
||||
if (auto error = stage2::structural_parser<stage2::tape_builder>::parse<false>(*this, _doc)) { return error; }
|
||||
|
||||
// If we didn't make it to the end, it's an error
|
||||
if ( next_structural_index != n_structural_indexes ) {
|
||||
|
@ -119,7 +120,7 @@ WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) no
|
|||
}
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
|
||||
return stage2::parse_structurals<true>(*this, _doc);
|
||||
return stage2::structural_parser<stage2::tape_builder>::parse<true>(*this, _doc);
|
||||
}
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
|
||||
|
|
|
@ -82,6 +82,7 @@ really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t> prev2, c
|
|||
#include "westmere/stringparsing.h"
|
||||
#include "westmere/numberparsing.h"
|
||||
#include "generic/stage2/structural_parser.h"
|
||||
#include "generic/stage2/tape_builder.h"
|
||||
|
||||
//
|
||||
// Implementation-specific overrides
|
||||
|
@ -113,7 +114,7 @@ WARN_UNUSED bool implementation::validate_utf8(const char *buf, size_t len) cons
|
|||
}
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) noexcept {
|
||||
if (auto error = stage2::parse_structurals<false>(*this, _doc)) { return error; }
|
||||
if (auto error = stage2::structural_parser<stage2::tape_builder>::parse<false>(*this, _doc)) { return error; }
|
||||
|
||||
// If we didn't make it to the end, it's an error
|
||||
if ( next_structural_index != n_structural_indexes ) {
|
||||
|
@ -125,7 +126,7 @@ WARN_UNUSED error_code dom_parser_implementation::stage2(dom::document &_doc) no
|
|||
}
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::stage2_next(dom::document &_doc) noexcept {
|
||||
return stage2::parse_structurals<true>(*this, _doc);
|
||||
return stage2::structural_parser<stage2::tape_builder>::parse<true>(*this, _doc);
|
||||
}
|
||||
|
||||
WARN_UNUSED error_code dom_parser_implementation::parse(const uint8_t *_buf, size_t _len, dom::document &_doc) noexcept {
|
||||
|
|
Loading…
Reference in New Issue