-- file: TexExtensionsImpl.mesa
-- Pascal-to-Mesa translator output, translated at September 27, 1985 10:21:38 am PDT


DIRECTORY
  PascalBasic,
  TexTypes,
  TexSysdep,
  TexSysdepInline,
  TexInteraction,
  TexMemory,
  TexSymbols,
  TexScan,
  TexDvi,
  TexBuildPage,
  TexRest,
  TexExtensions;

TexExtensionsImpl: PROGRAM IMPORTS TexTypes, TexSysdep, TexSysdepInline, TexInteraction, TexMemory, TexSymbols, TexScan, TexDvi, TexBuildPage, TexRest EXPORTS TexExtensions = PUBLIC
BEGIN OPEN PascalBasic, TexTypes, TexSysdep, TexSysdepInline, TexInteraction, TexMemory, TexSymbols, TexScan, TexDvi, TexBuildPage, TexRest, TexExtensions;
 PrintWriteWhatsit: PROCEDURE[S: StrNumber,P: Halfword]
 = 
BEGIN PrintEsc[S];
IF  INT[Mem[P+1]↑.Hh.Lh]<16  THEN PrintInt[Mem[P+1]↑.Hh.Lh] ELSE IF Mem[P+1]↑.Hh.
Lh=16  THEN PrintChar[42] ELSE PrintChar[45]; END;--:1355----78:
--:618----619:----1368:
 SpecialOut: PROCEDURE[P: Halfword] = 
BEGIN OldSetting:PascalInteger[0..21];K:PoolPointer;
 IF CurH#DviH  THEN BEGIN Movement[CurH-DviH,143];DviH←CurH;
 END;IF CurV#DviV  THEN BEGIN Movement[CurV-DviV,157];DviV←CurV;
 END;OldSetting←Selector;Selector←21;
ShowTokenList[Mem[Mem[P+1]↑.Hh.Rh]↑.Hh.Rh,0,PoolSize-PoolPtr];
Selector←OldSetting;
BEGIN IF  INT[PoolPtr+1]>PoolSize  THEN Overflow[129,PoolSize-InitPoolPtr]
; END;
IF( INT[PoolPtr]-StrStart↑[StrPtr])<256  THEN BEGIN BEGIN DviBuf↑[DviPtr]←
239;DviPtr←DviPtr+1;IF DviPtr=DviLimit  THEN DviSwap[]; END;
BEGIN DviBuf↑[DviPtr]←( INT[PoolPtr]-StrStart↑[StrPtr]);
DviPtr←DviPtr+1;IF DviPtr=DviLimit  THEN DviSwap[]; END;
 END  ELSE BEGIN BEGIN DviBuf↑[DviPtr]←242;DviPtr←DviPtr+1;
IF DviPtr=DviLimit  THEN DviSwap[]; END;
DviFour[( INT[PoolPtr]-StrStart↑[StrPtr])]; END;
FOR i:INT    IN [ INT[StrStart↑[StrPtr]].. INT[ INT[PoolPtr]-1 ]] DO  K ← i;  DviBuf↑[DviPtr]←
StrPool↑[K];DviPtr←DviPtr+1;IF DviPtr=DviLimit  THEN DviSwap[]; ENDLOOP;
PoolPtr←StrStart↑[StrPtr]; END;--:1368----1370:
 WriteOut: PROCEDURE[P: Halfword] = 
BEGIN OldSetting:PascalInteger[0..21];OldMode:PascalInteger;
J:SmallNumber;Q, R:Halfword;--1371:--Q←GetAvail[];Mem[Q]↑.Hh.Lh←637;
R←GetAvail[];Mem[Q]↑.Hh.Rh←R;Mem[R]↑.Hh.Lh←6862;BeginTokenList[Q,4];
BeginTokenList[Mem[P+1]↑.Hh.Rh,15];Q←GetAvail[];Mem[Q]↑.Hh.Lh←379;
BeginTokenList[Q,4];OldMode←CurList.ModeField;
CurList.ModeField←0;CurCs←WriteLoc;Q←ScanToks[FALSE,TRUE];
GetToken[];IF CurTok#6862  THEN--1372:--BEGIN BEGIN IF Interaction=3  THEN NULL;
PrintNl[134];Print[1144]; END;BEGIN HelpPtr←2;HelpLine↑[1]←1145;
HelpLine↑[0]←865; END;Error[];DO GetToken[]; IF CurTok=6862 THEN EXIT; ENDLOOP;
 END--:1372--;CurList.ModeField←OldMode;EndTokenList--:1371--[];
OldSetting←Selector;J←Mem[P+1]↑.Hh.Lh;
IF WriteOpen↑[J] THEN Selector←J  ELSE BEGIN IF(J=17)AND (Selector=19) THEN
Selector←18;PrintNl[210]; END;
ShowTokenList[Mem[DefRef]↑.Hh.Rh,0,BufSize-10];PrintLn[];
FlushList[DefRef];Selector←OldSetting; END;--:1370----1373:
 OutWhat: PROCEDURE[P: Halfword] = 
BEGIN J:SmallNumber;
 SELECT Mem[P]↑.Hh.B1 FROM 0,1,2 =>--1374:
IF  NOT DoingLeaders  THEN BEGIN J←Mem[P+1]↑.Hh.Lh;
IF Mem[P]↑.Hh.B1=1  THEN WriteOut[P] ELSE BEGIN IF WriteOpen↑[J] THEN
AClose[@WriteFile↑[J]];
IF Mem[P]↑.Hh.B1=2  THEN WriteOpen↑[J]←FALSE  ELSE IF  INT[J]<16  THEN BEGIN
CurName←Mem[P+1]↑.Hh.Rh;CurArea←Mem[P+2]↑.Hh.Lh;
CurExt←Mem[P+2]↑.Hh.Rh;IF CurExt=210  THEN CurExt←647;
PackFileName[CurName,CurArea,CurExt];
WHILE  NOT AOpenOut[@WriteFile↑[J]]DO PromptFileName[1147,647] ENDLOOP ;
WriteOpen↑[J]←TRUE; END; END; END--:1374--;3 =>SpecialOut[P];
 ENDCASE =>Confusion[1146]; END;--:1373----:1378----1396:
 PressOutWhat: PROCEDURE[P: Halfword]
 = 
BEGIN SELECT Mem[P]↑.Hh.B1 FROM 0,1,2 =>OutWhat[P];3 => NULL;
 ENDCASE =>Confusion[1146]; END;--:1396----1379:-- NewWhatsit: PROCEDURE[S: SmallNumber,W: SmallNumber] = 
BEGIN P:Halfword;
 P←GetNode[W];Mem[P]↑.Hh.B0←8;Mem[P]↑.Hh.B1←S;
Mem[CurList.TailField]↑.Hh.Rh←P;CurList.TailField←P; END;--:1349
--1350:-- NewWriteWhatsit: PROCEDURE[W: SmallNumber]
 = 
BEGIN NewWhatsit[CurChr,W];
IF W#2  THEN ScanFourBitInt [] ELSE BEGIN ScanInt[];
IF CurVal<0  THEN CurVal←17  ELSE IF CurVal>15  THEN CurVal←16; END;
Mem[CurList.TailField+1]↑.Hh.Lh←CurVal; END;--:1350
 DoExtension: PROCEDURE = 
BEGIN I, J, K:PascalInteger;P, Q, R:Halfword;
 SELECT CurChr FROM 0 =>--1351:--BEGIN NewWriteWhatsit[3];
ScanOptionalEquals[];ScanFileName[];
Mem[CurList.TailField+1]↑.Hh.Rh←CurName;
Mem[CurList.TailField+2]↑.Hh.Lh←CurArea;
Mem[CurList.TailField+2]↑.Hh.Rh←CurExt; END--:1351--;1 =>--1352:
BEGIN K←CurCs;NewWriteWhatsit[2];CurCs←K;
P←ScanToks[FALSE,FALSE];Mem[CurList.TailField+1]↑.Hh.Rh←DefRef;
 END--:1352--;2 =>--1353:--BEGIN NewWriteWhatsit[2];
Mem[CurList.TailField+1]↑.Hh.Rh←0; END--:1353--;3 =>--1354:
BEGIN NewWhatsit[3,2];Mem[CurList.TailField+1]↑.Hh.Lh←0;
P←ScanToks[FALSE,TRUE];Mem[CurList.TailField+1]↑.Hh.Rh←DefRef;
 END--:1354--;4 =>--1375:--BEGIN GetXToken[];
IF(CurCmd=59)AND ( INT[CurChr]<=2) THEN BEGIN P←CurList.TailField;
DoExtension[];OutWhat[CurList.TailField];
FlushNodeList[CurList.TailField];CurList.TailField←P;
Mem[P]↑.Hh.Rh←0; END  ELSE BackInput[]; END--:1375--;
 ENDCASE =>Confusion[1139]; END;--:1348----1068:

END.