-- file: TangleImpl.mesa -- Pascal-to-Mesa translator output, translated at September 14, 1985 3:58:20 pm PDT DIRECTORY PascalBasic, PascalWizardFiles, TanglePrivate; TangleImpl: PROGRAM IMPORTS PascalBasic, PascalWizardFiles, TanglePrivate EXPORTS TanglePrivate = PUBLIC BEGIN OPEN PascalBasic, PascalWizardFiles, TanglePrivate; --2:----4:----$C-,A+,D- ----[$C+,D+]----:4 --:78----9:-- History: PascalInteger[0..3]; --:9----13:--Xord: LONG POINTER TO ARRAY PascalChar OF AsciiCode ← PascalStaticZone.NEW[ARRAY PascalChar OF AsciiCode]; Xchr: LONG POINTER TO ARRAY AsciiCode OF PascalChar ← PascalStaticZone.NEW[ARRAY AsciiCode OF PascalChar]; --:13----20:-- TermOut: TextFile; --:20----23: WebFile: TextFile; ChangeFile: TextFile; --:23----25: PascalFile: TextFile; Pool: TextFile; --:25----27: Buffer: LONG POINTER TO ARRAY PascalInteger[0..5000] OF AsciiCode ← PascalStaticZone.NEW[ARRAY PascalInteger[0..5000] OF AsciiCode]; --:27----29:-- PhaseOne: PascalBoolean; ByteStart: LONG POINTER TO ARRAY PascalInteger[0..4000] OF SixteenBits ← PascalStaticZone.NEW[ARRAY PascalInteger[0..4000] OF SixteenBits]; TokStart: LONG POINTER TO ARRAY PascalInteger[0..2000] OF SixteenBits ← PascalStaticZone.NEW[ARRAY PascalInteger[0..2000] OF SixteenBits]; Link: LONG POINTER TO ARRAY PascalInteger[0..4000] OF SixteenBits ← PascalStaticZone.NEW[ARRAY PascalInteger[0..4000] OF SixteenBits]; Ilk: LONG POINTER TO ARRAY PascalInteger[0..4000] OF SixteenBits ← PascalStaticZone.NEW[ARRAY PascalInteger[0..4000] OF SixteenBits]; Equiv: LONG POINTER TO ARRAY PascalInteger[0..4000] OF SixteenBits ← PascalStaticZone.NEW[ARRAY PascalInteger[0..4000] OF SixteenBits]; TextLink: LONG POINTER TO ARRAY PascalInteger[0..2000] OF SixteenBits ← PascalStaticZone.NEW[ARRAY PascalInteger[0..2000] OF SixteenBits]; --:38----40: NamePtr: NamePointer; StringPtr: NamePointer; BytePtr: LONG POINTER TO ARRAY PascalInteger[0..1] OF PascalInteger[0..45000] ← PascalStaticZone.NEW[ARRAY PascalInteger[0..1] OF PascalInteger[0..45000]]; PoolCheckSum: PascalInteger; --:40----44: TextPtr: TextPointer; TokPtr: LONG POINTER TO ARRAY PascalInteger[0..2] OF PascalInteger[0..50000] ← PascalStaticZone.NEW[ARRAY PascalInteger[0..2] OF PascalInteger[0..50000]]; Z: PascalInteger[0..2]; --MAX←TOK←PTR:ARRAY[0..2]OF 0..MAX←TOKS;----:44----50:-- IdFirst: PascalInteger[0..BufSize]; IdLoc: PascalInteger[0..BufSize]; DoubleChars: PascalInteger[0..BufSize]; Hash: LONG POINTER TO ARRAY PascalInteger[0..353] OF SixteenBits ← PascalStaticZone.NEW[ARRAY PascalInteger[0..353] OF SixteenBits]; ChopHash: LONG POINTER TO ARRAY PascalInteger[0..353] OF SixteenBits ← PascalStaticZone.NEW[ARRAY PascalInteger[0..353] OF SixteenBits]; ChoppedId: LONG POINTER TO ARRAY PascalInteger[0..12] OF AsciiCode ← PascalStaticZone.NEW[ARRAY PascalInteger[0..12] OF AsciiCode]; --:50----65: ModText: LONG POINTER TO ARRAY PascalInteger[0..400] OF AsciiCode ← PascalStaticZone.NEW[ARRAY PascalInteger[0..400] OF AsciiCode]; --:65----70: LastUnnamed: TextPointer; --:70----79:-- CurState: OutputState; Stack: LONG POINTER TO ARRAY PascalInteger[1..50] OF OutputState ← PascalStaticZone.NEW[ARRAY PascalInteger[1..50] OF OutputState]; StackPtr: PascalInteger[0..StackSize]; --:79 --80:-- Zo: PascalInteger[0..2]; --:80----82:-- BraceLevel: EightBits; --:82----86:-- CurVal: PascalInteger; --:86----94:--OutBuf: LONG POINTER TO ARRAY PascalInteger[0..144] OF AsciiCode ← PascalStaticZone.NEW[ARRAY PascalInteger[0..144] OF AsciiCode]; OutPtr: PascalInteger[0..OutBufSize]; BreakPtr: PascalInteger[0..OutBufSize]; SemiPtr: PascalInteger[0..OutBufSize]; --:94----95:-- OutState: EightBits; OutVal: PascalInteger; OutApp: PascalInteger; OutSign: AsciiCode; LastSign: PascalInteger[-1..1]; --:95----100: OutContrib: LONG POINTER TO ARRAY PascalInteger[1..72] OF AsciiCode ← PascalStaticZone.NEW[ARRAY PascalInteger[1..72] OF AsciiCode]; --:100----124:-- Line: PascalInteger; OtherLine: PascalInteger; TempLine: PascalInteger; Limit: PascalInteger[0..BufSize]; Loc: PascalInteger[0..BufSize]; InputHasEnded: PascalBoolean; Changing: PascalBoolean; --:124----126: ChangeBuffer: LONG POINTER TO ARRAY PascalInteger[0..5000] OF AsciiCode ← PascalStaticZone.NEW[ARRAY PascalInteger[0..5000] OF AsciiCode]; ChangeLimit: PascalInteger[0..BufSize]; --:126----143:-- CurModule: NamePointer; ScanningHex: PascalBoolean; --:143----156: NextControl: EightBits; --:156----164:-- CurReplText: TextPointer; --:164 --171:-- ModuleCount: PascalInteger[0..12287]; Error9999: ERROR = CODE; TangleRun: UnsafeCommandProc = BEGIN --FOR ZO:=0 TO 2 DO MAX←TOK←PTR[ZO]:=TOK←PTR[ZO]; -- ----112:-- {ENABLE Error9999 => GOTO Label9999;Initialize[];--134:--OpenInput[];Line←0;OtherLine←0;Changing←TRUE; PrimeTheChangeBuffer[];Changing← NOT Changing;TempLine←OtherLine; OtherLine←Line;Line←TempLine;Limit←0;Loc←1;Buffer↑[0]←32; InputHasEnded←FALSE;--:134--{PascalWriteLongString[file: @TermOut, item: "This is Tangle 2.7 for Cedar 6.0"]; PascalWriteLn[file: @TermOut]};--183: PhaseOne←TRUE;ModuleCount←0;DO NextControl←SkipAhead[]; IF NextControl=136 THEN EXIT; ENDLOOP;WHILE NOT InputHasEnded DO ScanModule[] ENDLOOP ;--138: IF ChangeLimit#0 THEN BEGIN FOR i:INT IN [ INT[0 ].. INT[ChangeLimit ]] DO Loc ← i; Buffer↑[Loc] ←ChangeBuffer↑[Loc] ENDLOOP;Limit←ChangeLimit;Changing←TRUE; Line←OtherLine;Loc←ChangeLimit;BEGIN PascalWriteLn[file: @TermOut]; PascalWriteLongString[file: @TermOut, item: "! Change file entry did not match"];Error[]; END; END--:138--; PhaseOne←FALSE;--:183--IF TextLink↑[0]=0 THEN BEGIN BEGIN PascalWriteLn[file: @TermOut]; PascalWriteLongString[file: @TermOut, item: "! No output was specified."]; END; IF History=0 THEN History←1; END ELSE BEGIN --96:-- BEGIN PascalWriteLn[file: @TermOut]; PascalWriteLongString[file: @TermOut, item: "Writing the output file"]; END;PascalTextBREAK[file: @TermOut];--83: StackPtr←1;BraceLevel←0;CurState.NameField←0; CurState.ReplField←TextLink↑[0];Zo← CurState.ReplField MOD 3; CurState.ByteField←TokStart↑[CurState.ReplField]; CurState.EndField←TokStart↑[CurState.ReplField+3]; CurState.ModField←0;--:83--OutState←0;OutPtr←0;BreakPtr←0; SemiPtr←0;OutBuf↑[0]←0;Line←1;--:96--SendTheOutput[];--98: BreakPtr←OutPtr;SemiPtr←0;FlushBuffer[]; IF BraceLevel#0 THEN BEGIN PascalWriteLn[file: @TermOut]; {PascalWriteLongString[file: @TermOut, item: "! Program ended at brace level "]; PascalWriteInteger[file: @TermOut, item: BraceLevel, fieldMinLength: 1]};Error[]; END;--:98--BEGIN PascalWriteLn[file: @TermOut];PascalWriteLongString[file: @TermOut, item: "Done."]; END; END--:112--; EXITS Label9999 => NULL};IF INT[StringPtr]>128 THEN--184:--BEGIN BEGIN PascalWriteLn[file: @TermOut]; {PascalWriteInteger[file: @TermOut, item: StringPtr-128, fieldMinLength: 1]; PascalWriteLongString[file: @TermOut, item: " strings written to string pool file."] }; END;PascalWriteLongString[file: @Pool, item: "*"]; FOR i:INT IN [ INT[1 ].. INT[9 ]] DO StringPtr ← i; OutBuf↑[StringPtr]← PoolCheckSum MOD 10;PoolCheckSum← PoolCheckSum /10; ENDLOOP; FOR i:INT DECREASING IN [ INT[1 ].. INT[9 ]] DO StringPtr ← i; PascalWriteChar[file: @Pool, item: Xchr↑[48+OutBuf↑[StringPtr]]] ENDLOOP; PascalWriteLn[file: @Pool]; END--:184--;--[186:]BEGIN WRITELN(TERM←OUT); -- WRITE(TERM←OUT,'Memory usage statistics:');END;BEGIN WRITELN(TERM←OUT); -- WRITE(TERM←OUT,NAME←PTR:1,' names, ',TEXT←PTR:1,' replacement texts;'); -- END;BEGIN WRITELN(TERM←OUT);WRITE(TERM←OUT,BYTE←PTR[0]:1);END; -- FOR WO:=1 TO 1 DO WRITE(TERM←OUT,'+',BYTE←PTR[WO]:1); -- WRITE(TERM←OUT,' bytes, ',MAX←TOK←PTR[0]:1); -- FOR ZO:=1 TO 2 DO WRITE(TERM←OUT,'+',MAX←TOK←PTR[ZO]:1); -- WRITE(TERM←OUT,' tokens.');[:186];--FileClose[@WebFile]; FileClose[@ChangeFile];FileClose[@PascalFile];FileClose[@Pool];--187: SELECT History FROM 0 =>BEGIN PascalWriteLn[file: @TermOut]; PascalWriteLongString[file: @TermOut, item: "(No errors were found.)"]; END;1 =>BEGIN PascalWriteLn[file: @TermOut]; PascalWriteLongString[file: @TermOut, item: "(Did you see the warning message above?)"]; END; 2 =>BEGIN PascalWriteLn[file: @TermOut]; PascalWriteLongString[file: @TermOut, item: "(Pardon me, but I think I spotted something wrong.)"]; END;3 =>BEGIN PascalWriteLn[file: @TermOut]; PascalWriteLongString[file: @TermOut, item: "(That was a fatal error, my friend.)"]; END; ENDCASE--:187--; PascalWriteLn[file: @TermOut];--:182 END; PascalRegister["Tangle", TangleRun]; END.