From 7954a9925a76d45a665934944d80b09638c8340b Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 4 May 2025 18:24:32 +0900 Subject: fix issue where identifier whose name contains underscore cannot be parsed --- main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index c8431b1..beaa35b 100644 --- a/main.c +++ b/main.c @@ -212,7 +212,7 @@ TOKEN* tokenize(char* src, int len) { tok += 1; } else if (isalpha(c)) { int start = pos; - while (isalnum(src[pos])) { + while (isalnum(src[pos]) || src[pos] == '_') { pos += 1; } if (strstr(src + start, "break") == src + start) { @@ -1379,10 +1379,11 @@ int main() { TOKEN* tokens = tokenize(source, source_len); // for (int i = 0; tokens[i].kind != TK_EOF; i++) { - // for (int j = 0; j < tokens[i].len; j++) { - // putchar(tokens[i].value[j]); + // if (tokens[i].value) { + // printf("%s\n", tokens[i].value); + // } else { + // printf("(%d)\n", tokens[i].kind); // } - // printf("\n"); // } PARSER* parser = parser_new(tokens); -- cgit v1.2.3-70-g09d2