From aa1dd020edb82f26dd5bc29378177cfcaa4c53ed Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Sun, 8 Jan 2023 10:00:08 -0800 Subject: print functions completed --- src/lexer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lexer.c') diff --git a/src/lexer.c b/src/lexer.c index 29c6542..e58197a 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -26,7 +26,7 @@ lexer_t *init_lexer(char *source) { } void lexer_move(lexer_t *lexer) { - if (lexer->c != '\0') { + if (lexer->c != '\0' && lexer->c != EOF) { lexer->i++; lexer->c = lexer->source[lexer->i]; if (lexer->c == '\n') { @@ -39,7 +39,7 @@ void lexer_move(lexer_t *lexer) { void lexer_ignore_whitespace(lexer_t *lexer) { while (isspace(lexer->c)) { - if (lexer->c == '\0') + if (lexer->c == '\0' || lexer->c == EOF) return; lexer_move(lexer); } -- cgit