<> <> <> <> <> <> <> <> <> <> <> <> DIRECTORY TiogaNode, TiogaLooks, Rope; TextFind: CEDAR DEFINITIONS = BEGIN RefTextNode: TYPE = TiogaNode.RefTextNode; Offset: TYPE = TiogaNode.Offset; ROPE: TYPE = Rope.ROPE; MaxLen: Offset = LAST[Offset]; CR: CHAR = 'M-100B; MalformedPattern: ERROR [ec:PatternErrorCode]; PatternErrorCode: TYPE = { toobig, -- pattern too long endquote, -- pattern ends with ' endtilda, -- pattern ends with ~ boundary, -- pattern has | inside rather than at beginning or end missingNameEnd, -- pattern has < without matching > unmatchedNameEnd -- pattern has > without previous < }; Finder: TYPE = REF FinderRec; FinderRec: TYPE; NameLoc: PROC [finder: Finder, name: ROPE] RETURNS [at, atEnd: Offset]; <> <> NameLooks: PROC [finder: Finder, name: ROPE] RETURNS [looks: TiogaLooks.Looks]; <> <> Create: PROC [ pattern: RefTextNode, literal, word, ignoreLooks, ignoreCase, addBounds: BOOLEAN _ FALSE, patternStart: Offset _ 0, patternLen: Offset _ MaxLen] RETURNS [finder: Finder]; <> <> <> <> <> <> <> CreateFromRope: PROC [pattern: ROPE, literal, word, ignoreCase, addBounds: BOOLEAN _ FALSE, patternStart: Offset _ 0, patternLen: Offset _ MaxLen] RETURNS [finder: Finder]; SearchRope: PROC [finder: Finder, rope: Rope.ROPE, start: Offset _ 0, len: Offset _ MaxLen, interrupt: REF BOOL _ NIL] RETURNS [found: BOOLEAN, at, atEnd, before, after: Offset]; Try: PROC [finder: Finder, text: RefTextNode, start: Offset _ 0, len: Offset _ MaxLen, looksExact: BOOLEAN _ FALSE, interrupt: REF BOOL _ NIL] RETURNS [found: BOOLEAN, at, atEnd, before, after: Offset]; <> <> <> <> <> < atEnd if used } in pattern>> <> <> <> SearchRopeBackwards: PROC [finder: Finder, rope: Rope.ROPE, start: Offset _ 0, len: Offset _ MaxLen, interrupt: REF BOOL _ NIL] RETURNS [found: BOOLEAN, at, atEnd, before, after: Offset]; TryBackwards: PROC [finder: Finder, text: RefTextNode, start: Offset _ 0, len: Offset _ MaxLen, looksExact: BOOLEAN _ FALSE, interrupt: REF BOOL _ NIL] RETURNS [found: BOOLEAN, at, atEnd, before, after: Offset]; <> <> Find: PROC [pattern, text: RefTextNode, literal, word, ignoreLooks, ignoreCase, looksExact, addBounds: BOOLEAN _ FALSE, patternStart: Offset _ 0, patternLen: Offset _ MaxLen, textStart: Offset _ 0, textLen: Offset _ MaxLen, interrupt: REF BOOL _ NIL] RETURNS [found: BOOLEAN, at, atEnd, before, after: Offset] = INLINE { [found,at,atEnd,before,after] _ Try[Create[pattern,literal,word,ignoreLooks,ignoreCase,addBounds,patternStart,patternLen], text,textStart,textLen,looksExact,interrupt] }; BackwardsFind: PROC [pattern, text: RefTextNode, literal, word, ignoreLooks, ignoreCase, looksExact, addBounds: BOOLEAN _ FALSE, patternStart: Offset _ 0, patternLen: Offset _ MaxLen, textStart: Offset _ 0, textLen: Offset _ MaxLen, interrupt: REF BOOL _ NIL] RETURNS [found: BOOLEAN, at, atEnd, before, after: Offset] = INLINE { [found,at,atEnd,before,after] _ TryBackwards[ Create[pattern,literal,word,ignoreLooks,ignoreCase,addBounds,patternStart,patternLen], text,textStart,textLen,looksExact,interrupt] }; END.