From 603c6709fbe167e8b885dba2cb0dd27ffca5a94b Mon Sep 17 00:00:00 2001 From: Max Wash Date: Fri, 6 Dec 2024 13:48:08 +0000 Subject: [PATCH] frontend: add debug-print support for ATOM and STRING nodes; add colour to several node types --- frontend/debug.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/frontend/debug.c b/frontend/debug.c index 01e6a55..61ccc53 100644 --- a/frontend/debug.c +++ b/frontend/debug.c @@ -144,6 +144,9 @@ extern enum ivy_status print_ast_node( case IVY_AST_UNIT_PACKAGE: case IVY_AST_UNIT_IMPORT: case IVY_AST_COND_GROUP: + case IVY_AST_WHILE_LOOP: + case IVY_AST_FOR_LOOP: + case IVY_AST_RETURN: b_puts("[magenta]"); break; case IVY_AST_OP: @@ -154,6 +157,7 @@ extern enum ivy_status print_ast_node( break; case IVY_AST_INT: case IVY_AST_DOUBLE: + case IVY_AST_ATOM: b_puts("[yellow]"); break; case IVY_AST_COND: @@ -168,6 +172,9 @@ extern enum ivy_status print_ast_node( case IVY_AST_FSTRING: b_puts("[green]"); break; + case IVY_AST_DISCARD: + b_puts("[dark_grey]"); + break; default: break; } @@ -190,6 +197,16 @@ extern enum ivy_status print_ast_node( b_printf(" (%s)", v->n_content->t_str); break; } + case IVY_AST_STRING: { + struct ivy_ast_string_node *v = (struct ivy_ast_string_node *)node; + b_printf(" (\"%s\")", v->n_value->t_str); + break; + } + case IVY_AST_ATOM: { + struct ivy_ast_atom_node *v = (struct ivy_ast_atom_node *)node; + b_printf(" (%s)", v->n_content->t_str); + break; + } case IVY_AST_SELECTOR: { struct ivy_ast_selector_node *v = (struct ivy_ast_selector_node *)node;