/** * See Copyright Notice in picrin.h */ #include #include "picrin.h" #include "picrin/pair.h" #include "picrin/read.h" #include "picrin/lib.h" #include "picrin/macro.h" #include "picrin/error.h" static pic_value pic_features(pic_state *pic) { pic_value features = pic_nil_value(); pic_get_args(pic, ""); pic_push(pic, pic_sym_value(pic_intern_cstr(pic, "r7rs")), features); pic_push(pic, pic_sym_value(pic_intern_cstr(pic, "ieee-float")), features); pic_push(pic, pic_sym_value(pic_intern_cstr(pic, "picrin")), features); return features; } static pic_value pic_libraries(pic_state *pic) { pic_value libs = pic_nil_value(), lib; pic_get_args(pic, ""); pic_for_each (lib, pic->libs) { libs = pic_cons(pic, pic_car(pic, lib), libs); } return libs; } void pic_init_bool(pic_state *); void pic_init_pair(pic_state *); void pic_init_port(pic_state *); void pic_init_number(pic_state *); void pic_init_file(pic_state *); void pic_init_proc(pic_state *); void pic_init_symbol(pic_state *); void pic_init_vector(pic_state *); void pic_init_blob(pic_state *); void pic_init_cont(pic_state *); void pic_init_char(pic_state *); void pic_init_error(pic_state *); void pic_init_str(pic_state *); void pic_init_macro(pic_state *); void pic_init_var(pic_state *); void pic_init_write(pic_state *); void pic_init_read(pic_state *); void pic_init_dict(pic_state *); void pic_init_record(pic_state *); void pic_init_lib(pic_state *); #define DONE pic_gc_arena_restore(pic, ai); void pic_init_core(pic_state *pic) { size_t ai = pic_gc_arena_preserve(pic); pic_init_reader(pic); pic_deflibrary (pic, "(picrin base core)") { pic_define_syntactic_keyword(pic, pic->lib->env, pic->sDEFINE, pic->rDEFINE); pic_define_syntactic_keyword(pic, pic->lib->env, pic->sSETBANG, pic->rSETBANG); pic_define_syntactic_keyword(pic, pic->lib->env, pic->sQUOTE, pic->rQUOTE); pic_define_syntactic_keyword(pic, pic->lib->env, pic->sLAMBDA, pic->rLAMBDA); pic_define_syntactic_keyword(pic, pic->lib->env, pic->sIF, pic->rIF); pic_define_syntactic_keyword(pic, pic->lib->env, pic->sBEGIN, pic->rBEGIN); pic_define_syntactic_keyword(pic, pic->lib->env, pic->sDEFINE_SYNTAX, pic->rDEFINE_SYNTAX); } pic_deflibrary (pic, "(picrin library)") { pic_defun(pic, "libraries", pic_libraries); } pic_deflibrary (pic, "(scheme base)") { pic_defun(pic, "features", pic_features); pic_init_bool(pic); DONE; pic_init_pair(pic); DONE; pic_init_port(pic); DONE; pic_init_number(pic); DONE; pic_init_file(pic); DONE; pic_init_proc(pic); DONE; pic_init_symbol(pic); DONE; pic_init_vector(pic); DONE; pic_init_blob(pic); DONE; pic_init_cont(pic); DONE; pic_init_char(pic); DONE; pic_init_error(pic); DONE; pic_init_str(pic); DONE; pic_init_macro(pic); DONE; pic_init_var(pic); DONE; pic_init_write(pic); DONE; pic_init_read(pic); DONE; pic_init_dict(pic); DONE; pic_init_record(pic); DONE; pic_init_lib(pic); DONE; } }