MCPcopy Create free account
hub / github.com/LaBatata101/sith-language-server / parse_octet

Method parse_octet

crates/sith_python_parser/src/string.rs:141–158  ·  view source on GitHub ↗
(&mut self, o: u8)

Source from the content-addressed store, hash-verified

139 }
140
141 fn parse_octet(&mut self, o: u8) -> char {
142 let mut radix_bytes = [o, 0, 0];
143 let mut len = 1;
144
145 while len < 3 {
146 let Some(b'0'..=b'7') = self.peek_byte() else {
147 break;
148 };
149
150 radix_bytes[len] = self.next_byte().unwrap();
151 len += 1;
152 }
153
154 // OK because radix_bytes is always going to be in the ASCII range.
155 let radix_str = std::str::from_utf8(&radix_bytes[..len]).expect("ASCII bytes");
156 let value = u32::from_str_radix(radix_str, 8).unwrap();
157 char::from_u32(value).unwrap()
158 }
159
160 fn parse_unicode_name(&mut self) -> Result<char, LexicalError> {
161 let start_pos = self.position();

Callers 1

parse_escaped_charMethod · 0.80

Calls 3

peek_byteMethod · 0.80
next_byteMethod · 0.80
expectMethod · 0.80

Tested by

no test coverage detected