From 346507f767d71c69e55b9f663449eb39e1bc7e54 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Thu, 5 Jan 2023 12:11:33 -0800 Subject: lists evaluate for non built-in functions --- src/main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 92e7764..9eec089 100644 --- a/src/main.c +++ b/src/main.c @@ -83,7 +83,7 @@ int main(int argc, char **argv) { /* DONE: TEST PARSING AND STORING BINDINGS */ /* lexer_t *lexer = init_lexer("(bind x \"hello world\")"); */ /* parser_t *parser = init_parser(lexer); */ - /* ast_t *root = parse_all(parser); */ + /* parse_all(parser); */ /* if (hash_table_exists(parser->symbol_table, "x")) { */ /* printf("YES!\n"); */ /* ast_t *str = hash_table_get(parser->symbol_table, "x"); */ @@ -92,11 +92,21 @@ int main(int argc, char **argv) { /* TODO: TEST HASH TABLE COLLISIONS */ /* DONE: TEST BUILTIN FUNCTIONS */ - lexer_t *lexer = init_lexer("(/ (+ 3.0 4.0) 4)"); + /* lexer_t *lexer = init_lexer("(* (+ 3.0 4.0) 4)"); */ + /* parser_t *parser = init_parser(lexer); */ + /* visitor_t *visitor = init_visitor(parser); */ + /* ast_t *root = eval(visitor); */ + /* ast_t *res = root->subnodes[0]; */ + /* print(res); */ + /* TODO: TEST NON-BUILTIN FUNCTIONS (stack frame) */ + + lexer_t *lexer = init_lexer("((lambda (x y) (+ x y)) (+ 3.0 4.0) 4)"); parser_t *parser = init_parser(lexer); visitor_t *visitor = init_visitor(parser); + ast_t *root = eval(visitor); ast_t *res = root->subnodes[0]; - printf("%f\n", res->float_value); + print(res); + return 0; } -- cgit