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

Method lex_number

crates/sith_python_parser/src/lexer.rs:1002–1016  ·  view source on GitHub ↗

Numeric lexing. The feast can start!

(&mut self, first: char)

Source from the content-addressed store, hash-verified

1000
1001 /// Numeric lexing. The feast can start!
1002 fn lex_number(&mut self, first: char) -> TokenKind {
1003 if first == '0' {
1004 if self.cursor.eat_if(|c| matches!(c, 'x' | 'X')).is_some() {
1005 self.lex_number_radix(Radix::Hex)
1006 } else if self.cursor.eat_if(|c| matches!(c, 'o' | 'O')).is_some() {
1007 self.lex_number_radix(Radix::Octal)
1008 } else if self.cursor.eat_if(|c| matches!(c, 'b' | 'B')).is_some() {
1009 self.lex_number_radix(Radix::Binary)
1010 } else {
1011 self.lex_decimal_number(first)
1012 }
1013 } else {
1014 self.lex_decimal_number(first)
1015 }
1016 }
1017
1018 /// Lex a hex/octal/decimal/binary number without a decimal point.
1019 fn lex_number_radix(&mut self, radix: Radix) -> TokenKind {

Callers 1

Calls 3

eat_ifMethod · 0.80
lex_number_radixMethod · 0.80
lex_decimal_numberMethod · 0.80

Tested by

no test coverage detected