diff --git a/include/picrin.h b/include/picrin.h index 9b063923..083cfcda 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -85,6 +85,9 @@ typedef struct { pic_sym rDEFINE_SYNTAX, rIMPORT, rEXPORT; pic_sym rDEFINE_LIBRARY, rIN_LIBRARY; + struct pic_lib *PICRIN_BASE; + struct pic_lib *PICRIN_USER; + xhash syms; /* name to symbol */ xhash sym_names; /* symbol to name */ int sym_cnt; diff --git a/init.c b/init.c index eaf0c005..62a19090 100644 --- a/init.c +++ b/init.c @@ -4,7 +4,6 @@ #include "picrin.h" #include "picrin/pair.h" -#include "picrin/read.h" #include "picrin/lib.h" #include "picrin/macro.h" #include "picrin/error.h" @@ -36,8 +35,6 @@ pic_init_core(pic_state *pic) { size_t ai = pic_gc_arena_preserve(pic); - pic_init_reader(pic); - pic_deflibrary (pic, "(picrin base)") { pic_define_syntactic_keyword(pic, pic->lib->env, pic->sDEFINE, pic->rDEFINE); pic_define_syntactic_keyword(pic, pic->lib->env, pic->sSETBANG, pic->rSETBANG); diff --git a/state.c b/state.c index d9427f3d..ccf53a80 100644 --- a/state.c +++ b/state.c @@ -140,11 +140,15 @@ pic_open(int argc, char *argv[], char **envp) pic->blk->depth = 0; pic->blk->in = pic->blk->out = NULL; - pic_init_core(pic); + /* init readers */ + pic_init_reader(pic); - /* set library */ - pic_make_library(pic, pic_read_cstr(pic, "(picrin user)")); - pic_in_library(pic, pic_read_cstr(pic, "(picrin user)")); + /* standard libraries */ + pic->PICRIN_BASE = pic_make_library(pic, pic_read_cstr(pic, "(picrin base)")); + pic->PICRIN_USER = pic_make_library(pic, pic_read_cstr(pic, "(picrin user)")); + pic->lib = pic->PICRIN_USER; + + pic_init_core(pic); return pic; }