typedef pic_value pic_list
This commit is contained in:
parent
c357a9302d
commit
3b8868c577
|
@ -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 *);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
26
src/read.c
26
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue