tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | LICENSE

commit f07afd43ddde10cb2194feba67dc5fe8eb967baf
parent 39bfce81a3ad58a63c9db89bdb08e61347737f28
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Thu,  7 Feb 2019 17:14:45 -0800

Add read primitive to prompt user for input

Diffstat:
tibs/io.c | 15+++++++++++++++
1 file changed, 15 insertions(+), 0 deletions(-)

diff --git a/tibs/io.c b/tibs/io.c @@ -42,6 +42,20 @@ prim_print(Env env, Val args) } static Val +prim_read(Env env, Val args) +{ + char *file; + Val v; + struct Str str = { NULL }; + if (!(file = tisp_read_file(NULL))) + return mk_sym(env, "quit"); + str.d = file; + v = tisp_read(env, &str); + free(file); + return v; +} + +static Val prim_newline(Env env, Val args) { return mk_str(env, "\n"); @@ -51,5 +65,6 @@ void tib_env_io(Env env) { tsp_env_fn(print); + tsp_env_fn(read); tsp_env_fn(newline); }