MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / check_digits

Method check_digits

compiler/src/modules/lexer/scan.rs:69–82  ·  view source on GitHub ↗

Underscores must sit between digits: no leading, trailing, or consecutive. Empty body only valid after a decimal dot. */

(&mut self, start: usize, end: usize, allow_empty: bool)

Source from the content-addressed store, hash-verified

67
68 /* Underscores must sit between digits: no leading, trailing, or consecutive. Empty body only valid after a decimal dot. */
69 fn check_digits(&mut self, start: usize, end: usize, allow_empty: bool) {
70 if start == end {
71 if !allow_empty {
72 self.report(start, end, "missing digits in numeric literal");
73 }
74 return;
75 }
76 let s = &self.src[start..end];
77 if s[0] == b'_' || s[s.len() - 1] == b'_' {
78 self.report(start, end, "invalid '_' in numeric literal");
79 } else if s.windows(2).any(|w| w == [b'_', b'_']) {
80 self.report(start, end, "consecutive '_' in numeric literal");
81 }
82 }
83 fn scan_hex_digits(&mut self) {
84 self.scan_while(|b| b.is_ascii_hexdigit() || b == b'_');
85 }

Callers 3

scan_exponentMethod · 0.80
scan_numberMethod · 0.80
scan_dot_numberMethod · 0.80

Calls 2

reportMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected