import and export take multiple spec in a time

This commit is contained in:
Yuichi Nishiwaki 2013-12-09 09:22:38 -08:00
parent 39b28fa674
commit d871c6f06c
1 changed files with 40 additions and 35 deletions

View File

@ -279,7 +279,10 @@ macroexpand(pic_state *pic, pic_value expr, struct pic_senv *senv)
struct pic_lib *lib; struct pic_lib *lib;
struct xh_iterator it; struct xh_iterator it;
lib = pic_find_library(pic, pic_cadr(pic, expr)); for (v = pic_cdr(pic, expr); ! pic_nil_p(v); v = pic_cdr(pic, v)) {
pic_value spec = pic_car(pic, v);
lib = pic_find_library(pic, spec);
if (! lib) { if (! lib) {
pic_error(pic, "library not found"); pic_error(pic, "library not found");
} }
@ -311,16 +314,18 @@ macroexpand(pic_state *pic, pic_value expr, struct pic_senv *senv)
} }
xh_next(lib->exports, &it); xh_next(lib->exports, &it);
} }
}
return pic_false_value(); return pic_false_value();
} }
case PIC_STX_EXPORT: { case PIC_STX_EXPORT: {
v = pic_cadr(pic, expr); for (v = pic_cdr(pic, expr); ! pic_nil_p(v); v = pic_cdr(pic, v)) {
if (! pic_symbol_p(v)) { pic_value spec = pic_car(pic, v);
if (! pic_symbol_p(spec)) {
pic_error(pic, "syntax error"); pic_error(pic, "syntax error");
} }
/* TODO: warn if symbol is shadowed by local variable */ /* TODO: warn if symbol is shadowed by local variable */
pic_export(pic, pic_sym(v)); pic_export(pic, pic_sym(spec));
}
return pic_false_value(); return pic_false_value();
} }
case PIC_STX_DEFSYNTAX: { case PIC_STX_DEFSYNTAX: {