ref: 50f83a91220940042962fdb55d07bb03991f52be
dir: /main.c/
#include <u.h> #include <libc.h> #include "dat.h" #include "fns.h" void usage(void); void main(int argc, char *argv[]) { char *parsetestfile = nil; ARGBEGIN{ case 'd': debug = 1; break; case 'f': parsetestfile = EARGF(usage()); break; default: usage(); }ARGEND if(argc != 0) usage(); if(parsetestfile){ int fd = open(parsetestfile, OREAD); if(fd < 0) exits("open"); Term *database = parse(fd, 0); Term *goal; for(goal = initgoals; goal != nil; goal = goal->next){ Binding *bindings = nil; evalquery(database, goal, &bindings); } repl(database); } exits(nil); } void usage(void) { fprint(2, "Usage: pprolog [-d]\n"); exits("Usage"); }