function _parseValue()

in packages/miew/src/io/parsers/readCIF.js [42:97]


  function _parseValue() {
    let val;
    if ((code === 46 || code === 63) && (i + 1 >= n || _isWhitespace(source.charCodeAt(i + 1)))) { // '.' or '?' .....
      // it's a missing value
      ++column;
      ++i;
      return undefined;
    }
    if (newline && code === 59) { // ';' ......................................................................
      // parse multi-line string
      j = i;
      let lines = 0;
      do {
        j = _inlineIndexOf(10, source, j + 1); // '\n'
        if (j === -1) {
          throw new ParsingError('Unterminated text block found', line, column);
        }
        ++lines;
      } while ((j + 1 < n && source.charCodeAt(j + 1) !== code) || j + 1 >= n);
      val = source.substring(i + 1, j).replace(/\r/g, '');
      i = j + 2;
      line += lines;
      column = 1;
      newline = false;
      return val;
    }
    if (code === 39 || code === 34) { // ''' or '"' ...........................................................
      // parse quoted string
      j = i;
      do {
        j = _inlineIndexOf(code, source, j + 1);
        if (j === -1) {
          throw new ParsingError('Unterminated quoted string found', line, column);
        }
      } while (j + 1 < n && !_isWhitespace(source.charCodeAt(j + 1)));
      val = source.substring(i + 1, j);
      column += j - i + 1;
      i = j + 1;
      return val;
    } // ......................................................................................................
    // parse until the first whitespace
    j = i;
    while (j < n && !_isWhitespace(source.charCodeAt(j))) {
      ++j;
    }
    val = source.substring(i, j);
    column += j - i;
    i = j;
    // try to convert to a number
    const num = Number(val);
    if (!Number.isNaN(num)) {
      return num;
    }
    // or leave as an unquoted string
    return val;
  }