From 74097b6252ec8c7b368807381f764b8614e9bf9f Mon Sep 17 00:00:00 2001 From: nasr Date: Tue, 10 Mar 2026 22:22:49 +0000 Subject: feature(main): reading from stdin and then segfaulting --- source/engine.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/source/engine.c b/source/engine.c index 3527e27..67b5491 100644 --- a/source/engine.c +++ b/source/engine.c @@ -63,14 +63,20 @@ query_tokenizer(mem_arena *arena, string8 *buffer) end = index; } - s32 new_token_size = end - start; + // save the token + // TODO(nasr): work on the string macros cuz no work + { + + s32 new_token_size = end - start; + + tok->lexeme->data = &buffer->data[index]; + tok->lexeme->size = new_token_size; - tok->lexeme->data = &buffer->data[index]; - tok->lexeme->size = new_token_size; + tok->next = tok; + start = index + 1; - tok->next = tok; - start = index + 1; + } } return tok; @@ -91,7 +97,7 @@ int main(int c, char **v) string8 buffer = load_file(v[1]); - print("database engine in nasr"); + print("\nDatabase Engine\n"); for(;;) { @@ -99,22 +105,14 @@ int main(int c, char **v) { { u8 line_buffer[256] = {}; - s64 codepoint = os_read(STDIN_FD, line_buffer, 256); - unused(codepoint); - for(s32 index = 0; index < 256; ++index) + s32 err = os_read(STDIN_FD, line_buffer, 256); + if(err < 0) { - if(line_buffer[index] == '\n') - { - print("exiting"); - return 0; - } - else if(line_buffer[index] == ' ') - { + print("error reading from stdin"); + } - print("TODO(nasr): "); - } + query_tokenizer(global_arena, &StringLit(line_buffer)); - } } { -- cgit v1.3