From 000658c8405f93bf8ce1e03a9055e6944e730534 Mon Sep 17 00:00:00 2001 From: c+1 Date: Sat, 18 Nov 2023 23:14:24 -0500 Subject: I honestly don't remember. Parser stuff. Probably. --- src/include/tree.h | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'src/include/tree.h') diff --git a/src/include/tree.h b/src/include/tree.h index b878852..3dfb5be 100644 --- a/src/include/tree.h +++ b/src/include/tree.h @@ -3,9 +3,7 @@ #include "util.h" -/* The Abstract Syntax Tree (AST) structure. */ -typedef struct TREE { - enum TREE_TYPE { +typedef enum TREE_TYPE { TREE_TYPE_BLOCK, TREE_TYPE_LINT, TREE_TYPE_LSTR, @@ -14,14 +12,21 @@ typedef struct TREE { TREE_TYPE_CARG, TREE_TYPE_DEF, TREE_TYPE_CAL, - } type; +} tree_type_t; + +/* The Abstract Syntax Tree (AST) structure. */ +typedef struct TREE { + tree_type_t type; union TREE_DATA{ /* Block. */ struct TREE_DATA_BLOCK { /* The first expression in the block. */ struct TREE* val; - /* The next expression in the block. If it's'nt a block, end the block. */ + /* + The next block in the linked list. + - If it's `NULL`, it's the end of the block. + */ struct TREE* nxt; } block; @@ -75,19 +80,7 @@ tree_t* tree_init(int type); /* Destroy the AST. */ void tree_destroy(tree_t* tree); -/* TODO: Implement a better target organization structure that's better for searching. */ -typedef struct TREE_TARG { - tree_t* tree; - struct TREE_TARG* nxt; -} tree_targ_t; - -/* Create a new target. */ -tree_targ_t* tree_targ_init(tree_t* tree); -/* - Destroy a target. - - Frees all subsequent targets in `nxt`. - - Does not free the `tree`. -*/ -void tree_targ_destroy(tree_targ_t* targ); +/* Print a tree. */ +void tree_print(tree_t* tree, int nest); #endif -- cgit v1.2.3