frontend: add debug-print support for ATOM and STRING nodes; add colour to several node types

This commit is contained in:
2024-12-06 13:48:08 +00:00
parent 4cfb1e56ea
commit 603c6709fb

View File

@@ -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;