DIRECTORY Process USING [CheckForAbort], FS USING [ErrorDesc, Error, StreamOpen, ExpandName], IO USING [STREAM, GetIndex, PutF], RopeFile USING [FromStream], Rope USING [ROPE, Concat, Equal, Length, Fetch], Commander USING [CommandProc, Register, Handle], CommandTool USING [ArgumentVector, Parse, Failed], FileNames USING [ResolveRelativePath, IsAPattern, IsADirectory, ConvertToSlashFormat, CurrentWorkingDirectory], ISMessage USING [OpenTempFile, OpenTiogaOutput, WriteTiogaOutputFile], ISNode USING [Implementation, ImplementationObject, GetImplementation, SetImplementation], ISTiogaIntern USING [DefaultPrintProc, DefaultInternalizeProc, InternalizeDocument, PrintPara, InternalizePara, PrintChars, InternalizeChars, InternalizeStyle, InternalizeProperties, InternalizeLooks], ISToken USING [NodeTVHandle], ISScan USING [CreateScan, CollectNode, ScanHandle, InitializeScanThroughCurly, AdvanceScan]; ISTestImpl: CEDAR PROGRAM IMPORTS Commander, CommandTool, FileNames, FS, IO, RopeFile, ISScan, ISNode, ISTiogaIntern, ISMessage, Rope, Process ~ BEGIN ISTestProc: Commander.CommandProc = { destinationDirectory: Rope.ROPE _ NIL; leftArrowExists: BOOL; FSErrorMsg1: PROC [error: FS.ErrorDesc] RETURNS [Rope.ROPE] = { SELECT error.group FROM lock => RETURN[" -- locked!"]; ENDCASE => IF error.code = $unknownFile THEN RETURN [" -- not found!"] ELSE RETURN[Rope.Concat["\n -- FS.Error: ", error.explanation]]; }; HandleAFile: PROC [to, from: Rope.ROPE] = { Process.CheckForAbort[]; cmd.out.PutF[" %g _ %g\n", [rope[to]], [rope[from]]]; {ENABLE FS.Error => IF error.group # bug THEN {msg _ FSErrorMsg1[error];}; s: IO.STREAM _ FS.StreamOpen[to, $create]; script: Rope.ROPE; i: INT; pattern: Rope.ROPE; handle: ISToken.NodeTVHandle; scanner: ISScan.ScanHandle; implementation, documentImpl, paraImpl, charsImpl, styleImpl, propertiesImpl, looksImpl: ISNode.Implementation; ISMessage.OpenTempFile[]; ISMessage.OpenTiogaOutput[to]; pattern _ from; pattern _ FileNames.ResolveRelativePath[pattern]; pattern _ FS.ExpandName[pattern].fullFName; s _ FS.StreamOpen[pattern]; i _ IO.GetIndex[s]; script _ RopeFile.FromStream[s]; documentImpl _ NEW[ISNode.ImplementationObject]; documentImpl.internalize _ ISTiogaIntern.InternalizeDocument; [] _ ISNode.SetImplementation [$DOCUMENT, $Tioga, documentImpl]; paraImpl _ NEW[ISNode.ImplementationObject]; paraImpl.internalize _ ISTiogaIntern.InternalizePara; paraImpl.printTioga _ ISTiogaIntern.PrintPara; [] _ ISNode.SetImplementation [$PARA, $Tioga, paraImpl]; charsImpl _ NEW[ISNode.ImplementationObject]; charsImpl.internalize _ ISTiogaIntern.InternalizeChars; charsImpl.printTioga _ ISTiogaIntern.PrintChars; [] _ ISNode.SetImplementation [$CHARS, $Tioga, charsImpl]; styleImpl _ NEW[ISNode.ImplementationObject]; styleImpl.internalize _ ISTiogaIntern.InternalizeStyle; [] _ ISNode.SetImplementation [$STYLE, $Tioga, styleImpl]; looksImpl _ NEW[ISNode.ImplementationObject]; looksImpl.internalize _ ISTiogaIntern.InternalizeLooks; [] _ ISNode.SetImplementation [$LOOKS, $Tioga, looksImpl]; propertiesImpl _ NEW[ISNode.ImplementationObject]; propertiesImpl.internalize _ ISTiogaIntern.InternalizeProperties; [] _ ISNode.SetImplementation [$PROPERTIES, $Tioga, propertiesImpl]; implementation _ ISNode.GetImplementation[NIL, NIL]; implementation.internalize _ ISTiogaIntern.DefaultInternalizeProc; implementation.printTioga _ ISTiogaIntern.DefaultPrintProc; [] _ ISNode.SetImplementation[NIL, NIL, implementation]; scanner _ ISScan.CreateScan[base: script, index: i]; ISScan.InitializeScanThroughCurly[scanner]; ISScan.AdvanceScan[scanner]; handle _ ISScan.CollectNode[scanner]; ISMessage.WriteTiogaOutputFile[]; }; }; argv: CommandTool.ArgumentVector _ CommandTool.Parse[cmd ! CommandTool.Failed => {msg _ errorMsg; GO TO Die}]; nArgs: NAT _ argv.argc; { i: NAT _ 1; length: INT; Bump: PROC [scratch: NAT] = { FOR j: NAT IN (scratch..nArgs) DO argv[j - 1] _ argv[j]; ENDLOOP; nArgs _ nArgs - 1; }; WHILE i < nArgs DO length _ argv[i].Length[]; SELECT TRUE FROM length = 0 => Bump[i]; argv[i].Fetch[0] = '- => { FOR j: INT IN [1..length) DO SELECT argv[i].Fetch[j] FROM ENDCASE; ENDLOOP; Bump[i]; }; ENDCASE => i _ i + 1; ENDLOOP; }; -- end of switch processing leftArrowExists _ nArgs >= 3 AND Rope.Equal[argv[2], "_"]; FOR i: NAT IN [1..nArgs) DO argv[i] _ FileNames.ConvertToSlashFormat[FileNames.ResolveRelativePath[argv[i]]]; ENDLOOP; IF leftArrowExists THEN { IF FileNames.IsADirectory[argv[1]] THEN destinationDirectory _ argv[1] ELSE { IF nArgs # 4 OR FileNames.IsAPattern[argv[1]] OR FileNames.IsAPattern[argv[3]] THEN RETURN[$Failure, "Bad syntax for copying a file"]; HandleAFile[from: argv[3], to: argv[1]]; RETURN[IF msg # NIL THEN $Failure ELSE NIL, msg]; }; } ELSE destinationDirectory _ FileNames.ConvertToSlashFormat[FileNames.CurrentWorkingDirectory[]]; EXITS Die => result _ $Failure; }; Commander.Register["ISTest", ISTestProc, "Try out IS parser."]; END. BISTestImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. MKaplan, September 12, 1985 3:21:57 am PDT [cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL] Process switches no switches... First find out whether there is a _ anywhere. If there is, it must be the second arg. ΚΊ˜šœΟmœ1™LIcode™*—J™šΟk ˜ Kšœžœ˜Kšžœžœ,˜4Kšžœžœžœ˜"Kšœ žœ˜Kšœžœžœ ˜0Kšœ žœ!˜0Kšœ žœ!˜2Jšœ žœ`˜oKšœ žœ7˜FKšœžœN˜ZKšœžœΆ˜ΙKšœžœ˜KšœžœP˜\—K˜KšΠln œž ˜Kšžœ$žœC˜tšœž˜K˜•StartOfExpansionL -- [cmd: Commander.Handle] RETURNS [result: REF ANY _ NIL, msg: ROPE _ NIL]šΟn œ˜%KšΠckH™HJ˜Jšœžœžœ˜&Kšœžœ˜K˜š   œžœ žœ žœžœ˜?šžœ ž˜Kšœžœ˜šžœ˜ šžœ˜Kšžœžœ˜Kšžœžœ6˜A———Kšœ˜—K˜š  œžœžœ˜+Kšœ˜Kšœ6˜6šœž˜šžœ ˜ Kšžœžœ˜6—Kšœžœžœžœ˜*Jšœ ž˜Jšœžœ˜Jšœžœ˜Jšœ˜J˜Jšœo˜oK˜Kšœ˜J˜Jšœ˜Jšœ1˜1Jšœ žœ˜+Jšœžœ˜Jšœžœ ˜Jšœžœž˜ J˜Jšœžœ˜0Kšœ=˜=Kšœ@˜@Jšœ žœ˜,Kšœ5˜5Kšœ.˜.Kšœ8˜8Jšœ žœ˜-Kšœ7˜7Kšœ0˜0Kšœ:˜:Jšœ žœ˜-Kšœ7˜7Kšœ:˜:Jšœ žœ˜-Kšœ7˜7Kšœ:˜:Jšœžœ˜2KšœA˜AKšœD˜DKšœ*žœžœ˜4JšœB˜BJšœ;˜;Jšœžœžœ˜8Jšœ4˜4Jšœ+˜+Jšœ˜Jšœ%˜%J˜!Kšœ˜—K˜K˜—šœ8˜8Kšœ)žœžœ˜5—Kšœžœ ˜˜K˜—˜K™Kšœžœ˜ Kšœžœ˜ š œžœ žœ˜šžœžœžœž˜!K˜Kšžœ˜—K˜K˜—K™šžœ ž˜K˜šžœžœž˜Kšœ˜šœ˜šžœžœžœ ž˜šžœž˜K™Kšžœ˜—Kšžœ˜—K˜K˜—Kšžœ˜—Kšžœ˜—KšœΟc˜—K™K™VK˜Kšœžœ˜:šžœžœžœ ž˜KšœQ˜QKšžœ˜—K˜šžœ˜šžœ˜šžœ ˜"Kšžœ˜#šžœ˜šžœ žœžœ˜NKšžœžœ,˜7—Kšœ(˜(Kš žœžœžœžœ žœžœ˜1K˜——K˜—šžœ˜KšœD˜D——šž˜Kšœ˜—K˜—K˜Jšœ?˜?Kšžœ˜——…—JF