summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/main.nxs4
-rw-r--r--src/main.c2
-rw-r--r--src/visitor.c11
3 files changed, 5 insertions, 12 deletions
diff --git a/doc/main.nxs b/doc/main.nxs
index 381161a..3dd0ebf 100644
--- a/doc/main.nxs
+++ b/doc/main.nxs
@@ -2,5 +2,5 @@
(bind factorial (lambda (n)
(if (= n 0) 1 (* n (factorial (print(- n 1)))))))
-(fib 7)
-(+ (factorial 5) 10)
+(print(fib 7))
+(print (+ (factorial 5) 10))
diff --git a/src/main.c b/src/main.c
index 5315549..db5846d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -164,7 +164,7 @@ int main(int argc, char **argv) {
parser_t *parser = init_parser(lexer);
visitor_t *visitor = init_visitor(parser);
ast_t *root = eval(visitor);
- print_root(root);
+ /* print_root(root); */
}
return 0;
diff --git a/src/visitor.c b/src/visitor.c
index 22f09ed..374ad02 100644
--- a/src/visitor.c
+++ b/src/visitor.c
@@ -2,6 +2,7 @@
#include "./include/hash_table.h"
#include "./include/macros.h"
#include "./include/parser.h"
+#include "./include/print.h"
#include "./include/stack.h"
#include <stdbool.h>
#include <stdlib.h>
@@ -445,15 +446,7 @@ ast_t *eval_list(visitor_t *v, ast_t *e) {
eval_error(v, e);
ast_t *arg1 = eval_expr(v, args->car);
- if (arg1->type == AST_STRING) {
- printf("%s\n", arg1->string_value);
- } else if (arg1->type == AST_INT) {
- printf("%d\n", arg1->int_value);
- } else if (arg1->type == AST_FLOAT) {
- printf("%f\n", arg1->float_value);
- } else {
- printf("print statement for this datatype not implemented.\n");
- }
+ print(arg1);
return arg1;
}