summaryrefslogtreecommitdiff
path: root/repl.c
diff options
context:
space:
mode:
authorPeter Mikkelsen <peter@pmikkelsen.com>2021-06-30 14:04:31 +0000
committerPeter Mikkelsen <peter@pmikkelsen.com>2021-06-30 14:04:31 +0000
commit8fde6e4845eeafe6ffc4179218a3ac9e8049c0e6 (patch)
tree85e9cecb26f680f8aa49577892f97d610e9cf0d6 /repl.c
parentee4298a2cfbbd9e015cfc775d9d714a9f5035846 (diff)
Commit repl.c file
Diffstat (limited to 'repl.c')
-rw-r--r--repl.c29
1 files changed, 29 insertions, 0 deletions
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 <u.h>
+#include <libc.h>
+
+#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