diff --git a/src/init.c b/src/init.c index 59b4bdd4..b1ef3b08 100644 --- a/src/init.c +++ b/src/init.c @@ -3,6 +3,8 @@ #include "picrin.h" #include "picrin/pair.h" +#include "picrin/lib.h" +#include "picrin/macro.h" void pic_init_bool(pic_state *); void pic_init_pair(pic_state *); @@ -90,9 +92,22 @@ pic_features(pic_state *pic) void pic_init_core(pic_state *pic) { - int ai; + int ai = pic_gc_arena_preserve(pic); + + pic_make_library(pic, pic_parse(pic, "(scheme base)")); + pic_in_library(pic, pic_parse(pic, "(scheme base)")); + + /* load core syntaces */ + pic->lib->senv = pic_core_syntactic_env(pic); + pic_export(pic, pic_intern_cstr(pic, "define")); + pic_export(pic, pic_intern_cstr(pic, "set!")); + pic_export(pic, pic_intern_cstr(pic, "quote")); + pic_export(pic, pic_intern_cstr(pic, "lambda")); + pic_export(pic, pic_intern_cstr(pic, "if")); + pic_export(pic, pic_intern_cstr(pic, "begin")); + pic_export(pic, pic_intern_cstr(pic, "define-macro")); + pic_export(pic, pic_intern_cstr(pic, "define-syntax")); - ai = pic_gc_arena_preserve(pic); pic_init_bool(pic); DONE; pic_init_pair(pic); DONE; pic_init_port(pic); DONE; diff --git a/src/state.c b/src/state.c index a75fe04a..d38af7ac 100644 --- a/src/state.c +++ b/src/state.c @@ -118,12 +118,12 @@ pic_open(int argc, char *argv[], char **envp) register_core_symbol(pic, sGE, ">="); pic_gc_arena_restore(pic, ai); + pic_init_core(pic); + /* set library */ pic_make_library(pic, pic_parse(pic, "user")); pic_in_library(pic, pic_parse(pic, "user")); - pic_init_core(pic); - return pic; }