can read external .lisp file
This commit is contained in:
parent
3ae8c663e7
commit
cf54be4c78
10
macro.lisp
Normal file
10
macro.lisp
Normal file
@ -0,0 +1,10 @@
|
||||
(defn list (x . y) (cons x y))
|
||||
|
||||
(macro cond (expr. rest)
|
||||
(if rest (list 'if (car expr) (car (cdr expr)) (cons 'cond rest))
|
||||
expr))
|
||||
|
||||
(macro and (expr . rest)
|
||||
(if rest (list 'if expr (cons 'and rest)) expr))
|
||||
|
||||
;(cond ((== 1 0) 0) ((== 1 1) -1) (+ 100000000))
|
||||
11
main.c
11
main.c
@ -72,15 +72,12 @@ loop(Object *env, FILE *f)
|
||||
skipline(f);
|
||||
}
|
||||
while(1){
|
||||
printf(">> ");
|
||||
Object *res = nextexpr(f);
|
||||
printexpr(res);
|
||||
res = eval(env, res);
|
||||
printgc("status", gc);
|
||||
printf("=============res===========\n");
|
||||
printexpr(res);
|
||||
printf("=============env===========\n");
|
||||
printexpr(env);
|
||||
printf("===========================\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,5 +86,11 @@ main(int argc, char *argv[])
|
||||
{
|
||||
gc = newgc(&argc, 400);
|
||||
Object *env = newenv(gc, &Nil, &Nil, &Nil);
|
||||
for(int i = 1; i < argc; ++i){
|
||||
FILE *f = fopen(argv[i], "r");
|
||||
if(f == 0)
|
||||
panic("can't open %s", argv[i]);
|
||||
loop(env, f);
|
||||
}
|
||||
loop(env, stdin);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user