#[inline]
pub const fn is_atom_chr(chr: char) -> bool {
matches!(
chr,
'!' | '#'
| '$'
| '%'
| '&'
| '*'
| '+'
| '-'
| '.'
| '/'
| '0'..='9'
| ':'
| '<'
| '='
| '>'
| '?'
| '@'
| 'A'..='Z'
| '_'
| 'a'..='z'
| '~'
)
}
#[inline]
pub const fn is_atom_string_chr(chr: char) -> bool {
matches!(chr, ' '..='~' if chr != '"' && chr != '\\')
}
pub fn check_atom(atom: &str) -> bool {
if atom.is_empty() {
return false;
}
let mut iter = atom.chars();
let mut in_string = false;
loop {
if !in_string {
match iter.next() {
None => return true,
Some('"') => in_string = true,
Some(chr) if is_atom_chr(chr) => {}
Some(_) => return false,
}
} else {
match iter.next() {
None => return false,
Some('"') => in_string = false,
Some('\\') => match iter.next() {
Some('"' | '\\') => {}
Some(chr) if is_atom_string_chr(chr) => {}
Some(_) | None => return false,
},
Some(chr) if is_atom_string_chr(chr) => {}
Some(_) => return false,
}
}
}
}