2023-02-11 23:13:05 +00:00
|
|
|
/// Whether `c` is between `0-9`
|
2022-11-28 23:33:34 +00:00
|
|
|
pub fn is_digit(c: char) -> bool {
|
|
|
|
'0' <= c && c <= '9'
|
|
|
|
}
|
|
|
|
|
2023-09-10 16:16:34 +00:00
|
|
|
/// Whether `c` is between `0-9a-fA-F`
|
2022-11-28 23:33:34 +00:00
|
|
|
pub fn is_hex_digit(c: char) -> bool {
|
|
|
|
is_digit(c) || 'a' <= c && c <= 'f' || 'A' <= c && c <= 'F'
|
|
|
|
}
|
|
|
|
|
2023-02-11 23:13:05 +00:00
|
|
|
/// Joins a String and a char
|
2022-11-28 23:33:34 +00:00
|
|
|
pub fn str_append(current: String, c: char) -> String {
|
|
|
|
format!("{}{}", current, c)
|
|
|
|
}
|
|
|
|
|
2023-02-11 23:13:05 +00:00
|
|
|
/// Whether `c` is an operator char.
|
2022-11-28 23:33:34 +00:00
|
|
|
pub fn is_operator(c: char) -> bool {
|
2023-03-14 21:10:43 +00:00
|
|
|
c == '+'
|
|
|
|
|| c == '-'
|
|
|
|
|| c == '='
|
|
|
|
|| c == '*'
|
|
|
|
|| c == '!'
|
|
|
|
|| c == '\\'
|
|
|
|
|| c == '/'
|
|
|
|
|| c == '|'
|
|
|
|
|| c == '@'
|
|
|
|
|| c == '#'
|
|
|
|
|| c == '$'
|
|
|
|
|| c == '~'
|
|
|
|
|| c == '%'
|
|
|
|
|| c == '&'
|
|
|
|
|| c == '?'
|
|
|
|
|| c == '<'
|
|
|
|
|| c == '>'
|
|
|
|
|| c == '^'
|
|
|
|
|| c == '.'
|
|
|
|
|| c == ':'
|
2022-11-28 23:33:34 +00:00
|
|
|
}
|
2022-11-30 13:38:43 +00:00
|
|
|
|
2023-02-11 23:13:05 +00:00
|
|
|
/// Whether `c` is between `a-z`
|
2022-12-01 13:33:48 +00:00
|
|
|
pub fn is_lowercase(c: char) -> bool {
|
|
|
|
c >= 'a' && c <= 'z'
|
|
|
|
}
|
|
|
|
|
2023-02-11 23:13:05 +00:00
|
|
|
/// Whether `c` is between `A-Z`
|
2022-12-01 13:33:48 +00:00
|
|
|
pub fn is_uppercase(c: char) -> bool {
|
|
|
|
c >= 'A' && c <= 'Z'
|
|
|
|
}
|
|
|
|
|
2023-02-11 23:13:05 +00:00
|
|
|
/// Whether `c` is between `a-zA-Z_0-9`
|
2022-12-01 13:33:48 +00:00
|
|
|
pub fn is_identifier_char(c: char) -> bool {
|
|
|
|
is_lowercase(c) || is_uppercase(c) || c == '_' || is_digit(c)
|
2022-11-30 13:38:43 +00:00
|
|
|
}
|