
'BEGIN''INTEGER''ARRAY' IL1,IL2,TAAL[1:160],DIG[1:20],
	FRN1,FRN2,FRLN,FTBD,FLINE[1:150];
'INTEGER' INDEV,DEV,SIZE,CHAR,LINE,BS,DECL,TYPE,ID1,ID2,NLAB,FIRST,
	MAX,LDPT,NADR,DBASE,NODEC,ADDR,HEL1,DEPTH,FIXSP,HMPD;
'BOOLEAN' SECOND,DOLL,LETTER,DIGIT,FOUND,
	TABLES,FRED,HOL1,STRING,CPR;

'PROCEDURE' IN6;
'IF' DOLL 'THEN''BEGIN' WARN(27); 'GOTO' EPROG 'END'
'ELSE'
'BEGIN'
LOOP:	CHIN(INDEV,CHAR);
'IF' CHAR=137 'THEN' CHAR:=160;
'IF' 'NOT' STRING 'AND' CHAR=160 'OR' CHAR=138
	'OR' CHAR=140 'OR' CHAR=192 'THEN''GOTO' LOOP;
'IF' CHAR=141 'THEN''BEGIN' LINE:=LINE+1; 'GOTO' LOOP 'END';
CHAR:=CHAR-('IF' CHAR>=192 'THEN' 192 'ELSE' 128);
DOLL:=CHAR=36;
'END';

'PROCEDURE' ABSA;
'BEGIN'
ABS1:	IN6;
'IF' CHAR#39 'THEN' BS:=CHAR
'ELSE'	'BEGIN'
	IN6; BS:=40*CHAR; IN6; BS:=BS+CHAR;
LBS1:	IN6; 'IF' CHAR#39 'THEN''GOTO' LBS1;
	'IF' BS<64 'THEN' BS:=BS+64;
	'END' LONG BASIC SYMBOL
'END' ABSA;


'PROCEDURE' ABS;
'BEGIN'
'IF' HOL1 'THEN'
	'BEGIN' BS:=HEL1; HOL1:='FALSE'
	'END'
'ELSE''BEGIN''INTEGER' HEL3;
	ABSA; 'IF' BS=58 'OR' BS=60 'OR' BS=62 'THEN'
		'BEGIN' HEL1:=BS; ABSA;
		'IF' BS=61 'THEN' BS:=
			('IF' HEL1=58 'THEN' 33 'ELSE''IF'
			HEL1=60 'THEN' 63 'ELSE' 38)
		'ELSE''BEGIN' HEL3:=BS; BS:=HEL1; HEL1:=HEL3;
			HOL1:='TRUE' 'END'
		'END'
	'END';
LETTER:=BS<27;
DIGIT:=BS>47 'AND' BS<58;
'END' ABS;

'BOOLEAN''PROCEDURE' TERM;
TERM:=BS=214 'OR' BS=59 'OR' BS=212 'OR' BS=36;

'PROCEDURE' SEMI(FNO); 'VALUE' FNO; 'INTEGER' FNO;
'BEGIN' CHFAIL(59,FNO); COMMENT 'END';

'PROCEDURE' COMMENT;
L:	'IF' BS=135 'THEN'
	'BEGIN' CL: IN6; 'IF' CHAR#59 'THEN''GOTO' CL 'ELSE'
		'BEGIN' ABS; 'GOTO' L
		'END'
	'END' CHECK FOR COMMENT;


'BOOLEAN''PROCEDURE' BTYPE;
BTYPE:=TYPE=3 'OR' TYPE=7 'OR' TYPE=13;

'PROCEDURE' DEFINE(L1,L2); 'VALUE' L1,L2; 'INTEGER' L1,L2;
'BEGIN' WRITE(DEV,"L",L1,"=L",L2); SKIP(DEV) 'END';

'INTEGER''PROCEDURE' LOWER(X); 'VALUE' X; 'INTEGER' X;
LOWER:=X-X%64*64;

'PROCEDURE' IDENT;
'BEGIN' ID1:=BS; ID2:=0;
ABS; 'IF' LETTER 'OR' DIGIT 'THEN'
	'BEGIN' ID1:=58*ID1+BS; ABS;
	'IF' LETTER 'OR' DIGIT 'THEN'
	'BEGIN' ID2:=BS; ABS;
	'IF' LETTER 'OR' DIGIT 'THEN'
	'BEGIN' ID2:=58*ID2+BS;
ID4:	ABS; 'IF' LETTER 'OR' DIGIT 'THEN''GOTO' ID4;
	'END''END''END';
FOUND:='FALSE';
'FOR' DECL:=NODEC 'STEP' -1 'UNTIL' 1 'DO'
	'IF' ID1=IL1[DECL] 'THEN'
	'BEGIN''IF' ID2=IL2[DECL] 'THEN'
	'BEGIN'
	FOUND:='TRUE';
	TYPE:=TAAL[DECL]%64; ADDR:=LOWER(TAAL[DECL]);
	'GOTO' ESRC;
	'END''END';
ESRC: 'END' SEARCH DECLARATION LIST;

'PROCEDURE' PAD;
'IF' SECOND 'THEN' CODE(0);

'PROCEDURE' CODE(X); 'VALUE' X; 'INTEGER' X;
'IF' SECOND 'THEN'
	'BEGIN' WRITE(DEV,64*FIRST+X); SECOND:='FALSE';
	SKIP(DEV); SIZE:=SIZE+1;
	'END'
'ELSE'	'BEGIN' FIRST:=X; SECOND:='TRUE'
	'END';

'PROCEDURE' LDEC(LNO); 'VALUE' LNO; 'INTEGER' LNO;
'BEGIN' PAD; WRITE(DEV,"L",LNO,",")
'END';

'PROCEDURE' LABEL(LNO); 'VALUE' LNO; 'INTEGER' LNO;
'BEGIN' PAD; WRITE(DEV,"L",LNO); SKIP(DEV); SIZE:=SIZE+1;
'END';

'INTEGER''PROCEDURE' JMPNEW;
'BEGIN' JMP(NLAB);
JMPNEW:=NLAB; NLAB:=NLAB+1 'END';

'PROCEDURE' JMP(LNO); 'VALUE' LNO; 'INTEGER' LNO;
'BEGIN' CODE(9); LABEL(LNO) 'END';

'INTEGER''PROCEDURE' CJMP;
'BEGIN' CODE(28); LABEL(NLAB);
CJMP:=NLAB; NLAB:=NLAB+1 'END';

'PROCEDURE' SID;
'BEGIN'
'IF' TABLES 'THEN'
	'BEGIN' SKIP(1); PR2(ID1); PR2(ID2);
	WRITE(1," ",ADDR," ",TYPE)
	'END';
'IF' NODEC=160 'THEN' WARN(15) 'ELSE' NODEC:=NODEC+1;
'IF' FOUND 'AND' DECL>DBASE 'THEN' WARN(1);
'IF' TYPE#4 'AND' TYPE<10 'THEN'
	'BEGIN' 'IF' ADDR>FIXSP 'THEN' FIXSP:=ADDR;
	'IF' ADDR>63 'THEN' WARN(5)
	'END' 'ELSE' ADDR:=20;
IL1[NODEC]:=ID1; IL2[NODEC]:=ID2; TAAL[NODEC]:=64*TYPE+ADDR;
'END' STORE IDENT IN LIST;


'PROCEDURE' DARR;
'BEGIN''INTEGER' FIRST, COUNT;
DAR1: FIRST:=NADR; COUNT:=1;
DAR2: IDENT; ADDR:=NADR; NADR:=NADR+1; SID;
	'IF' BS=44 'THEN''BEGIN' COUNT:=COUNT+1;
		ABS; 'GOTO' DAR2 'END';
	CHFAIL(27,18); GET INTEGER;
	CHFAIL(58,18); GET INTEGER;
	CHFAIL(29,18);
	CODE(1); CODE(COUNT); CODE(FIRST);
'IF' BS#59 'THEN''BEGIN' CHFAIL(44,18); 'GOTO' DAR1 'END';
ABS; COMMENT 'END' DECLARE ARRAY;

'PROCEDURE' DTV;
'BEGIN''INTEGER' STYP; STYP:=TYPE;
DTV1: IDENT; TYPE:=STYP; ADDR:=NADR; NADR:=NADR+1;
SID; 'IF' BS=44 'THEN''BEGIN' ABS; 'GOTO' DTV1 'END';
'IF' BS=59 'THEN''BEGIN' ABS; COMMENT 'END''ELSE' ABS;
'END' DECLARE VARIABLE LIST;

'PROCEDURE' GET INTEGER;
AE;

'PROCEDURE' SFR;
'BEGIN''INTEGER' I;
'IF' FOUND 'AND' DECL<=6 'THEN''GOTO' ESFR;
'IF' LDPT#0 'THEN'
	'FOR' I:=1 'STEP' 1 'UNTIL' LDPT 'DO'
	'IF' FRN1[I]=ID1 'THEN'
	'BEGIN''IF' FRN2[I]=ID2 'THEN'
	'BEGIN''IF' LOWER(FTBD[I])=TYPE
		'OR' LOWER(FTBD[I])=TYPE+10 'THEN'
	'BEGIN''IF' DEPTH=FTBD[I]%64 'OR' TYPE>9 'THEN'
	'BEGIN' ADDR:=FRLN[I]; 'GOTO' ESFR
	'END';
	'END''END''END';
'IF' LDPT=150 'THEN' WARN(30) 'ELSE' LDPT:=LDPT+1;
'IF' LDPT>MAX 'THEN' MAX:=LDPT;
FRN1[LDPT]:=ID1; FRN2[LDPT]:=ID2; FTBD[LDPT]:=64*DEPTH+TYPE+10;
ADDR:=NLAB; FRLN[LDPT]:=NLAB; NLAB:=NLAB+1; FLINE[LDPT]:=LINE;
ESFR: 'END' RETURN PROCEDURE LABEL IF DECLARED, ELSE SET FORWARD REF;

'PROCEDURE' DLAB;
'BEGIN''INTEGER' I; ADDR:=NLAB; SID;
'IF' LDPT=150 'THEN' WARN(30) 'ELSE' LDPT:=LDPT+1; LDEC(NLAB);
FRLN[LDPT]:=NLAB; ADDR:=NLAB; NLAB:=NLAB+1;
FTBD[LDPT]:=64*DEPTH+TYPE; FRN1[LDPT]:=ID1; FRN2[LDPT]:=ID2;
	'FOR' I:=1 'STEP' 1 'UNTIL' LDPT 'DO'
	'IF' FRN1[I]=ID1 'THEN'
	'BEGIN''IF' FRN2[I]=ID2 'THEN'
	'BEGIN''IF' LOWER(FTBD[I])=TYPE+10 'THEN'
	'BEGIN''IF' DEPTH=FTBD[I]%64 'OR' TYPE>9 'THEN'
		'BEGIN' DEFINE(FRLN[I],ADDR);
		DELETE(I); I:=I-1
		'END' DELETE SATISFIED FORWARD REFS
	'END''END''END'
'END' PUT LABEL OR PROCEDURE DECLARATION IN LIST;

'PROCEDURE' DELETE(ITEM); 'VALUE' ITEM; 'INTEGER' ITEM;
'BEGIN'
FRN1[ITEM]:=FRN1[LDPT]; FRN2[ITEM]:=FRN2[LDPT];
FRLN[ITEM]:=FRLN[LDPT]; FTBD[ITEM]:=FTBD[LDPT];
FLINE[ITEM]:=FLINE[LDPT]; LDPT:=LDPT-1;
'END' DELETE ITEM FROM LABEL/PROCEDURE LISTS;

'PROCEDURE' PCALL; 'BEGIN' 'INTEGER' STYP; STYP:=TYPE;
'IF' FOUND 'AND' DECL<=6 'THEN'
'BEGIN' CHFAIL(40,32);
'IF' ADDR=1 'THEN'
	'BEGIN' GET INTEGER; CODE(2); CODE(40); 'GOTO' ECAL
	'END' COMPLIE SKIP
'ELSE''IF' ADDR=2 'THEN'
	'BEGIN' GET INTEGER; CODE(2);
CAL1:	'IF' BS#44 'THEN''GOTO' ECAL; ABS;
	CODE(3); IDENT; PUTOUT; 'GOTO' CAL1
	'END' COMPILE READ
'ELSE''IF' ADDR=3 'THEN'
	'BEGIN' GET INTEGER; CODE(2);
CAL2:	'IF' BS#44 'THEN''GOTO' ECAL; ABS;
	'IF' BS=34 'THEN'
	'BEGIN'
	STRING:='TRUE'; ABS; CODE(5);
CAL3:	CODE(BS); ABS;
	'IF' BS#34 'THEN''GOTO' CAL3;
	ABS; CODE(0);
	SKIP(DEV); STRING:='FALSE'; 'GOTO' CAL2
	'END'
'ELSE''BEGIN' GET INTEGER; CODE(6);
	'GOTO' CAL2
	'END'
	'END' COMPLIE WRITE
'ELSE''IF' ADDR=4 'THEN'
	'BEGIN' GET INTEGER; CODE(2);
	'IF' BS#44 'THEN''GOTO' ECAL; ABS;
	CODE(7); IDENT; PUTOUT
	'END' COMPILE CHIN
'ELSE''IF' ADDR=5 'THEN'
	'BEGIN' GET INTEGER; CODE(2);
	'IF' BS#44 'THEN''GOTO' ECAL; ABS;
	GET INTEGER; CODE(8);
	'END' COMPILE CHOUT
'ELSE''IF' ADDR=6 'THEN''BEGIN' GET INTEGER; CODE(39)
	'END' COMPILE DISK
'END' CALL OF BUILT IN ROUTINES
'ELSE''BEGIN' 'INTEGER' COUNT,PRAD;
	SFR; 'IF' BS#40 'THEN'
		'BEGIN' CODE(11); LABEL(ADDR); 'GOTO' ECL2
		'END' CALL OF PARAMETERLESS PROCEDURE;
	COUNT:=0; PRAD:=ADDR; ABS;
NPAR:	'IF' 'NOT' LETTER 'THEN'
	'BEGIN' 'IF' BS=578 'OR' BS=818 'OR' BS=241 'THEN' BE
		'ELSE' AE
	'END' PARA]ETER NOT STARTING WITH LETTER
	'ELSE'
	'BEGIN' IDENT; 'IF''NOT' FOUND 'THEN' WARN(29);
	FRED:='TRUE'; EXPRESSION;
	'END' PARAM STARTING WITH IDENT;
	COUNT:=COUNT+1; 'IF' BS=44 'THEN'
		'BEGIN' ABS; 'GOTO' NPAR
		'END';
	'IF' COUNT<5 'THEN' 
		'BEGIN' CODE(COUNT+42); LABEL(PRAD)
		'END'
	'ELSE''BEGIN' CODE(36); CODE(COUNT); LABEL(PRAD);
		'END'
'END' USER DECLARED PROCEDURE CALL;
ECAL: CHFAIL(41,21);
ECL2: TYPE:=STYP	'END' PROCEDURE CALL;

'PROCEDURE' STATEMENT;
'BEGIN'
ST:
'IF' LETTER 'THEN'
'BEGIN' IDENT;
'IF' BS=58 'THEN'
	'BEGIN' TYPE:=4; DLAB; ABS; 'GOTO' ST 'END'
'ELSE''IF' BS=27 'OR' BS=33 'THEN' ASSIGNMENT
'ELSE'	'BEGIN' TYPE:=10; PCALL 'END'
'END' UNCONDITIONAL NON-GOTO

'ELSE''IF' BS=366 'THEN'
'BEGIN''INTEGER' L1,L2;
L1:=IFCLAUSE; STATEMENT;
'IF' BS#212 'THEN' LDEC(L1)
'ELSE''BEGIN' ABS; L2:=JMPNEW; LDEC(L1);
	STATEMENT; LDEC(L2) 'END'
'END' CONDITIONAL

'ELSE' 'IF' BS=295 'THEN'
'BEGIN' ABS; IDENT; TYPE:=4; SFR;
JMP(ADDR);
'END' GOTO STATEMENT

'ELSE' 'IF' BS=255 'THEN'
'BEGIN''INTEGER' L1,L2,L3,CVA,GLOBAL;
ABS; IDENT; 'IF''NOT' FOUND 'OR' TYPE#2 'THEN' WARN(13); 
CVA:=ADDR;
GLOBAL:='IF' DECL<=HMPD 'AND' CPR 'THEN' 0 'ELSE' 2;
ASSIGNMENT; CHFAIL(780,22);
L1:=NLAB; L2:=NLAB+1; NLAB:=NLAB+2; SKIP(DEV);
JMP(L1); LDEC(L2);
GET INTEGER; CHFAIL(854,22);
GET INTEGER; CHFAIL(175,22);
CODE(34); CODE(GLOBAL); CODE(CVA);
L3:=CJMP; LDEC(L1); STATEMENT;
JMP(L2); LDEC(L3);
'END' FORSTATEMENT

'ELSE' 'IF' BS=85 'THEN'
'BEGIN''INTEGER' I,J,SDBASE,SNADR,JPPL;
'BOOLEAN' PLS,BLOCK;
ABS; COMMENT; PLS:='FALSE'; BLOCK:='FALSE';
NDEC:	'IF' BS=374 'OR' BS=95 'THEN'
	'BEGIN' 'IF''NOT' BLOCK 'THEN'
		'BEGIN' BLOCK:='TRUE'; DEPTH:=DEPTH+1;
		SDBASE:=DBASE; DBASE:=NODEC; SNADR:=NADR;
		'END';
		TYPE:='IF' BS=374 'THEN' 2 'ELSE' 3; ABS;
	'IF' BS=658 'THEN'
		'BEGIN' ABS; 'IF' 'NOT' PLS 'THEN'
			'BEGIN' JPPL:=JMPNEW; PLS:='TRUE'
			'END';
			DPROC; 'GOTO' NDEC
		'END'
		'ELSE' 'IF' BS=122 'THEN'
		'BEGIN' ABS; 'IF' PLS 'THEN'
			'BEGIN' LDEC(JPPL); PLS:='FALSE'
			'END';
			TYPE:=TYPE+4; DARR; 'GOTO' NDEC
		'END'
		'ELSE''BEGIN' DTV; 'GOTO' NDEC 'END'
	'END'
	'ELSE''IF' BS=658 'THEN'
	'BEGIN' 'IF''NOT' BLOCK 'THEN'
		'BEGIN' BLOCK:='TRUE'; DEPTH:=DEPTH+1;
		SDBASE:=DBASE; DBASE:=NODEC; SNADR:=NADR;
		'END';
	TYPE:=0; ABS; 'IF' 'NOT' PLS 'THEN'
		'BEGIN' JPPL:=JMPNEW; PLS:='TRUE'
		'END';
		DPROC; 'GOTO' NDEC
	'END';
'IF' PLS 'THEN''BEGIN' PLS:='FALSE'; LDEC(JPPL) 'END';
TAIL:	STATEMENT; 'IF' BS=59 'THEN'
		'BEGIN' ABS; COMMENT; 'GOTO' TAIL 'END'
	'ELSE''IF' BS#214 'THEN' FAIL(16);
ECOM:	ABS; 'IF''NOT' TERM 'THEN''GOTO' ECOM;

'IF' BLOCK 'THEN'
'BEGIN'
DEPTH:=DEPTH-1; NODEC:=DBASE; DBASE:=SDBASE; NADR:=SNADR;
'IF' LDPT#0 'THEN'
'FOR' I:=1 'STEP' 1 'UNTIL' LDPT 'DO''IF' FTBD[I]%64>DEPTH 'THEN'
	'BEGIN''INTEGER' FTYP; FTYP:=LOWER(FTBD[I]);
	'IF' FTYP<14 'THEN'
		'BEGIN' DELETE(I); I:=I-1
		'END' DELETE LABEL/PROCEDURE OUT OF SCOPE
	'ELSE''BEGIN' FTBD[I]:=64*DEPTH+FTYP;
		'FOR' J:=1 'STEP' 1 'UNTIL' LDPT 'DO'
		'IF' FRN1[I]=FRN1[J] 'THEN'
		'BEGIN''IF' FRN2[I]=FRN2[J] 'THEN'
		'BEGIN''IF' LOWER(FTBD[J])=FTYP-10 'THEN'
		'BEGIN''IF' FTBD[J]%64=DEPTH 'THEN'
			'BEGIN' DEFINE(FRLN[I],FRLN[J]);
			DELETE(I); I:=I-1; 'GOTO' EXLOOP
			'END' SEARCH FOR LABEL DECLARATION;
		'END''END''END';
	EXLOOP:	'END' FORWARD LABEL SATISFACTION DEPTH CHANGE
	'END' SCOPE CHECK AND LABEL FORWARD REFERENCE CHECK
'END' BLOCK END
'END' BLOCK OR COMPOUND;
'END' STATEMENT;


'PROCEDURE' DPROC;
	'BEGIN' 'INTEGER' SNADR,SDBASE,SFIXSP,PINL,SLTYP;
	CPR:='TRUE';
	SLTYP:=TYPE+10; IDENT; TYPE:=SLTYP; DLAB;
	HMPD:=NODEC; SFIXSP:=FIXSP; SNADR:=NADR;
	SDBASE:=DBASE; DBASE:=NODEC; DEPTH:=DEPTH+1;
	FIXSP:=3; NADR:=4; LABEL(NLAB);
	PINL:=NLAB; NLAB:=NLAB+1;
	'IF' BS=40 'THEN'
		'BEGIN' ABS; TYPE:=0; DTV 'END';
	SEMI(28);
LOOP:	'IF' BS=881 'THEN'
	'BEGIN'
	LOP: ABS; 'IF' BS#59 'THEN''GOTO' LOP;
	ABS; 'GOTO' LOOP
	'END' IGNORE VALUE
	'ELSE''IF' BS=374 'OR' BS=95 'THEN'
	'BEGIN' 'BOOLEAN' BOOL; BOOL:=BS=95; ABS;
	LOP: IDENT; 'IF''NOT' FOUND 'OR' TYPE#0 'THEN' WARN(29)
	'ELSE' TAAL[DECL]:=64*('IF' BOOL 'THEN' 3 'ELSE' 2)+ADDR;
	'IF' BS=44 'THEN''BEGIN' ABS; 'GOTO' LOP 'END'
	'ELSE''BEGIN' SEMI(43); 'GOTO' LOOP 'END'
	'END' TYPE SPECIFICATION;
'FOR' DECL:=NODEC 'STEP' -1 'UNTIL' DBASE+1 'DO'
	'IF' TAAL[DECL]%64=0 'THEN' WARN(40);
	STATEMENT;
	CODE('IF' SLTYP>10 'THEN' 47 'ELSE' 10);
	WRITE(DEV,"L",PINL,"=",FIXSP); SKIP(DEV);
	NADR:=SNADR; NODEC:=HMPD; FIXSP:=SFIXSP;
	DBASE:=SDBASE; DEPTH:=DEPTH-1;
	SEMI(23); CPR:='FALSE';
'IF' LDPT#0 'THEN'
'FOR' PINL:=1 'STEP' 1 'UNTIL' LDPT 'DO'
'IF' FTBD[PINL]%64>DEPTH 'THEN'
	'BEGIN''INTEGER' FTYP; FTYP:=LOWER(FTBD[PINL]);
	'IF' FTYP<14 'THEN'
	'BEGIN' DELETE(PINL); PINL:=PINL-1
	'END' DELETE LABELS DECLARED IN PROCEDURE
	'ELSE' FTBD[PINL]:=64*DEPTH+FTYP;
	'END' DEAL WITH END OF FICTITIOUS BLOCK;
'END' DECLARE PROCEDURE;


'PROCEDURE' SUBSCRIPT;
'BEGIN''INTEGER' STYPE; STYPE:=TYPE-4;
CHFAIL(27,3); GETINTEGER; CHFAIL(29,4);
TYPE:=STYPE 'END';

'PROCEDURE' FETCH;
'BEGIN'
'IF' FRED 'THEN' FRED:='FALSE''ELSE' IDENT;
'IF' 'NOT' FOUND 'THEN' TYPE:=TYPE+10;
'IF' TYPE>10 'THEN'
	'BEGIN' PCALL; TYPE:=TYPE-10
	'END'
'ELSE' 'IF' TYPE>4 'THEN'
	'BEGIN' 'INTEGER' SDEC; SDEC:=DECL;
	SUBSCRIPT; CODE(14); CODE(LOWER(TAAL[SDEC]));
	'END'
'ELSE' GETOUT;
'END' FETCH VARIABLE;

'PROCEDURE' EXPRESSION;
'IF' BTYPE 'THEN' BE 'ELSE' AE;

'PROCEDURE' ASSIGNMENT;
'BEGIN' 'IF''NOT' FOUND 'THEN' WARN(17);
'IF' TYPE>10 'THEN'
	'BEGIN' CHFAIL(33,24); TYPE:=TYPE-10; EXPRESSION;
	CODE(4); CODE(3); SKIP(DEV)
	'END'
'ELSE''IF' TYPE>4 'THEN'
	'BEGIN' 'INTEGER' SDEC; SDEC:=DECL;
	SUBSCRIPT; CHFAIL(33,24); EXPRESSION;
	CODE(15); CODE(LOWER(TAAL[SDEC]));
	'END'
'ELSE''BEGIN''INTEGER' SDECL;
	SDECL:=DECL; CHFAIL(33,24); EXPRESSION;
	ADDR:=LOWER(TAAL[SDECL]); DECL:=SDECL; PUTOUT;
	'END'
'END' ASSIGNMENT;

'PROCEDURE' PR1(X); 'VALUE' X; 'INTEGER' X;
'IF' X#0 'THEN'
CHOUT(1,X+('IF' X<=31 'THEN' 192 'ELSE' 128));

'PROCEDURE' PR2(X); 'VALUE' X; 'INTEGER' X;
'BEGIN''INTEGER' C1,C2;
C1:=X%58; C2:=X-58*C1;
PR1(C1); PR1(C2)
'END' PRINT 2 CHARS OF IDENT;

'PROCEDURE' WARN(X); 'VALUE' X; 'INTEGER' X;
'BEGIN'	SKIP(1); DEV:=0;
WRITE(1,"FAIL ",X," LINE ",LINE," IDENT ");
PR2(ID1); PR2(ID2);
'END' FAILURE WARNING;

'PROCEDURE' FAIL(X); 'VALUE' X; 'INTEGER' X;
'BEGIN' WARN(X); 'IF' TERM 'THEN' ABS;
NEXT:	ABS; 'IF''NOT' TERM 'THEN''BEGIN' ABS; 'GOTO' NEXT 'END';
'END' FAILURE OUTPUT;

'PROCEDURE' CHFAIL(SYM,FNO); 'VALUE' SYM,FNO; 'INTEGER' SYM,FNO;
'BEGIN''IF' BS#SYM 'THEN' WARN(FNO); ABS 'END';


'PROCEDURE' APRIME;
'BEGIN''BOOLEAN' NEG;
'IF' FRED 'THEN''BEGIN' FETCH; 'GOTO' EAPR
		'END';
'IF' BS=43 'THEN''BEGIN' ABS; NEG:='FALSE' 'END'
'ELSE''IF' BS=45 'THEN''BEGIN' ABS; NEG:='TRUE' 'END'
'ELSE' NEG:='FALSE';

'IF' BS=40 'THEN'
	'BEGIN' ABS; AE; CHFAIL(41,12)
	'END'
'ELSE''IF' LETTER 'THEN'
	'BEGIN' TYPE:=2;
	FETCH; 'IF' TYPE#2 'THEN' WARN(17);
	'END'
'ELSE'	'BEGIN''INTEGER' I,J,K,L; I:=0;
	'IF''NOT' DIGIT 'THEN' FAIL(10);
APR1:	I:=I+1; DIG[I]:=BS+128;
	ABS; 'IF' DIGIT 'THEN''GOTO' APR1;
		K:=0; L:=0;
		'FOR' J:=1 'STEP' 1 'UNTIL' I 'DO'
			'BEGIN' K:=10*K+DIG[J]-176; L:=L*10;
			'IF' K>=64 'THEN'
				'BEGIN' L:=L+K%64; K:=K-64*(K%64)
				'END';
			'END';
		'IF' K=0 'AND' L=0 'THEN' CODE(29)
		'ELSE' 'IF' L=0 'THEN''BEGIN' CODE(42); CODE(K) 'END'
		'ELSE''BEGIN' CODE(16); CODE(L); CODE(K) 'END'
	'END';
'IF' NEG 'THEN' CODE(17);
EAPR: 'END' ARITHMETIC PRIMARY;

'PROCEDURE' AFAC;
'BEGIN' APRIME;
AFA1:	'IF' BS=30 'THEN'
	'BEGIN' ABS; APRIME; CODE(18);
	'GOTO' AFA1
	'END';
'END' ARITHMETIC FACTOR;


'PROCEDURE' ATERM;
'BEGIN'
AFAC;
ATE1:	'IF' BS=42 'THEN'
	'BEGIN' ABS; AFAC; CODE(19);
	'GOTO' ATE1
	'END' MULTIPLY CASE
'ELSE''IF' BS=47 'THEN' WARN(19)
'ELSE''IF' BS=37 'THEN'
	'BEGIN' ABS; AFAC;
	CODE(20); 'GOTO' ATE1
	'END' INTEGER DIVISION CASE;
'END' ARITHMETIC TERM;

'PROCEDURE' SAE;
'BEGIN' ATERM;
SAE1:	'IF' BS=43 'THEN'
	'BEGIN' ABS; ATERM;
	CODE(13); 'GOTO' SAE1
	'END' ADDITION CASE
'ELSE''IF' BS=45 'THEN'
	'BEGIN' ABS; ATERM;
	CODE(21); 'GOTO' SAE1
	'END' SUBTRACTION CASE;
'END' SIMPLE ARITHMETIC EXPRESSION;

'PROCEDURE' AE;
'IF' BS=366 'THEN'
'BEGIN' 'INTEGER' L1,L2;
L1:=IFCLAUSE; SAE; CHFAIL(212,7);
L2:=JMPNEW; LDEC(L1); AE;
LDEC(L2);
'END'
'ELSE' SAE;


'PROCEDURE' RE;
'BEGIN''INTEGER' SBS;
AE; SBS:=BS; ABS; AE;
'IF' SBS=61 'THEN' CODE(22)
'ELSE''IF' SBS=35 'THEN' CODE(23)
'ELSE''IF' SBS=60 'THEN' CODE(24)
'ELSE''IF' SBS=62 'THEN' CODE(25)
'ELSE''IF' SBS=63 'THEN' CODE(26)
'ELSE''IF' SBS=38 'THEN' CODE(27)
'ELSE' FAIL(9);
'END' RELATIONAL BOOLEAN;

'PROCEDURE' PUTOUT;
'BEGIN'
CODE('IF' DECL<=HMPD 'AND' CPR 'THEN' 37 'ELSE' 4);
CODE(ADDR); 'END' STORE TO A VARIABLE;

'PROCEDURE' GETOUT;
'BEGIN'
CODE('IF' DECL<=HMPD 'AND' CPR 'THEN' 38 'ELSE' 12);
CODE(ADDR); 'END' FETCH VARIABLE;

'INTEGER''PROCEDURE' IFCLAUSE;
'BEGIN' ABS; BE; CHFAIL(808,25);
IFCLAUSE:=CJMP 'END' IFCLAUSE;

'PROCEDURE' BPRIM;
'BEGIN' 'BOOLEAN' NOT;
'IF' FRED 'THEN''BEGIN' FETCH; 'GOTO' EBPRIM 'END';
'IF' BS=575 'THEN''BEGIN' NOT:='TRUE'; ABS 'END''ELSE' NOT:='FALSE';
'IF' BS=818 'THEN'
	'BEGIN' ABS; CODE(29); CODE(30) 'END'
'ELSE''IF' BS=241 'THEN'
	'BEGIN' ABS; CODE(29) 'END'
'ELSE''IF' LETTER 'THEN'
	'BEGIN' TYPE:=3; IDENT; FRED:='TRUE';
	'IF' BTYPE 'THEN' FETCH 'ELSE' RE; TYPE:=3;
	'END'
'ELSE''IF' BS=40 'THEN'
	'BEGIN' ABS; BE; CHFAIL(41,14) 'END'
'ELSE' RE;
'IF' NOT 'THEN' CODE(30);
EBPRIM:
'END' BPRIME;

'PROCEDURE' BTERM;
'BEGIN' BPRIM;
BTM1: 'IF' BS=118 'THEN'
	'BEGIN' ABS; BPRIM; CODE(31); 'GOTO' BTM1 'END';
'END' BOOL TERM;

'PROCEDURE' SBE;
'BEGIN' BTERM;
SBE1: 'IF' BS=618 'THEN'
	'BEGIN' ABS; BTERM; CODE(32); 'GOTO' SBE1 'END';
'END' SIMPLE BOOLEAN EXPRESSION;

'PROCEDURE' BE;
'BEGIN''IF' BS#366 'THEN' SBE 'ELSE'
	'BEGIN''INTEGER' L1,L2;
	L1:=IFCLAUSE; SBE; CHFAIL(212,8);
	L2:=JMPNEW; LDEC(L1);
	BE; LDEC(L2) 'END';
'END' BOOLEAN EXPRESSION;

MAX:=0;
SKIP(1); WRITE(1,"ROGALGOL INTEGER SYSTEM COMPILER MK12");
HOL1:='FALSE'; CPR:='FALSE'; STRING:='FALSE';
HMPD:=0; LDPT:=0; FIXSP:=0; DEPTH:=0; DOLL:='FALSE'; LINE:=1;
NLAB:=11; NODEC:=6; NADR:=1; FRED:='FALSE'; SECOND:='FALSE';
SIZE:=0; CHIN(0,INDEV);
'IF' INDEV=0 'THEN'
'BEGIN' SKIP(1); WRITE(1,"OUTPUT-"); READ(1,DEV);
TABLES:=DEV>9; DEV:=DEV-DEV%10*10;
'IF' DEV=3 'THEN' DISK(2);
SKIP(1); WRITE(1,"INPUT-"); READ(1,INDEV);
'IF' INDEV=3 'THEN' DISK(1);
'END' NORMAL SYSTEM OR NO SYSTEM OVERLAY 'ELSE'
'BEGIN' DISK(1); CHIN(0,INDEV); TABLES:=INDEV<0; DEV:=3; INDEV:=3;
'END' SYSTEM OVERLAY TO CALL CD ONCE;
SKIP(DEV); WRITE(DEV,"DECIMAL"); SKIP(DEV); WRITE(DEV,"FIELD 1");
SKIP(DEV); WRITE(DEV,"*1"); SKIP(DEV);
IL1[1]:=1113; IL2[1]:=538;
IL1[2]:=1049; IL2[2]:=62;
IL1[3]:=1352; IL2[3]:=542;
IL1[4]:=182; IL2[4]:=536;
IL1[5]:=182; IL2[5]:=891;
IL1[6]:=241; IL2[6]:=1113;
'FOR' DECL:=1 'STEP' 1 'UNTIL' 6 'DO' TAAL[DECL]:=640+DECL;
ABS; STATEMENT;
'IF' BS#36 'THEN' WARN(6); CODE(63); PAD;
'IF' LDPT#0 'THEN'
'FOR' DECL:=1 'STEP' 1 'UNTIL' LDPT 'DO'
	'BEGIN'	ID1:=FRN1[DECL]; ID2:=FRN2[DECL];
	LINE:=FLINE[DECL]; WARN(2)
	'END';
WRITE(DEV,"V=.;FIELD 0;*16;V;",FIXSP,";"); CHOUT(DEV,164);
SKIP(DEV); CHOUT(DEV,154);
EPROG: SKIP(1);
WRITE(1,"SIZE ",SIZE);
WRITE(1," MAX ",MAX);
'END' OF INTEGER SUBSET COMPILER
$

*U*18+5