PLtoTFExternalsImpl.mesa
Edited by Michael Plass on December 30, 1982 4:03 pm
Implements those procedures called by PLtoTF as externals.
Last Edited by: Ramshaw, October 11, 1983 10:01 am
Pavel, October 23, 1985 10:49:19 am PDT
DIRECTORY
FS,
IO,
PascalBasic,
PascalWizardFiles,
Rope,
PLtoTFExternals,
PLtoTFPrivate;
PLtoTFExternalsImpl: PROGRAM
IMPORTS FS, IO, PascalWizardFiles, PascalBasic, Rope
EXPORTS PLtoTFExternals =
BEGIN OPEN PascalWizardFiles, PascalBasic, PLtoTFPrivate;
TtyRewrite: PUBLIC PROC [F: PascalTextFilePtr] =
BEGIN
PascalOpenTextFileTTYOutput[F];
END;
ByteFileReset: PROC [F: LONG POINTER TO ByteFile, Ext: Alfa] =
BEGIN
inStream: IO.STREAM;
so: FS.StreamOptions ← FS.defaultStreamOptions;
so[tiogaRead] ← FALSE;
inStream ← FS.StreamOpen[fileName: Rope.Cat[FileNameRoot[], ".", RopeFromAlfa[Ext]], streamOptions: so];
PascalOpenFileWithStream[@(F^.baseFile), inStream];
PascalRESET[file: @(F^.baseFile), length: 1, element: @(F^.element)];
END;
FileReset: PUBLIC PROC [F: PascalTextFilePtr, Ext: Alfa] =
BEGIN
inStream: IO.STREAM;
inStream ← FS.StreamOpen[Rope.Cat[FileNameRoot[], ".", RopeFromAlfa[Ext]]];
PascalOpenTextFileWithStream[F, inStream];
PascalTextRESET[F];
END;
ByteFileRewrite: PUBLIC PROC [F: LONG POINTER TO ByteFile, Ext: Alfa] =
BEGIN
outStream: IO.STREAM;
outStream ← FS.StreamOpen[Rope.Cat[FileNameRoot[], ".", RopeFromAlfa[Ext]], $create];
PascalOpenFileWithStream[@(F^.baseFile), outStream];
END;
FileRewrite: PROC [F: PascalTextFilePtr, Ext: Alfa] =
BEGIN
outStream: IO.STREAM;
outStream ← FS.StreamOpen[Rope.Cat[FileNameRoot[], ".", RopeFromAlfa[Ext]], $create];
PascalOpenTextFileWithStream[F, outStream];
PascalTextREWRITE[F];
END;
FileClose: PUBLIC PROC [F: PascalTextFilePtr] =
BEGIN
PascalCloseTextFile[F];
END;
ByteFileClose: PUBLIC PROC [F: LONG POINTER TO ByteFile] =
BEGIN
PascalCloseFile[@(F^.baseFile)];
END;
fileNameRootBreak: PRIVATE IO.BreakProc = CHECKED
BEGIN
RETURN[SELECT char FROM
IN ['0..'9], IN ['A..'Z], IN ['a..'z], '-, '+, '# => other,
ENDCASE => sepr];
END;
FileNameRoot: PROC RETURNS [ROPE] =
BEGIN
RETURN[IO.RIS[commandLineTail].GetTokenRope[breakProc: fileNameRootBreak].token];
END;
RopeFromAlfa: PROC [a: Alfa] RETURNS [r: ROPE] =
BEGIN
r ← NIL;
FOR i:AlfaIndex IN AlfaIndex DO
IF a[i] = ' THEN EXIT;
r ← Rope.Concat[r, Rope.FromChar[a[i]]];
ENDLOOP;
END;
END.