Numeric lexing. The feast can start!
(&mut self, first: char)
| 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 { |
no test coverage detected