about summary refs log tree commit diff
path: root/src/main.c
diff options
context:
space:
mode:
authorNakidai <plaza521@inbox.ru>2024-08-23 20:43:31 +0300
committerNakidai <plaza521@inbox.ru>2024-08-23 20:43:31 +0300
commit2b0e05cbc1e4d9beccd3a5867c8730880f6ecc10 (patch)
treef0e5e31e6259e0b6ea940c1d4c394b976a4bac74 /src/main.c
parent9e4058194742794f7742f19cb1a0bb3451ce22ea (diff)
download3cl-2b0e05cbc1e4d9beccd3a5867c8730880f6ecc10.tar.gz
3cl-2b0e05cbc1e4d9beccd3a5867c8730880f6ecc10.zip
Start to rewriting code
Since there's some UB in the master I decided to rewrite code from
scratch again. I hope that attempt will be better :D
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/main.c b/src/main.c
index 0d69855..2df5779 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,5 +1,4 @@
 #include "main.h"
-#include "types.h"
 
 #include <getopt.h>
 #include <stdbool.h>
@@ -7,15 +6,16 @@
 #include <stdlib.h>
 #include <stdnoreturn.h>
 
-#include "cccl.h"
 #include "platform/getch.h"
+#include "3cl.h"
+#include "readfile.h"
 
 
-const s8 *program_name;
+const char *program_name;
 
-static const s8 *const usage_message =
+static const char *const usage_message =
     "usage: %s [-h] file\n";
-static const s8 *const usage_description =
+static const char *const usage_description =
     "ccl language interpreter\n"
     "Arguments:\n"
     "  file         file to execute\n"
@@ -35,12 +35,12 @@ noreturn void usage(bool full)
     exit(full ? 0 : 1);
 }
 
-int main(i32 argc, s8 **argv)
+int main(int argc, char **argv)
 {
     program_name = argv[0];
     getch_init();
 
-    i32 ch;
+    int ch;
     while ((ch = getopt_long(argc, argv, "h", long_options, NULL)) != EOF)
     {
         switch (ch)
@@ -56,10 +56,9 @@ int main(i32 argc, s8 **argv)
     if (argv[optind] == NULL)
         usage(false);
 
-    cccl_init(argv[optind]);
-        cccl_read();
-        cccl_run();
-    cccl_free();
-
-    return 0;
+    char *code = readfile(argv[optind]);
+    struct CCL ccl;
+    ccl_init(&ccl, code, getch, (void(*)(int))putchar);
+    free(code);
+    ccl_free(&ccl);
 }