-- file: WeavePhaseII.mesa
-- Pascal-to-Mesa translator output, translated at September 23, 1986 1:27:38 pm PDT


DIRECTORY
  PascalBasic,
  PascalWizardFiles,
  WeaveProcs,
  WeaveVars;

WeavePhaseII: PROGRAM IMPORTS PascalWizardFiles, WeaveProcs, WeaveVars EXPORTS WeaveProcs = PUBLIC
BEGIN OPEN PascalBasic, PascalWizardFiles, WeaveProcs, WeaveVars;
 FinishPascal: PROCEDURE = 
BEGIN P:TextPointer;
 BEGIN IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←92;IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←80; END;
BEGIN IF  INT[TokPtr+2]>MaxToks  THEN BEGIN PascalWriteLn[file: @TermOut];
{PascalWriteLongString[file: @TermOut, item: "! Sorry, "]; PascalWriteLongString[file: @TermOut, item: "token"]; PascalWriteLongString[file: @TermOut, item: " capacity exceeded"]};Error[];
History←3;JumpOut[]; END;TokMem↑[TokPtr]←141;TokPtr←TokPtr+1; END;
AppComment[];P←Translate[];TokMem↑[TokPtr]←P+40960;TokPtr←TokPtr+1;
MakeOutput[];
IF  INT[OutPtr]>1  THEN IF OutBuf↑[OutPtr-1]=92  THEN IF OutBuf↑[OutPtr]=54
 THEN OutPtr←OutPtr-2  ELSE IF OutBuf↑[OutPtr]=55  THEN OutBuf↑[OutPtr
]←89;BEGIN IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←92;IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←112;
IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←97;IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←114; END;FinishLine[];
--IF TEXT←PTR>MAX←TXT←PTR THEN MAX←TXT←PTR:=TEXT←PTR;
-- IF TOK←PTR>MAX←TOK←PTR THEN MAX←TOK←PTR:=TOK←PTR;
-- IF SCRAP←PTR>MAX←SCR←PTR THEN MAX←SCR←PTR:=SCRAP←PTR;--TokPtr←1;
TextPtr←1;ScrapPtr←0; END;--:227----237:
 Footnote: PROCEDURE[Flag: SixteenBits] = 
BEGIN  Q:XrefNumber;
 
 {IF  INT[Xmem↑[CurXref].NumField]<=Flag  THEN  GOTO Label10;FinishLine[];
BEGIN IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←92; END;
IF Flag=0  THEN BEGIN IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←85;
 END  ELSE BEGIN IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←65; END;BEGIN IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←32;
IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←115;IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←101;
IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←99; END;BEGIN IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←116;
IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←105;IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←111;
IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←110; END;--238:--Q←CurXref;
IF  INT[Xmem↑[Xmem↑[Q].XlinkField].NumField]>Flag  THEN BEGIN IF 
OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;OutBuf↑[OutPtr]←115; END;
BEGIN IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←126; END;
{WHILE TRUE DO BEGIN OutMod[ INT[Xmem↑[CurXref].NumField]-Flag];
CurXref←Xmem↑[CurXref].XlinkField;
IF  INT[Xmem↑[CurXref].NumField]<=Flag  THEN  GOTO Label30;
IF( INT[Xmem↑[Xmem↑[CurXref].XlinkField].NumField]>Flag)OR (CurXref#Xmem↑[Q].
XlinkField) THEN BEGIN IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←44; END;
BEGIN IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←32; END;
IF  INT[Xmem↑[Xmem↑[CurXref].XlinkField].NumField]<=Flag  THEN BEGIN IF
OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←97;IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←110;
IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←100;IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←126; END; END ENDLOOP ;EXITS Label30 => NULL};--:238--BEGIN IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←46; END;EXITS Label10 => NULL}; END;--:237----250:
 PhaseIi: PROCEDURE
 = 
BEGIN ModCountPlusDefFlag:SixteenBits;--219:--ResetInput[];
BEGIN PascalWriteLn[file: @TermOut];PascalWriteLongString[file: @TermOut, item: "Writing the output file..."];
 END;ModuleCount←0;CopyLimbo[];FinishLine[];FlushBuffer[0,FALSE];
WHILE  NOT InputHasEnded DO--221:--BEGIN  ModuleCount←ModuleCount+1;
--222:--BEGIN IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←92; END;
IF Buffer↑[Loc-1]#42  THEN BEGIN IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←77;
 END  ELSE BEGIN BEGIN IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←78; END;
{PascalWriteLongString[file: @TermOut, item: "*"]; PascalWriteInteger[file: @TermOut, item: ModuleCount, fieldMinLength: 1]};PascalTextBREAK[file: @TermOut]; END;
OutMod[ModuleCount];BEGIN IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←46;
IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←32; END--:222--;SaveLine←OutLine;SavePlace←OutPtr;
--223:--DO NextControl←CopyTex[];
SELECT NextControl FROM 124 =>BEGIN StackPtr←0;CurState.ModeField←1;
OutputPascal[]; END;64 =>BEGIN IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←64; END;12 =>--224:
BEGIN BEGIN IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←92;IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←79;
IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←123; END;
WHILE( INT[Buffer↑[Loc]]>=48)AND ( INT[Buffer↑[Loc]]<=55)DO BEGIN BEGIN IF 
OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←Buffer↑[Loc]; END;Loc←Loc+1; END ENDLOOP ;
BEGIN IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←125; END; END--:224--;13 =>--225:
BEGIN BEGIN IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←92;IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←72;
IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←123; END;
WHILE(( INT[Buffer↑[Loc]]>=48)AND ( INT[Buffer↑[Loc]]<=57))OR (( INT[Buffer↑[Loc]]>=65)AND (
 INT[Buffer↑[Loc]]<=70))DO BEGIN BEGIN IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←Buffer↑[Loc]; END;Loc←Loc+1; END ENDLOOP ;
BEGIN IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←125; END; END--:225--;
134,131,132,133,146 =>BEGIN Loc←Loc-2;NextControl←GetNext[];
IF NextControl=134  THEN BEGIN IF  NOT PhaseOne  THEN BEGIN 
PascalWriteLn[file: @TermOut];PascalWriteLongString[file: @TermOut, item: "! TeX string should be in Pascal text only"];
Error[]; END; END; END;
9,10,135,137,138,139,140,141,136,142 =>BEGIN IF  NOT PhaseOne  THEN BEGIN
PascalWriteLn[file: @TermOut];PascalWriteLongString[file: @TermOut, item: "! You can't do that in TeX text"];
Error[]; END; END; ENDCASE => NULL; IF  INT[NextControl]>=143--:223-- THEN EXIT; ENDLOOP;--226:
IF  INT[NextControl]<=144  THEN BEGIN IF(SaveLine#OutLine)OR (
SavePlace#OutPtr) THEN BEGIN IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←92;
IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←89; END;SaveLine←OutLine;SavePlace←OutPtr; END;
WHILE  INT[NextControl]<=144 DO BEGIN StackPtr←0;CurState.ModeField←1;
IF NextControl=144  THEN--228:--BEGIN BEGIN TokMem↑[TokPtr]←92;
TokPtr←TokPtr+1;TokMem↑[TokPtr]←68;TokPtr←TokPtr+1;
ScrapPtr←ScrapPtr+1;Cat↑[ScrapPtr]←3;Trans↑[ScrapPtr]←TextPtr;
TextPtr←TextPtr+1;TokStart↑[TextPtr]←TokPtr; END;
NextControl←GetNext[];
IF NextControl#130  THEN BEGIN IF  NOT PhaseOne  THEN BEGIN 
PascalWriteLn[file: @TermOut];PascalWriteLongString[file: @TermOut, item: "! Improper macro definition"];Error[]; END;
 END  ELSE BEGIN TokMem↑[TokPtr]←10240+IdLookup[0];TokPtr←TokPtr+1;
ScrapPtr←ScrapPtr+1;Cat↑[ScrapPtr]←2;Trans↑[ScrapPtr]←TextPtr;
TextPtr←TextPtr+1;TokStart↑[TextPtr]←TokPtr; END;
NextControl←GetNext[]; END--:228-- ELSE--229:
BEGIN BEGIN TokMem↑[TokPtr]←92;TokPtr←TokPtr+1;
TokMem↑[TokPtr]←70;TokPtr←TokPtr+1;ScrapPtr←ScrapPtr+1;
Cat↑[ScrapPtr]←3;Trans↑[ScrapPtr]←TextPtr;TextPtr←TextPtr+1;
TokStart↑[TextPtr]←TokPtr; END;NextControl←GetNext[];
IF NextControl=130  THEN BEGIN BEGIN TokMem↑[TokPtr]←10240+IdLookup[0
];TokPtr←TokPtr+1;ScrapPtr←ScrapPtr+1;Cat↑[ScrapPtr]←2;
Trans↑[ScrapPtr]←TextPtr;TextPtr←TextPtr+1;
TokStart↑[TextPtr]←TokPtr; END;NextControl←GetNext[];
IF NextControl=30  THEN BEGIN BEGIN TokMem↑[TokPtr]←92;
TokPtr←TokPtr+1;TokMem↑[TokPtr]←83;TokPtr←TokPtr+1;
ScrapPtr←ScrapPtr+1;Cat↑[ScrapPtr]←2;Trans↑[ScrapPtr]←TextPtr;
TextPtr←TextPtr+1;TokStart↑[TextPtr]←TokPtr; END;
NextControl←GetNext[];
IF NextControl=130  THEN BEGIN BEGIN TokMem↑[TokPtr]←10240+IdLookup[0
];TokPtr←TokPtr+1;ScrapPtr←ScrapPtr+1;Cat↑[ScrapPtr]←2;
Trans↑[ScrapPtr]←TextPtr;TextPtr←TextPtr+1;
TokStart↑[TextPtr]←TokPtr; END;BEGIN ScrapPtr←ScrapPtr+1;
Cat↑[ScrapPtr]←9;Trans↑[ScrapPtr]←0; END;NextControl←GetNext[]; END;
 END; END;
IF ScrapPtr#5  THEN BEGIN IF  NOT PhaseOne  THEN BEGIN 
PascalWriteLn[file: @TermOut];PascalWriteLongString[file: @TermOut, item: "! Improper format definition"];Error[]; END; END; END--:229--;
OuterParse[];FinishPascal[]; END--:226-- ENDLOOP ;--231:--ThisModule←0;
IF  INT[NextControl]<=146  THEN BEGIN IF(SaveLine#OutLine)OR (
SavePlace#OutPtr) THEN BEGIN IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←92;
IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←89; END;StackPtr←0;CurState.ModeField←1;
IF NextControl=145  THEN NextControl←GetNext [] ELSE BEGIN  ThisModule←
CurModule;--232:--DO NextControl←GetNext[]; IF NextControl#43 THEN EXIT; ENDLOOP;
IF(NextControl#61)AND (NextControl#30) THEN BEGIN IF  NOT PhaseOne
 THEN BEGIN PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! You need an = sign after the section name"];Error[]; END;
 END  ELSE NextControl←GetNext[];
IF  INT[OutPtr]>1  THEN IF(OutBuf↑[OutPtr]=89)AND (OutBuf↑[OutPtr-1]=92) THEN
BEGIN TokMem↑[TokPtr]←139;TokPtr←TokPtr+1; END;
BEGIN TokMem↑[TokPtr]←30720+ThisModule;TokPtr←TokPtr+1;
ScrapPtr←ScrapPtr+1;Cat↑[ScrapPtr]←22;Trans↑[ScrapPtr]←TextPtr;
TextPtr←TextPtr+1;TokStart↑[TextPtr]←TokPtr; END;
CurXref←Xref↑[ThisModule];ModCountPlusDefFlag←ModuleCount+10240;
IF Xmem↑[CurXref].NumField#ModCountPlusDefFlag  THEN BEGIN BEGIN
TokMem↑[TokPtr]←132;TokPtr←TokPtr+1;TokMem↑[TokPtr]←43;
TokPtr←TokPtr+1;TokMem↑[TokPtr]←125;TokPtr←TokPtr+1;
ScrapPtr←ScrapPtr+1;Cat↑[ScrapPtr]←2;Trans↑[ScrapPtr]←TextPtr;
TextPtr←TextPtr+1;TokStart↑[TextPtr]←TokPtr; END;ThisModule←0;
 END;BEGIN TokMem↑[TokPtr]←92;TokPtr←TokPtr+1;TokMem↑[TokPtr]←83;
TokPtr←TokPtr+1;ScrapPtr←ScrapPtr+1;Cat↑[ScrapPtr]←2;
Trans↑[ScrapPtr]←TextPtr;TextPtr←TextPtr+1;
TokStart↑[TextPtr]←TokPtr; END;BEGIN TokMem↑[TokPtr]←141;
TokPtr←TokPtr+1;ScrapPtr←ScrapPtr+1;Cat↑[ScrapPtr]←9;
Trans↑[ScrapPtr]←TextPtr;TextPtr←TextPtr+1;
TokStart↑[TextPtr]←TokPtr; END;--:232-- END;
WHILE  INT[NextControl]<=146 DO BEGIN OuterParse[];--233:
IF  INT[NextControl]<146  THEN BEGIN BEGIN IF  NOT PhaseOne  THEN BEGIN 
PascalWriteLn[file: @TermOut];PascalWriteLongString[file: @TermOut, item: "! You can't do that in Pascal text"];Error[];
 END; END;NextControl←GetNext[];
 END  ELSE IF NextControl=146  THEN BEGIN BEGIN TokMem↑[TokPtr]←
30720+CurModule;TokPtr←TokPtr+1;ScrapPtr←ScrapPtr+1;Cat↑[ScrapPtr]←22;
Trans↑[ScrapPtr]←TextPtr;TextPtr←TextPtr+1;
TokStart↑[TextPtr]←TokPtr; END;NextControl←GetNext[]; END--:233--; END ENDLOOP ;
FinishPascal[]; END--:231--;--234:--IF  INT[ThisModule]>0  THEN BEGIN--236:
FirstXref←Xref↑[ThisModule];ThisXref←Xmem↑[FirstXref].XlinkField;
IF  INT[Xmem↑[ThisXref].NumField]>10240  THEN BEGIN MidXref←ThisXref;
CurXref←0;DO NextXref←Xmem↑[ThisXref].XlinkField;
Xmem↑[ThisXref].XlinkField←CurXref;CurXref←ThisXref;
ThisXref←NextXref; IF  INT[Xmem↑[ThisXref].NumField]<=10240 THEN EXIT; ENDLOOP;
Xmem↑[FirstXref].XlinkField←CurXref; END  ELSE MidXref←0;CurXref←0;
WHILE ThisXref#0 DO BEGIN NextXref←Xmem↑[ThisXref].XlinkField;
Xmem↑[ThisXref].XlinkField←CurXref;CurXref←ThisXref;
ThisXref←NextXref; END ENDLOOP ;
IF  INT[MidXref]>0  THEN Xmem↑[MidXref].XlinkField←CurXref  ELSE Xmem↑
[FirstXref].XlinkField←CurXref;
CurXref←Xmem↑[FirstXref].XlinkField--:236--;Footnote[10240];
Footnote[0]; END--:234--;--239:--BEGIN IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←92;
IF OutPtr=LineLength  THEN BreakOut[];OutPtr←OutPtr+1;
OutBuf↑[OutPtr]←102;IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←105; END;FinishLine[];
FlushBuffer[0,FALSE];--:239-- END--:221----:219-- ENDLOOP ; END;
END.