summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPreston Pan <preston@nullring.xyz>2023-01-06 15:48:46 -0800
committerPreston Pan <preston@nullring.xyz>2023-01-06 15:48:46 -0800
commitf32cb9a129ebf1755ea300cf311f487c5b9f0f04 (patch)
tree77865e1aa41a6c306a6479448147e3320c3e6578
parentbbbc9f428b7226f1ddac1a78af63e71a96c0b90f (diff)
fully operational evaluator; makefile changed
-rw-r--r--Makefile2
-rw-r--r--doc/main.nxs3
-rw-r--r--src/visitor.c8
3 files changed, 7 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index d49039e..ce5ad74 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
CC = gcc
CFLAGS = -g -Wall
-nxs:
+nxs: src/ast.c src/hash_table.c src/lexer.c src/macros.c src/main.c src/parser.c src/print.c src/stack.c src/token.c src/visitor.c
cc src/*.c $(CFLAGS) -o nxs
clean:
diff --git a/doc/main.nxs b/doc/main.nxs
index e0839b5..274067c 100644
--- a/doc/main.nxs
+++ b/doc/main.nxs
@@ -1,4 +1,5 @@
(bind factorial (lambda (n)
(if (= n 0) 1 (* n (factorial (- n 1))))))
-(factorial 3)
+(* (factorial 4) 24)
+"hello world!"
diff --git a/src/visitor.c b/src/visitor.c
index 10782c8..ba29f3f 100644
--- a/src/visitor.c
+++ b/src/visitor.c
@@ -67,7 +67,7 @@ bool is_built_in(ast_t *e) {
* =, equal (for strings), input */
ast_t *eval_symbol(visitor_t *v, ast_t *e) {
/* hash_table_t *lmao = stack_peek(v->stack_frame); */
- printf("%s\n", e->string_value);
+ /* printf("%s\n", e->string_value); */
hash_table_t *h = stack_peek(v->stack_frame);
if (is_built_in(e))
return e;
@@ -87,7 +87,7 @@ ast_t *eval_symbol(visitor_t *v, ast_t *e) {
hash_table_add(v->eval_table, e->string_value, eval);
return eval;
} else {
- printf("symbol error\n");
+ /* printf("symbol error\n"); */
eval_error(v, e);
return NULL;
}
@@ -433,7 +433,7 @@ ast_t *eval_list(visitor_t *v, ast_t *e) {
}
ast_t *eval_expr(visitor_t *v, ast_t *e) {
- ast_type_print(e);
+ /* ast_type_print(e); */
if (is_self_evaluating(e))
return e;
else if (e->type == AST_PAIR && is_proper_list(e))
@@ -441,7 +441,7 @@ ast_t *eval_expr(visitor_t *v, ast_t *e) {
else if (e->type == AST_SYMBOL)
return eval_symbol(v, e);
else {
- printf("eval error\n");
+ /* printf("eval error\n"); */
eval_error(v, e);
return NULL;
}