chromium/third_party/blink/renderer/platform/json/json_parser.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/platform/json/json_parser.h"

#include "base/memory/raw_ptr.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "third_party/blink/renderer/platform/json/json_values.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_to_number.h"

namespace blink {

namespace {

const int kMaxStackLimit =;

Error;

String FormatErrorMessage(Error error, int line, int column) {}

// Note: all parsing functions take a |cursor| parameter which is
// where they start parsing from.
// If the parsing succeeds, |cursor| will point to the position
// right after the parsed value, "consuming" some portion of the input.
// If the parsing fails, |cursor| will point to the error position.

template <typename CharType>
struct Cursor {};

enum Token {};

template <typename CharType>
Error ParseConstToken(Cursor<CharType>* cursor,
                      const CharType* end,
                      const char* token) {}

template <typename CharType>
Error ReadInt(Cursor<CharType>* cursor,
              const CharType* end,
              bool can_have_leading_zeros) {}

template <typename CharType>
Error ParseNumberToken(Cursor<CharType>* cursor, const CharType* end) {}

template <typename CharType>
Error ReadHexDigits(Cursor<CharType>* cursor, const CharType* end, int digits) {}

template <typename CharType>
Error ParseStringToken(Cursor<CharType>* cursor, const CharType* end) {}

template <typename CharType>
Error SkipComment(Cursor<CharType>* cursor, const CharType* end) {}

template <typename CharType>
Error SkipWhitespaceAndComments(Cursor<CharType>* cursor,
                                const CharType* end,
                                JSONCommentState& comment_state) {}

template <typename CharType>
Error ParseToken(Cursor<CharType>* cursor,
                 const CharType* end,
                 Token* token,
                 Cursor<CharType>* token_start,
                 JSONCommentState& comment_state) {}

template <typename CharType>
inline int HexToInt(CharType c) {}

template <typename CharType>
Error DecodeString(Cursor<CharType>* cursor,
                   const CharType* end,
                   String* output) {}

template <typename CharType>
Error BuildValue(Cursor<CharType>* cursor,
                 const CharType* end,
                 int max_depth,
                 JSONCommentState& comment_state,
                 std::unique_ptr<JSONValue>* result,
                 Vector<String>* duplicate_keys) {}

template <typename CharType>
JSONParseError ParseJSONInternal(const CharType* start_ptr,
                                 unsigned length,
                                 int max_depth,
                                 JSONCommentState& comment_state,
                                 std::unique_ptr<JSONValue>* result) {}

}  // anonymous namespace

std::unique_ptr<JSONValue> ParseJSON(const String& json,
                                     JSONParseError* opt_error) {}

std::unique_ptr<JSONValue> ParseJSONWithCommentsDeprecated(
    const String& json,
    JSONParseError* opt_error,
    bool* opt_has_comments) {}

std::unique_ptr<JSONValue> ParseJSON(const String& json,
                                     JSONCommentState& comment_state,
                                     int max_depth,
                                     JSONParseError* opt_error) {}

}  // namespace blink