ThreeC4PrimImpl5.mesa: August 22, 1985 1:07:51 pm PDT
Sturgis, May 9, 1986 3:50:39 pm PDT
DIRECTORY
ThreeC4Support USING[GetReportStream],
ThreeC4BaseDecl1Def USING[NameNode],
ThreeC4BaseDecl2Def USING[ContextNode],
ThreeC4BasicAbTypesDef USING[FindParseTree, WholeFileNode],
ThreeC4PrimImplDefs USING[GetNameIds, RecordParseTree],
ThreeC4CentralDef USING[ParseOneStream],
FS USING[StreamOpen],
IO USING[Close, PutF, rope, STREAM],
Rope USING[Cat, ROPE];
ThreeC4PrimImpl5: CEDAR PROGRAM IMPORTS ThreeC4Support, ThreeC4BasicAbTypesDef, ThreeC4PrimImplDefs, ThreeC4CentralDef, FS, IO, Rope EXPORTS ThreeC4BasicAbTypesDef, ThreeC4PrimImplDefs =
BEGIN OPEN ThreeC4BaseDecl1Def, ThreeC4BaseDecl2Def, ThreeC4BasicAbTypesDef, ThreeC4PrimImplDefs;
sourceFNSuffix: Rope.ROPE ← NIL; -- normal running state = ".7Casaba"
targetFNPrefix: Rope.ROPE ← NIL; -- normal running state = ""
SetMode: PUBLIC PROC[targetFilesNamePrefix: Rope.ROPE, sourceFilesNameSuffix: Rope.ROPE] = {sourceFNSuffix ← sourceFilesNameSuffix; targetFNPrefix ← targetFilesNamePrefix};
ReadModeInfo: PUBLIC PROC RETURNS[targetFilesNamePrefix: Rope.ROPE, sourceFilesNameSuffix: Rope.ROPE] = {RETURN[targetFNPrefix, sourceFNSuffix]};
ClearMode: PUBLIC PROC = {sourceFNSuffix ← targetFNPrefix ← NIL};
-- parse call
ReadAndParseFile: PUBLIC PROC[name: Rope.ROPE] RETURNS[WholeFileNode] =
BEGIN
sourceStream: IO.STREAM ← FS.StreamOpen[Rope.Cat[name, sourceFNSuffix]];
root: REF ANY ← ThreeC4CentralDef.ParseOneStream[sourceStream, 0, NIL];
IO.Close[sourceStream];
RETURN[NARROW[root]];
END;
FindOrReadAndParseTree: PUBLIC PROC[context: ContextNode, name: NameNode] RETURNS[ContextNode, WholeFileNode] =
BEGIN
tree: WholeFileNode ← FindParseTree[context, name];
IF tree = NIL THEN -- we have to read and parse it
BEGIN
tree ← ReadAndParseFile[GetNameIds[name].id1.text];
context ← RecordParseTree[context, name, tree];
END;
RETURN[context, tree];
END;
-- some error handling stuff
ReportError: PUBLIC PROC[msg: Rope.ROPE] =
BEGIN
IO.PutF[ThreeC4Support.GetReportStream[], "%g\N", IO.rope[msg]];
END;
END..