unicode: Rename is_XID_start to is_xid_start, is_XID_continue to is_xid_continue
This commit is contained in:
parent
76ddd2b154
commit
f39c29d0bc
5 changed files with 33 additions and 8 deletions
|
@ -383,7 +383,7 @@ impl<'a> Parser<'a> {
|
||||||
/// characters.
|
/// characters.
|
||||||
fn word(&mut self) -> &'a str {
|
fn word(&mut self) -> &'a str {
|
||||||
let start = match self.cur.clone().next() {
|
let start = match self.cur.clone().next() {
|
||||||
Some((pos, c)) if c.is_XID_start() => {
|
Some((pos, c)) if c.is_xid_start() => {
|
||||||
self.cur.next();
|
self.cur.next();
|
||||||
pos
|
pos
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ impl<'a> Parser<'a> {
|
||||||
let mut end;
|
let mut end;
|
||||||
loop {
|
loop {
|
||||||
match self.cur.clone().next() {
|
match self.cur.clone().next() {
|
||||||
Some((_, c)) if c.is_XID_continue() => {
|
Some((_, c)) if c.is_xid_continue() => {
|
||||||
self.cur.next();
|
self.cur.next();
|
||||||
}
|
}
|
||||||
Some((pos, _)) => { end = pos; break }
|
Some((pos, _)) => { end = pos; break }
|
||||||
|
|
|
@ -271,7 +271,7 @@ pub fn sanitize(s: &str) -> String {
|
||||||
// Underscore-qualify anything that didn't start as an ident.
|
// Underscore-qualify anything that didn't start as an ident.
|
||||||
if result.len() > 0u &&
|
if result.len() > 0u &&
|
||||||
result.as_bytes()[0] != '_' as u8 &&
|
result.as_bytes()[0] != '_' as u8 &&
|
||||||
! (result.as_bytes()[0] as char).is_XID_start() {
|
! (result.as_bytes()[0] as char).is_xid_start() {
|
||||||
return format!("_{}", result.as_slice());
|
return format!("_{}", result.as_slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -299,8 +299,8 @@ impl Collector {
|
||||||
// we use these headings as test names, so it's good if
|
// we use these headings as test names, so it's good if
|
||||||
// they're valid identifiers.
|
// they're valid identifiers.
|
||||||
let name = name.chars().enumerate().map(|(i, c)| {
|
let name = name.chars().enumerate().map(|(i, c)| {
|
||||||
if (i == 0 && c.is_XID_start()) ||
|
if (i == 0 && c.is_xid_start()) ||
|
||||||
(i != 0 && c.is_XID_continue()) {
|
(i != 0 && c.is_xid_continue()) {
|
||||||
c
|
c
|
||||||
} else {
|
} else {
|
||||||
'_'
|
'_'
|
||||||
|
|
|
@ -692,7 +692,7 @@ impl<'a> StringReader<'a> {
|
||||||
// integer literal followed by field/method access or a range pattern
|
// integer literal followed by field/method access or a range pattern
|
||||||
// (`0..2` and `12.foo()`)
|
// (`0..2` and `12.foo()`)
|
||||||
if self.curr_is('.') && !self.nextch_is('.') && !self.nextch().unwrap_or('\0')
|
if self.curr_is('.') && !self.nextch_is('.') && !self.nextch().unwrap_or('\0')
|
||||||
.is_XID_start() {
|
.is_xid_start() {
|
||||||
// might have stuff after the ., and if it does, it needs to start
|
// might have stuff after the ., and if it does, it needs to start
|
||||||
// with a number
|
// with a number
|
||||||
self.bump();
|
self.bump();
|
||||||
|
@ -1385,7 +1385,7 @@ fn ident_start(c: Option<char>) -> bool {
|
||||||
(c >= 'a' && c <= 'z')
|
(c >= 'a' && c <= 'z')
|
||||||
|| (c >= 'A' && c <= 'Z')
|
|| (c >= 'A' && c <= 'Z')
|
||||||
|| c == '_'
|
|| c == '_'
|
||||||
|| (c > '\x7f' && c.is_XID_start())
|
|| (c > '\x7f' && c.is_xid_start())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ident_continue(c: Option<char>) -> bool {
|
fn ident_continue(c: Option<char>) -> bool {
|
||||||
|
@ -1395,7 +1395,7 @@ fn ident_continue(c: Option<char>) -> bool {
|
||||||
|| (c >= 'A' && c <= 'Z')
|
|| (c >= 'A' && c <= 'Z')
|
||||||
|| (c >= '0' && c <= '9')
|
|| (c >= '0' && c <= '9')
|
||||||
|| c == '_'
|
|| c == '_'
|
||||||
|| (c > '\x7f' && c.is_XID_continue())
|
|| (c > '\x7f' && c.is_xid_continue())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -167,8 +167,18 @@ pub trait UnicodeChar {
|
||||||
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
|
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
|
||||||
/// mostly similar to ID_Start but modified for closure under NFKx.
|
/// mostly similar to ID_Start but modified for closure under NFKx.
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
#[deprecated = "use is_xid_start"]
|
||||||
fn is_XID_start(self) -> bool;
|
fn is_XID_start(self) -> bool;
|
||||||
|
|
||||||
|
/// Returns whether the specified character satisfies the 'XID_Start'
|
||||||
|
/// Unicode property.
|
||||||
|
///
|
||||||
|
/// 'XID_Start' is a Unicode Derived Property specified in
|
||||||
|
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
|
||||||
|
/// mostly similar to ID_Start but modified for closure under NFKx.
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
fn is_xid_start(self) -> bool;
|
||||||
|
|
||||||
/// Returns whether the specified `char` satisfies the 'XID_Continue'
|
/// Returns whether the specified `char` satisfies the 'XID_Continue'
|
||||||
/// Unicode property.
|
/// Unicode property.
|
||||||
///
|
///
|
||||||
|
@ -176,8 +186,17 @@ pub trait UnicodeChar {
|
||||||
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
|
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
|
||||||
/// mostly similar to 'ID_Continue' but modified for closure under NFKx.
|
/// mostly similar to 'ID_Continue' but modified for closure under NFKx.
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
#[deprecated = "use is_xid_continue"]
|
||||||
fn is_XID_continue(self) -> bool;
|
fn is_XID_continue(self) -> bool;
|
||||||
|
|
||||||
|
/// Returns whether the specified `char` satisfies the 'XID_Continue'
|
||||||
|
/// Unicode property.
|
||||||
|
///
|
||||||
|
/// 'XID_Continue' is a Unicode Derived Property specified in
|
||||||
|
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
|
||||||
|
/// mostly similar to 'ID_Continue' but modified for closure under NFKx.
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
fn is_xid_continue(self) -> bool;
|
||||||
|
|
||||||
/// Indicates whether a character is in lowercase.
|
/// Indicates whether a character is in lowercase.
|
||||||
///
|
///
|
||||||
|
@ -267,10 +286,16 @@ impl UnicodeChar for char {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deprecated = "use is_xid_start"]
|
||||||
fn is_XID_start(self) -> bool { derived_property::XID_Start(self) }
|
fn is_XID_start(self) -> bool { derived_property::XID_Start(self) }
|
||||||
|
|
||||||
|
#[deprecated = "use is_xid_continue"]
|
||||||
fn is_XID_continue(self) -> bool { derived_property::XID_Continue(self) }
|
fn is_XID_continue(self) -> bool { derived_property::XID_Continue(self) }
|
||||||
|
|
||||||
|
fn is_xid_start(self) -> bool { derived_property::XID_Start(self) }
|
||||||
|
|
||||||
|
fn is_xid_continue(self) -> bool { derived_property::XID_Continue(self) }
|
||||||
|
|
||||||
fn is_lowercase(self) -> bool {
|
fn is_lowercase(self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
'a' ... 'z' => true,
|
'a' ... 'z' => true,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue