some progress
some progress
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user