INTERFACERdUtils ; IMPORT Rd, Thread, AtomList; PROCEDURE Find (rd: Rd.T; pattern: TEXT; canonicalize: Canonicalize := NIL): [-1 .. LAST(CARDINAL)] RAISES {Rd.Failure, Thread.Alerted};
Finds the first occurrence of pattern, reading forward from the current position of rd. If no match is found, Find returns -1 and leaves rd positioned at the end. If Rd.Failure, or Thread.Alerted is raised while reading characters from rd, the exception propagates through to the caller of Find and the position of rd is undefined. If a match is found, Find returns the index of the first character of the match and leaves rd positioned to read the character following the match. A null pattern causes an instant match, with no advancement of rd. If canonicalize is set, Find uses canonicalize to map characters in both rd and pattern into a connonical form. See IgnoreASCIICase below.This uses a pretty poor algorithm and demands that the reader be seekable.
PROCEDURE FindString ( rd : Rd.T; READONLY pattern : ARRAY OF CHAR; canonicalize: Canonicalize := NIL): [-1 .. LAST(CARDINAL)] RAISES {Rd.Failure, Thread.Alerted};
= Find(rd, Text.FromSub(pattern), canonicalize).
PROCEDURE FindChar (rd : Rd.T; pattern : CHAR; canonicalize: Canonicalize := NIL): [-1 .. LAST(CARDINAL)] RAISES {Rd.Failure, Thread.Alerted};
= Find(rd, Text.FromChar(pattern), canonicalize).
PROCEDURE FailureText (f: AtomList.T): TEXT;
Rd.i3 says:EXCEPTION Failure (AtomList.T)
.FailureText returns a text describing the failure
f
. Returns eitherNIL
or the names of the Atom.ToText of each element of this list separated by colons.
TYPE Canonicalize = PROCEDURE(ch: CHAR): CHAR; PROCEDURE ToUpperCaseASCII(ch: CHAR): CHAR; (* Converts ASCII lower case characters to upper case, returns all other characters unchanged. See ASCII.i3. *) END RdUtils.