MCPcopy Create free account
hub / github.com/astral-sh/ruff / bump_int

Method bump_int

crates/ruff_python_parser/src/parser/mod.rs:406–422  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

404 }
405
406 fn bump_int(&mut self) -> Int {
407 let text = self.current_token_text();
408 let value = if let Some(digits) =
409 text.strip_prefix("0x").or_else(|| text.strip_prefix("0X"))
410 {
411 Int::from_str_radix(&strip_underscores(digits), 16, text)
412 } else if let Some(digits) = text.strip_prefix("0o").or_else(|| text.strip_prefix("0O")) {
413 Int::from_str_radix(&strip_underscores(digits), 8, text)
414 } else if let Some(digits) = text.strip_prefix("0b").or_else(|| text.strip_prefix("0B")) {
415 Int::from_str_radix(&strip_underscores(digits), 2, text)
416 } else {
417 Int::from_str(&strip_underscores(text))
418 }
419 .expect("lexer validated integer literal");
420 self.bump(TokenKind::Int);
421 value
422 }
423
424 fn bump_float(&mut self) -> f64 {
425 let value = f64::from_str(&strip_underscores(self.current_token_text()))

Callers 2

parse_atomMethod · 0.80

Calls 6

strip_underscoresFunction · 0.85
current_token_textMethod · 0.80
expectMethod · 0.80
strip_prefixMethod · 0.80
or_elseMethod · 0.45
bumpMethod · 0.45

Tested by

no test coverage detected