summaryrefslogtreecommitdiff
path: root/source/engine.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/engine.c')
-rw-r--r--source/engine.c36
1 files 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)
63 end = index; 63 end = index;
64 } 64 }
65 65
66 s32 new_token_size = end - start; 66 // save the token
67 // TODO(nasr): work on the string macros cuz no work
68 {
69
70 s32 new_token_size = end - start;
71
72 tok->lexeme->data = &buffer->data[index];
73 tok->lexeme->size = new_token_size;
67 74
68 tok->lexeme->data = &buffer->data[index]; 75 tok->next = tok;
69 tok->lexeme->size = new_token_size; 76 start = index + 1;
70 77
71 tok->next = tok;
72 start = index + 1;
73 78
79 }
74 } 80 }
75 81
76 return tok; 82 return tok;
@@ -91,7 +97,7 @@ int main(int c, char **v)
91 97
92 string8 buffer = load_file(v[1]); 98 string8 buffer = load_file(v[1]);
93 99
94 print("database engine in nasr"); 100 print("\nDatabase Engine\n");
95 101
96 for(;;) 102 for(;;)
97 { 103 {
@@ -99,22 +105,14 @@ int main(int c, char **v)
99 { 105 {
100 { 106 {
101 u8 line_buffer[256] = {}; 107 u8 line_buffer[256] = {};
102 s64 codepoint = os_read(STDIN_FD, line_buffer, 256); 108 s32 err = os_read(STDIN_FD, line_buffer, 256);
103 unused(codepoint); 109 if(err < 0)
104 for(s32 index = 0; index < 256; ++index)
105 { 110 {
106 if(line_buffer[index] == '\n') 111 print("error reading from stdin");
107 { 112 }
108 print("exiting");
109 return 0;
110 }
111 else if(line_buffer[index] == ' ')
112 {
113 113
114 print("TODO(nasr): "); 114 query_tokenizer(global_arena, &StringLit(line_buffer));
115 }
116 115
117 }
118 } 116 }
119 117
120 { 118 {