ThreeC4Driver.mesa
Copied from Tran5Driver on October 21, 1985 10:54:50 am PDT
Sturgis, May 10, 1986 3:54:25 pm PDT
DIRECTORY
Commander USING[CommandProc, Register],
IO USING[CharClass, Close, EndOfStream, GetTokenRope, IDProc, RIS, STREAM],
FS USING[StreamOpen],
OneCasabaParser USING[GetReportStream],
ThreeC4Support USING[GetReportStream],
ThreeC4BaseDecl1Def USING[FileSeqNode],
ThreeC4BaseDecl2Def USING[BuildEmptyContext],
ThreeC4PrimImplDefs USING[ClearMode, ReadModeInfo, SetMode, WriteFiles],
ThreeC4CentralDef USING[ParseOneStream],
ThreeC4BasicAbTypesDef USING[WholeFileNode],
Rope USING[Cat, ROPE];
ThreeC4Driver: CEDAR MONITOR
IMPORTS Commander, FS, IO, OneCasabaParser, Rope, ThreeC4Support, ThreeC4BaseDecl2Def, ThreeC4PrimImplDefs, ThreeC4CentralDef =
BEGIN OPEN Commander, IO, Rope;
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
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;
[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]];
ThreeC4PrimImplDefs.WriteFiles[files, targetFilesNamePrefix];
END;
main code
Register["ThreeC4", ThreeC4];
Register["TestThreeC4", TestThreeC4];
Register["XTran7", XTran7];
END..