diff options
author | c+1 | 2023-05-12 11:49:12 -0400 |
---|---|---|
committer | c+1 | 2023-05-12 11:49:12 -0400 |
commit | 17d6e6a265c44569f4533e12cc04442013ab3b3e (patch) | |
tree | 25233a2ca455b220a6ecae4d46139a55fd8b100b /src/main.c | |
parent | 07077e2974d74efaee109c9da3500ef86aeecd06 (diff) |
nothing workds help
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -6,10 +6,38 @@ int main(int argc, char* argv[]) { + FILE *fsource; + long fsource_size; + char *source; + + fsource = fopen ("examples/hello.halk", "rb"); + if (!fsource) { fputs("Source file not found.", stderr); exit(1); }; + + fseek(fsource, 0L, SEEK_END); + fsource_size = ftell(fsource); + rewind(fsource); + + source = calloc(1, fsource_size + 1); + if (!source) { + fclose(fsource); + fputs("Memory allocation faled.", stderr); + exit(1); + } + + if (1 != fread(source, fsource_size, 1, fsource)) { + fclose(fsource); + free(source); + fputs("Could not read source file.", stderr); + exit(1); + } + lexer_t* lexer = lexer_init( - "[a simple test script]\nlet it = \"Hello, World!\";\nsay it;" + source ); + fclose(fsource); + free(source); + printf("\n=== INPUT =======\n%s\n=== END INPUT ===\n", lexer->content); token_t* token = NULL; |