From 3b8868c577b572d1788b81b005d1dd0be89caed1 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sat, 1 Mar 2014 20:54:02 +0900 Subject: [PATCH] typedef pic_value pic_list --- include/picrin.h | 4 ++-- include/picrin/value.h | 1 + src/read.c | 26 +++++++++++++------------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/picrin.h b/include/picrin.h index f4697732..d576b021 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -164,8 +164,8 @@ char *pic_strdup(pic_state *, const char *); char *pic_strndup(pic_state *, const char *, size_t); pic_value pic_read(pic_state *, const char *); -pic_value pic_read_file(pic_state *, FILE *); /* returns a list of read data. When input string is incomplete, returns undef. */ -pic_value pic_read_cstr(pic_state *, const char *); +pic_list pic_read_file(pic_state *, FILE *); /* When input string is incomplete, returns undef. */ +pic_list pic_read_cstr(pic_state *, const char *); pic_value pic_load(pic_state *, const char *); diff --git a/include/picrin/value.h b/include/picrin/value.h index 46ba1efe..628259fc 100644 --- a/include/picrin/value.h +++ b/include/picrin/value.h @@ -122,6 +122,7 @@ struct pic_proc; struct pic_port; /* set aliases to basic types */ +typedef pic_value pic_list; typedef struct pic_pair pic_pair; typedef struct pic_string pic_str; typedef struct pic_vector pic_vec; diff --git a/src/read.c b/src/read.c index 99a32cff..b44ebabe 100644 --- a/src/read.c +++ b/src/read.c @@ -176,11 +176,11 @@ read_one(yyscan_t scanner) return read(tok, scanner); } -pic_value +pic_list read_many(yyscan_t scanner) { int tok; - pic_value val; + pic_value vals; if (setjmp(yyjmp) != 0) { if (yymsg) { @@ -189,11 +189,11 @@ read_many(yyscan_t scanner) return pic_undef_value(); /* incomplete string */ } - val = pic_nil_value(); + vals = pic_nil_value(); while ((tok = gettok(scanner)) != tEOF) { - val = pic_cons(pic, read(tok, scanner), val); + vals = pic_cons(pic, read(tok, scanner), vals); } - return pic_reverse(pic, val); + return pic_reverse(pic, vals); } #undef pic @@ -216,38 +216,38 @@ pic_read(pic_state *pic, const char *cstr) return val; } -pic_value +pic_list pic_read_file(pic_state *pic, FILE *file) { yyscan_t scanner; struct parser_control ctrl; - pic_value val; + pic_value vals; ctrl.pic = pic; yylex_init_extra(&ctrl, &scanner); yyset_in(file, scanner); - val = read_many(scanner); + vals = read_many(scanner); yylex_destroy(scanner); - return val; + return vals; } -pic_value +pic_list pic_read_cstr(pic_state *pic, const char *cstr) { yyscan_t scanner; struct parser_control ctrl; - pic_value val; + pic_value vals; ctrl.pic = pic; yylex_init_extra(&ctrl, &scanner); yy_scan_string(cstr, scanner); - val = read_many(scanner); + vals = read_many(scanner); yylex_destroy(scanner); - return val; + return vals; }