From 8fde6e4845eeafe6ffc4179218a3ac9e8049c0e6 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Wed, 30 Jun 2021 14:04:31 +0000 Subject: Commit repl.c file --- repl.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 repl.c diff --git a/repl.c b/repl.c new file mode 100644 index 0000000..e81c2f2 --- /dev/null +++ b/repl.c @@ -0,0 +1,29 @@ +#include +#include + +#include "dat.h" +#include "fns.h" + +void +repl(Term *database) +{ + int fd = 0; /* Standard input */ + while(1){ + print("?- "); + Term *query = parse(fd, 1); + Binding *bindings = nil; + int success = evalquery(database, query, &bindings); + if(success == 0) + print("false.\n"); + else{ + if(bindings == nil) + print("true.\n"); + else{ + while(bindings){ + print("%S = %S\n", bindings->name, prettyprint(bindings->value)); + bindings = bindings->next; + } + } + } + } +} \ No newline at end of file -- cgit v1.2.3