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


DIRECTORY
  PascalBasic,
  TexTypes,
  TexInteraction,
  TexMemory,
  TexSymbols,
  TexOps,
  TexParagraph,
  TexSysdepInline;

TexParagraph2Impl: PROGRAM IMPORTS TexTypes, TexInteraction, TexMemory, TexSymbols, TexOps, TexParagraph, TexSysdepInline EXPORTS TexParagraph = PUBLIC
BEGIN OPEN PascalBasic, TexTypes, TexInteraction, TexMemory, TexSymbols, TexOps, TexParagraph, TexSysdepInline;
 LineBreak: PROCEDURE[FinalWidowPenalty: PascalInteger]
 = 
BEGIN --862:--AutoBreaking:PascalBoolean;PrevP:Halfword;
Q, R, S:Halfword;F:InternalFontNumber;--:862----893:--J:SmallNumber;
C:PascalInteger[0..255];--:893-- LineBreakInner: PROCEDURE = 
BEGIN--816:
Mem[64997]↑.Hh.Rh←Mem[CurList.HeadField]↑.Hh.Rh;
IF( INT[CurList.TailField]>=HiMemMin) THEN BEGIN Mem[CurList.TailField]↑.
Hh.Rh←NewPenalty[10000];
CurList.TailField←Mem[CurList.TailField]↑.Hh.Rh;
 END  ELSE IF Mem[CurList.TailField]↑.Hh.B0#10  THEN BEGIN Mem[CurList.
TailField]↑.Hh.Rh←NewPenalty[10000];
CurList.TailField←Mem[CurList.TailField]↑.Hh.Rh;
 END  ELSE BEGIN Mem[CurList.TailField]↑.Hh.B0←12;
DeleteGlueRef[Mem[CurList.TailField+1]↑.Hh.Lh];
FlushNodeList[Mem[CurList.TailField+1]↑.Hh.Rh];
Mem[CurList.TailField+1]↑.Int←10000; END;
Mem[CurList.TailField]↑.Hh.Rh←NewParamGlue[14];PopNest[];--:816----827:
NoShrinkErrorYet←TRUE;
IF(Mem[Eqtb↑[3033].Hh.Rh]↑.Hh.B1#0)AND (Mem[Eqtb↑[3033].Hh.Rh+3]↑.Int#0)
 THEN BEGIN Eqtb↑[3033].Hh.Rh←FiniteShrink[Eqtb↑[3033].Hh.Rh]; END;
IF(Mem[Eqtb↑[3034].Hh.Rh]↑.Hh.B1#0)AND (Mem[Eqtb↑[3034].Hh.Rh+3]↑.Int#0)
 THEN BEGIN Eqtb↑[3034].Hh.Rh←FiniteShrink[Eqtb↑[3034].Hh.Rh]; END;
Q←Eqtb↑[3033].Hh.Rh;R←Eqtb↑[3034].Hh.Rh;
Background↑[1]←Mem[Q+1]↑.Int+Mem[R+1]↑.Int;Background↑[2]←0;
Background↑[3]←0;Background↑[4]←0;Background↑[5]←0;
Background↑[2+Mem[Q]↑.Hh.B0]←Mem[Q+2]↑.Int;
Background↑[2+Mem[R]↑.Hh.B0]←Background↑[2+Mem[R]↑.Hh.B0]+Mem[R+2]↑.Int;
Background↑[6]←Mem[Q+3]↑.Int+Mem[R+3]↑.Int;--:827----834:
MinimumDemerits←1073741823;MinimalDemerits↑[3]←1073741823;
MinimalDemerits↑[2]←1073741823;MinimalDemerits↑[1]←1073741823;
MinimalDemerits↑[0]←1073741823;--:834----848:
IF Eqtb↑[3556].Hh.Rh=0  THEN IF Eqtb↑[5218].Int=0  THEN BEGIN
LastSpecialLine←0;SecondWidth←Eqtb↑[5204].Int;SecondIndent←0;
 END  ELSE--849:--BEGIN LastSpecialLine←ABS[Eqtb↑[4808].Int];
IF Eqtb↑[4808].Int<0  THEN BEGIN FirstWidth←Eqtb↑[5204].Int-ABS[Eqtb↑[5218
].Int];
IF Eqtb↑[5218].Int>=0  THEN FirstIndent←Eqtb↑[5218].Int  ELSE FirstIndent
←0;SecondWidth←Eqtb↑[5204].Int;SecondIndent←0;
 END  ELSE BEGIN FirstWidth←Eqtb↑[5204].Int;FirstIndent←0;
SecondWidth←Eqtb↑[5204].Int-ABS[Eqtb↑[5218].Int];
IF Eqtb↑[5218].Int>=0  THEN SecondIndent←Eqtb↑[5218].Int  ELSE
SecondIndent←0; END; END--:849
 ELSE BEGIN LastSpecialLine← INT[Mem[Eqtb↑[3556].Hh.Rh]↑.Hh.Lh]-1;
SecondWidth←Mem[Eqtb↑[3556].Hh.Rh+ INT[2]*(LastSpecialLine+1)]↑.Int;
SecondIndent←Mem[Eqtb↑[3556].Hh.Rh+ INT[2]*LastSpecialLine+1]↑.Int; END;
IF Eqtb↑[4786].Int=0  THEN EasyLine←LastSpecialLine  ELSE EasyLine←
65515--:848--; END; --876:
 PackBeginLine←CurList.MlField;
LineBreakInner[];--863:--Threshold←Eqtb↑[4767].Int;
IF Threshold>=0  THEN BEGIN IF Eqtb↑[4799].Int>0  THEN BEGIN
BeginDiagnostic[];PrintNl[792]; END;SecondPass←FALSE;
 END  ELSE BEGIN Threshold←Eqtb↑[4768].Int;SecondPass←TRUE;
IF Eqtb↑[4799].Int>0  THEN BeginDiagnostic[]; END;{WHILE TRUE DO BEGIN--864:
Q←GetNode[3];Mem[Q]↑.Hh.B0←0;Mem[Q]↑.Hh.B1←2;Mem[Q]↑.Hh.Rh←64994;
Mem[Q+1]↑.Hh.Rh←0;Mem[Q+1]↑.Hh.Lh←CurList.PgField+1;Mem[Q+2]↑.Int←0;
Mem[64994]↑.Hh.Rh←Q;ActiveWidth↑[1]←Background↑[1];
ActiveWidth↑[2]←Background↑[2];ActiveWidth↑[3]←Background↑[3];
ActiveWidth↑[4]←Background↑[4];ActiveWidth↑[5]←Background↑[5];
ActiveWidth↑[6]←Background↑[6];Passive←0;PrintedNode←64997;
PassNumber←0;FontInShortDisplay←0--:864--;CurP←Mem[64997]↑.Hh.Rh;
AutoBreaking←TRUE;PrevP←CurP;
WHILE(CurP#0)AND (Mem[64994]↑.Hh.Rh#64994)DO--866:
BEGIN IF( INT[CurP]>=HiMemMin) THEN--867:--BEGIN PrevP←CurP;
DO F←Mem[CurP]↑.Hh.B0;
ActiveWidth↑[1]←ActiveWidth↑[1]+FontInfo↑[WidthBase↑[F]+FontInfo↑
[CharBase↑[F]+Mem[CurP]↑.Hh.B1].Qqqq.B0].Int;CurP←Mem[CurP]↑.Hh.Rh;
 IF NOT ( INT[CurP]>=HiMemMin) THEN EXIT; ENDLOOP; END--:867--;
SELECT Mem[CurP]↑.Hh.B0 FROM 0,1,2 =>ActiveWidth↑[1]←ActiveWidth↑[1]+Mem[
CurP+1]↑.Int;8 =>--1362:----:1362-- NULL;10 =>BEGIN--868:
IF AutoBreaking  THEN BEGIN IF( INT[PrevP]>=HiMemMin) THEN TryBreak[0,0]
 ELSE IF( INT[Mem[PrevP]↑.Hh.B0]<9) THEN TryBreak[0,0]; END--:868--;--869:
BEGIN IF(Mem[Mem[CurP+1]↑.Hh.Lh]↑.Hh.B1#0)AND (Mem[Mem[CurP+1]↑.Hh.Lh+3]↑.
Int#0) THEN BEGIN Mem[CurP+1]↑.Hh.Lh←FiniteShrink[Mem[CurP+1]↑.Hh.Lh];
 END;Q←Mem[CurP+1]↑.Hh.Lh;ActiveWidth↑[1]←ActiveWidth↑[1]+Mem[Q+1]↑.Int;
ActiveWidth↑[2+Mem[Q]↑.Hh.B0]←ActiveWidth↑[2+Mem[Q]↑.Hh.B0]+Mem[Q+2]↑.Int;
ActiveWidth↑[6]←ActiveWidth↑[6]+Mem[Q+3]↑.Int; END--:869--;
IF  SecondPass AND AutoBreaking  THEN--894:--BEGIN S←Mem[CurP]↑.Hh.Rh;
{IF S#0  THEN BEGIN--896:
--899:--  {WHILE TRUE DO BEGIN IF( INT[S]>=HiMemMin) THEN BEGIN C←Mem[S]↑.Hh.B1;
Hf←Mem[S]↑.Hh.B0;
 END  ELSE IF Mem[S]↑.Hh.B0=6  THEN BEGIN Q←Mem[S+1]↑.Hh.Rh;C←Mem[Q]↑.Hh.B1;
Hf←Mem[Q]↑.Hh.B0;
 END  ELSE IF(Mem[S]↑.Hh.B0=11)AND (Mem[S]↑.Hh.B1=0) THEN C←128  ELSE IF Mem[S
]↑.Hh.B0=8  THEN C←128  ELSE  GOTO Label31;
IF  INT[C]<128  THEN IF Eqtb↑[4255+C].Hh.Rh#0  THEN IF(Eqtb↑[4255+C].Hh.Rh=C)OR (
Eqtb↑[4805].Int>0) THEN  GOTO Label32  ELSE  GOTO Label31;S←Mem[S]↑.Hh.Rh; END ENDLOOP ;
EXITS Label32 => NULL};IF HyphenChar↑[Hf]<0  THEN  GOTO Label31;
IF HyphenChar↑[Hf]>255  THEN  GOTO Label31;Ha←S--:896--;--897:--Hn←0;
{WHILE TRUE DO BEGIN IF( INT[S]>=HiMemMin) THEN BEGIN IF Mem[S]↑.Hh.B0#Hf  THEN
 GOTO Label33;C←Mem[S]↑.Hh.B1;IF  INT[C]>=128  THEN  GOTO Label33;
IF(Eqtb↑[4255+C].Hh.Rh=0)OR (Hn=63) THEN  GOTO Label33;Hb←S;Hn←Hn+1;Hu↑[Hn]←C;
Hc↑[Hn]← INT[Eqtb↑[4255+C].Hh.Rh]-1; END  ELSE IF Mem[S]↑.Hh.B0=6  THEN--898:
BEGIN J←Hn;Q←Mem[S+1]↑.Hh.Rh;IF Mem[Q]↑.Hh.B0#Hf  THEN  GOTO Label33;
DO C←Mem[Q]↑.Hh.B1;IF  INT[C]>=128  THEN  GOTO Label33;
IF(Eqtb↑[4255+C].Hh.Rh=0)OR (J=63) THEN  GOTO Label33;J←J+1;Hu↑[J]←C;
Hc↑[J]← INT[Eqtb↑[4255+C].Hh.Rh]-1;Q←Mem[Q]↑.Hh.Rh; IF Q=0 THEN EXIT; ENDLOOP;Hb←S;Hn←J;
 END--:898-- ELSE IF(Mem[S]↑.Hh.B0#11)OR (Mem[S]↑.Hh.B1#0) THEN  GOTO Label33;
S←Mem[S]↑.Hh.Rh; END ENDLOOP ;EXITS Label33 => NULL};--:897--IF  INT[Hn]<5  THEN  GOTO Label31;
{WHILE TRUE DO BEGIN IF NOT (( INT[S]>=HiMemMin)) THEN SELECT Mem[S]↑.Hh.B0 FROM 6 => NULL;
11 =>IF Mem[S]↑.Hh.B1#0  THEN  GOTO Label34;8,10,12,3,5,4 => GOTO Label34;
 ENDCASE => GOTO Label31 ;S←Mem[S]↑.Hh.Rh; END ENDLOOP ;EXITS Label34 => NULL};--:899--Hyphenate[]; END;
EXITS Label31 => NULL}; END--:894--; END;
11 =>BEGIN IF  NOT ( INT[Mem[CurP]↑.Hh.Rh]>=HiMemMin)AND AutoBreaking  THEN IF
Mem[Mem[CurP]↑.Hh.Rh]↑.Hh.B0=10  THEN TryBreak[0,0];
ActiveWidth↑[1]←ActiveWidth↑[1]+Mem[CurP+1]↑.Int; END;
6 =>BEGIN F←Mem[CurP+1]↑.Hh.B0;
ActiveWidth↑[1]←ActiveWidth↑[1]+FontInfo↑[WidthBase↑[F]+FontInfo↑
[CharBase↑[F]+Mem[CurP+1]↑.Hh.B1].Qqqq.B0].Int; END;7 =>--870:
BEGIN S←Mem[CurP+1]↑.Hh.Lh;DiscWidth←0;
IF S=0  THEN TryBreak[Eqtb↑[4771].Int,1] ELSE BEGIN DO--871:
IF( INT[S]>=HiMemMin) THEN BEGIN F←Mem[S]↑.Hh.B0;
DiscWidth←DiscWidth+FontInfo↑[WidthBase↑[F]+FontInfo↑[
CharBase↑[F]+Mem[S]↑.Hh.B1].Qqqq.B0].Int;
 END  ELSE SELECT Mem[S]↑.Hh.B0 FROM 6 =>BEGIN F←Mem[S+1]↑.Hh.B0;
DiscWidth←DiscWidth+FontInfo↑[WidthBase↑[F]+FontInfo↑[
CharBase↑[F]+Mem[S+1]↑.Hh.B1].Qqqq.B0].Int; END;
0,1,2,11 =>DiscWidth←DiscWidth+Mem[S+1]↑.Int;
 ENDCASE =>Confusion[795]--:871--;S←Mem[S]↑.Hh.Rh; IF S=0 THEN EXIT; ENDLOOP;
ActiveWidth↑[1]←ActiveWidth↑[1]+DiscWidth;TryBreak[Eqtb↑[4770].Int,1];
ActiveWidth↑[1]←ActiveWidth↑[1]-DiscWidth; END; END--:870--;
9 =>BEGIN AutoBreaking←(Mem[CurP]↑.Hh.B1=1);
BEGIN IF  NOT ( INT[Mem[CurP]↑.Hh.Rh]>=HiMemMin)AND AutoBreaking  THEN IF Mem[
Mem[CurP]↑.Hh.Rh]↑.Hh.B0=10  THEN TryBreak[0,0];
ActiveWidth↑[1]←ActiveWidth↑[1]+Mem[CurP+1]↑.Int; END; END;
12 =>TryBreak[Mem[CurP+1]↑.Int,0];4,3,5 => NULL; ENDCASE =>Confusion[794];
PrevP←CurP;CurP←Mem[CurP]↑.Hh.Rh; END--:866-- ENDLOOP ;IF CurP=0  THEN--873:
BEGIN TryBreak[-10000,1];IF Mem[64994]↑.Hh.Rh#64994  THEN BEGIN--874:
R←Mem[64994]↑.Hh.Rh;FewestDemerits←1073741823;
DO IF Mem[R]↑.Hh.B0#2  THEN IF Mem[R+2]↑.Int<FewestDemerits  THEN
BEGIN FewestDemerits←Mem[R+2]↑.Int;BestBet←R; END;R←Mem[R]↑.Hh.Rh;
 IF R=64994 THEN EXIT; ENDLOOP;BestLine←Mem[BestBet+1]↑.Hh.Lh--:874--;
IF Eqtb↑[4786].Int=0  THEN  GOTO Label30;--875:--BEGIN R←Mem[64994]↑.Hh.Rh;
ActualLooseness←0;
DO IF Mem[R]↑.Hh.B0#2  THEN BEGIN LineDiff← INT[Mem[R+1]↑.Hh.Lh]-BestLine
;IF((LineDiff<ActualLooseness)AND (Eqtb↑[4786].Int<=LineDiff))OR ((
LineDiff>ActualLooseness)AND (Eqtb↑[4786].Int>=LineDiff)) THEN BEGIN
BestBet←R;ActualLooseness←LineDiff;FewestDemerits←Mem[R+2]↑.Int;
 END  ELSE IF(LineDiff=ActualLooseness)AND (Mem[R+2]↑.Int<FewestDemerits)
 THEN BEGIN BestBet←R;FewestDemerits←Mem[R+2]↑.Int; END; END;
R←Mem[R]↑.Hh.Rh; IF R=64994 THEN EXIT; ENDLOOP;BestLine←Mem[BestBet+1]↑.Hh.Lh; END--:875
;IF (ActualLooseness=Eqtb↑[4786].Int)OR SecondPass  THEN  GOTO Label30; END;
 END--:873--;--865:--Q←Mem[64994]↑.Hh.Rh;
WHILE Q#64994 DO BEGIN CurP←Mem[Q]↑.Hh.Rh;
IF Mem[Q]↑.Hh.B0=2  THEN FreeNode[Q,7] ELSE FreeNode[Q,3];Q←CurP; END ENDLOOP ;
Q←Passive;WHILE Q#0 DO BEGIN CurP←Mem[Q]↑.Hh.Rh;FreeNode[Q,2];
Q←CurP; END--:865-- ENDLOOP ;IF Eqtb↑[4799].Int>0  THEN PrintNl[793];
Threshold←Eqtb↑[4768].Int;SecondPass←TRUE; END ENDLOOP ;
EXITS Label30 => NULL};IF Eqtb↑[4799].Int>0  THEN EndDiagnostic[TRUE];--:863--PostLineBreak[FinalWidowPenalty]--:876--;--865:--Q←Mem[64994]↑.Hh.Rh;
WHILE Q#64994 DO BEGIN CurP←Mem[Q]↑.Hh.Rh;
IF Mem[Q]↑.Hh.B0=2  THEN FreeNode[Q,7] ELSE FreeNode[Q,3];Q←CurP; END ENDLOOP ;
Q←Passive;WHILE Q#0 DO BEGIN CurP←Mem[Q]↑.Hh.Rh;FreeNode[Q,2];
Q←CurP; END--:865-- ENDLOOP ;PackBeginLine←0; END;--:815----934:

END.