}
fn parse_character(lexer: &mut Lexer<Token>) -> Result<char, LexError> {
let target = &lexer.slice()[2..];
static NAME_MAP: OnceLock<HashMap<Box<str>, char>> = OnceLock::new();
let name_map = NAME_MAP.get_or_init(|| {
let mut map = HashMap::new();
map.insert("alarm".into(), '\u{7}');
map.insert("backspace".into(), '\u{8}');
map.insert("delete".into(), '\u{7f}');
map.insert("escape".into(), '\u{1b}');
map.insert("newline".into(), '\n');
map.insert("null".into(), '\0');
map.insert("return".into(), '\r');
map.insert("space".into(), ' ');
map.insert("tab".into(), '\t');
map.insert("lambda".into(), '\u{3bb}');
map
});
match target {
c if name_map.contains_key(c) => name_map.get(c).copied().ok_or(LexError::Unknown),
c if c.starts_with('x')
&& c.chars().skip(1).all(|c| c.is_ascii_hexdigit())
// Don't match '#\x'
&& c.chars().count() > 1 =>
{
// We know that x is 1 byte long, so chop it off
let hex_str = &c[1..];
char::from_u32(u32::from_str_radix(hex_str, 16)?).ok_or(LexError::Unknown)
}
c if c.chars().count() == 1 => c.chars().next().ok_or(LexError::Unknown),
_ => Err(LexError::Unknown),
}