add pic_define_syntactic_keyword
This commit is contained in:
parent
708f348674
commit
8750b9b4dd
|
@ -42,6 +42,8 @@ pic_sym pic_add_rename(pic_state *, struct pic_senv *, pic_sym);
|
||||||
bool pic_find_rename(pic_state *, struct pic_senv *, pic_sym, pic_sym * /* = NULL */);
|
bool pic_find_rename(pic_state *, struct pic_senv *, pic_sym, pic_sym * /* = NULL */);
|
||||||
void pic_put_rename(pic_state *, struct pic_senv *, pic_sym, pic_sym);
|
void pic_put_rename(pic_state *, struct pic_senv *, pic_sym, pic_sym);
|
||||||
|
|
||||||
|
void pic_define_syntactic_keyword(pic_state *, struct pic_senv *, pic_sym);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
21
src/init.c
21
src/init.c
|
@ -86,20 +86,13 @@ pic_init_core(pic_state *pic)
|
||||||
|
|
||||||
/* load core syntaces */
|
/* load core syntaces */
|
||||||
pic->lib->senv = pic_null_syntactic_environment(pic);
|
pic->lib->senv = pic_null_syntactic_environment(pic);
|
||||||
pic_put_rename(pic, pic->lib->senv, pic->sDEFINE, pic->sDEFINE);
|
pic_define_syntactic_keyword(pic, pic->lib->senv, pic->sDEFINE);
|
||||||
pic_put_rename(pic, pic->lib->senv, pic->sSETBANG, pic->sSETBANG);
|
pic_define_syntactic_keyword(pic, pic->lib->senv, pic->sSETBANG);
|
||||||
pic_put_rename(pic, pic->lib->senv, pic->sQUOTE, pic->sQUOTE);
|
pic_define_syntactic_keyword(pic, pic->lib->senv, pic->sQUOTE);
|
||||||
pic_put_rename(pic, pic->lib->senv, pic->sLAMBDA, pic->sLAMBDA);
|
pic_define_syntactic_keyword(pic, pic->lib->senv, pic->sLAMBDA);
|
||||||
pic_put_rename(pic, pic->lib->senv, pic->sIF, pic->sIF);
|
pic_define_syntactic_keyword(pic, pic->lib->senv, pic->sIF);
|
||||||
pic_put_rename(pic, pic->lib->senv, pic->sBEGIN, pic->sBEGIN);
|
pic_define_syntactic_keyword(pic, pic->lib->senv, pic->sBEGIN);
|
||||||
pic_put_rename(pic, pic->lib->senv, pic->sDEFINE_SYNTAX, pic->sDEFINE_SYNTAX);
|
pic_define_syntactic_keyword(pic, pic->lib->senv, pic->sDEFINE_SYNTAX);
|
||||||
pic_export(pic, pic->sDEFINE);
|
|
||||||
pic_export(pic, pic->sSETBANG);
|
|
||||||
pic_export(pic, pic->sQUOTE);
|
|
||||||
pic_export(pic, pic->sLAMBDA);
|
|
||||||
pic_export(pic, pic->sIF);
|
|
||||||
pic_export(pic, pic->sBEGIN);
|
|
||||||
pic_export(pic, pic->sDEFINE_SYNTAX);
|
|
||||||
|
|
||||||
pic_init_bool(pic); DONE;
|
pic_init_bool(pic); DONE;
|
||||||
pic_init_pair(pic); DONE;
|
pic_init_pair(pic); DONE;
|
||||||
|
|
19
src/macro.c
19
src/macro.c
|
@ -20,13 +20,23 @@ pic_null_syntactic_environment(pic_state *pic)
|
||||||
senv->up = NULL;
|
senv->up = NULL;
|
||||||
xh_init_int(&senv->renames, sizeof(pic_sym));
|
xh_init_int(&senv->renames, sizeof(pic_sym));
|
||||||
|
|
||||||
pic_put_rename(pic, senv, pic->sDEFINE_LIBRARY, pic->sDEFINE_LIBRARY);
|
pic_define_syntactic_keyword(pic, senv, pic->sDEFINE_LIBRARY);
|
||||||
pic_put_rename(pic, senv, pic->sIMPORT, pic->sIMPORT);
|
pic_define_syntactic_keyword(pic, senv, pic->sIMPORT);
|
||||||
pic_put_rename(pic, senv, pic->sEXPORT, pic->sEXPORT);
|
pic_define_syntactic_keyword(pic, senv, pic->sEXPORT);
|
||||||
|
|
||||||
return senv;
|
return senv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pic_define_syntactic_keyword(pic_state *pic, struct pic_senv *senv, pic_sym sym)
|
||||||
|
{
|
||||||
|
pic_put_rename(pic, senv, sym, sym);
|
||||||
|
|
||||||
|
if (pic->lib && pic->lib->senv == senv) {
|
||||||
|
pic_export(pic, sym);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pic_sym
|
pic_sym
|
||||||
pic_add_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym)
|
pic_add_rename(pic_state *pic, struct pic_senv *senv, pic_sym sym)
|
||||||
{
|
{
|
||||||
|
@ -969,8 +979,7 @@ pic_init_macro(pic_state *pic)
|
||||||
pic_deflibrary ("(picrin macro)") {
|
pic_deflibrary ("(picrin macro)") {
|
||||||
|
|
||||||
/* export define-macro syntax */
|
/* export define-macro syntax */
|
||||||
pic_put_rename(pic, pic->lib->senv, pic->sDEFINE_MACRO, pic->sDEFINE_MACRO);
|
pic_define_syntactic_keyword(pic, pic->lib->senv, pic->sDEFINE_MACRO);
|
||||||
pic_export(pic, pic->sDEFINE_MACRO);
|
|
||||||
|
|
||||||
pic_defun(pic, "gensym", pic_macro_gensym);
|
pic_defun(pic, "gensym", pic_macro_gensym);
|
||||||
pic_defun(pic, "macroexpand", pic_macro_macroexpand);
|
pic_defun(pic, "macroexpand", pic_macro_macroexpand);
|
||||||
|
|
Loading…
Reference in New Issue