diff options
author | c | 2023-12-05 12:41:05 -0500 |
---|---|---|
committer | c | 2023-12-05 12:41:05 -0500 |
commit | 3139398d475830f976895d27e772d4e926490881 (patch) | |
tree | ea91cd31c6c12739670fd958a1cf9fd445ea2b28 /src/token.c | |
parent | 9f051cf7a3483935c9a740c5339c19fedbdc80e4 (diff) |
Made AST output look fancy.
Diffstat (limited to 'src/token.c')
-rw-r--r-- | src/token.c | 7 |
1 files changed, 4 insertions, 3 deletions
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); } |