From 6e5db6a3e26cb2982f9723178b73836050250203 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sat, 16 Nov 2024 17:06:02 +0000 Subject: [PATCH] frontend: compile: print lex token details as they are read --- frontend/cmd/compile.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/cmd/compile.c b/frontend/cmd/compile.c index 85e10c6..fcdf5fe 100644 --- a/frontend/cmd/compile.c +++ b/frontend/cmd/compile.c @@ -44,7 +44,24 @@ static int compile_file(const char *path) break; } - printf("read token!\n"); + printf("%s", ivy_lex_token_type_to_string(tok->t_type)); + + switch (tok->t_type) { + case IVY_TOK_IDENT: + case IVY_TOK_LABEL: + printf("(%s)", tok->t_str); + break; + case IVY_TOK_SYMBOL: + printf("(%s)", ivy_symbol_to_string(tok->t_symbol)); + break; + case IVY_TOK_KEYWORD: + printf("(%s)", ivy_keyword_to_string(tok->t_keyword)); + break; + default: + break; + } + + printf("\n"); } int r = (lex.lex_status == IVY_OK || lex.lex_status == IVY_ERR_EOF) ? 0