aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..f3147bb
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <string.h>
+#include "../include/parser.h"
+
+int main() {
+ const char *code;
+ Parser parser;
+ BufferView code_view;
+ int result;
+
+ 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");
+ 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");
+ return 1;
+ }
+
+ /* No need to do this here as the program is exiting */
+ /* parser_deinit(&parser); */
+ return 0;
+}