parse function

Node parse(
  1. String input,
  2. Settings settings
)

Implementation

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

  if (tokenList.isEmpty) {
    throw errorEof(input, tokenList, settings);
  }

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

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

  final token = tokenList[value.index];

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