Scanner - Use is_ascii_digit() instead of is_digit(10)

This commit is contained in:
Emmanuel BENOîT 2022-12-31 10:15:55 +01:00
parent 45ed237818
commit e918d90e39

View file

@ -131,7 +131,7 @@ impl Scanner {
' ' | '\r' | '\t' => (), ' ' | '\r' | '\t' => (),
'\n' => self.line += 1, '\n' => self.line += 1,
// Numbers // Numbers
ch if ch.is_digit(10) => self.number(err_hdl), ch if ch.is_ascii_digit() => self.number(err_hdl),
// Identifiers // Identifiers
ch if ch.is_ascii_alphabetic() => self.identifier(), ch if ch.is_ascii_alphabetic() => self.identifier(),
// Anything else is an error // Anything else is an error
@ -163,12 +163,12 @@ impl Scanner {
/// Read the rest of a number. /// Read the rest of a number.
fn number(&mut self, err_hdl: &mut ErrorHandler) { fn number(&mut self, err_hdl: &mut ErrorHandler) {
while self.peek().is_digit(10) { while self.peek().is_ascii_digit() {
self.current += 1; self.current += 1;
} }
if self.peek() == '.' && self.peek_next().is_digit(10) { if self.peek() == '.' && self.peek_next().is_ascii_digit() {
self.current += 1; self.current += 1;
while self.peek().is_digit(10) { while self.peek().is_ascii_digit() {
self.current += 1; self.current += 1;
} }
} }