From 9083582a5d3bfc8fae859b2ce124d86ad7420dcc Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Fri, 6 Jan 2023 11:44:20 -0800 Subject: recursion works now --- src/main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/main.c') 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)"); */ -- cgit