-- file: WeaveCode.mesa
-- Pascal-to-Mesa translator output, translated at September 15, 1985 4:11:16 pm PDT


DIRECTORY
  PascalBasic,
  PascalWizardFiles,
  WeaveProcs,
  WeaveVars;

WeaveCode: PROGRAM IMPORTS PascalWizardFiles, WeaveProcs, WeaveVars EXPORTS WeaveProcs = PUBLIC
BEGIN OPEN PascalBasic, PascalWizardFiles, WeaveProcs, WeaveVars;
 ControlCode: PROCEDURE[C: AsciiCode] RETURNS[ControlCodeResult: EightBits]
 = 
BEGIN SELECT C FROM 64 =>ControlCodeResult←64;39 =>ControlCodeResult←12;
34 =>ControlCodeResult←13;36 =>ControlCodeResult←135;32,9,42 =>ControlCodeResult←147;
61 =>ControlCodeResult←2;92 =>ControlCodeResult←3;68,100 =>ControlCodeResult←144;
70,102 =>ControlCodeResult←143;123 =>ControlCodeResult←9;125 =>ControlCodeResult←10;
80,112 =>ControlCodeResult←145;38 =>ControlCodeResult←136;60 =>ControlCodeResult←146;
62 =>BEGIN BEGIN IF  NOT PhaseOne  THEN BEGIN PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! Extra @>"];Error[]; END; END;ControlCodeResult←0; END;
84,116 =>ControlCodeResult←134;33 =>ControlCodeResult←126;63 =>ControlCodeResult←125;
94 =>ControlCodeResult←131;58 =>ControlCodeResult←132;46 =>ControlCodeResult←133;
44 =>ControlCodeResult←137;124 =>ControlCodeResult←138;47 =>ControlCodeResult←139;
35 =>ControlCodeResult←140;43 =>ControlCodeResult←141;59 =>ControlCodeResult←142;--89:
--48,49,50:BEGIN TRACING:=C-48;CONTROL←CODE:=0;END;----:89
 ENDCASE =>BEGIN BEGIN IF  NOT PhaseOne  THEN BEGIN PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! Unknown control code"];Error[]; END; END;ControlCodeResult←0;
 END ; END;--:88----90:-- SkipLimbo: PROCEDURE = 
BEGIN  C:AsciiCode;
 {WHILE TRUE DO IF  INT[Loc]>Limit  THEN BEGIN GetLine[];
IF InputHasEnded  THEN  GOTO Label10; END  ELSE BEGIN Buffer↑[Limit+1]←64;
WHILE Buffer↑[Loc]#64 DO Loc←Loc+1 ENDLOOP ;IF  INT[Loc]<=Limit  THEN BEGIN Loc←Loc+2;
C←Buffer↑[Loc-1];IF(C=32)OR (C=9)OR (C=42) THEN  GOTO Label10; END; END ENDLOOP ;EXITS Label10 => NULL}; END;
--:90----91:-- SkipTex: PROCEDURE RETURNS[SkipTexResult: EightBits] = 
BEGIN  C:EightBits;
 {WHILE TRUE DO BEGIN IF  INT[Loc]>Limit  THEN BEGIN GetLine[];
IF InputHasEnded  THEN BEGIN C←147; GOTO Label30; END; END;
Buffer↑[Limit+1]←64;DO C←Buffer↑[Loc];Loc←Loc+1;
IF C=124  THEN  GOTO Label30; IF C=64 THEN EXIT; ENDLOOP;
IF  INT[Loc]<=Limit  THEN BEGIN C←ControlCode[Buffer↑[Loc]];Loc←Loc+1;
 GOTO Label30; END; END ENDLOOP ;EXITS Label30 => NULL};SkipTexResult←C; END;--:91----92:
 SkipComment: PROCEDURE[Bal: EightBits] RETURNS[SkipCommentResult: EightBits] = 
BEGIN 
 C:AsciiCode;
 {WHILE TRUE DO BEGIN IF  INT[Loc]>Limit  THEN BEGIN GetLine[];
IF InputHasEnded  THEN BEGIN Bal←0; GOTO Label30; END; END;C←Buffer↑[Loc];
Loc←Loc+1;IF C=124  THEN  GOTO Label30;--93:--IF C=64  THEN BEGIN C←Buffer↑[Loc];
IF(C#32)AND (C#9)AND (C#42) THEN Loc←Loc+1  ELSE BEGIN Loc←Loc-1;
Bal←0; GOTO Label30;
 END ; END  ELSE IF(C=92)AND (Buffer↑[Loc]#64) THEN Loc←Loc+1  ELSE IF C=123
 THEN Bal←Bal+1  ELSE IF C=125  THEN BEGIN Bal←Bal-1;
IF Bal=0  THEN  GOTO Label30; END--:93--; END ENDLOOP ;EXITS Label30 => NULL};SkipCommentResult←Bal; END;--:92----96:
 GetNext: PROCEDURE RETURNS[GetNextResult: EightBits] = 
BEGIN  C:EightBits;
D:EightBits;J, K:PascalInteger[0..LongestName];
 DO {--Label20:--{IF  INT[Loc]>Limit  THEN BEGIN GetLine[];
IF InputHasEnded  THEN BEGIN C←147; GOTO Label31; END; END;C←Buffer↑[Loc];
Loc←Loc+1;IF ScanningHex  THEN--97:
IF(( INT[C]>=48)AND ( INT[C]<=57))OR (( INT[C]>=65)AND ( INT[C]<=70)) THEN  GOTO Label31  ELSE ScanningHex
←FALSE--:97--;
SELECT C FROM 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85
,86,87,88,89,90,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111
,112,113,114,115,116,117,118,119,120,121,122 =>--99:
BEGIN IF((C=69)OR (C=101))AND ( INT[Loc]>1) THEN IF( INT[Buffer↑[Loc-2]]<=57)AND ( INT[Buffer↑
[Loc-2]]>=48) THEN C←128;IF C#128  THEN BEGIN Loc←Loc-1;IdFirst←Loc;
DO Loc←Loc+1;D←Buffer↑[Loc];
 IF(( INT[D]<48)OR (( INT[D]>57)AND ( INT[D]<65))OR (( INT[D]>90)AND ( INT[D]<97))OR ( INT[D]>122))AND (D#95) THEN EXIT; ENDLOOP;
C←130;IdLoc←Loc; END; END--:99--;39,34 =>--100:--BEGIN IdFirst←Loc-1;
DO D←Buffer↑[Loc];Loc←Loc+1;
IF  INT[Loc]>Limit  THEN BEGIN BEGIN IF  NOT PhaseOne  THEN BEGIN 
PascalWriteLn[file: @TermOut];PascalWriteLongString[file: @TermOut, item: "! String constant didn't end"];Error[]; END; END;
Loc←Limit;D←C; END; IF D=C THEN EXIT; ENDLOOP;IdLoc←Loc;C←129; END--:100--;64 =>--101:
BEGIN C←ControlCode[Buffer↑[Loc]];Loc←Loc+1;
IF C=126  THEN BEGIN XrefSwitch←10240; GOTO Label20;
 END  ELSE IF C=125  THEN BEGIN XrefSwitch←0; GOTO Label20;
 END  ELSE IF( INT[C]<=134)AND ( INT[C]>=131) THEN--107:--BEGIN IdFirst←Loc;
Buffer↑[Limit+1]←64;WHILE Buffer↑[Loc]#64 DO Loc←Loc+1 ENDLOOP ;IdLoc←Loc;
IF  INT[Loc]>Limit  THEN BEGIN BEGIN IF  NOT PhaseOne  THEN BEGIN 
PascalWriteLn[file: @TermOut];PascalWriteLongString[file: @TermOut, item: "! Control text didn't end"];Error[]; END; END;
Loc←Limit; END  ELSE BEGIN Loc←Loc+2;
IF Buffer↑[Loc-1]#62  THEN BEGIN IF  NOT PhaseOne  THEN BEGIN 
PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! Control codes are forbidden in control text"];Error[];
 END; END; END; END--:107
 ELSE IF C=13  THEN ScanningHex←TRUE  ELSE IF C=146  THEN--102:--BEGIN--104:
K←0;{WHILE TRUE DO BEGIN IF  INT[Loc]>Limit  THEN BEGIN GetLine[];
IF InputHasEnded  THEN BEGIN BEGIN IF  NOT PhaseOne  THEN BEGIN 
PascalWriteLn[file: @TermOut];PascalWriteLongString[file: @TermOut, item: "! Input ended in section name"];Error[]; END; END;
Loc←1; GOTO Label30; END; END;D←Buffer↑[Loc];--105:
IF D=64  THEN BEGIN D←Buffer↑[Loc+1];IF D=62  THEN BEGIN Loc←Loc+2;
 GOTO Label30; END;
IF(D=32)OR (D=9)OR (D=42) THEN BEGIN BEGIN IF  NOT PhaseOne  THEN BEGIN
PascalWriteLn[file: @TermOut];PascalWriteLongString[file: @TermOut, item: "! Section name didn't end"];Error[];
 END; END; GOTO Label30; END;K←K+1;ModText↑[K]←64;Loc←Loc+1; END--:105--;
Loc←Loc+1;IF  INT[K]<LongestName-1  THEN K←K+1;
IF(D=32)OR (D=9) THEN BEGIN D←32;IF ModText↑[K-1]=32  THEN K←K-1; END;
ModText↑[K]←D; END ENDLOOP ;EXITS Label30 => NULL};--106:
IF  INT[K]>=LongestName-2  THEN BEGIN BEGIN PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! Section name too long: "]; END;
FOR i:INT    IN [ INT[1 ].. INT[25 ]] DO  J ← i; PascalWriteChar[file: @TermOut, item: Xchr↑[ModText↑[J]]] ENDLOOP;
PascalWriteLongString[file: @TermOut, item: "..."];IF History=0  THEN History←1; END--:106--;
IF(ModText↑[K]=32)AND ( INT[K]>0) THEN K←K-1--:104--;
IF  INT[K]>3  THEN BEGIN IF(ModText↑[K]=46)AND (ModText↑[K-1]=46)AND (ModText↑[K
-2]=46) THEN CurModule←PrefixLookup[K-3] ELSE CurModule←ModLookup[K]
; END  ELSE CurModule←ModLookup[K];XrefSwitch←0; END--:102
 ELSE IF C=2  THEN--108:--BEGIN IdFirst←Loc;Loc←Loc+1;
Buffer↑[Limit+1]←64;Buffer↑[Limit+2]←62;
WHILE(Buffer↑[Loc]#64)OR (Buffer↑[Loc+1]#62)DO Loc←Loc+1 ENDLOOP ;
IF  INT[Loc]>=Limit  THEN BEGIN IF  NOT PhaseOne  THEN BEGIN PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! Verbatim string didn't end"];Error[]; END; END;
IdLoc←Loc;Loc←Loc+2; END--:108--; END--:101--;--98:
46 =>IF Buffer↑[Loc]=46  THEN BEGIN IF  INT[Loc]<=Limit  THEN BEGIN C←32;
Loc←Loc+1; END;
 END  ELSE IF Buffer↑[Loc]=41  THEN BEGIN IF  INT[Loc]<=Limit  THEN BEGIN C←93;
Loc←Loc+1; END; END;
58 =>IF Buffer↑[Loc]=61  THEN BEGIN IF  INT[Loc]<=Limit  THEN BEGIN C←24;
Loc←Loc+1; END; END;
61 =>IF Buffer↑[Loc]=61  THEN BEGIN IF  INT[Loc]<=Limit  THEN BEGIN C←30;
Loc←Loc+1; END; END;
62 =>IF Buffer↑[Loc]=61  THEN BEGIN IF  INT[Loc]<=Limit  THEN BEGIN C←29;
Loc←Loc+1; END; END;
60 =>IF Buffer↑[Loc]=61  THEN BEGIN IF  INT[Loc]<=Limit  THEN BEGIN C←28;
Loc←Loc+1; END;
 END  ELSE IF Buffer↑[Loc]=62  THEN BEGIN IF  INT[Loc]<=Limit  THEN BEGIN C←26;
Loc←Loc+1; END; END;
40 =>IF Buffer↑[Loc]=42  THEN BEGIN IF  INT[Loc]<=Limit  THEN BEGIN C←9;
Loc←Loc+1; END;
 END  ELSE IF Buffer↑[Loc]=46  THEN BEGIN IF  INT[Loc]<=Limit  THEN BEGIN C←91;
Loc←Loc+1; END; END;
42 =>IF Buffer↑[Loc]=41  THEN BEGIN IF  INT[Loc]<=Limit  THEN BEGIN C←10;
Loc←Loc+1; END; END;--:98--32,9 => GOTO Label20; ENDCASE => NULL;
EXITS Label31 => NULL};--IF TROUBLE←SHOOTING THEN DEBUG←HELP;--GetNextResult←C;EXIT; EXITS Label20 => NULL} ENDLOOP; END;--:96----112:
 CopyLimbo: PROCEDURE = 
BEGIN 
 C:AsciiCode;
 {WHILE TRUE DO IF  INT[Loc]>Limit  THEN BEGIN FinishLine[];GetLine[];
IF InputHasEnded  THEN  GOTO Label10; END  ELSE BEGIN Buffer↑[Limit+1]←64;
--134:--WHILE Buffer↑[Loc]#64 DO BEGIN BEGIN IF OutPtr=LineLength  THEN
BreakOut[];OutPtr←OutPtr+1;OutBuf↑[OutPtr]←Buffer↑[Loc]; END;
Loc←Loc+1; END ENDLOOP ;IF  INT[Loc]<=Limit  THEN BEGIN Loc←Loc+2;C←Buffer↑[Loc-1];
IF(C=32)OR (C=9)OR (C=42) THEN  GOTO Label10;
IF(C#122)AND (C#90) THEN BEGIN BEGIN IF OutPtr=LineLength  THEN
BreakOut[];OutPtr←OutPtr+1;OutBuf↑[OutPtr]←64; END;
IF C#64  THEN BEGIN IF  NOT PhaseOne  THEN BEGIN PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! Double @ required outside of sections"];Error[]; END; END;
 END; END--:134--; END ENDLOOP ;EXITS Label10 => NULL}; END;--:133----135:-- CopyTex: PROCEDURE RETURNS[CopyTexResult: EightBits]
 = 
BEGIN  C:EightBits;
 {WHILE TRUE DO BEGIN IF  INT[Loc]>Limit  THEN BEGIN FinishLine[];GetLine[];
IF InputHasEnded  THEN BEGIN C←147; GOTO Label30; END; END;
Buffer↑[Limit+1]←64;--136:--DO C←Buffer↑[Loc];Loc←Loc+1;
IF C=124  THEN  GOTO Label30;
IF C#64  THEN BEGIN BEGIN IF OutPtr=LineLength  THEN BreakOut[];
OutPtr←OutPtr+1;OutBuf↑[OutPtr]←C; END;
IF(OutPtr=1)AND ((C=32)OR (C=9)) THEN OutPtr←OutPtr-1; END; IF C=64 THEN EXIT; ENDLOOP;
IF  INT[Loc]<=Limit  THEN BEGIN C←ControlCode[Buffer↑[Loc]];Loc←Loc+1;
 GOTO Label30; END--:136--; END ENDLOOP ;EXITS Label30 => NULL};CopyTexResult←C; END;--:135----137:
 CopyComment: PROCEDURE[Bal: EightBits] RETURNS[CopyCommentResult: EightBits] = 
BEGIN 
 C:AsciiCode;
 {WHILE TRUE DO BEGIN IF  INT[Loc]>Limit  THEN BEGIN GetLine[];
IF InputHasEnded  THEN BEGIN  BEGIN IF  NOT PhaseOne  THEN BEGIN 
PascalWriteLn[file: @TermOut];PascalWriteLongString[file: @TermOut, item: "! Input ended in mid-comment"];Error[]; END; END;
Loc←1;--139:--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]←32;TokPtr←TokPtr+1; END;
DO 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]←125;TokPtr←TokPtr+1; END;
Bal←Bal-1; IF Bal=0 THEN EXIT; ENDLOOP; GOTO Label30;--:139-- END; END;C←Buffer↑[Loc];Loc←Loc+1;
IF C=124  THEN  GOTO Label30;
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]←C;TokPtr←TokPtr+1; END;
--138:--IF C=64  THEN BEGIN Loc←Loc+1;
IF Buffer↑[Loc-1]#64  THEN BEGIN  BEGIN IF  NOT PhaseOne  THEN BEGIN
PascalWriteLn[file: @TermOut];PascalWriteLongString[file: @TermOut, item: "! Illegal use of @ in comment"];Error[];
 END; END;Loc←Loc-2;TokPtr←TokPtr-1;--139:
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]←32;TokPtr←TokPtr+1; END;
DO 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]←125;TokPtr←TokPtr+1; END;
Bal←Bal-1; IF Bal=0 THEN EXIT; ENDLOOP; GOTO Label30;--:139-- END;
 END  ELSE IF(C=92)AND (Buffer↑[Loc]#64) THEN BEGIN 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]←Buffer↑[Loc];
TokPtr←TokPtr+1; END;Loc←Loc+1;
 END  ELSE IF C=123  THEN Bal←Bal+1  ELSE IF C=125  THEN BEGIN Bal←Bal-1;
IF Bal=0  THEN  GOTO Label30; END--:138--; END ENDLOOP ;EXITS Label30 => NULL};CopyCommentResult←Bal; END;--:137

END.