Parse a hex representation of a Unicode codepoint. This handles both hex notations, i.e., `\xFF` and `\x{FFFF}`. This expects the parser to be positioned at the `x`, `u` or `U` prefix. The parser is advanced to the first character immediately following the hexadecimal literal.
(&self)
| 1570 | /// be positioned at the `x`, `u` or `U` prefix. The parser is advanced to |
| 1571 | /// the first character immediately following the hexadecimal literal. |
| 1572 | fn parse_hex(&self) -> Result<ast::Literal> { |
| 1573 | assert!(self.char() == 'x' |
| 1574 | || self.char() == 'u' |
| 1575 | || self.char() == 'U'); |
| 1576 | |
| 1577 | let hex_kind = match self.char() { |
| 1578 | 'x' => ast::HexLiteralKind::X, |
| 1579 | 'u' => ast::HexLiteralKind::UnicodeShort, |
| 1580 | _ => ast::HexLiteralKind::UnicodeLong, |
| 1581 | }; |
| 1582 | if !self.bump_and_bump_space() { |
| 1583 | return Err(self.error( |
| 1584 | self.span(), |
| 1585 | ast::ErrorKind::EscapeUnexpectedEof, |
| 1586 | )); |
| 1587 | } |
| 1588 | if self.char() == '{' { |
| 1589 | self.parse_hex_brace(hex_kind) |
| 1590 | } else { |
| 1591 | self.parse_hex_digits(hex_kind) |
| 1592 | } |
| 1593 | } |
| 1594 | |
| 1595 | /// Parse an N-digit hex representation of a Unicode codepoint. This |
| 1596 | /// expects the parser to be positioned at the first digit and will advance |
no test coverage detected