SpellingWordMap.mesa
Last edited by Nix at October 22, 1983 6:49 pm
DIRECTORY
Rope USING [ROPE];
SpellingWordMap: CEDAR DEFINITIONS =
BEGIN
ROPE: TYPE = Rope.ROPE;
MapWordsInRope:
PROC [words: ROPE, buffer: REF TEXT, f: PROC [REF TEXT] RETURNS [BOOL]]
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 ['A..'Z]+['a..'z], 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.
MapWordsInRopeBackward:
PROC [words: ROPE, buffer: REF TEXT, f: PROC [REF TEXT] RETURNS [BOOL]]
RETURNS [premature: BOOL, wordStart, wordEnd: INT, newBuffer: REF TEXT];
END.