DIRECTORY Basics, CharDisplays, Commander, CommanderOps, DisplayControllers, FileNames, FS, IO, MessageWindow, RedBlackTree, Rope, TermProgs; TermProgsImpl: CEDAR PROGRAM IMPORTS CommanderOps, FileNames, FS, IO, MessageWindow, RedBlackTree, Rope EXPORTS TermProgs = {OPEN TermProgs; TermData: TYPE = REF TermDataRep; TermDataRep: TYPE = RECORD [ termName, bcdBase, bcdDir: ROPE ¬ NIL, term: Term ¬ NIL]; terms: RedBlackTree.Table ~ RedBlackTree.Create[GetTermKey, CompareTermDatas]; GetTerm: PUBLIC PROC [name: ROPE, cmd: Commander.Handle] RETURNS [term: Term] = { td: TermData ¬ NARROW[terms.Lookup[name]]; IF td = NIL THEN RETURN [NIL]; IF td.term # NIL THEN RETURN [td.term]; [] ¬ CommanderOps.DoCommand[ commandLine: IO.PutFR1["TerminalRun%g", [rope[td.bcdBase]]], parent: cmd]; td ¬ NARROW[terms.Lookup[name]]; term ¬ IF td # NIL THEN td.term ELSE NIL; }; RegTerm: PUBLIC PROC [name: ROPE, term: Term] = { td: TermData ¬ NARROW[terms.Lookup[name]]; IF td = NIL THEN { td ¬ NEW [TermDataRep ¬ [termName: name]]; terms.Insert[td, name]}; td.term ¬ term; }; EnumerateTerms: PUBLIC PROC [consume: PROC [name: ROPE, term: Term]] = { PerTermData: PROC [item: REF ANY] RETURNS [stop: BOOL] = { td: TermData ¬ NARROW[item]; consume[td.termName, td.term]; stop ¬ FALSE}; terms.EnumerateIncreasing[PerTermData]; }; CompareTermDatas: PROC [k, data: REF ANY] RETURNS [c: Basics.Comparison] = { r1: ROPE ¬ NARROW[k]; r2: ROPE ¬ GetTermKey[data]; c ¬ r1.Compare[r2, FALSE]}; GetTermKey: PROC [data: REF ANY] RETURNS [key: ROPE] = {td: TermData ¬ NARROW[data]; key ¬ td.termName}; Start: PROC = { ConsumeTerms: PROC [fullFName: ROPE] RETURNS [continue: BOOL] = { termsFName, bcdDir: ROPE; cp: FS.ComponentPositions; fromTerms: IO.STREAM ¬ NIL; continue ¬ TRUE; [termsFName, cp] ¬ FS.ExpandName[fullFName]; bcdDir ¬ termsFName.Substr[start: 0, len: cp.subDirs.start+cp.subDirs.length]; fromTerms ¬ FS.StreamOpen[termsFName]; FOR i: INT ¬ fromTerms.SkipWhitespace[], fromTerms.SkipWhitespace[] WHILE NOT fromTerms.EndOf[] DO termName: ROPE ¬ fromTerms.GetRopeLiteral[]; td: TermData ¬ NEW [TermDataRep ¬ [ termName: termName, bcdBase: termsFName.Substr[cp.base.start, cp.base.length], bcdDir: bcdDir ]]; terms.Insert[td, termName !RedBlackTree.DuplicateKey => CONTINUE]; ENDLOOP; fromTerms.Close[]; }; enumErr ¬ [ok, NIL, NIL]; FS.EnumerateForNames[FS.ExpandName[Rope.Cat[FileNames.CurrentWorkingDirectory[], "Em*.terms", SELECT Basics.bitsPerWord FROM 16 => "!H", 32 => NIL, ENDCASE => ERROR]].fullFName, ConsumeTerms ! FS.Error => {enumErr ¬ error; CONTINUE}]; IF enumErr.group # ok THEN SayErr[]; RETURN}; SayErr: PROC ~ { MessageWindow.Append[enumErr.explanation]}; enumErr: FS.ErrorDesc; Start[]; }. τ TermProgsImpl.Mesa Copyright Σ 1990, 1992 by Xerox Corporation. All rights reserved. Last Edited by: Spreitzer, May 5, 1985 2:13:01 pm PDT Last tweaked by Mike Spreitzer on July 18, 1990 10:13 am PDT Willie-s, June 12, 1992 1:52 pm PDT Κώ–(cedarcode) style•NewlineDelimiter ™code™Kšœ Οeœ7™BJ™5K™