/// Move pointer to position of token
/// @access private
/// @param {String} $source - JSON complete source
/// @param {Number} $pointer - current pointer
/// @param {String} $token - token to reach
/// @throw Expected $token; found $char.
/// @throw Expected $token but reached end of stream.
/// @return {Number} - new pointer
/// @require {function} _throw
@function _consume($source, $pointer, $token) {
  $length: str-length($source);

  @while $pointer <= $length {
    $char: str-slice($source, $pointer, $pointer);
    $pointer: $pointer + 1;

    @if $char == $token {
      @return $pointer;
    } @else if $char == " " or $char == "	" {
      // @continue;
    } @else {
      @return _throw("Expected `#{$token}`; found `#{$char}`.", $pointer);
    }
  }

  @return _throw("Expected `#{$token}` but reached end of stream.", $pointer);
}
