SpellingWordMap.mesa
Copyright Ó 1987, 1992 by Xerox Corporation. All rights reserved.
Last edited by Nix at October 22, 1983 6:49 pm
Tim Diebert: January 26, 1987 4:49:21 pm PST
Last tweaked by Mike Spreitzer on February 17, 1989 4:19:00 pm PST
DIRECTORY
Rope USING [ROPE];
SpellingWordMap: CEDAR DEFINITIONS =
BEGIN
ROPE: TYPE = Rope.ROPE;
CharSet: TYPE ~ REF CharSetPrivate;
CharSetPrivate: TYPE ~ ARRAY CHAR OF BOOL;
MapWordsInRope:
PROC [words: ROPE, alphabetic: CharSet, buffer: REF TEXT, f: PROC [REF TEXT, REF ANY, INT] RETURNS [BOOL], data: REF ANY, offset: INT]
RETURNS [premature: BOOL, wordStart, wordEnd: INT, newBuffer: REF TEXT];
Maps the function f over each of the words in the ROPE words, stopping either when f returns TRUE or when all of the words are exhausted. A word is defined to be the longest non-empty sequence of alphabetic characters, with embedded apostrophes allowed: "abcd" is a word, "ab'cd" is a word, but "abcd'" is not a word. The accumulation and testing of words is carried out in the buffer, which is grown to accomodate long words, and which is returned (possibly longer) when the mapping is complete. On return, premature is TRUE iff the function f returned TRUE on some word. If premature is true, then wordStart and wordEnd are set to the starting index and stopping index of the word for which f returned true. If premature is false, then these values denote nothing of interest. The data argument is passed to f in the second position, and the starting index of the word, plus the offset, is the third argument.
MapWordsInRopeBackward:
PROC [words: ROPE, alphabetic: CharSet, buffer: REF TEXT, f: PROC [REF TEXT, REF ANY, INT] RETURNS [BOOL], data: REF ANY, offset: INT]
RETURNS [premature: BOOL, wordStart, wordEnd: INT, newBuffer: REF TEXT];
END.