From 3bdd778b564cd4391becd4af9508da06a721388e Mon Sep 17 00:00:00 2001 From: _N3m0 Date: Sun, 31 Dec 2023 18:04:56 +0100 Subject: [PATCH] lexer go brrr --- lexer.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lexer.c b/lexer.c index c5da1d9..1e6d0d5 100644 --- a/lexer.c +++ b/lexer.c @@ -8,6 +8,7 @@ Cursor cursor = { }; char* nextchar(void){ + if (cursor.chunk >= page.len) return NULL; if (page.chunks[cursor.chunk][cursor.offset+1] == '\0'){ cursor.chunk++; cursor.offset = 0; @@ -34,9 +35,11 @@ Token* nexttoken(void){ */ puts(""); - for (int i=0; i<200; i++){ - printf("%c", *nextchar()); - } + char* c = nextchar(); + do { + printf("%c", *c); + c = nextchar(); + } while (c != NULL); puts(""); return token;