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

Method radix_run

crates/sith_python_parser/src/lexer.rs:1162–1176  ·  view source on GitHub ↗

Consume a sequence of numbers with the given radix, the digits can be decorated with underscores like this: '`1_2_3_4`' == '1234'

(&mut self, number: &mut LexedText, radix: Radix)

Source from the content-addressed store, hash-verified

1160 /// the digits can be decorated with underscores
1161 /// like this: '`1_2_3_4`' == '1234'
1162 fn radix_run(&mut self, number: &mut LexedText, radix: Radix) {
1163 loop {
1164 if let Some(c) = self.cursor.eat_if(|c| radix.is_digit(c)) {
1165 number.push(c);
1166 }
1167 // Number that contains `_` separators. Remove them from the parsed text.
1168 else if self.cursor.first() == '_' && radix.is_digit(self.cursor.second()) {
1169 // Skip over `_`
1170 self.cursor.bump();
1171 number.skip_char();
1172 } else {
1173 break;
1174 }
1175 }
1176 }
1177
1178 /// Lex a single comment.
1179 fn lex_comment(&mut self) -> TokenKind {

Callers 2

lex_number_radixMethod · 0.80
lex_decimal_numberMethod · 0.80

Calls 7

eat_ifMethod · 0.80
is_digitMethod · 0.80
secondMethod · 0.80
skip_charMethod · 0.80
pushMethod · 0.45
firstMethod · 0.45
bumpMethod · 0.45

Tested by

no test coverage detected