diff options
author | c | 2024-03-23 10:52:52 -0400 |
---|---|---|
committer | c | 2024-03-23 10:52:52 -0400 |
commit | bbcda663d5b2b2f055de12107e0abab536e5beea (patch) | |
tree | a70ec5edb9912ca3bbbf230fba6196741b2c8394 /src/tree.c | |
parent | 53d5c419bdfaa58c2cf7c30e51e4515f66fa85a1 (diff) |
Doubly-linked the abstract syntax tree.
Diffstat (limited to 'src/tree.c')
-rw-r--r-- | src/tree.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1,11 +1,13 @@ #include "include/tree.h" -tree_t* tree_init(tree_type_t type) { +tree_t* tree_init(tree_type_t type, tree_t* parent) { tree_t* tree; tree = emalloc(sizeof(tree_t)); tree->type = type; + + tree->parent = parent; switch (tree->type) { case TREE_TYPE_BLOCK: @@ -153,7 +155,7 @@ void tree_print(tree_t* tree, int nest) { "\x1b[%dm",nc);sprintf(bc,"\x1b[%d;1m" ,nc);NULL;NULL;0x0;0;0;0;0;NULL;0x0;0; #define NEST0(T)LOG_RAWF("%s%s"T"\x1b"\ - """""""""""""""""""""""""[0m\n",bc,sp) + "[0m -> %d\n",bc,sp,tree->parent?tree->parent->type:-1) #define NEST1(T)LOG_RAWF("%s%s"T"\x1b"\ """""""""""""""""""""""""[0m\n",c,sp); #define NEST2(T)LOG_RAWF("%s \x1b[39;"\ |