aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-02-24 02:10:58 +0100
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:40 +0200
commit11dc4b81935e3dfee997c421d8d6fa166edd7a05 (patch)
treeccb08be54209a4900c740c9ed58e8f9c2910811d /src/main.c
Initial commit, Function declaration work somewhat
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;
+}