some progress

This commit is contained in:
2026-10-03 17:13:04 +02:00
parent b553af59c2
commit ac7a341f76
4 changed files with 70 additions and 57 deletions
+4 -4
View File
@@ -60,22 +60,22 @@ bool scan_eof(scanner_t *s) {
return *s->cur == '\0';
}
bool scan_literal(scanner_t *s, char const *lit) {
scan_result_t scan_literal(scanner_t *s, char const *lit) {
char const *save = s->cur;
while (*lit && *lit == *s->cur) {
lit++;
s->cur++;
}
if (*lit == '\0') {
return true;
return (scan_result_t) { .ok = true };
}
s->cur = save;
return false;
return scan_error(s, "literal not present");
}
int scan_repeat_literal(scanner_t *s, char const *lit) {
int n_repeats = 0;
while (scan_literal(s, lit)) {
while (scan_literal(s, lit).ok) {
n_repeats++;
}
return n_repeats;