MCPcopy Create free account
hub / github.com/davidblewett/rure-python / parse_hex

Method parse_hex

regex/regex-syntax/src/ast/parse.rs:1572–1593  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

parse_escapeMethod · 0.80

Calls 6

bump_and_bump_spaceMethod · 0.80
parse_hex_braceMethod · 0.80
parse_hex_digitsMethod · 0.80
charMethod · 0.45
errorMethod · 0.45
spanMethod · 0.45

Tested by

no test coverage detected