From 8fd64902c7752a9607974b093cd1946bc5ff79d6 Mon Sep 17 00:00:00 2001 From: hachem Date: Sun, 30 Aug 2026 02:15:04 +0200 Subject: add: start basic work on the lexer --- src/main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 1d97acb..9a9dae4 100644 --- a/src/main.c +++ b/src/main.c @@ -2,6 +2,7 @@ #include "io/file.h" #include "cli/args.h" +#include "lexer/lexer.h" int main(int argc, char** argv) { @@ -17,7 +18,15 @@ int main(int argc, char** argv) if (!read_file(args.input_path, &source)) return 1; - printf("read %zu bytes from %s\n", source.size, args.input_path); + struct Lexer lexer = create_lexer(source.data); + + for (;;) + { + struct Token token = scan_token(&lexer); + printf("%4u %-14s %.*s\n", token.line, token_type_name(token.type), (int)token.length, token.start); + if (token.type == TOKEN_EOF) + break; + } free_file(&source); return 0; -- cgit v1.3