(&mut self)
| 199 | } |
| 200 | |
| 201 | fn parse_unicode_name(&mut self) -> Result<char, LexicalError> { |
| 202 | let start_pos = self.position(); |
| 203 | let Some('{') = self.next_char() else { |
| 204 | return Err(LexicalError::new( |
| 205 | LexicalErrorType::MissingUnicodeLbrace, |
| 206 | TextRange::empty(start_pos), |
| 207 | )); |
| 208 | }; |
| 209 | |
| 210 | let start_pos = self.position(); |
| 211 | let Some(close_idx) = self.source[self.cursor..].find('}') else { |
| 212 | return Err(LexicalError::new( |
| 213 | LexicalErrorType::MissingUnicodeRbrace, |
| 214 | TextRange::empty(self.compute_position(self.source.len())), |
| 215 | )); |
| 216 | }; |
| 217 | |
| 218 | let name_and_ending = self.skip_bytes(close_idx + 1); |
| 219 | let name = &name_and_ending[..name_and_ending.len() - 1]; |
| 220 | |
| 221 | unicode_names2::character(name).ok_or_else(|| { |
| 222 | LexicalError::new( |
| 223 | LexicalErrorType::UnicodeError, |
| 224 | // The cursor is right after the `}` character, so we subtract 1 to get the correct |
| 225 | // range of the unicode name. |
| 226 | TextRange::new( |
| 227 | start_pos, |
| 228 | self.compute_position(self.cursor - '}'.len_utf8()), |
| 229 | ), |
| 230 | ) |
| 231 | }) |
| 232 | } |
| 233 | |
| 234 | /// Parse an escaped character, returning the new character. |
| 235 | fn parse_escaped_char(&mut self) -> Result<Option<EscapedChar>, LexicalError> { |
no test coverage detected