From 18d4c9d9b20cf5236f8789dbac19e57bd529931b Mon Sep 17 00:00:00 2001 From: _N3m0 Date: Mon, 1 Jan 2024 10:22:59 +0100 Subject: [PATCH] fix: lexer nextchar go out of available chunks --- lexer.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lexer.c b/lexer.c index 1e6d0d5..7f00a0f 100644 --- a/lexer.c +++ b/lexer.c @@ -8,13 +8,15 @@ Cursor cursor = { }; char* nextchar(void){ - if (cursor.chunk >= page.len) return NULL; + if (cursor.chunk >= page.len){ + return NULL; + } if (page.chunks[cursor.chunk][cursor.offset+1] == '\0'){ cursor.chunk++; cursor.offset = 0; } else { cursor.offset++; - } + } return &page.chunks[cursor.chunk][cursor.offset]; } @@ -23,17 +25,6 @@ Token* nexttoken(void){ Token* token = malloc(sizeof(Token)); token->type = NO_TYPE; - /* - while (nextchar() == '<'); - - char c = '\0'; - do { - c = nextchar(); - printf("%c", c);; - } while (c != '>'); - puts(""); - */ - puts(""); char* c = nextchar(); do {