aboutsummaryrefslogtreecommitdiff
path: root/src/tree.c
diff options
context:
space:
mode:
authorc2024-03-23 10:52:52 -0400
committerc2024-03-23 10:52:52 -0400
commitbbcda663d5b2b2f055de12107e0abab536e5beea (patch)
treea70ec5edb9912ca3bbbf230fba6196741b2c8394 /src/tree.c
parent53d5c419bdfaa58c2cf7c30e51e4515f66fa85a1 (diff)
Doubly-linked the abstract syntax tree.
Diffstat (limited to 'src/tree.c')
-rw-r--r--src/tree.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/tree.c b/src/tree.c
index 58fba36..84334be 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -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;"\