add digit scanning function to scanner

This commit is contained in:
2025-12-07 00:12:47 +01:00
parent e13f66b9e4
commit c0d6f53808
2 changed files with 11 additions and 0 deletions
+9
View File
@@ -82,6 +82,15 @@ bool scan_whitespace(scanner_t *s) {
return save != s->cur;
}
bool scan_digit(scanner_t *s) {
if (!isdigit((unsigned char)*s->cur)) {
return false;
}
s->value.digit = (*s->cur) - '0';
s->cur++;
return true;
}
bool scan_i64(scanner_t *s) {
const char *save = s->cur;
if (*s->cur == '-' || *s->cur == '+') s->cur++;