From 1d0ee825c8b70e9456bebc4bf2bc8366c2e89cbd Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Mon, 11 Oct 2021 12:16:28 +0200 Subject: Add a minimal read_line implementation --- src/bootstrap/main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/bootstrap/main.c') diff --git a/src/bootstrap/main.c b/src/bootstrap/main.c index b5fd821..662831e 100755 --- a/src/bootstrap/main.c +++ b/src/bootstrap/main.c @@ -4,6 +4,7 @@ #include #include "string_view.c" +#include "read_line.c" void process_source(const StringView *source) { @@ -14,11 +15,17 @@ process_source(const StringView *source) { void run_repl(void) { - printf("BDL REPL (Press Ctrl-C to exit)\n"); + printf("BDL REPL (Press Ctrl-D or Ctrl-C to exit)\n"); while (true) { printf(REPL_PROMPT); - getchar(); - process_source(NULL); + StringView sv = read_line(); + if (sv.start == NULL) { + return; + } + process_source(&sv); + if (sv.n != 0) { + printf("\n"); + } } } -- cgit v1.2.1