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: STREAM ← RIS[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];
END;