-- RopeFind.mesa -- derived from EditorFind.Mesa of Laurel 6 -- written by Bill Paxton, May 1981 -- last edit by Bill Paxton, 3-Jun-81 12:34:33 -- This module provides a "Find" operation for ropes DIRECTORY Rope; RopeFind: DEFINITIONS = BEGIN OPEN r:Rope; Rope: TYPE = r.Ref; Int: TYPE = LONG INTEGER; MaxLen: Int = LAST[Int]; MalformedPattern: ERROR; Find: PROC [pattern, rope: Rope, start: Int ← 0, len: Int ← MaxLen] RETURNS [found: BOOLEAN, at, atEnd, patternEnd: Int] = INLINE { [found,at,atEnd,patternEnd] ← Try[Create[pattern],rope,start,len] }; -- Searches for a match to pattern within [start .. start+len) of rope. -- If found, returns TRUE, with [at .. atEnd) the matched range, Finder: TYPE = REF FinderRec; FinderRec: TYPE; Create: PROC [pattern: Rope] RETURNS [finder: Finder]; Try: PROC [finder: Finder, rope: Rope, start: Int ← 0, len: Int ← MaxLen] RETURNS [found: BOOLEAN, at, atEnd, patternEnd: Int]; -- ***** Initialization StartRopeFind: PROC; -- for initialization only END.