char () { if (position == limit) { throw createParseError("Unterminated escape sequence"); } char escaped = sourceSequence.charAt(position++); return switch (escaped) { case 'u' -> { if (position + 4 > limit) { throw createParseError("Unterminated escape sequence"); } // Equivalent to Integer.parseInt(stringPool.get(buffer, pos, 4), 16); char result = 0; for (int i = position, end = i + 4; i < end; i++) { char c = sourceSequence.charAt(i); result <<= 4; if (c >= '0' && c <= '9') { result += (c - '0'); } else if (c >= 'a' && c <= 'f') { result += (c - 'a' + 10); } else if (c >= 'A' && c <= 'F') { result += (c - 'A' + 10); } else { throw new NumberFormatException("\\u" + sourceSequence.subSequence(position, position + 4)); } } position += 4; yield result; } case 't' -> '\t'; case 'b' -> '\b'; case 'n' -> '\n'; case 'r' -> '\r'; case 'f' -> '\f'; //case '\n', '\'', '"', '\\', default -> escaped; }; }