Skip to content

Commit 87b6f99

Browse files
committed
refactor(lexer): clarify and reformat comments
1 parent d04b1b3 commit 87b6f99

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

crates/oxc_parser/src/lexer/unicode.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,21 @@ impl<'a> Lexer<'a> {
206206
/// * `https://mathiasbynens.be/notes/javascript-identifiers-es6`
207207
fn surrogate_pair(&mut self) -> Option<SurrogatePair> {
208208
let high = self.hex_4_digits()?;
209-
// The first code unit of a surrogate pair is always in the range from 0xD800 to 0xDBFF, and is called a high surrogate or a lead surrogate.
209+
// The first code unit of a surrogate pair is always in the range from 0xD800 to 0xDBFF,
210+
// and is called a high surrogate or a lead surrogate.
210211
let is_pair =
211212
(0xD800..=0xDBFF).contains(&high) && self.peek_2_bytes() == Some([b'\\', b'u']);
212213
if !is_pair {
213214
return Some(SurrogatePair::CodePoint(high));
214215
}
215216

217+
// We checked above that next 2 chars are `\u`
216218
self.consume_2_chars();
217219

218220
let low = self.hex_4_digits()?;
219221

220-
// The second code unit of a surrogate pair is always in the range from 0xDC00 to 0xDFFF, and is called a low surrogate or a trail surrogate.
222+
// The second code unit of a surrogate pair is always in the range from 0xDC00 to 0xDFFF,
223+
// and is called a low surrogate or a trail surrogate.
221224
if !(0xDC00..=0xDFFF).contains(&low) {
222225
return Some(SurrogatePair::HighLow(high, low));
223226
}

0 commit comments

Comments
 (0)