-- file: TexScan5Impl.mesa -- Pascal-to-Mesa translator output, translated at September 27, 1985 10:21:37 am PDT DIRECTORY PascalBasic, PascalWizardFiles, TexSysdep, TexTypes, TexInteraction, TexBuildPage, TexMemory, TexSymbols, TexScan, TexOps, TexRest, TexSysdepInline; TexScan5Impl: PROGRAM IMPORTS PascalBasic, TexSysdep, TexTypes, TexInteraction, TexMemory, TexSymbols, TexScan, TexOps, TexRest, TexSysdepInline EXPORTS TexScan = PUBLIC BEGIN OPEN PascalBasic, PascalWizardFiles, TexSysdep, TexTypes, TexInteraction, TexBuildPage, TexMemory, TexSymbols, TexScan, TexOps, TexRest, TexSysdepInline; Expand: PROCEDURE = BEGIN T:Halfword;P, Q, R:Halfword;J:PascalInteger[0..BufSize]; CvBackup:PascalInteger;CvlBackup, RadixBackup:SmallNumber; BackupBackup:Halfword;SaveScannerStatus:SmallNumber; CvBackup←CurVal;CvlBackup←CurValLevel;RadixBackup←Radix; BackupBackup←Mem[64987]↑.Hh.Rh;IF INT[CurCmd]<110 THEN--367: BEGIN IF Eqtb↑[4803].Int>1 THEN ShowCurCmdChr[]; SELECT CurCmd FROM 109 =>--386: BEGIN IF CurMark↑[CurChr]#0 THEN BeginTokenList[CurMark↑[CurChr],14 ]; END--:386--;101 =>--368:--BEGIN GetToken[];T←CurTok;GetToken[]; IF INT[CurCmd]>99 THEN Expand [] ELSE BackInput[];CurTok←T;BackInput[]; END--:368--;102 =>--369:--BEGIN SaveScannerStatus←ScannerStatus; ScannerStatus←0;GetToken[];ScannerStatus←SaveScannerStatus; T←CurTok;BackInput[];IF INT[T]>=4096 THEN BEGIN P←GetAvail[]; Mem[P]↑.Hh.Lh←6863;Mem[P]↑.Hh.Rh←CurInput.LocField; CurInput.StartField←P;CurInput.LocField←P; END; END--:369--;106 =>--372: BEGIN R←GetAvail[];P←R;DO GetXToken[]; IF CurCs=0 THEN BEGIN Q←GetAvail[];Mem[P]↑.Hh.Rh←Q; Mem[Q]↑.Hh.Lh←CurTok;P←Q; END; IF CurCs#0 THEN EXIT; ENDLOOP;IF CurCmd#66 THEN--373: BEGIN BEGIN IF Interaction=3 THEN NULL;PrintNl[134];Print[486]; END; PrintEsc[367];Print[487];BEGIN HelpPtr←2;HelpLine↑[1]←488; HelpLine↑[0]←489; END;BackError[]; END--:373--;--374:--J←First; P←Mem[R]↑.Hh.Rh; WHILE P#0 DO BEGIN IF INT[J]>=MaxBufStack THEN BEGIN MaxBufStack←J+1; IF MaxBufStack=BufSize THEN Overflow[128,BufSize]; END; Buffer↑[J]← PascalMODPower2Mask[Mem[P]↑.Hh.Lh ,255];J←J+1;P←Mem[P]↑.Hh.Rh; END ENDLOOP ; IF INT[J]>First+1 THEN BEGIN NoNewControlSequence←FALSE; CurCs←IdLookup[First,J-First];NoNewControlSequence←TRUE; END ELSE IF J=First THEN CurCs←257 ELSE CurCs←129+Buffer↑[First]--:374 -- --;FlushList[R]; IF Eqtb↑[CurCs].Hh.B0=100 THEN BEGIN Eqtb↑[CurCs]←Eqtb↑[2765]; END; CurTok← INT[CurCs]+4096;BackInput[]; END--:372--;107 =>ConvToks[]; 108 =>InsTheToks[];104 =>Conditional[];105 =>--510: IF INT[CurChr]>IfLimit THEN IF IfLimit=1 THEN InsertRelax [] ELSE BEGIN BEGIN IF Interaction=3 THEN NULL;PrintNl[134];Print[636]; END; PrintCmdChr[105,CurChr];BEGIN HelpPtr←1;HelpLine↑[0]←637; END; Error[]; END ELSE BEGIN WHILE CurChr#2 DO PassText[] ENDLOOP ;--496: BEGIN P←CondPtr;IfLine←Mem[P+1]↑.Int;CurIf←Mem[P]↑.Hh.B1; IfLimit←Mem[P]↑.Hh.B0;CondPtr←Mem[P]↑.Hh.Rh;FreeNode[P,2]; END--:496--; END--:510--;103 =>--378: IF INT[CurChr]>0 THEN ForceEof←TRUE ELSE IF NameInProgress THEN InsertRelax [] ELSE StartInput--:378--[]; ENDCASE =>--370: BEGIN BEGIN IF Interaction=3 THEN NULL;PrintNl[134];Print[480]; END; BEGIN HelpPtr←5;HelpLine↑[4]←481;HelpLine↑[3]←482;HelpLine↑[2]←483; HelpLine↑[1]←484;HelpLine↑[0]←485; END;Error[]; END--:370--; END--:367 ELSE IF INT[CurCmd]<114 THEN MacroCall [] ELSE--375:--BEGIN CurTok←6860; BackInput[]; END--:375--;CurVal←CvBackup;CurValLevel←CvlBackup; Radix←RadixBackup;Mem[64987]↑.Hh.Rh←BackupBackup; END;--:366----380: TheToks: PROCEDURE RETURNS[TheToksResult: Halfword] = BEGIN OldSetting:PascalInteger[0..21];P, Q, R:Halfword; GetXToken[];ScanSomethingInternal[5,FALSE]; IF INT[CurValLevel]>=4 THEN--466:--BEGIN P←64997;Mem[P]↑.Hh.Rh←0; IF CurValLevel=4 THEN BEGIN Q←GetAvail[];Mem[P]↑.Hh.Rh←Q; Mem[Q]↑.Hh.Lh←4096+CurVal;P←Q; END ELSE IF CurVal#0 THEN BEGIN R←Mem[CurVal]↑.Hh.Rh; WHILE R#0 DO BEGIN BEGIN BEGIN Q←Avail; IF Q=0 THEN Q←GetAvail [] ELSE BEGIN Avail←Mem[Q]↑.Hh.Rh;Mem[Q]↑.Hh.Rh←0; DynUsed←DynUsed+1; END; END;Mem[P]↑.Hh.Rh←Q;Mem[Q]↑.Hh.Lh←Mem[R]↑.Hh.Lh; P←Q; END;R←Mem[R]↑.Hh.Rh; END ENDLOOP ; END;TheToksResult←P; END--:466 ELSE BEGIN OldSetting←Selector;Selector←21; SELECT CurValLevel FROM 0 =>PrintInt[CurVal]; 1 =>BEGIN PrintScaled[CurVal];Print[265]; END; 2 =>BEGIN PrintSpec[CurVal,265];DeleteGlueRef[CurVal]; END; 3 =>BEGIN PrintSpec[CurVal,209];DeleteGlueRef[CurVal]; END; ENDCASE; Selector←OldSetting;TheToksResult←StrToks[]; END; END;--:465----467: InsTheToks: PROCEDURE = BEGIN Mem[64988]↑.Hh.Rh←TheToks[]; BeginTokenList[Mem[64997]↑.Hh.Rh,4]; END;--:467----470: ConvToks: PROCEDURE = BEGIN OldSetting:PascalInteger[0..21];C:PascalInteger[0..5]; SaveScannerStatus:SmallNumber; C←CurChr;--471: SELECT C FROM 0,1 =>ScanInt[];2,3 =>BEGIN SaveScannerStatus←ScannerStatus; ScannerStatus←0;GetToken[];ScannerStatus←SaveScannerStatus; END; 4 =>ScanFontIdent[];5 =>IF JobName=0 THEN OpenLogFile[]; ENDCASE--:471--; OldSetting←Selector;Selector←21;--472:--SELECT C FROM 0 =>PrintInt[CurVal]; 1 =>PrintRomanInt[CurVal]; 2 =>IF CurCs#0 THEN SprintCs[CurCs] ELSE PrintChar[CurChr]; 3 =>PrintMeaning[];4 =>BEGIN Print[FontName↑[CurVal]]; IF FontSize↑[CurVal]#FontDsize↑[CurVal] THEN BEGIN Print[601]; PrintScaled[FontSize↑[CurVal]];Print[265]; END; END;5 =>Print[JobName]; ENDCASE--:472--;Selector←OldSetting;Mem[64988]↑.Hh.Rh←StrToks[]; BeginTokenList[Mem[64997]↑.Hh.Rh,4]; END;--:470----473: ScanToks: PROCEDURE[MacroDef,Xpand: PascalBoolean] RETURNS[ScanToksResult: Halfword] = BEGIN T:Halfword;S:Halfword;P:Halfword;Q:Halfword;Unbalance:Halfword; HashBrace:Halfword; IF MacroDef THEN ScannerStatus←2 ELSE ScannerStatus←5; WarningIndex←CurCs;DefRef←GetAvail[];Mem[DefRef]↑.Hh.Lh←0; P←DefRef;HashBrace←0;T←3120;{IF MacroDef THEN--474: BEGIN {{WHILE TRUE DO BEGIN GetToken[];IF INT[CurTok]<768 THEN GOTO Label31; IF CurCmd=6 THEN--476:--BEGIN S← INT[3328]+CurChr;GetToken[]; IF CurCmd=1 THEN BEGIN HashBrace←CurTok;BEGIN Q←GetAvail[]; Mem[P]↑.Hh.Rh←Q;Mem[Q]↑.Hh.Lh←CurTok;P←Q; END;BEGIN Q←GetAvail[]; Mem[P]↑.Hh.Rh←Q;Mem[Q]↑.Hh.Lh←3584;P←Q; END; GOTO Label30; END; IF T=3129 THEN BEGIN BEGIN IF Interaction=3 THEN NULL;PrintNl[134]; Print[604]; END;BEGIN HelpPtr←1;HelpLine↑[0]←605; END;Error[]; END ELSE BEGIN T←T+1; IF CurTok#T THEN BEGIN BEGIN IF Interaction=3 THEN NULL;PrintNl[134]; Print[606]; END;BEGIN HelpPtr←2;HelpLine↑[1]←607;HelpLine↑[0]←608; END;BackError[]; END;CurTok←S; END; END--:476--;BEGIN Q←GetAvail[]; Mem[P]↑.Hh.Rh←Q;Mem[Q]↑.Hh.Lh←CurTok;P←Q; END; END ENDLOOP ; EXITS Label31 => NULL};BEGIN Q←GetAvail[];Mem[P]↑.Hh.Rh←Q;Mem[Q]↑.Hh.Lh←3584;P←Q; END; IF CurCmd=2 THEN--475:--BEGIN BEGIN IF Interaction=3 THEN NULL;PrintNl[134]; Print[518]; END;AlignState←AlignState+1;BEGIN HelpPtr←2; HelpLine↑[1]←602;HelpLine↑[0]←603; END;Error[]; GOTO Label40; END--:475--; EXITS Label30 => NULL}; END--:474-- ELSE ScanLeftBrace[];--477:--Unbalance←1; WHILE TRUE DO BEGIN IF Xpand THEN--478: BEGIN {WHILE TRUE DO BEGIN GetNext[];IF CurCmd#108 THEN GOTO Label32; Q←TheToks[]; IF Mem[64997]↑.Hh.Rh#0 THEN BEGIN Mem[P]↑.Hh.Rh←Mem[64997]↑.Hh.Rh;P←Q; END; END ENDLOOP ;EXITS Label32 => NULL};XToken []; END--:478-- ELSE GetToken[]; IF INT[CurTok]<768 THEN IF INT[CurCmd]<2 THEN Unbalance←Unbalance+1 ELSE BEGIN Unbalance← INT[Unbalance]-1;IF Unbalance=0 THEN GOTO Label40; END ELSE IF CurCmd=6 THEN IF MacroDef THEN--479:--BEGIN S←CurTok; IF Xpand THEN GetXToken [] ELSE GetToken[]; IF CurCmd#6 THEN IF( INT[CurTok]<=3120)OR ( INT[CurTok]>T) THEN BEGIN BEGIN IF Interaction=3 THEN NULL;PrintNl[134];Print[609]; END; SprintCs[WarningIndex];BEGIN HelpPtr←3;HelpLine↑[2]←610; HelpLine↑[1]←611;HelpLine↑[0]←612; END;BackError[];CurTok←S; END ELSE CurTok← INT[1232]+CurChr; END--:479--;BEGIN Q←GetAvail[]; Mem[P]↑.Hh.Rh←Q;Mem[Q]↑.Hh.Lh←CurTok;P←Q; END; END--:477-- ENDLOOP ; EXITS Label40 => NULL};ScannerStatus←0;IF HashBrace#0 THEN BEGIN Q←GetAvail[]; Mem[P]↑.Hh.Rh←Q;Mem[Q]↑.Hh.Lh←HashBrace;P←Q; END;ScanToksResult←P; END; --:473----482:-- ReadToks: PROCEDURE[N: PascalInteger,R: Halfword] = BEGIN P:Halfword;Q:Halfword;S:PascalInteger;M:SmallNumber; ScannerStatus←2;WarningIndex←R;DefRef←GetAvail[]; Mem[DefRef]↑.Hh.Lh←0;P←DefRef;BEGIN Q←GetAvail[];Mem[P]↑.Hh.Rh←Q; Mem[Q]↑.Hh.Lh←3584;P←Q; END;IF(N<0)OR (N>15) THEN M←16 ELSE M←N; S←AlignState;AlignState←1000000;DO--483:--BeginFileReading[]; CurInput.NameField←M+1;IF ReadOpen↑[M]=2 THEN--484: IF INT[Interaction]>1 THEN IF N<0 THEN BEGIN Print[210];TermInput[]; END ELSE BEGIN PrintLn[];SprintCs[R];BEGIN Print[61];TermInput[]; END; N←-1; END ELSE FatalError[613]--:484-- ELSE IF ReadOpen↑[M]=1 THEN--485: IF InputLn[@ReadFile↑[M],FALSE] THEN ReadOpen↑[M]←0 ELSE BEGIN AClose[ @ReadFile↑[M]];ReadOpen↑[M]←2; END--:485-- ELSE--486: BEGIN IF NOT InputLn[@ReadFile↑[M],TRUE] THEN BEGIN AClose[@ReadFile↑[M]] ;ReadOpen↑[M]←2;IF AlignState#1000000 THEN BEGIN Runaway[]; BEGIN IF Interaction=3 THEN NULL;PrintNl[134];Print[614]; END;PrintEsc[395]; BEGIN HelpPtr←1;HelpLine↑[0]←615; END;AlignState←1000000;Error[]; END; END; END--:486--;CurInput.LimitField←Last; IF(Eqtb↑[4815].Int<0)OR (Eqtb↑[4815].Int>127) THEN CurInput.LimitField← INT[CurInput.LimitField]-1 ELSE Buffer↑[CurInput.LimitField]←Eqtb↑[4815]. Int;First←CurInput.LimitField+1; CurInput.LocField←CurInput.StartField;CurInput.StateField←33; {WHILE TRUE DO BEGIN GetToken[];IF CurTok=0 THEN GOTO Label30; BEGIN Q←GetAvail[];Mem[P]↑.Hh.Rh←Q;Mem[Q]↑.Hh.Lh←CurTok;P←Q; END; END ENDLOOP ; EXITS Label30 => NULL};EndFileReading--:483--[]; IF AlignState=1000000 THEN EXIT; ENDLOOP;CurVal←DefRef; ScannerStatus←0;AlignState←S; END;--:482----494:-- PassText: PROCEDURE = BEGIN L:PascalInteger;SaveScannerStatus:SmallNumber; SaveScannerStatus←ScannerStatus;ScannerStatus←1;L←0; SkipLine←Line;{WHILE TRUE DO BEGIN GetNext[]; IF CurCmd=105 THEN BEGIN IF L=0 THEN GOTO Label30;IF CurChr=2 THEN L←L-1; END ELSE IF CurCmd=104 THEN L←L+1; END ENDLOOP ; EXITS Label30 => NULL};ScannerStatus←SaveScannerStatus; END;--:494----497: ChangeIfLimit: PROCEDURE[L: SmallNumber,P: Halfword] = BEGIN Q:Halfword; {IF P=CondPtr THEN IfLimit←L ELSE BEGIN Q←CondPtr; WHILE TRUE DO BEGIN IF Q=0 THEN Confusion[616]; IF Mem[Q]↑.Hh.Rh=P THEN BEGIN Mem[Q]↑.Hh.B0←L; GOTO Label10; END; Q←Mem[Q]↑.Hh.Rh; END ENDLOOP ; END;EXITS Label10 => NULL}; END;--:497----498:-- Conditional: PROCEDURE = BEGIN B:PascalBoolean;R:PascalInteger[60..62];M, N:PascalInteger;P, Q:Halfword; SaveScannerStatus:SmallNumber;SaveCondPtr:Halfword; ThisIf:SmallNumber;--495:--BEGIN P←GetNode[2]; Mem[P]↑.Hh.Rh←CondPtr;Mem[P]↑.Hh.B0←IfLimit;Mem[P]↑.Hh.B1←CurIf; Mem[P+1]↑.Int←IfLine;CondPtr←P;CurIf←CurChr;IfLimit←1; IfLine←Line; END--:495--;SaveCondPtr←CondPtr;ThisIf←CurChr;--501: {{SELECT ThisIf FROM 0,1 =>--506:--BEGIN BEGIN GetXToken[]; IF CurCmd=0 THEN IF CurChr=257 THEN BEGIN CurCmd←13; CurChr← INT[CurTok]-4097; END; END; IF( INT[CurCmd]>13)OR ( INT[CurChr]>127) THEN BEGIN M←0;N←256; END ELSE BEGIN M←CurCmd;N←CurChr; END;BEGIN GetXToken[]; IF CurCmd=0 THEN IF CurChr=257 THEN BEGIN CurCmd←13; CurChr← INT[CurTok]-4097; END; END; IF( INT[CurCmd]>13)OR ( INT[CurChr]>127) THEN BEGIN CurCmd←0;CurChr←256; END; IF ThisIf=0 THEN B←(N=CurChr) ELSE B←(M=CurCmd); END--:506--;2,3 =>--503: BEGIN IF ThisIf=2 THEN ScanInt [] ELSE ScanDimen[FALSE,FALSE,FALSE]; N←CurVal;--406:--DO GetXToken[]; IF CurCmd#10--:406-- THEN EXIT; ENDLOOP; IF( INT[CurTok]>=3132)AND ( INT[CurTok]<=3134) THEN R← INT[CurTok]-3072 ELSE BEGIN BEGIN IF Interaction=3 THEN NULL;PrintNl[134];Print[640]; END; PrintCmdChr[104,ThisIf];BEGIN HelpPtr←1;HelpLine↑[0]←641; END; BackError[];R←61; END; IF ThisIf=2 THEN ScanInt [] ELSE ScanDimen[FALSE,FALSE,FALSE]; SELECT R FROM 60 =>B←(N<CurVal);61 =>B←(N=CurVal);62 =>B←(N>CurVal); ENDCASE; END--:503--;4 =>--504:--BEGIN ScanInt[];B←PascalODD[CurVal]; END--:504--; 5 =>B←(ABS[CurList.ModeField]=1);6 =>B←(ABS[CurList.ModeField]=101); 7 =>B←(ABS[CurList.ModeField]=201);8 =>B←( INT[CurList.ModeField]<0); 9,10,11 =>--505:--BEGIN ScanEightBitInt[];P←Eqtb↑[3822+CurVal].Hh.Rh; IF ThisIf=9 THEN B←(P=0) ELSE IF P=0 THEN B←FALSE ELSE IF ThisIf=10 THEN B←(Mem[P]↑.Hh.B0=0) ELSE B←(Mem[P]↑.Hh.B0=1); END--:505--;12 =>--507: BEGIN SaveScannerStatus←ScannerStatus;ScannerStatus←0;GetNext[]; N←CurCs;P←CurCmd;Q←CurChr;GetNext[]; IF CurCmd#P THEN B←FALSE ELSE IF INT[CurCmd]<110 THEN B←(CurChr=Q) ELSE-- -- 508:--BEGIN P←Mem[CurChr]↑.Hh.Rh;Q←Mem[Eqtb↑[N].Hh.Rh]↑.Hh.Rh; WHILE(P#0)AND (Q#0)DO IF Mem[P]↑.Hh.Lh#Mem[Q]↑.Hh.Lh THEN P←0 ELSE BEGIN P←Mem[P]↑.Hh.Rh;Q←Mem[Q]↑.Hh.Rh; END ENDLOOP ;B←((P=0)AND (Q=0)); END--:508--; ScannerStatus←SaveScannerStatus; END--:507--; 13 =>BEGIN ScanFourBitInt[];B←(ReadOpen↑[CurVal]=2); END;14 =>B←TRUE; 15 =>B←FALSE;16 =>--509:--BEGIN ScanInt[];N←CurVal; IF Eqtb↑[4803].Int>1 THEN BEGIN BeginDiagnostic[];Print[642];PrintInt[N]; PrintChar[125];EndDiagnostic[FALSE]; END;WHILE N#0 DO BEGIN PassText[]; IF CondPtr=SaveCondPtr THEN IF CurChr=4 THEN N←N-1 ELSE GOTO Label50 ELSE IF CurChr=2 THEN--496:--BEGIN P←CondPtr;IfLine←Mem[P+1]↑.Int; CurIf←Mem[P]↑.Hh.B1;IfLimit←Mem[P]↑.Hh.B0;CondPtr←Mem[P]↑.Hh.Rh; FreeNode[P,2]; END--:496--; END ENDLOOP ;ChangeIfLimit[4,SaveCondPtr]; GOTO Label10; END--:509--; ENDCASE--:501--;IF Eqtb↑[4803].Int>1 THEN--502: BEGIN BeginDiagnostic[];IF B THEN Print[638] ELSE Print[639]; EndDiagnostic[FALSE]; END--:502--; IF B THEN BEGIN ChangeIfLimit[3,SaveCondPtr]; GOTO Label10; END;--500: WHILE TRUE DO BEGIN PassText[]; IF CondPtr=SaveCondPtr THEN BEGIN IF CurChr#4 THEN GOTO Label50; BEGIN IF Interaction=3 THEN NULL;PrintNl[134];Print[636]; END;PrintEsc[634]; BEGIN HelpPtr←1;HelpLine↑[0]←637; END;Error[]; END ELSE IF CurChr=2 THEN--496:--BEGIN P←CondPtr;IfLine←Mem[P+1]↑.Int; CurIf←Mem[P]↑.Hh.B1;IfLimit←Mem[P]↑.Hh.B0;CondPtr←Mem[P]↑.Hh.Rh; FreeNode[P,2]; END--:496--; END--:500-- ENDLOOP ;EXITS Label50 => NULL};IF CurChr=2 THEN--496: BEGIN P←CondPtr;IfLine←Mem[P+1]↑.Int;CurIf←Mem[P]↑.Hh.B1; IfLimit←Mem[P]↑.Hh.B0;CondPtr←Mem[P]↑.Hh.Rh;FreeNode[P,2]; END--:496 ELSE IfLimit←2;EXITS Label10 => NULL}; END;--:498----515:-- BeginName: PROCEDURE = BEGIN AreaDelimiter←0;ExtDelimiter←0; END;--:515----516: END.