aboutsummaryrefslogtreecommitdiff
path: root/src/include/tree.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/tree.h')
-rw-r--r--src/include/tree.h31
1 files changed, 12 insertions, 19 deletions
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