Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - utilities/xlate.sai
There are no other files named xlate.sai in the archive.
begin "xlate"

require "{}<>" delimiters;

define	 = {begin},
	 = {end},
	repeat = {do},
	thru = {step 1 until},
	loopforever = {while true do},
	 = {'15&'12};

string INAME, ONAME, IDEV, ODEV, SWITCHES, S, T;
safe string array XTBL[0:'177];
integer BRK, EOF, CH;

setbreak (1, "/", null, "ir");
setbreak (2, "_=", null, "i");
setbreak (3, ":", null, "i");
setbreak (4, null, null, "iz");
setbreak (5, "0123456789", null, "xr");
setbreak (6, """", null, "i");

loopforever
	print ("OUTPUT_INPUT/SWITCHES"&&"*");
	SWITCHES _ inchwl;
	INAME _ scan (SWITCHES, 1, BRK);
	ONAME _ scan (INAME, 2, BRK);
"EXIT"	if length(ONAME) = 0 then DONE;
	if length(INAME) = 0 then INAME _ ONAME;
	IDEV _ scan (INAME, 3, BRK);
	if BRK  ":" then
		INAME _ IDEV;
		IDEV _ "dsk"
	;
	ODEV _ scan (ONAME, 3, BRK);
	if BRK  ":" then
		ONAME _ ODEV;
		ODEV _ "dsk"
	;

	for CH _ 0 thru '177 do XTBL[CH] _ CH;
	while length(SWITCHES) do
		if lop(SWITCHES)  "/" then
			print ("Switch not preceded by ""/"": ", SWITCHES, );
			call (0, "exit")
		;
		if (CH _ lop(SWITCHES)) = "'" and length(S _ scan (SWITCHES, 5, BRK))  0 then CH _ cvo(S);
		if not 0  CH  '177 then
			print ("Switch specified char > '177 (namely '", S, ")", );
			call (0, "exit")
		;
		if "_"  SWITCHES  "=" then
			print ("Switch must include ""_"" or ""="".", );
			call (0, "exit")
		;
		XTBL[CH] _ null;
		repeat
			BRK _ lop(SWITCHES);
			if (S _ lop(SWITCHES)) = """" then
				S _ null;
				repeat S _ S & scan (SWITCHES, 6, BRK) until SWITCHES  """"
			
			else if S = "'" and length(T _ scan (SWITCHES, 5, BRK))  0 then
				if not 0  (S _ cvo(T))  '177 then
					print ("Switch specified char > '177 (namely '", T, ")", );
					call (0, "exit")
				;
			XTBL[CH] _ XTBL[CH] & S
		 until SWITCHES  "&"
	;

	open (0, IDEV, 0, 19, 0, 1000, BRK, EOF_0);
	lookup (0, INAME, EOF);
	if EOF then
		print ("Can't find ", IDEV, ":", INAME, );
		call (0, "exit")
	;
	open (1, ODEV, 0, 0, 19, 1000, BRK, EOF);
	enter (1, ONAME, EOF);
	if EOF then
		print ("Can't write ", ODEV, ":", ONAME, );
		call (0, "exit")
	;

	while not EOF do
		S _ input (0, 4);
		T _ null;
		while length(S)  0 do T _ T & XTBL[lop(S)];
		out (1, T)
	;

	closo (1)

;

end "xlate"