docs: public List<String> parse(String line) throws ParseException {
      List<String> cols = new ArrayList<>();
      boolean afterQuote = false;
      boolean afterEscape = false;
      boolean afterSeparator = false;
      boolean outerQuote = false;
      boolean afterEndField = false;
      StringBuilder sb = new StringBuilder();
  
      for (int i = 0; ; ++i) {
        char c = (i == line.length()) ? EOT : line.charAt(i);
        if (afterEndField && c != separator && c != EOT) {
          if (!trim || c != ' ') {
            throw new ParseException("Extraneous character after end of quoted field", i);
          }
        } else if (afterEscape) {
          if (c == EOT) {
            // [abc\^]
            throw new ParseException("Escape not followed by a character", i);
          } else {
            // [abc\x...] => abcx...
            afterEscape = false;
            sb.append(c);
          }
        } else if (c == separator) {
          if (outerQuote && !afterQuote) {
            // ["abc,...] => abc,...
            sb.append(c);
            afterSeparator = false;
          } else {
            // [abc,...] => {abc, ...}
            endCol(cols, sb, i, outerQuote, afterQuote);
            afterQuote = afterEscape = afterEndField = outerQuote = false;
            afterSeparator = true;
          }
        } else if (c == EOT) {
          if (sb.length() != 0 || afterSeparator || outerQuote) {
            // [...,abc^] => {..., abc}
            // [...,^] => {..., ""}
            endCol(cols, sb, i, outerQuote, afterQuote);
          }
          return cols;
        } else if (c == escape) {
          // [...\...]
          afterEscape = true;
          afterSeparator = false;
        } else if (c == quote) {
          if (afterQuote && outerQuote) {
            // Two consecutive quotes inside quoted string, so the pair has to be internal
            // (the second quote cannot be terminating the field).
            sb.append(quote);
            afterQuote = false;
          } else if (sb.length() == 0 && !outerQuote) {
            outerQuote = true;
          } else if (sb.length() != 0 && !outerQuote) {
            // Fields that are not quote-delimited cannot have any internal quotes,
            // unless they are escaped which was already handled.
            throw new ParseException(escape == NUL
                ? "Unescaped quote inside non-quote-delimited field"
                : "Quote inside non-quote-delimited field",
                i);
          } else {
            afterQuote = true;
          }
          afterSeparator = false;
        } else if (c == ' ' && trim
            && ((!outerQuote && sb.length() == 0) // Trimmed space before field
                || afterEndField)) {              // Trimmed space after field
        } else if (c == ' ' && trim && afterQuote) {
          afterEndField = true;
        } else if (outerQuote && afterQuote) {
          // ["abc"x]
          throw new ParseException("Extraneous character after end of quoted field", i);
        } else {
          // Common character.
          sb.append(c);
          afterSeparator = false;
        }
      }
    }