DIRECTORY BasicTime USING [GMT, Now, ToPupTime], BcdDefs USING [VersionStamp], Commander USING [CommandProc, Register], CommandUtil USING [Failed, GetRootName, KeyValue, ListLength, PairList, Parse, SetExtension], FS USING [Error, GetInfo, OpenFileFromStream, StreamOpen], IO USING [Close, int, PutChar, PutF, PutRope, RIS, rope, STREAM, time], IOClasses USING [CreateDribbleOutputStream], Loader USING [BCDBuildTime], OSMiscOps USING [GenerateUniqueId], PGSConDefs USING [], Rope USING [Concat, Fetch, Find, Length, ROPE], TableCommand USING [CompileStrings, MakeModule]; TableControl: PROGRAM IMPORTS BasicTime, Commander, CommandUtil, FS, IO, IOClasses, Loader, OSMiscOps, Rope, TableCommand EXPORTS TableCommand, PGSConDefs = { ROPE: TYPE ~ Rope.ROPE; STREAM: TYPE ~ IO.STREAM; bcdTime: BasicTime.GMT ~ Loader.BCDBuildTime[Main]; warningsLogged: PUBLIC BOOL _ FALSE; log: STREAM _ NIL; seterrstream: PUBLIC PROC = { }; resetoutstream: PUBLIC PROC = { }; outeol: PUBLIC PROC [n: INTEGER] = { THROUGH[0..n) DO log.PutChar['\n] ENDLOOP }; outstring: PUBLIC PROC [string: ROPE] = { log.PutRope[string] }; sourceName: PUBLIC ROPE _ NIL; pgsVersion: PUBLIC BcdDefs.VersionStamp _ [0, 0, BasicTime.ToPupTime[bcdTime]]; sourceVersion: PUBLIC BcdDefs.VersionStamp _ [0, 0, 0]; objectVersion: PUBLIC BcdDefs.VersionStamp _ [0, 0, 0]; ExtensionIs: PROC [name, ext: ROPE] RETURNS [BOOL] = { index: INT ~ Rope.Find[s1: name, s2: ext, case: FALSE]; RETURN[index>0 AND index=(name.Length[]-ext.Length[])]; }; CreateTime: PUBLIC PROC[s: IO.STREAM] RETURNS[INT] = { created: BasicTime.GMT ~ FS.GetInfo[FS.OpenFileFromStream[s]].created; RETURN[LOOPHOLE[BasicTime.ToPupTime[created]]]; }; GenerateVersion: PUBLIC PROC RETURNS [version: BcdDefs.VersionStamp] = { RETURN [OSMiscOps.GenerateUniqueId[]]; }; WriteHerald: PROC[stream: IO.STREAM] = { stream.PutF["Cedar 5.1 Table Compiler of %g\n", IO.time[bcdTime]]; }; BadSemantics: ERROR = CODE; Main: Commander.CommandProc = TRUSTED { cmdStream: STREAM ~ IO.RIS[cmd.commandLine]; DoCommand: PROC[source: ROPE, args, results: CommandUtil.PairList, sw: ROPE] ~ { input: {strings, binary} _ $binary; compact: BOOL _ FALSE; dStar: BOOL _ TRUE; rootName: ROPE _ NIL; interfaceName: ROPE _ NIL; formatName: ROPE _ NIL; bcdName: ROPE _ NIL; GetCommand: PROC ~ { sourceName _ CommandUtil.SetExtension[source, "mesa"]; IF ExtensionIs[sourceName, ".mesa"] THEN { input _ $strings; compact _ TRUE }; IF args#NIL THEN { k: CARDINAL _ CommandUtil.ListLength[args]; name: ROPE; IF (name _ CommandUtil.KeyValue["interface", args])#NIL THEN { k _ k - 1; interfaceName _ CommandUtil.SetExtension[name, "bcd"] }; IF k # 0 THEN ERROR BadSemantics; }; IF results#NIL THEN { k: CARDINAL _ CommandUtil.ListLength[results]; name: ROPE; IF (name _ CommandUtil.KeyValue["bcd", results])#NIL THEN { k _ k - 1; interfaceName _ CommandUtil.SetExtension[name, "bcd"] }; IF (name _ CommandUtil.KeyValue["format", results])#NIL THEN { k _ k - 1; formatName _ CommandUtil.SetExtension[name, "format"] }; IF k # 0 THEN ERROR BadSemantics; }; IF sw#NIL THEN { sense: BOOL _ TRUE; FOR i: INT IN[0..sw.Length[]) DO char: CHAR _ sw.Fetch[i]; IF char IN['A..'Z] THEN char _ char+('a-'A); -- convert to lower case SELECT char FROM '-, '~ => { sense _ ~sense; LOOP }; 'a => dStar _ ~sense; 'c => compact _ sense; 'm => input _ $binary; 's => {input _ $strings; compact _ FALSE}; 't => {input _ $strings; compact _ TRUE}; ENDCASE => ERROR BadSemantics; sense _ TRUE; ENDLOOP; }; }; LogCommand: PROC = { log.PutF["\n%g %g, exporting %g to %g", IO.rope[IF input=$strings THEN "Compiling" ELSE "Processing"], IO.rope[sourceName], IO.rope[rootName], IO.rope[interfaceName]]; IF bcdName=NIL THEN log.PutChar['\n] ELSE log.PutF[", BCD to %g\n", IO.rope[bcdName]]; IF input=$strings THEN log.PutF["Record format on %g\n", IO.rope[formatName]]; }; GetCommand[]; rootName _ CommandUtil.GetRootName[sourceName]; IF interfaceName=NIL THEN interfaceName _ "SELF"; IF formatName=NIL THEN formatName _ rootName.Concat[".format"]; LogCommand[]; IF bcdName=NIL THEN bcdName _ rootName.Concat[".bcd"]; SELECT input FROM $strings => { nChars, nStrings: CARDINAL; [nStrings, nChars] _ TableCommand.CompileStrings[inputFile: sourceName, interfaceId: interfaceName, formatId: formatName, moduleId: bcdName, compact: compact, altoCode: ~dStar]; log.PutF["Strings: %g, characters: %g\n", IO.int[nStrings], IO.int[nChars]]; }; $binary => { TableCommand.MakeModule[inputFile: sourceName, interfaceId: interfaceName, moduleId: bcdName, altocode: ~dStar]; }; ENDCASE => ERROR; log.PutChar['\n]; }; logFile: STREAM _ FS.StreamOpen["TableCompiler.log", $create]; logFile.PutF["TableCompiler.log -- %g\n\n", IO.time[BasicTime.Now[]]]; log _ IOClasses.CreateDribbleOutputStream[cmd.out, logFile]; WriteHerald[log]; DO source, switches: ROPE; args, results: CommandUtil.PairList; [source, args, results, switches] _ CommandUtil.Parse[s: cmdStream ! CommandUtil.Failed => { log.PutRope[" -- Unparsable command"]; LOOP }]; IF source=NIL THEN EXIT; DoCommand[source, args, results, switches ! BadSemantics => { log.PutRope[" -- Illegal command"]; CONTINUE }; FS.Error => { log.PutRope[error.explanation]; CONTINUE }; ]; ENDLOOP; logFile.Close[]; log _ NIL; }; Commander.Register[key: "TableCompiler", proc: Main, doc: "Table compiler."]; }. òTableControl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Satterthwaite on January 10, 1983 4:42 pm Maxwell, August 10, 1983 3:36 pm Doug Wyatt, April 2, 1984 4:31:03 pm PST Russ Atkinson (RRA) March 19, 1985 10:05:15 am PST cursor control savedCursor: UserTerminal.CursorArray; TableCursor: UserTerminal.CursorArray = [ 177777b, 177777b, 177777b, 160007b, 160007b, 160007b, 160007b, 160007b, 160007b, 160007b, 160007b, 160007b, 160007b, 177777b, 177777b, 177777b]; PGSConDefs error logging interface version identification Command line parsing [bcd: bcdName, format: formatName] _ sourceFile[interface: interfaceName]/switches PROC [cmd: Handle] RETURNS [result: REF _ NIL, msg: Rope.ROPE _ NIL] initialization main loop Êz˜codešœ™Kšœ Ïmœ1™Kšžœžœžœ˜@—Kšžœ žœžœ˜$Kšžœžœ˜1Kšžœžœ#žœ˜NKšœ˜—K˜ Kšœ/˜/Kšžœžœžœ˜1Kšžœ žœžœ)˜?K˜ Kšžœ žœžœ#˜6šžœž˜˜ Kšœžœ˜˜GK˜DK˜$—Kšœ*žœžœ˜LKšœ˜—˜ ˜.K˜.K˜—K˜—Kšžœžœ˜—Kšœ˜Kšœ˜K˜—Kšœ™K˜Kšœ žœžœ*˜>Kšœ,žœ˜FK˜Kšœ<˜