summaryrefslogtreecommitdiff
path: root/main.c
blob: 76d8e04be2e52becf5eee39321e122a2550f8e6c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#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 *prog = parse(fd);
	
		Term *goal;
		for(goal = initgoals; goal != nil; goal = goal->next)
			evalquery(prog, goal);
	}

	exits(nil);
}

void
usage(void)
{
	fprint(2, "Usage: pprolog [-d]\n");
	exits("Usage");
}