parse function

Node parse(
  1. dynamic input,
  2. dynamic settings
)

Implementation

Node parse(input, settings) {
  final tokenList = tokenize(input, settings);

  if (tokenList.length == 0) {
    throw errorEof(input, tokenList, settings);
  }

  final value = _parseValue(input, tokenList, 0, settings);

  if (value.index == tokenList.length) {
    return value.value;
  }

  final token = tokenList[value.index];

  final src = settings.source ?? "";
  final msg = unexpectedToken(
      substring(input, token.loc!.start.offset, token.loc!.end.offset),
      src,
      token.loc!.start.line,
      token.loc!.start.column);
  throw new JSONASTException(
      msg, input, src, token.loc!.start.line, token.loc!.start.column);
}