From 3139398d475830f976895d27e772d4e926490881 Mon Sep 17 00:00:00 2001 From: c Date: Tue, 5 Dec 2023 12:41:05 -0500 Subject: Made AST output look fancy. --- src/token.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/token.c') diff --git a/src/token.c b/src/token.c index df71d17..bcb4c18 100644 --- a/src/token.c +++ b/src/token.c @@ -14,6 +14,8 @@ token_t* token_init(int type, char val) { } void token_destroy(token_t* token) { + if (!token) { return; } + if (token->nxt) { token_destroy(token->nxt); token->nxt = NULL; @@ -44,9 +46,8 @@ void token_add_char(token_t* token, char c) { } void token_print(token_t* token) { - - log_dbg("token/t=%d\t/v=%s", token->type, token->val); - + if (!token) { return; } + log_dbg("token/t=%d\t/v=%s", token->type, token->val); if (token->nxt) { token_print(token->nxt); } -- cgit v1.2.3