diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-02-27 22:26:35 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | 76d85a10f6cda93eba29dad5372e8160af7289c8 (patch) | |
tree | cfec3043ec45a5e83494ec109e87c239dad6cc47 /src/main.c | |
parent | 8201cd9f40897cf6b8e6973b28a8661108702ab1 (diff) |
Use multiple threads to parse
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 36 |
1 files changed, 13 insertions, 23 deletions
@@ -1,37 +1,27 @@ #include <stdio.h> #include <string.h> -#include "../include/parser.h" +#include "../include/compiler.h" int main() { - const char *code; - Parser parser; - BufferView code_view; + amal_compiler compiler; int result; + const char *filepath; + filepath = "tests/main.amal"; - code = - "const main = () {\n" - " var hello = () {\n" - " \n" - " }\n" - " hello()\n" - "}\n" - "const print = () {\n" - " \n" - "}"; - result = parser_init(&parser); - if(result != PARSER_OK) { - fprintf(stderr, "Failed to initialize parser\n"); + result = amal_compiler_init(&compiler); + if(result != AMAL_COMPILER_OK) { + fprintf(stderr, "Failed to initialize compiler, error code: %d\n", result); return 1; } - code_view = create_buffer_view(code, strlen(code)); - result = parser_parse_buffer(&parser, code_view); - if(result != PARSER_OK) { - fprintf(stderr, "Failed to parse\n"); + result = amal_compiler_load_file(&compiler, create_buffer_view(filepath, strlen(filepath))); + if(result != AMAL_COMPILER_OK) { + fprintf(stderr, "Failed to load file, error code: %d\n", result); return 1; } - /* No need to do this here as the program is exiting */ - /* parser_deinit(&parser); */ +#ifdef DEBUG + return amal_compiler_deinit(&compiler); +#endif return 0; } |