aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/src/main.c b/src/main.c
index f3147bb..c016892 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;
}