Guard
Error: PUBLIC ERROR [problem: Problem, explanation: ROPE] ~ CODE;
dictServer: PUBLIC ROPE ← UserProfile.Token["Dictionary.Server", "DictServer:PARC:Xerox"];
CrHandleFromRope:
INTERNAL
PROC [pattern:
ROPE]
RETURNS [h: CrRPC.Handle, name: XNSCHName.Name] ~ {
transport: ATOM ~ IF ( BYTES[CARDINAL] = 2 ) THEN $SPP ELSE $CMUX;
addr: XNS.Address;
[name, addr] ← XNSCH.LookupAddressFromRope[pattern];
IF ( addr = XNS.unknownAddress ) THEN
ERROR Error[courier, "Address not found"];
h ← CrRPC.CreateClientHandle[transport, NEW[XNS.Address ← addr]];
};
CourierProc: TYPE ~ PROC [h: CrRPC.Handle];
Guarded:
ENTRY
PROC [proc: CourierProc] ~ {
ENABLE {
UNWIND => { NULL };
Dictionary1.UseCourier, CrRPC.Error => { ERROR Error[courier, NIL] };
Dictionary1.RemoteError => { ERROR Error[service, string]; };
};
distingName: XNSCHName.Name; h: CrRPC.Handle ← NIL;
[h, distingName] ← CrHandleFromRope[dictServer];
proc[h];
CrRPC.DestroyClientHandle[h];
};
Public procs
Languages:
PUBLIC
PROC [user:
ROPE]
RETURNS [languages: LanguagesList] = {
xx: Dictionary1.Languages;
LanguagesOp: CourierProc ~ {
xx ← Dictionary1.GetLanguages[h, user];
};
Guarded[LanguagesOp];
languages ← LanguagesFor[xx];
};
Analyze:
PUBLIC
PROC [word: Word, language: Language]
RETURNS [analyses:
ROPE] = {
lrope: ROPE ~ Convert.RopeFromAtom[language, FALSE];
AnalyzeOp: CourierProc ~ {
analyses ← Dictionary1.Analyze[h, word, lrope];
};
Guarded[AnalyzeOp];
};
Translate:
PUBLIC
PROC [wordNumber: WordNumber, language: Language]
RETURNS [word: Word] = {
lrope: ROPE ~ Convert.RopeFromAtom[language, FALSE];
TranslateOp: CourierProc ~ {
word ← Dictionary1.ConvertWordNumber[h, wordNumber, lrope];
};
Guarded[TranslateOp];
};
ProofRead:
PUBLIC
PROC [paragraph: Paragraph, language: Language]
RETURNS [wordPosition: WordPosition] = {
lrope: ROPE ~ Convert.RopeFromAtom[language, FALSE];
temp: Dictionary1.Selection;
ProofReadOp: CourierProc ~ {
temp ← Dictionary1.ProofRead[h, paragraph, lrope];
};
Guarded[ProofReadOp];
wordPosition ← NEW[ExternalWordPositionObject ← [temp.start, temp.length] ];
};
Corrections:
PUBLIC
PROC [word: Word, language: Language]
RETURNS [wordsList: WordsList] = {
lrope: ROPE ~ Convert.RopeFromAtom[language, FALSE];
xx: Dictionary1.Words;
CorrectionsOp: CourierProc ~ {
xx ← Dictionary1.Corrections[h, word, lrope];
};
Guarded[CorrectionsOp];
wordsList ← WordsFor[xx];
};
Status:
PUBLIC
PROC
RETURNS [statusInfo:
ROPE] = {
StatusOp: CourierProc ~ {
statusInfo ← Dictionary1.Status[h];
};
Guarded[StatusOp];
};
CountWords:
PUBLIC
PROC [paragraph: Paragraph, language: Language]
RETURNS [wordCount:
INT32] = {
lrope: ROPE ~ Convert.RopeFromAtom[language, FALSE];
CountWordsOp: CourierProc ~ {
wordCount ← Dictionary1.CountWords[h, paragraph, lrope];
};
Guarded[CountWordsOp];
};
Conjugate:
PUBLIC
PROC [word: Word, form: Form, alternates: Alternates, language: Language]
RETURNS [conjugationsList: ConjugationsList] = {
frope: ROPE ~ Convert.RopeFromAtom[form, FALSE];
arope: ROPE ~ Convert.RopeFromAtom[alternates, FALSE];
lrope: ROPE ~ Convert.RopeFromAtom[language, FALSE];
xx: Dictionary1.Conjugations;
ConjugateOp: CourierProc ~ {
xx ← Dictionary1.Conjugate[h, word, frope, arope, lrope];
};
Guarded[ConjugateOp];
conjugationsList ← ConjugationsFor[xx];
};
Dictionaries:
PUBLIC
PROC [user: User]
RETURNS [dictionariesList: DictionariesList] = {
xx: Dictionary1.DictionariesAvailable;
DictionariesOp: CourierProc ~ {
xx ← Dictionary1.Dictionaries[h, user];
};
Guarded[DictionariesOp];
dictionariesList ← DictionariesAvailableFor[xx];
};
GetDefinition:
PUBLIC
PROC [word: Word, dictionary: Dictionary]
RETURNS [definition: Definition] = {
drope: ROPE ~ Convert.RopeFromAtom[dictionary, FALSE];
temp: Dictionary1.Definition;
runs: RunList;
GetDefinitionOp: CourierProc ~ {
temp ← Dictionary1.GetDefinition[h, word, drope];
};
Guarded[GetDefinitionOp];
runs ← RunsFor[temp.runs];
definition ← NEW[ExternalDefinitionObject ←
[definition: temp.definition, looks: runs] ];
};
Pronunciation:
PUBLIC
PROC [word: Word, dictionary: Dictionary]
RETURNS [wordPronounced:
ROPE] = {
drope: ROPE ~ Convert.RopeFromAtom[dictionary, FALSE];
PronunciationOp: CourierProc ~ {
wordPronounced ← Dictionary1.Pronunciation[h, word, drope];
};
Guarded[PronunciationOp];
};
GetLooks:
PUBLIC
PROC [dictionary: Dictionary]
RETURNS [looksList: LooksList] = {
drope: ROPE ~ Convert.RopeFromAtom[dictionary, FALSE];
xx: Dictionary1.Looks;
GetLooksOp: CourierProc ~ {
xx ← Dictionary1.GetLooks[h, drope];
};
Guarded[GetLooksOp];
looksList ← LooksFor[xx];
};
Enumerate:
PUBLIC
PROC [wordNumber: WordNumber, dictionary: Dictionary]
RETURNS [definition: Definition] = {
drope: ROPE ~ Convert.RopeFromAtom[dictionary, FALSE];
temp: Dictionary1.Definition;
runs: RunList;
EnumerateOp: CourierProc ~ {
temp ← Dictionary1.Enumerate[h, wordNumber, drope];
};
Guarded[EnumerateOp];
runs ← RunsFor[temp.runs];
definition ← NEW[ExternalDefinitionObject ←
[definition: temp.definition, looks: runs] ];
};
ConvertCodes:
PROC [codes: CodesList]
RETURNS [seq: Dictionary1.Codes] ~ {
length: CARDINAL;
FOR tail: CodesList ← codes, tail.rest
WHILE ( tail #
NIL )
DO length ← length.
SUCC;
ENDLOOP;
have to figure out how big to make the sequence
seq ← NEW[Dictionary1.CodesObject[length]];
FOR i:
CARDINAL
IN [0..length)
DO
rope: ROPE ~ Convert.RopeFromAtom[codes.first];
seq[i] ← rope;
codes ← codes.rest;
ENDLOOP;
};
EnumerateRaw:
PUBLIC
PROC [wordNumber: WordNumber, codes: CodesList, dictionary: Dictionary]
RETURNS [rawDefinitionList: RawDefinitionList] = {
drope: ROPE ~ Convert.RopeFromAtom[dictionary, FALSE];
seq: Dictionary1.Codes ~ ConvertCodes[codes];
xx: Dictionary1.RawDefinition;
EnumerateRawOp: CourierProc ~ {
xx ← Dictionary1.EnumerateRaw[h, wordNumber, seq, drope];
};
Guarded[EnumerateRawOp];
rawDefinitionList ← RawDefinitionFor[xx];
};
SearchForWord:
PUBLIC
PROC [unparsedClasses: UnparsedClasses, minKeyWords: MinKeyWords, minWord: MinWord, maxWord: MaxWord, dictionary: Dictionary]
RETURNS [intersectionResultsList: IntersectionResultsList] = {
drope: ROPE ~ Convert.RopeFromAtom[dictionary, FALSE];
xx: Dictionary1.IntersectionResults;
trans: REF;
SearchForWordOp: CourierProc ~ {
xx ← Dictionary1.SearchForWord[h, unparsedClasses, minKeyWords, minWord, maxWord, drope];
};
Guarded[SearchForWordOp];
intersectionResultsList ← IntersectionResultsFor[xx];
};
Synonyms:
PUBLIC
PROC [word: Word, dictionary: Dictionary]
RETURNS [externalSynonymHandle: ExternalSynonymHandle] = {
drope: ROPE ~ Convert.RopeFromAtom[dictionary, FALSE];
internal: Dictionary1.SynonymClasses;
external: ExternalSynonymSeqHandle;
classes: SynonymClassesList;
SynonymsOp: CourierProc ~ {
internal ← Dictionary1.Synonyms[h, word, drope];
};
Guarded[SynonymsOp];
external ← NEW[ExternalSynonymSeqObject ←
[handle: internal] ];
classes ← SynonymClassesFor[internal];
externalSynonymHandle ← NEW[ExternalSynonymObject ←
[synonymList: classes, externalSynonymSeqHandle: external] ];
};
NewSearchForWord:
PUBLIC
PROC [externalSynonymHandle: ExternalSynonymHandle, minKeyWords: MinKeyWords, minWord: MinWord, maxWord: MaxWord, dictionary: Dictionary]
RETURNS [intersectionResultsList: IntersectionResultsList] = {
drope: ROPE ~ Convert.RopeFromAtom[dictionary, FALSE];
classes: Dictionary1.SynonymClasses ~ externalSynonymHandle.externalSynonymSeqHandle.handle;
xx: Dictionary1.IntersectionResults;
trans: REF;
NewSearchForWordOp: CourierProc ~ {
xx ← Dictionary1.NewSearchForWord[h, classes, minKeyWords, minWord, maxWord, drope];
};
Guarded[NewSearchForWordOp];
intersectionResultsList ← IntersectionResultsFor[xx];
};
RawSearchForWord:
PUBLIC
PROC [externalSynonymHandle: ExternalSynonymHandle, minKeyWords: MinKeyWords, minWord: MinWord, maxWord: MaxWord, dictionary: Dictionary]
RETURNS [rawIntersectionResultsList: RawIntersectionResultsList] = {
drope: ROPE ~ Convert.RopeFromAtom[dictionary, FALSE];
classes: Dictionary1.SynonymClasses ~ externalSynonymHandle.externalSynonymSeqHandle.handle;
xx: Dictionary1.RawIntersectionResults;
trans: REF;
RawSearchForWordOp: CourierProc ~ {
xx ← Dictionary1.RawSearchForWord[h, classes, minKeyWords, minWord, maxWord, drope];
};
Guarded[RawSearchForWordOp];
rawIntersectionResultsList ← RawIntersectionResultsFor[xx];
};
}.