add read function support

This commit is contained in:
Yuichi Nishiwaki 2014-06-25 22:36:56 +09:00
parent 6b8903bd83
commit bc2a684961
2 changed files with 20 additions and 0 deletions

View File

@ -29,6 +29,7 @@ void pic_init_macro(pic_state *);
void pic_init_var(pic_state *);
void pic_init_load(pic_state *);
void pic_init_write(pic_state *);
void pic_init_read(pic_state *);
void pic_init_dict(pic_state *);
void pic_load_piclib(pic_state *);
@ -94,6 +95,7 @@ pic_init_core(pic_state *pic)
pic_init_var(pic); DONE;
pic_init_load(pic); DONE;
pic_init_write(pic); DONE;
pic_init_read(pic); DONE;
pic_init_dict(pic); DONE;
pic_load_piclib(pic); DONE;

View File

@ -616,3 +616,21 @@ pic_parse_cstr(pic_state *pic, const char *str)
return pic_parse(pic, port);
}
static pic_value
pic_read_read(pic_state *pic)
{
struct pic_port *port = pic_stdin(pic);
pic_get_args(pic, "|p", &port);
return pic_read(pic, port);
}
void
pic_init_read(pic_state *pic)
{
pic_deflibrary ("(scheme read)") {
pic_defun(pic, "read", pic_read_read);
}
}