shithub: pprolog

ref: 4fba3e66dce0d167d2031a0d1f1f6f4571cbd981
dir: /main.c/

View raw version
#include <u.h>
#include <libc.h>
#include <bio.h>

#include "dat.h"
#include "fns.h"

void usage(void);
void repl(int, char **);

void
main(int argc, char *argv[])
{
	initflags();
	initstreams();
	initmodules();
	repl(argc, argv);

	exits(nil);
}

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

void
repl(int argc, char *argv[])
{
	Term *args = nil;
	while(argc > 0){
		Term *arg = mkatom(runesmprint("%s", argv[argc-1]));
		args = appendterm(arg, args);
		argc--;
	}
	args = mklist(args);
	Term *start = mkcompound(L"start", 1, args);
	evalquery(start);	
}