-- TextFindPrivate.mesa
-- last edit by Bill Paxton, February 23, 1983 3:46 pm
DIRECTORY
TextFind,
TextLooks,
TextNode,
LooksReader,
Rope,
RopeReader,
RunReader;
TextFindPrivate: CEDAR DEFINITIONS =
BEGIN OPEN TextFind;
-- ***** Declarations *****
EightBit: CHAR = 200C;
CharMask: CHAR = 177C;
LegalCharacters: TYPE = CHAR[0C .. 177C];
anyStringPattern: CHAR = EightBit;
oneCharPattern: CHAR = EightBit + 1;
oneBlankPattern: CHAR = EightBit + 2;
oneNonBlankPattern: CHAR = EightBit + 3;
anyBlankPattern: CHAR = EightBit + 4;
anyNonBlankPattern: CHAR = EightBit + 5;
oneAlphaPattern: CHAR = EightBit + 6;
oneNonAlphaPattern: CHAR = EightBit + 7;
anyAlphaPattern: CHAR = EightBit + 8;
anyNonAlphaPattern: CHAR = EightBit + 9;
leftBracketPattern: CHAR = EightBit + 10;
rightBracketPattern: CHAR = EightBit + 11;
leftBoundaryPattern: CHAR = EightBit + 12;
rightBoundaryPattern: CHAR = EightBit + 13;
maxStringPattern: CHAR = EightBit + 14;
maxBlankPattern: CHAR = EightBit + 15;
maxNonBlankPattern: CHAR = EightBit + 16;
maxAlphaPattern: CHAR = EightBit + 17;
maxNonAlphaPattern: CHAR = EightBit + 18;
nopPattern: CHAR = EightBit+19;
MaxPatternLength: NAT = 1024;
TextStackArray: TYPE = RECORD[stack: SEQUENCE length: NAT OF Offset];
PatternStackArray: TYPE = RECORD[stack: SEQUENCE length: NAT OF NAT];
LooksArray: TYPE = RECORD[looks: SEQUENCE length: NAT OF TextLooks.Looks];
NameArray: TYPE = RECORD [array: SEQUENCE length: NAT OF NameRec];
NameRec: TYPE = RECORD [name: ROPE, at, atEnd: Offset, looks: TextLooks.Looks];
PatternArray: TYPE = RECORD [pat: SEQUENCE length: NAT OF PatRec];
PatRec:
TYPE =
RECORD [
SELECT tag:*
FROM
pattern => [char: CHAR],
not => [char: CHAR],
startname => [index: NAT],
endname => [index: NAT],
ENDCASE];
anyStringPat: pattern PatRec = [pattern[anyStringPattern]];
anyAlphaPat: pattern PatRec = [pattern[anyAlphaPattern]];
anyNonAlphaPat: pattern PatRec = [pattern[anyNonAlphaPattern]];
anyBlankPat: pattern PatRec = [pattern[anyBlankPattern]];
anyNonBlankPat: pattern PatRec = [pattern[anyNonBlankPattern]];
leftBoundaryPat: pattern PatRec = [pattern[leftBoundaryPattern]];
rightBoundaryPat: pattern PatRec = [pattern[rightBoundaryPattern]];
nonPat: pattern PatRec = [pattern[0C]];
IsWord:
PROC [rope:
ROPE, at, atEnd: TextNode.Offset]
RETURNS [BOOLEAN];
Boundary:
PROC [char:
CHAR]
RETURNS [
BOOLEAN] =
INLINE {
RETURN [char = leftBoundaryPattern OR char = rightBoundaryPattern] };
Pat:
PROC [p:PatRec]
RETURNS [pp: pattern PatRec] =
INLINE {
WITH p:p
SELECT
FROM
pattern => pp ← p;
ENDCASE => pp ← nonPat; };
Finder: TYPE = REF FinderRec;
FinderRecord:
TYPE =
RECORD [
stackSize: NAT ← 0,
patternPosStack: REF PatternStackArray,
textPosStack: REF TextStackArray,
textLenStack: REF TextStackArray,
patternArray: REF PatternArray,
length: NAT ← 0,
patternLooks: REF LooksArray,
nameArray: REF NameArray,
firstPatChar1, firstPatChar2, lastPatChar1, lastPatChar2: CHAR ← 377C,
ropeReader: RopeReader.Ref,
lksReader: LooksReader.Ref,
runReader: RunReader.Ref,
looks: TextLooks.Looks,
looksOnly: BOOLEAN ← FALSE,
wordSearch: BOOLEAN ← FALSE,
leftBracketSeen, rightBracketSeen: BOOLEAN ← FALSE,
firstPatternCharIsNormal, lastPatternCharIsNormal: BOOLEAN ← FALSE
];
END.