diff options
| author | Felix Perktold <Felix.Perktold@student.uibk.ac.at> | 2025-12-21 22:03:34 +0100 |
|---|---|---|
| committer | Felix Perktold <Felix.Perktold@student.uibk.ac.at> | 2025-12-21 22:03:34 +0100 |
| commit | c7878cd824360c6bf8a8e987acfa6a31140e9d69 (patch) | |
| tree | b1b882d77df4a5571c38cf6aada7666890a6423b /lisp.h | |
| parent | 47debf8cc2197187a347b43a795120638b017d5f (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 'lisp.h')
| -rw-r--r-- | lisp.h | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -11,7 +11,8 @@ typedef enum { VT_STRING, VT_NIL, VT_PAIR, - VT_LAMBDA + VT_LAMBDA, + VT_BUILTIN } val_type; struct value { @@ -30,6 +31,9 @@ struct value { value *body; env *env; } lambda; + struct { + value *(*fn) (env *, value *); + } builtin; } as; }; @@ -39,6 +43,7 @@ value *make_symbol(const char *sym); value *make_string(const char *str); value *make_nil(); value *make_lambda(env *e, value *params, value *body); +value *make_builtin(value *(*fn) (env *, value *)); value *cons(value *car, value *cdr); value *car(value *cons); value *cdr(value *cons); @@ -64,4 +69,16 @@ value *eval_pair(env *e, value *val); value *apply(value *lambda, value *args); +value *builtin_cons(env *e, value *args); +value *builtin_car(env *e, value *args); +value *builtin_cdr(env *e, value *args); +value *builtin_isnull(env *e, value *args); +value *builtin_add(env *e, value *args); +value *builtin_sub(env *e, value *args); +value *builtin_mul(env *e, value *args); +value *builtin_div(env *e, value *args); +value *builtin_le(env *e, value *args); + +int is_integer(double x); + #endif |
