uses file.FileInput, file.read,
     io.InputStream,
     kmp.match_next, kmp.match_begin, io.printi, io.print

main(args:array[string]):int = (
	s:string = "";
	p:string = "free";

	if (length args < 1) (
		print("usage: kmp_test <file>\N");
		return 1
	);

	in: FileInput = read(args[0]);

	if (in == null) (
		print("Couldn't open " + args[0] + "\N");
		return 1
	);

	while (! in.eof()) (
		s = s + in.readln();
	);

	precomputed:array[int] = match_begin(s, p);

	i:int = 0;
	j:int = 0;
	while (j<1000) (
		i = match_next(s,p,precomputed, i);
		if (i == -1) (j++; i = -1);
		// printi(i);print("\N");
		i++;
	);

	0
)
