From cb19f33fef747f1916df74910706ed1728f258c3 Mon Sep 17 00:00:00 2001 From: yenru0 Date: Fri, 3 Oct 2025 16:59:36 +0900 Subject: [PATCH] fix scan.c for ID accept non-alphabet characters and resolve some warning --- src/main.c | 2 +- src/scan.c | 3 +-- src/util.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index e685e43..83c53f8 100644 --- a/src/main.c +++ b/src/main.c @@ -45,7 +45,7 @@ int TraceCode = FALSE; int Error = FALSE; -main(int argc, char *argv[]) { +int main(int argc, char *argv[]) { TreeNode *syntaxTree; char pgm[120]; /* source code file name */ if (argc != 2) { diff --git a/src/scan.c b/src/scan.c index a4e40cf..c942414 100644 --- a/src/scan.c +++ b/src/scan.c @@ -219,7 +219,6 @@ TokenType getToken(void) { /* index for storing into tokenString */ currentToken = ERROR; } break; - case INLT: state = DONE; if (c == '=') { @@ -249,7 +248,7 @@ TokenType getToken(void) { /* index for storing into tokenString */ } break; case INID: - if (!isalpha(c)) { /* backup in the input */ + if (!isalnum(c)) { /* backup in the input */ ungetNextChar(); save = FALSE; state = DONE; diff --git a/src/util.c b/src/util.c index fe4904f..4bc50de 100644 --- a/src/util.c +++ b/src/util.c @@ -156,7 +156,7 @@ char *copyString(char *s) { /* Variable indentno is used by printTree to * store current number of spaces to indent */ -static indentno = 0; +static int indentno = 0; /* macros to increase/decrease indentation */ #define INDENT indentno += 2