ThreeC4Driver.mesa
Copied from Tran5Driver on October 21, 1985 10:54:50 am PDT
Sturgis, May 10, 1986 3:54:25 pm PDT
Shoup, June 23, 1986 9:52:04 am PDT
DIRECTORY
Commander USING[CommandProc, Register],
IO USING[CharClass, Close, EndOfStream, GetTokenRope, IDProc, int, PutF, RIS, STREAM],
FS USING[StreamOpen],
OneCasabaParser USING[GetReportStream],
ThreeC4Support USING[GetReportStream],
ThreeC4BaseDecl1Def USING[FileSeqNode],
ThreeC4BaseDecl2Def USING[BuildEmptyContext],
ThreeC4PrimImplDefs USING[ClearMode, GlobalEnvHandle, GlobalEnvRec, GetGlobalEnv, ReadModeInfo, SetMode, WriteFiles, UnrecoveredError],
ThreeC4CentralDef USING[ParseOneStream],
ThreeC4BasicAbTypesDef USING[WholeFileNode],
Rope USING[Cat, ROPE],
ProcessProps USING [AddPropList],
List USING [PutAssoc];
ThreeC4Driver: CEDAR MONITOR
IMPORTS Commander, FS, IO, OneCasabaParser, Rope, ThreeC4Support, ThreeC4BaseDecl2Def, ThreeC4PrimImplDefs, ThreeC4CentralDef, ProcessProps, List =
BEGIN OPEN Commander, IO, Rope, ThreeC4PrimImplDefs, ProcessProps, List;
debugFlags: CARDINAL ← 0;
TestThreeC4: ENTRY CommandProc =
BEGIN
ENABLE UNWIND => ThreeC4PrimImplDefs.ClearMode[];
ThreeC4PrimImplDefs.SetMode["X", ".ThreeC4"];
[result, msg] ← DoIt[cmd];
ThreeC4PrimImplDefs.ClearMode[];
END;
XTran7: ENTRY CommandProc =
BEGIN
ENABLE UNWIND => ThreeC4PrimImplDefs.ClearMode[];
ThreeC4PrimImplDefs.SetMode["", ".7Casaba"];
[result, msg] ← DoIt[cmd];
ThreeC4PrimImplDefs.ClearMode[];
END;
ThreeC4: ENTRY CommandProc =
BEGIN
ENABLE UNWIND => ThreeC4PrimImplDefs.ClearMode[];
ThreeC4PrimImplDefs.SetMode["", ".ThreeC4"];
[result, msg] ← DoIt[cmd];
ThreeC4PrimImplDefs.ClearMode[];
END;
DoIt: CommandProc =
BEGIN
ENABLE ThreeC4PrimImplDefs.UnrecoveredError =>
BEGIN
IO.PutF[cmd.out, "\NProcessing Terminated\N"];
IO.PutF[cmd.out, "%g errors\N", IO.int[GetGlobalEnv[].errorCount]];
GOTO Quit;
END;
commandLineStream: STREAMRIS[cmd.commandLine];
errorFlag: BOOLEAN ← FALSE;
rootName: ROPE; rootSubName: ROPE;
sourceFileNameSuffix: Rope.ROPE;
targetFilesNamePrefix: Rope.ROPE;
sourceStream: STREAM;
root: ThreeC4BasicAbTypesDef.WholeFileNode;
files: ThreeC4BaseDecl1Def.FileSeqNode;
globalEnv: GlobalEnvHandle;
DoItBody: PROC =
BEGIN
[targetFilesNamePrefix, sourceFileNameSuffix] ← ThreeC4PrimImplDefs.ReadModeInfo[];
rootName ← GetTokenRope[commandLineStream, IDProc
! EndOfStream => {rootName ← NIL; CONTINUE}].token;
Close[commandLineStream];
sourceStream ← FS.StreamOpen[Rope.Cat[rootName, rootSubName, sourceFileNameSuffix]];
root ← NARROW[ThreeC4CentralDef.ParseOneStream[sourceStream, debugFlags, cmd.out
! OneCasabaParser.GetReportStream => {errorFlag ← TRUE; RESUME[cmd.out]}]];
Close[sourceStream];
IF errorFlag THEN RETURN;
files ← root.procs.FormFileSeq[root, ThreeC4BaseDecl2Def.BuildEmptyContext[] !
ThreeC4Support.GetReportStream => RESUME[cmd.out];
OneCasabaParser.GetReportStream => RESUME[cmd.out]];
globalEnv ← GetGlobalEnv[];
IF globalEnv.errorCount = 0 THEN
BEGIN
IO.PutF[cmd.out, "\Nno errors -- writing files . . .\N"];
ThreeC4PrimImplDefs.WriteFiles[files, targetFilesNamePrefix, cmd.out];
END
ELSE
IO.PutF[cmd.out, "\N%g errors\N", IO.int[globalEnv.errorCount]];
END;



AddPropList[PutAssoc[$ThreeCasabaFourGlobalEnv, NEW[GlobalEnvRec], NIL], DoItBody];
EXITS
Quit => NULL;
END;
main code
Register["ThreeC4", ThreeC4];
Register["TestThreeC4", TestThreeC4];
Register["XTran7", XTran7];
END..