summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorFelix Perktold <Felix.Perktold@student.uibk.ac.at>2025-12-21 22:03:34 +0100
committerFelix Perktold <Felix.Perktold@student.uibk.ac.at>2025-12-21 22:03:34 +0100
commitc7878cd824360c6bf8a8e987acfa6a31140e9d69 (patch)
treeb1b882d77df4a5571c38cf6aada7666890a6423b /main.c
parent47debf8cc2197187a347b43a795120638b017d5f (diff)
add builtins, add pretty printing for lists, fix erroneous symbol x not found for forms (define, lambda ...) add check for head->type == VT_SYMBOL on forms (so a string cannot be misinterpreted as a form symbol), move is_integer from lisp.y to lisp.h/lisp.c
Diffstat (limited to 'main.c')
-rw-r--r--main.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/main.c b/main.c
index c9f9acd..f297402 100644
--- a/main.c
+++ b/main.c
@@ -12,6 +12,15 @@ env *global_env = NULL;
int main(void) {
// init global env
global_env = env_create(NULL);
+ env_define(global_env, "cons", make_builtin(builtin_cons));
+ env_define(global_env, "car", make_builtin(builtin_car));
+ env_define(global_env, "cdr", make_builtin(builtin_cdr));
+ env_define(global_env, "null?", make_builtin(builtin_isnull));
+ env_define(global_env, "+", make_builtin(builtin_add));
+ env_define(global_env, "-", make_builtin(builtin_sub));
+ env_define(global_env, "*", make_builtin(builtin_mul));
+ env_define(global_env, "/", make_builtin(builtin_div));
+ env_define(global_env, "<=", make_builtin(builtin_le));
// START REPL
char* line;
while ((line = readline("λ > ")) != NULL) {