DIRECTORY Rope, Interscript, FileIO USING [Open, OpenFailed], Process, SafeStorage, IO; InterscriptImpl: CEDAR PROGRAM IMPORTS Interscript, IO, SafeStorage, FileIO, Rope, Process = BEGIN OPEN Interscript; ROPE: TYPE ~ Rope.ROPE; MainLoop: PROCEDURE = { error, fileName: ROPE; bindTbl: BTHandle; vin, vout: IO.STREAM; scriptZone: ZONE _ SafeStorage.NewZone[sr: quantized]; script: IO.STREAM; [in: vin, out: vout] _ IO.CreateViewerStreams[name: "Interscript"]; BEGIN ENABLE IO.Error => GO TO quit; DO vout.Put[IO.rope["Type the name of the file to be internalized (extension .is83 is assumed): "]]; fileName _ GetFileName[in: vin, dfltExt: "is83"]; script _ FileIO.Open[fileName: fileName ! FileIO.OpenFailed => {vout.Put[IO.rope["\nCouldn't open the file named "], IO.rope[fileName], IO.rope["\n"]]; LOOP}]; EXIT; ENDLOOP; DO vout.Put[IO.rope["Internalizing "], IO.rope[fileName], IO.rope[": "]]; error _ Internalize[stream: script, z: scriptZone]; IF error = NIL THEN {vout.Put[IO.rope["No errors\n"]]; EXIT} ELSE vout.Put[IO.rope[error], IO.rope["\n"]]; ENDLOOP; EXITS quit => RETURN; END; }; GetFileName: PROC [in: IO.STREAM, dfltExt: ROPE _ NIL] RETURNS [name: ROPE] = { point: INT; name _ in.GetRope[]; IF (point _ name.Index[s2: "."]) >= name.Length[] THEN name _ name.Cat[".", dfltExt]; }; TRUSTED {Process.Detach[FORK MainLoop[]]}; END. ŠInterscriptImpl.mesa Last Edited by: Mitchell, February 7, 1983 3:46 pm ask user for name of script (e.g., foo.is83, extension for "interscript-83", is assumed) ask if user would like to see script printed, e.g., fully expanded, or just shown span boundaries. open stream for the file initialize binding table, scanner; call parser if error from parsing, restart parsing when user confirms (so he can fix an error and then plow on). reads a file name from the in stream. If no .extension is given, the dfltExt, if any, is assumed and is appended to the file name from the stream. Change Log Created by Mitchell, February 7, 1983 10:41 am. Κ˜JšœΟc™Jšœ2™2unitšΟk ˜ Jšœ˜Jšœ ˜ Jšœžœ˜ J˜J˜ Jšžœ˜—šœžœžœ˜ Jšžœžœ$˜;—Jšœžœžœ ˜Jšžœžœžœ˜J˜šΟnœž œ˜IcodešœX™XJšœb™bJšœ™Jšœ.™.Jšœd™dJšœžœ˜Jšœ˜J•StartOfExpansion[name: ROPE]šœ žœžœ˜Jšœ žœ&˜6Jšœžœžœ˜šœžœ*˜CJšžœžœžœ žœ˜$šž˜Jšœ žœV˜aJ˜1–Ξ[fileName: ROPE, accessOptions: FileIO.AccessOptions _ read, createOptions: FileIO.CreateOptions _ none, closeOptions: FileIO.CloseOptions _ 6, transaction: FileIO.Trans, raw: FileIO.RawOption _ FALSE, createLength: INT _ 2560, streamBufferParms: FileIO.StreamBufferParms _ [bufferSize: 25, bufferSwapUnitSize: 5]]šœ*˜*Jšœžœ*žœ!žœ˜u—Jšžœ˜Jšžœ˜—šž˜Jšœ žœžœ ˜FJšœ3˜3Jš žœ žœžœ žœžœ˜[s1: ROPE, pos1: INT _ 0, s2: ROPE, case: BOOL _ TRUE]šžœ0žœ˜UJ˜—Kšžœžœ˜*Jšžœ˜Isubtitle™ K™1K™J˜—…—H η