From 617ee5aa682bb13e3be9c53b58b394cdc6414f05 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sat, 7 Dec 2013 18:38:47 -0800 Subject: [PATCH] add pic_parse --- include/picrin.h | 1 + src/parse.y | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/picrin.h b/include/picrin.h index afce63bf..fb8079db 100644 --- a/include/picrin.h +++ b/include/picrin.h @@ -114,6 +114,7 @@ void pic_vec_extend_ip(pic_state *, struct pic_vector *, int); int pic_parse_file(pic_state *, FILE *file, pic_value *); int pic_parse_cstr(pic_state *, const char *, pic_value *); +pic_value pic_parse(pic_state *, const char *); pic_value pic_apply(pic_state *pic, struct pic_proc *, pic_value); pic_value pic_apply_argv(pic_state *pic, struct pic_proc *, size_t, ...); diff --git a/src/parse.y b/src/parse.y index 00bf58a2..23853488 100644 --- a/src/parse.y +++ b/src/parse.y @@ -431,3 +431,16 @@ pic_parse_cstr(pic_state *pic, const char *str, pic_value *v) return r; } + +pic_value +pic_parse(pic_state *pic, const char *src) +{ + pic_value vs; + int r; + + r = pic_parse_cstr(pic, src, &vs); + if (r != 1) { + return pic_undef_value(); + } + return pic_car(pic, vs); +}