diff options
author | Preston Pan <preston@nullring.xyz> | 2023-01-02 22:31:49 -0800 |
---|---|---|
committer | Preston Pan <preston@nullring.xyz> | 2023-01-02 22:31:49 -0800 |
commit | 64feef1b9ea72adf7ba32998e9dca7d507607498 (patch) | |
tree | a409e61877bb51aa6fb2477175dabbf3dbccf298 /src/visitor.c |
a lot of stuff.
Diffstat (limited to 'src/visitor.c')
-rw-r--r-- | src/visitor.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/visitor.c b/src/visitor.c new file mode 100644 index 0000000..25296c1 --- /dev/null +++ b/src/visitor.c @@ -0,0 +1,25 @@ +#include "./include/visitor.h" +#include "./include/hash_table.h" +#include "./include/macros.h" +#include "./include/stack.h" +#include <stdlib.h> + +visitor_t *init_visitor(ast_t *root) { + visitor_t *v = (visitor_t *)malloc(sizeof(visitor_t)); + if (v == NULL) + die("malloc on visitor"); + v->stack_frame = init_stack(512); + v->symbol_table = init_hash_table(10000); + v->root = root; + return v; +} + +bool is_self_evaluating(ast_t *e) { + if (e->type == AST_STRING || e->type == AST_INT || e->type == AST_FLOAT || + e->type == AST_BOOL || e->type == AST_FUNCTION) + return true; + + if (e->type == AST_PAIR && e->car == NULL && e->cdr == NULL) + return true; + return false; +} |