Improve identifier parsing checks

This commit is contained in:
Maxim Svistunov 2024-02-05 13:36:36 +01:00
parent 03e357fd40
commit 0b17d6cef7

View file

@ -17,7 +17,10 @@ pub fn parse_identifier(input: &str) -> IResult<&str, &str> {
let (_, first) = peek(anychar)(input)?; let (_, first) = peek(anychar)(input)?;
if first.is_alphabetic() || first == '_' { if first.is_alphabetic() || first == '_' {
take_while(|c: char| { take_while(|c: char| {
is_alphanumeric(c as u8) || c == '_' match c {
'a'..='z' | 'A'..='Z' | '_' | '0'..='9' => true,
_ => false
}
})(input) })(input)
} else { } else {
Err(nom::Err::Error(make_error( Err(nom::Err::Error(make_error(