add scan_repeat_literal to scanner
This commit is contained in:
@@ -233,6 +233,7 @@ void scanner_error(scanner_t *s, const char *message);
|
||||
void scanner_error_and_recover(scanner_t *s, const char *message);
|
||||
bool scan_eof(scanner_t *s);
|
||||
bool scan_literal(scanner_t *s, const char *lit);
|
||||
int scan_repeat_literal(scanner_t *s, const char *lit);
|
||||
bool scan_whitespace(scanner_t *s);
|
||||
bool scan_digit(scanner_t *s);
|
||||
bool scan_i64(scanner_t *s);
|
||||
|
||||
@@ -76,6 +76,14 @@ bool scan_literal(scanner_t *s, const char *lit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int scan_repeat_literal(scanner_t *s, const char *lit) {
|
||||
int n_repeats = 0;
|
||||
while (scan_literal(s, lit)) {
|
||||
n_repeats++;
|
||||
}
|
||||
return n_repeats;
|
||||
}
|
||||
|
||||
bool scan_whitespace(scanner_t *s) {
|
||||
const char *save = s->cur;
|
||||
while (isspace((unsigned char)*s->cur)) s->cur++;
|
||||
|
||||
Reference in New Issue
Block a user