-- file: TanglePrivate.mesa
-- Pascal-to-Mesa translator output, translated at September 23, 1986 11:39:50 am PDT


DIRECTORY
  PascalBasic,
  PascalWizardFiles;

TanglePrivate: DEFINITIONS IMPORTS  =
BEGIN OPEN PascalBasic, PascalWizardFiles;
--8:--BufSize: PascalInteger =5000;
MaxBytes: PascalInteger =45000;
MaxToks: PascalInteger =50000;
MaxNames: PascalInteger =4000;

MaxTexts: PascalInteger =2000;
HashSize: PascalInteger =353;
LongestName: PascalInteger =400;
LineLength: PascalInteger =72;

OutBufSize: PascalInteger =144;
StackSize: PascalInteger =50;
MaxIdLength: PascalInteger =72;
UnambigLength: PascalInteger =12;
--:8
--11:--AsciiCode: TYPE =PascalInteger[0..127];
--:11----12:--TextFile: TYPE =   PascalTextFile;
--:12
--37:--EightBits: TYPE =PascalInteger[0..255];
SixteenBits: TYPE =PascalInteger[0..65535];
--:37----39:
NamePointer: TYPE =PascalInteger[0..MaxNames];
--:39----43:--TextPointer: TYPE =PascalInteger[0..MaxTexts];
--:43----78:
OutputState: TYPE =RECORD [ EndField:SixteenBits,ByteField:SixteenBits,
NameField:NamePointer,ReplField:TextPointer,ModField:PascalInteger[0..12287]];

History: PascalInteger[0..3];
Xord: LONG POINTER TO ARRAY PascalChar OF  AsciiCode;
Xchr: LONG POINTER TO ARRAY AsciiCode OF  PascalChar;

TermOut: TextFile;

WebFile: TextFile;

ChangeFile: TextFile;

PascalFile: TextFile;

Pool: TextFile;
Buffer: LONG POINTER TO ARRAY PascalInteger[0..BufSize] OF  AsciiCode;

PhaseOne: PascalBoolean;
ByteStart: LONG POINTER TO ARRAY PascalInteger[0..MaxNames] OF  SixteenBits;
TokStart: LONG POINTER TO ARRAY PascalInteger[0..MaxTexts] OF  SixteenBits;
Link: LONG POINTER TO ARRAY PascalInteger[0..MaxNames] OF  SixteenBits;
Ilk: LONG POINTER TO ARRAY PascalInteger[0..MaxNames] OF  SixteenBits;
Equiv: LONG POINTER TO ARRAY PascalInteger[0..MaxNames] OF  SixteenBits;
TextLink: LONG POINTER TO ARRAY PascalInteger[0..MaxTexts] OF  SixteenBits;

NamePtr: NamePointer;

StringPtr: NamePointer;
BytePtr: LONG POINTER TO ARRAY PascalInteger[0..1] OF  PascalInteger[0..MaxBytes];

PoolCheckSum: PascalInteger;

TextPtr: TextPointer;
TokPtr: LONG POINTER TO ARRAY PascalInteger[0..2] OF  PascalInteger[0..MaxToks];

Z: PascalInteger[0..2];

IdFirst: PascalInteger[0..BufSize];

IdLoc: PascalInteger[0..BufSize];

DoubleChars: PascalInteger[0..BufSize];
Hash: LONG POINTER TO ARRAY PascalInteger[0..HashSize] OF  SixteenBits;
ChopHash: LONG POINTER TO ARRAY PascalInteger[0..HashSize] OF  SixteenBits;
ChoppedId: LONG POINTER TO ARRAY PascalInteger[0..UnambigLength] OF  AsciiCode;
ModText: LONG POINTER TO ARRAY PascalInteger[0..LongestName] OF  AsciiCode;

LastUnnamed: TextPointer;

CurState: OutputState;
Stack: LONG POINTER TO ARRAY PascalInteger[1..StackSize] OF  OutputState;

StackPtr: PascalInteger[0..StackSize];

Zo: PascalInteger[0..2];

BraceLevel: EightBits;

CurVal: PascalInteger;
OutBuf: LONG POINTER TO ARRAY PascalInteger[0..OutBufSize] OF  AsciiCode;

OutPtr: PascalInteger[0..OutBufSize];

BreakPtr: PascalInteger[0..OutBufSize];

SemiPtr: PascalInteger[0..OutBufSize];

OutState: EightBits;

OutVal: PascalInteger;

OutApp: PascalInteger;

OutSign: AsciiCode;

LastSign: PascalInteger[-1..1];
OutContrib: LONG POINTER TO ARRAY PascalInteger[1..LineLength] OF  AsciiCode;

Line: PascalInteger;

OtherLine: PascalInteger;

TempLine: PascalInteger;

Limit: PascalInteger[0..BufSize];

Loc: PascalInteger[0..BufSize];

InputHasEnded: PascalBoolean;

Changing: PascalBoolean;
ChangeBuffer: LONG POINTER TO ARRAY PascalInteger[0..BufSize] OF  AsciiCode;

ChangeLimit: PascalInteger[0..BufSize];

CurModule: NamePointer;

ScanningHex: PascalBoolean;

NextControl: EightBits;

CurReplText: TextPointer;

ModuleCount: PascalInteger[0..12287];

--:171----179:----TROUBLE←SHOOTING:BOOLEAN;
-- DDT:INTEGER;DD:INTEGER;DEBUG←CYCLE:INTEGER;DEBUG←SKIPPED:INTEGER;
-- TERM←IN:TEXT←FILE;----:179----185:----WO:0..1;----:185----188:
 TtyReset: PROCEDURE[ F: LONG POINTER TO TextFile];


 TtyRewrite: PROCEDURE[ F: LONG POINTER TO TextFile];


 FileReset: PROCEDURE[ F: LONG POINTER TO TextFile,Ext: Alfa];


 FileRewrite: PROCEDURE[ F: LONG POINTER TO TextFile,Ext: Alfa];


 FileClose: PROCEDURE[ F: LONG POINTER TO TextFile];


 FileGetPos: PROCEDURE[ F: LONG POINTER TO TextFile] RETURNS[FileGetPosResult: PascalInteger];

--:188----30:
--PROCEDURE DEBUG←HELP;FORWARD;----:30----31:-- Error: PROCEDURE
;

 JumpOut: PROCEDURE;

 Initialize: PROCEDURE;

 OpenInput: PROCEDURE
;

 InputLn: PROCEDURE[ F: LONG POINTER TO TextFile] RETURNS[InputLnResult: PascalBoolean];

 PrintId: PROCEDURE[P: NamePointer];

 IdLookup: PROCEDURE[T: EightBits] RETURNS[IdLookupResult: NamePointer]
;

 ModLookup: PROCEDURE[L: SixteenBits] RETURNS[ModLookupResult: NamePointer];

 PrefixLookup: PROCEDURE[L: SixteenBits] RETURNS[PrefixLookupResult: NamePointer];

 StoreTwoBytes: PROCEDURE[X: SixteenBits]
;

--74:----PROCEDURE PRINT←REPL(P:TEXT←POINTER);VAR K:0..MAX←TOKS;
-- A:SIXTEEN←BITS;ZP:0..2;
-- BEGIN IF P>=TEXT←PTR THEN WRITE(TERM←OUT,'BAD')ELSE BEGIN K:=TOK←START[P
-- ];ZP:=P MOD 3;WHILE K<TOK←START[P+3]DO BEGIN A:=TOK←MEM[ZP,K];
-- IF A>=128 THEN[75:]BEGIN K:=K+1;
-- IF A<168 THEN BEGIN A:=(A-128)*256+TOK←MEM[ZP,K];PRINT←ID(A);
-- IF BYTE←MEM[A MOD 2,BYTE←START[A]]=34 THEN WRITE(TERM←OUT,'"')ELSE WRITE
-- (TERM←OUT,' ');END ELSE IF A<208 THEN BEGIN WRITE(TERM←OUT,'@<');
-- PRINT←ID((A-168)*256+TOK←MEM[ZP,K]);WRITE(TERM←OUT,'@>');
-- END ELSE BEGIN A:=(A-208)*256+TOK←MEM[ZP,K];
-- WRITE(TERM←OUT,'@',XCHR[123],A:1,'@',XCHR[125]);END;
-- END[:75]ELSE[76:]CASE A OF 9:WRITE(TERM←OUT,'@',XCHR[123]);
-- 10:WRITE(TERM←OUT,'@',XCHR[125]);12:WRITE(TERM←OUT,'@''');
-- 13:WRITE(TERM←OUT,'@"');125:WRITE(TERM←OUT,'@$');0:WRITE(TERM←OUT,'#');
-- 64:WRITE(TERM←OUT,'@@');2:WRITE(TERM←OUT,'@=');3:WRITE(TERM←OUT,'@\');
-- OTHERS:WRITE(TERM←OUT,XCHR[A])END[:76];K:=K+1;END;END;END;----:74----84:
 PushLevel: PROCEDURE[P: NamePointer]
;

 PopLevel: PROCEDURE;

 GetOutput: PROCEDURE RETURNS[GetOutputResult: SixteenBits];

 FlushBuffer: PROCEDURE
;

 AppVal: PROCEDURE[V: PascalInteger]
;

 SendOut: PROCEDURE[T: EightBits,
V: SixteenBits];

--:101----106:-- SendSign: PROCEDURE[V: PascalInteger]
;

 SendVal: PROCEDURE[V: PascalInteger];

--:107----113:-- SendTheOutput: PROCEDURE;

 LinesDontMatch: PROCEDURE RETURNS[LinesDontMatchResult: PascalBoolean]
;

 PrimeTheChangeBuffer: PROCEDURE;

--132:-- CheckChange: PROCEDURE;

 GetLine: PROCEDURE;

 ControlCode: PROCEDURE[C: AsciiCode] RETURNS[ControlCodeResult: EightBits]
;

 SkipAhead: PROCEDURE RETURNS[SkipAheadResult: EightBits];

--:140----141:-- SkipComment: PROCEDURE;

 GetNext: PROCEDURE RETURNS[GetNextResult: EightBits];

--:145----157:-- ScanNumeric: PROCEDURE[P: NamePointer];

 ScanRepl: PROCEDURE[T: EightBits];

 DefineMacro: PROCEDURE[T: EightBits];

 ScanModule: PROCEDURE
;

Error9999: ERROR;

END.