blob: 16bfc1fe856dff36fccc353e46746089dda00d9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
use crate::unicode_data::{
char_info, is_id_continue_non_bmp, is_id_start_non_bmp, IS_ID_CONTINUE_TABLE, IS_ID_START_TABLE,
};
const UTF16_MAX: char = '\u{ffff}';
fn is_id_start_ascii(c: char) -> bool {
IS_ID_START_TABLE[c as usize]
}
fn is_id_continue_ascii(c: char) -> bool {
IS_ID_CONTINUE_TABLE[c as usize]
}
fn is_id_start_bmp_non_ascii(c: char) -> bool {
char_info(c).is_id_start()
}
fn is_id_continue_bmp_non_ascii(c: char) -> bool {
char_info(c).is_id_continue()
}
pub fn is_id_start(c: char) -> bool {
if c > UTF16_MAX {
return is_id_start_non_bmp(c);
}
if c < '\u{80}' {
return is_id_start_ascii(c);
}
is_id_start_bmp_non_ascii(c)
}
pub fn is_id_continue(c: char) -> bool {
if c > UTF16_MAX {
return is_id_continue_non_bmp(c);
}
if c < '\u{80}' {
return is_id_continue_ascii(c);
}
is_id_continue_bmp_non_ascii(c)
}
|