function json_value()

in web/jslint/src/main/resources/data/jslint-2020-03-28.js [1473:1577]


function json_value() {
  var negative;

  if (next_token.id === "{") {
    return function json_object() {
      var brace = next_token;
      var object = empty();
      var properties = [];
      brace.expression = properties;
      advance("{");

      if (next_token.id !== "}") {
        (function next() {
          var name;
          var value;

          if (next_token.quote !== "\"") {
            warn("unexpected_a", next_token, next_token.quote);
          }

          name = next_token;
          advance("(string)");

          if (object[token.value] !== undefined) {
            warn("duplicate_a", token);
          } else if (token.value === "__proto__") {
            warn("bad_property_a", token);
          } else {
            object[token.value] = token;
          }

          advance(":");
          value = json_value();
          value.label = name;
          properties.push(value);

          if (next_token.id === ",") {
            advance(",");
            return next();
          }
        })();
      }

      advance("}", brace);
      return brace;
    }();
  }

  if (next_token.id === "[") {
    return function json_array() {
      var bracket = next_token;
      var elements = [];
      bracket.expression = elements;
      advance("[");

      if (next_token.id !== "]") {
        (function next() {
          elements.push(json_value());

          if (next_token.id === ",") {
            advance(",");
            return next();
          }
        })();
      }

      advance("]", bracket);
      return bracket;
    }();
  }

  if (next_token.id === "true" || next_token.id === "false" || next_token.id === "null") {
    advance();
    return token;
  }

  if (next_token.id === "(number)") {
    if (!rx_JSON_number.test(next_token.value)) {
      warn("unexpected_a");
    }

    advance();
    return token;
  }

  if (next_token.id === "(string)") {
    if (next_token.quote !== "\"") {
      warn("unexpected_a", next_token, next_token.quote);
    }

    advance();
    return token;
  }

  if (next_token.id === "-") {
    negative = next_token;
    negative.arity = "unary";
    advance("-");
    advance("(number)");
    negative.expression = token;
    return negative;
  }

  stop("unexpected_a");
} // Now we parse JavaScript.