summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorPreston Pan <preston@nullring.xyz>2023-01-06 11:44:20 -0800
committerPreston Pan <preston@nullring.xyz>2023-01-06 11:44:20 -0800
commit9083582a5d3bfc8fae859b2ce124d86ad7420dcc (patch)
tree8f5d9ccdb2c96e938205503697a288382bfe0126 /src/main.c
parent30f12dfc1f32688f377913c52b131aa78d7830b5 (diff)
recursion works now
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main.c b/src/main.c
index b111ec5..73885ad 100644
--- a/src/main.c
+++ b/src/main.c
@@ -85,13 +85,14 @@ int main(int argc, char **argv) {
/* print_root(root); */
/* TODO: TEST RECURSION */
- /* lexer_t *lexer = init_lexer("(bind factorial (lambda (x) (if (<= x 0) 1 (*
- * x" */
- /* "(factorial (- x 1)))))) (factorial 3)"); */
- /* parser_t *parser = init_parser(lexer); */
- /* visitor_t *visitor = init_visitor(parser); */
- /* ast_t *root = eval(visitor); */
- /* print_root(root); */
+ /* char *expr = "(if (= 0 0) 1 2)"; */
+ char *expr = "(bind factorial (lambda (n) (if (= n 0) 1 (* n (factorial (- n "
+ "1)))))) (factorial 3)";
+ lexer_t *lexer = init_lexer(expr);
+ parser_t *parser = init_parser(lexer);
+ visitor_t *visitor = init_visitor(parser);
+ ast_t *root = eval(visitor);
+ print_root(root);
/* lexer_t *lexer = init_lexer("((lambda (x y) (+ x y)) (+ 3 4) 4) (+ 3
* 4)"); */