|
|
|
@ -198,6 +198,11 @@ Pointer fn_fn(Pointer args, Pointer env) {
@@ -198,6 +198,11 @@ Pointer fn_fn(Pointer args, Pointer env) {
|
|
|
|
|
return func(args, env); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Pointer exit_fn(Pointer args, Pointer env) { |
|
|
|
|
(void) args; (void) env; |
|
|
|
|
exit(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#define SET_FUNC(s, fn) environment_set(NIL, symbol1(s), native_func(fn)) |
|
|
|
|
#define SET_FORM(s, fn) environment_set(NIL, symbol1(s), special_form(fn)) |
|
|
|
|
|
|
|
|
@ -226,6 +231,7 @@ void init(void) {
@@ -226,6 +231,7 @@ void init(void) {
|
|
|
|
|
SET_FUNC("~", lognot_fn); |
|
|
|
|
SET_FUNC("peek-char", peek_char_fn); |
|
|
|
|
SET_FUNC("read-char", read_char_fn); |
|
|
|
|
SET_FUNC("exit", exit_fn); |
|
|
|
|
|
|
|
|
|
SET_FORM("if", if_fn); |
|
|
|
|
SET_FORM("let", let_fn); |
|
|
|
@ -238,7 +244,9 @@ void init(void) {
@@ -238,7 +244,9 @@ void init(void) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void repl(void) { |
|
|
|
|
Pointer readed = read_fn(NIL, NIL); |
|
|
|
|
print(eval(readed, NIL), stdout); |
|
|
|
|
printf("\n"); |
|
|
|
|
while(true) { |
|
|
|
|
printf(">>> "); |
|
|
|
|
print(eval(read_fn(NIL, NIL), NIL), stdout); |
|
|
|
|
printf("\n"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|