accept '(define (f a b) ...)' style in C level

This commit is contained in:
Yuichi Nishiwaki 2014-08-25 17:41:29 +09:00
parent a03efeb0d3
commit 1656367be2
1 changed files with 7 additions and 0 deletions

View File

@ -163,6 +163,13 @@ macroexpand_define(pic_state *pic, pic_value expr, struct pic_senv *senv)
pic_sym sym, rename;
pic_value var, val;
while (pic_length(pic, expr) >= 2 && pic_pair_p(pic_cadr(pic, expr))) {
var = pic_car(pic, pic_cadr(pic, expr));
val = pic_cdr(pic, pic_cadr(pic, expr));
expr = pic_list3(pic, pic_sym_value(pic->rDEFINE), var, pic_cons(pic, pic_sym_value(pic->rLAMBDA), pic_cons(pic, val, pic_cddr(pic, expr))));
}
if (pic_length(pic, expr) != 3) {
pic_error(pic, "syntax error");
}