Add basic lexenv support
This commit is contained in:
+5
-11
@@ -1,26 +1,20 @@
|
||||
#include "lisp.h"
|
||||
#include "read.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
DEFUN(cool_func, "cool-func", (LispVal * a, LispVal *b), "(a &optional b)",
|
||||
"") {
|
||||
printf("A: ");
|
||||
debug_obj_info(stdout, a);
|
||||
printf("B: ");
|
||||
debug_obj_info(stdout, b);
|
||||
DEFUN(print, "print", (LispVal * v), "(v)", "") {
|
||||
debug_obj_info(stdout, v);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv) {
|
||||
lisp_init();
|
||||
REGISTER_GLOBAL_FUNCTION(cool_func);
|
||||
REGISTER_GLOBAL_FUNCTION(print);
|
||||
push_stack_frame(Qnil, Qnil, Qnil);
|
||||
ReadStream s;
|
||||
const char BUF[] = "(cool-func 1 (cons 1 2))";
|
||||
const char BUF[] = "(let ((a 1)) (print a))";
|
||||
read_stream_init(&s, BUF, sizeof(BUF) - 1);
|
||||
LispVal *l = read(&s);
|
||||
Feval(l);
|
||||
Feval(l, Qnil);
|
||||
lisp_gc_now(NULL);
|
||||
pop_stack_frame();
|
||||
lisp_shutdown();
|
||||
|
||||
Reference in New Issue
Block a user