aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/doer.h2
-rw-r--r--src/include/tree.h26
2 files changed, 19 insertions, 9 deletions
diff --git a/src/include/doer.h b/src/include/doer.h
index 0b4337b..a59a81a 100644
--- a/src/include/doer.h
+++ b/src/include/doer.h
@@ -49,6 +49,8 @@ typedef struct BLINF {
void doer_add_target(doer_t* doer, target_t* target);
tree_t* doer_find_target_from_call(target_t* targetl, tree_t* call);
+// Given a tree, evaluate it to a primitive type.
+tree_t* doer_eval_prim(doer_t* doer);
// Given a tree, evaluate it to a string (or type error).
char* doer_eval_str(doer_t* doer);
diff --git a/src/include/tree.h b/src/include/tree.h
index e1adf85..5e0279f 100644
--- a/src/include/tree.h
+++ b/src/include/tree.h
@@ -4,15 +4,15 @@
#include "util.h"
typedef enum TREE_TYPE {
- TREE_TYPE_BLOCK,
- TREE_TYPE_EXPR,
- TREE_TYPE_LINT,
- TREE_TYPE_LSTR,
- TREE_TYPE_TAG,
- TREE_TYPE_DARG,
- TREE_TYPE_CARG,
- TREE_TYPE_DEF,
- TREE_TYPE_CALL
+ TREE_TYPE_BLOCK = 0,
+ TREE_TYPE_EXPR = 1, // Deprecated.
+ TREE_TYPE_LINT = 2,
+ TREE_TYPE_LSTR = 3,
+ TREE_TYPE_TAG = 4,
+ TREE_TYPE_DARG = 5,
+ TREE_TYPE_CARG = 6,
+ TREE_TYPE_DEF = 7,
+ TREE_TYPE_CALL = 8,
} tree_type_t;
/* The Abstract Syntax Tree (AST) structure. */
@@ -87,12 +87,20 @@ tree_t* tree_init(tree_type_t type, tree_t* parent);
/* Destroy the AST (if it exists). */
void tree_destroy(tree_t* tree);
+void tree_rm(tree_t* t);
+// void tree_append(tree_t** dest, tree_t* t);
+
+tree_t* tree_copy_out(tree_t* tree);
+
/*
Compare two trees. For testing.
Returns 1 if the same, otherwise 0.
*/
int tree_cmp(tree_t* tree_0, tree_t* tree_1);
+// Swaps a tree for another.
+void tree_swp_call(tree_t* t0, tree_t* t1);
+
/* Print a tree. */
void tree_print(tree_t* tree, int nest);