-- file: TangleCode.mesa
-- Pascal-to-Mesa translator output, translated at September 14, 1985 3:58:20 pm PDT


DIRECTORY
  PascalBasic,
  PascalWizardFiles,
  TanglePrivate;

TangleCode: PROGRAM IMPORTS PascalWizardFiles, TanglePrivate EXPORTS TanglePrivate = PUBLIC
BEGIN OPEN PascalBasic, PascalWizardFiles, TanglePrivate;
 ControlCode: PROCEDURE[C: AsciiCode] RETURNS[ControlCodeResult: EightBits]
 = 
BEGIN SELECT C FROM 64 =>ControlCodeResult←64;39 =>ControlCodeResult←12;
34 =>ControlCodeResult←13;36 =>ControlCodeResult←125;32,9 =>ControlCodeResult←136;
42 =>BEGIN {PascalWriteLongString[file: @TermOut, item: "*"]; PascalWriteInteger[file: @TermOut, item: ModuleCount+1, fieldMinLength: 1]};PascalTextBREAK[file: @TermOut];
ControlCodeResult←136; END;68,100 =>ControlCodeResult←133;70,102 =>ControlCodeResult←132;
123 =>ControlCodeResult←9;125 =>ControlCodeResult←10;80,112 =>ControlCodeResult←134;
84,116,94,46,58 =>ControlCodeResult←131;38 =>ControlCodeResult←127;
60 =>ControlCodeResult←135;61 =>ControlCodeResult←2;92 =>ControlCodeResult←3;
 ENDCASE =>ControlCodeResult←0 ; END;--:139----140:
 SkipAhead: PROCEDURE RETURNS[SkipAheadResult: EightBits] = 
BEGIN  C:EightBits;
 {WHILE TRUE DO BEGIN IF  INT[Loc]>Limit  THEN BEGIN GetLine[];
IF InputHasEnded  THEN BEGIN C←136; GOTO Label30; END; END;
Buffer↑[Limit+1]←64;WHILE Buffer↑[Loc]#64 DO Loc←Loc+1 ENDLOOP ;
IF  INT[Loc]<=Limit  THEN BEGIN Loc←Loc+2;C←ControlCode[Buffer↑[Loc-1]];
IF(C#0)OR (Buffer↑[Loc-1]=62) THEN  GOTO Label30; END; END ENDLOOP ;EXITS Label30 => NULL};SkipAheadResult←C; END;
--:140----141:-- SkipComment: PROCEDURE = 
BEGIN  Bal:EightBits;
C:AsciiCode; Bal←0;
{WHILE TRUE DO BEGIN IF  INT[Loc]>Limit  THEN BEGIN GetLine[];
IF InputHasEnded  THEN BEGIN BEGIN PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! Input ended in mid-comment"];Error[]; END; GOTO Label10; END;
 END;C←Buffer↑[Loc];Loc←Loc+1;--142:--IF C=64  THEN BEGIN C←Buffer↑[Loc];
IF(C#32)AND (C#9)AND (C#42)AND (C#122)AND (C#90) THEN Loc←Loc+1  ELSE
BEGIN BEGIN PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! Section ended in mid-comment"];Error[]; END;Loc←Loc-1;
 GOTO Label10;
 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 IF Bal=0  THEN  GOTO Label10;
Bal←Bal-1; END--:142--; END ENDLOOP ;EXITS Label10 => NULL}; END;--:141----145:
 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←136; GOTO Label31; END; END;C←Buffer↑[Loc];
Loc←Loc+1;IF ScanningHex  THEN--146:
IF(( INT[C]>=48)AND ( INT[C]<=57))OR (( INT[C]>=65)AND ( INT[C]<=70)) THEN  GOTO Label31  ELSE ScanningHex
←FALSE--:146--;
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 =>--148:
BEGIN IF((C=101)OR (C=69))AND ( INT[Loc]>1) THEN IF( INT[Buffer↑[Loc-2]]<=57)AND ( INT[Buffer↑
[Loc-2]]>=48) THEN C←0;IF C#0  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;
IF  INT[Loc]>IdFirst+1  THEN BEGIN C←130;IdLoc←Loc; END; END  ELSE C←69;
 END--:148--;34 =>--149:--BEGIN DoubleChars←0;IdFirst←Loc-1;
DO D←Buffer↑[Loc];Loc←Loc+1;
IF(D=34)OR (D=64) THEN IF Buffer↑[Loc]=D  THEN BEGIN Loc←Loc+1;D←0;
DoubleChars←DoubleChars+1;
 END  ELSE BEGIN IF D=64  THEN BEGIN PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! Double @ sign missing"];Error[];
 END ; END  ELSE IF  INT[Loc]>Limit  THEN BEGIN BEGIN PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! String constant didn't end"];Error[]; END;D←34; END;
 IF D=34 THEN EXIT; ENDLOOP;IdLoc←Loc-1;C←130; END--:149--;64 =>--150:
BEGIN C←ControlCode[Buffer↑[Loc]];Loc←Loc+1;
IF C=0  THEN  GOTO Label20  ELSE IF C=13  THEN ScanningHex←TRUE  ELSE IF C=135
 THEN--151:--BEGIN--153:--
 K←0;
{WHILE TRUE DO BEGIN IF  INT[Loc]>Limit  THEN BEGIN GetLine[];
IF InputHasEnded  THEN BEGIN BEGIN PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! Input ended in section name"];Error[]; END; GOTO Label30; END;
 END;D←Buffer↑[Loc];--154:--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 PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! Section name didn't end"];Error[]; END; GOTO Label30; END;
K←K+1;ModText↑[K]←64;Loc←Loc+1; END--:154--;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};--155:
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--:155--;
IF(ModText↑[K]=32)AND ( INT[K]>0) THEN K←K-1;--:153--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]; END--:151
 ELSE IF C=131  THEN BEGIN DO C←SkipAhead[]; IF C#64 THEN EXIT; ENDLOOP;
IF Buffer↑[Loc-1]#62  THEN BEGIN PascalWriteLn[file: @TermOut];
PascalWriteLongString[file: @TermOut, item: "! Improper @ within control text"];Error[]; END; GOTO Label20;
 END; END--:150--;--147:
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;--:147--32,9 => GOTO Label20;123 =>BEGIN SkipComment[]; GOTO Label20;
 END; ENDCASE => NULL;EXITS Label31 => NULL};--IF TROUBLE←SHOOTING THEN DEBUG←HELP;--GetNextResult←C;EXIT; EXITS Label20 => NULL} ENDLOOP; END;

END.