int (int start, @NotNull String s, @NotNull StringBuilder result) { int i = parseBackSlash(s, start); if (i == -1) return -1; int prev = start; int nSlashes = 1; while (i < s.length()) { int nextIdx = parseBackSlash(s, i); if (nextIdx != -1) { result.append(s, prev, i); prev = i; i = nextIdx; nSlashes++; } else { break; } } if (i >= s.length()) { // line ends with a backslash result.append(s, prev, s.length()); } else if (nSlashes % 2 == 0) { // symbol after slashes is not escaped result.append(s, prev, i); } else { // found something that is escaped with a backslash char next = s.charAt(i); if (next == 'n') { result.append('\n'); } else if (next == '"') { return i; } else { result.append(s, prev, i).append(next); } return i + 1; } return i; }