diff options
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..cb6cbff --- /dev/null +++ b/src/main.c @@ -0,0 +1,41 @@ + +#include <filehandler.h> +#include <lexer.h> +#include <list.h> +#include <stdio.h> +#include <stdlib.h> +#include <token.h> + +int +main(int argc, char **argv) +{ + if (argc != 2) { + printf("Usage: %s <script>\n", argv[0]); + return 1; + } + + filehandler_t *f = (filehandler_t *) malloc(sizeof(filehandler_t)); + filehandler_init(f, argv[1]); + + bool opened = filehandler_open(f); + if (!opened) { + printf("Unable to open %s\n", argv[1]); + return 1; + } + + char *buffer = filehandler_read(f); + if (buffer == NULL) { + printf("Unable to read %s\n", argv[1]); + return 1; + } + + lexer_init(buffer); + lexer_scan_tokens(); + + // Token t(EOFF, "EOF", 221); + // printf("%s\n", t.to_string()); + // t.clean(); + + filehandler_close(f); + return 0; +} |
