<> DIRECTORY Generator USING [Handle], Rope USING [ROPE] ; Spell: CEDAR DEFINITIONS = BEGIN <> <> <> <> <> <> <> <> <> <> <> ROPE: TYPE = Rope.ROPE; SpellingList: TYPE = LIST OF ROPE; CorrectionClass: TYPE = {never, someMistakes, allAccountedFor, patternMatch, caseError, always}; SpellingGenerator: TYPE = REF SpellingGeneratorRecord; SpellingGeneratorRecord: TYPE = RECORD[clientData: REF ANY, private: REF SpellingGeneratorPrivateRecord]; SpellingGeneratorPrivateRecord: TYPE; Filter: TYPE = PROCEDURE[candidateRope: ROPE, unknown: ROPE] RETURNS [accept: BOOLEAN]; -- true means consider the candidate AbortProc: TYPE = PROC; <> ConfirmProc: TYPE = PROC [msg: ROPE, timeout: INT, defaultConfirm: BOOL] RETURNS [yes: BOOL]; <> InformProc: TYPE = PROC [msg: ROPE]; <> Modes: TYPE = REF READONLY ModesRecord; ModesRecord: TYPE = RECORD[ inform, confirm, disabled: CorrectionClass, timeout: INT, -- In msecs. -1 means never time out defaultConfirm: BOOL -- the default value to be used in case a confirmation times out, i.e. TRUE means the correction is confirmed, FALSE means it is rejected. ]; defaultModes: Modes; <> <> GetTheOne: PROCEDURE[ unknown: ROPE, spellingList: SpellingList _ NIL, generator: SpellingGenerator _ NIL, -- if both spellingList and generator are non-NIL, candidates will be taken from generator until it runs out, and then from spellingList. (If both spellingList and generator are NIL, then the correction will fail immediately.) abort: AbortProc _ NIL,-- NIL => never abort. confirm: ConfirmProc _ NIL, -- NIL => If confirmation is required, act as though user said No. inform: InformProc _ NIL,-- NIL => no output. filter: Filter _ NIL, modes: Modes _ NIL -- NIL means use values in user profile ] RETURNS [ROPE]; GetMatchingList: PROCEDURE[ pattern: ROPE, spellingList: SpellingList _ NIL, -- arguments same interpretation as for GetTheOne generator: SpellingGenerator _ NIL, abort: AbortProc _ NIL, confirm: ConfirmProc _ NIL, inform: InformProc _ NIL, filter: Filter _ NIL, modes: Modes _ NIL ] RETURNS [LIST OF ROPE]; <> <> <> GeneratorFromProcs: PROC [ initialize: PROCEDURE[self: SpellingGenerator] _ NIL, generate: PROCEDURE [self: SpellingGenerator] RETURNS [candidate: REF ANY], -- must narrow to ROPE or REF TEXT. terminate: PROCEDURE[self: SpellingGenerator] _ NIL, -- to be called when finished. clientData: REF ANY _ NIL ] RETURNS [SpellingGenerator]; <> << the value of generate must narrow to ROPE or REF TEXT. If the value narrows to a REF TEXT, a ROPE will be created only for those candidates that the spelling corrector is going to retain across calls to generate. This enables generate to return a scratch ref text for inspection, and not have to allocate a new rope for each candidate it generates.>> GeneratorFromEnumerator: PROC [ enumerator: PROC[self: Generator.Handle], clientData: REF ANY ] RETURNS [SpellingGenerator]; <> <> GetTheFile: PROC [ unknown: Rope.ROPE, defaultExt: Rope.ROPE _ NIL, abort: AbortProc _ NIL, confirm: ConfirmProc _ NIL, inform: InformProc _ NIL, modes: Modes _ NIL ] RETURNS [correct: Rope.ROPE]; <> <> <> <> <> < look at files with extension mesa for a misspelling of mumble (becauuse "mesa" is on extensionList)>> < same as above, except correction message will say Mumble -> rather than Mumble.mesa ->>> < correct msa to mesa, see if mumble.mesa exists, and if not, proceed as in case 1>> < only look at files with extension msa>> < examine all files with non-Null extensions, because "frob" is not on extensionlist.>> < only look at files with no extensions>> GetMatchingFileList: PROC [ unknown: Rope.ROPE, defaultExt: Rope.ROPE _ NIL, abort: AbortProc _ NIL, confirm: ConfirmProc _ NIL, inform: InformProc _ NIL, modes: Modes _ NIL ] RETURNS [files: LIST OF ROPE]; <> extensionList: SpellingList; <> AddExtension: PROC [ext: ROPE]; -- adds ext to extensionList. <> IsAPattern: PROC [unknown: ROPE] RETURNS[BOOLEAN]; <> END.