Separate is_valid_function_name.

This commit is contained in:
Stephen Chung
2021-08-30 15:42:47 +08:00
parent cb90ce96d2
commit 7b2b26aa0d
2 changed files with 13 additions and 5 deletions

View File

@@ -960,7 +960,7 @@ impl Token {
#[inline]
pub(crate) fn into_function_name_for_override(self) -> Result<String, Self> {
match self {
Self::Custom(s) | Self::Identifier(s) if is_valid_identifier(s.chars()) => Ok(s),
Self::Custom(s) | Self::Identifier(s) if is_valid_function_name(&s) => Ok(s),
_ => Err(self),
}
}
@@ -2015,6 +2015,13 @@ pub fn is_valid_identifier(name: impl Iterator<Item = char>) -> bool {
first_alphabetic
}
/// Is a text string a valid scripted function name?
#[inline(always)]
#[must_use]
pub fn is_valid_function_name(name: &str) -> bool {
is_valid_identifier(name.chars())
}
/// Is a character valid to start an identifier?
#[cfg(feature = "unicode-xid-ident")]
#[inline(always)]