From 0a3bcb4ab7c5884e9ad6bb47b05c9a8231395c93 Mon Sep 17 00:00:00 2001 From: Mel Date: Fri, 14 Mar 2025 22:48:06 +0100 Subject: Bootstrapping lexer Signed-off-by: Mel --- boot/catboot.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'boot/catboot.c') diff --git a/boot/catboot.c b/boot/catboot.c index 56aaeb6..e47d4b9 100644 --- a/boot/catboot.c +++ b/boot/catboot.c @@ -21,6 +21,7 @@ #include #include "common.c" +#include "lex.c" const ascii* read_file(const ascii* path) @@ -47,9 +48,18 @@ main(const int32 argc, const ascii* argv[]) return EXIT_FAILURE; } const ascii* file_path = argv[1]; - const ascii* source = read_file(file_path); - printf("%s", source); + const ascii* source_buffer = read_file(file_path); + struct String source = string_from_static_c_string(source_buffer); + + struct Lexer lexer; + lexer_new(&lexer, source); + + struct Token token; + do { + token = lexer_next(&lexer); + printf("%s ", token_kind_to_string(token.kind)); + } while (token.kind != TOKEN_END_OF_FILE); return EXIT_SUCCESS; } -- cgit 1.4.1