SELECT char
FROM
'' => {
IF RopeReader.GetIndex[finder.ropeReader] >= plen THEN ERROR MalformedPattern[endquote];
patternLength ← patternLength-1;
LitChar[RopeReader.Get[finder.ropeReader], GetLooks[], FALSE]
};
IN ['A .. 'Z], IN ['a .. 'z] => LitChar[char, looks, ignoreCase];
'~ => {
IF RopeReader.GetIndex[finder.ropeReader] >= plen THEN ERROR MalformedPattern[endtilda];
patternLength ← patternLength-1;
char ← RopeReader.Get[finder.ropeReader];
looks ← GetLooks[];
SELECT char
FROM
'' => {
IF RopeReader.GetIndex[finder.ropeReader] >= plen THEN
ERROR MalformedPattern[endquote];
patternLength ← patternLength-1;
NotChar[RopeReader.Get[finder.ropeReader], GetLooks[], FALSE]
};
IN ['A .. 'Z], IN ['a .. 'z] => NotChar[char, looks, ignoreCase];
'% => TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.oneNonBlankPattern]]};
'$ =>
IF psIndex > 0 AND finder.patternArray[psIndex-1]=[pattern[TextFindPrivate.anyNonBlankPattern]] AND
(finder.patternLooks=
NIL
OR finder.patternLooks[psIndex-1]=looks)
THEN {
-- change to max
patternLength ← patternLength-1;
psIndex ← psIndex-1;
TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.maxNonBlankPattern]]};
}
ELSE {
-- new entry
TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.anyNonBlankPattern]]};
finder.stackSize ← finder.stackSize+1;
};
'@ => TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.oneNonAlphaPattern]]};
'& =>
IF psIndex > 0 AND finder.patternArray[psIndex-1]=[pattern[TextFindPrivate.anyNonAlphaPattern]] AND
(finder.patternLooks=
NIL
OR finder.patternLooks[psIndex-1]=looks)
THEN {
-- change to max
patternLength ← patternLength-1;
psIndex ← psIndex-1;
TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.maxNonAlphaPattern]]}
}
ELSE {
-- new entry
TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.anyNonAlphaPattern]]};
finder.stackSize ← finder.stackSize+1;
};
ENDCASE => TRUSTED {finder.patternArray[psIndex] ← [not[char]]};
};
'# => TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.oneCharPattern]]};
'* =>
IF psIndex > 0 AND finder.patternArray[psIndex-1]=[pattern[TextFindPrivate.anyStringPattern]] AND
(finder.patternLooks=
NIL
OR finder.patternLooks[psIndex-1]=looks)
THEN {
-- change to max
psIndex ← psIndex-1;
patternLength ← patternLength-1;
finder.stackSize ← MAX[1, finder.stackSize];
TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.maxStringPattern]]};
}
ELSE {
-- new entry
TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.anyStringPattern]]};
IF looks # TextLooks.noLooks THEN finder.stackSize ← finder.stackSize+1;
};
'% => TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.oneBlankPattern]]};
'$ =>
IF psIndex > 0 AND finder.patternArray[psIndex-1]=[pattern[TextFindPrivate.anyBlankPattern]] AND
(finder.patternLooks=
NIL
OR finder.patternLooks[psIndex-1]=looks)
THEN {
-- change to max
patternLength ← patternLength-1;
psIndex ← psIndex-1;
TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.maxBlankPattern]]};
}
ELSE {
-- new entry
TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.anyBlankPattern]]};
finder.stackSize ← finder.stackSize+1;
};
'@ => TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.oneAlphaPattern]]};
'& =>
IF psIndex > 0 AND finder.patternArray[psIndex-1]=[pattern[TextFindPrivate.anyAlphaPattern]] AND
(finder.patternLooks=
NIL
OR finder.patternLooks[psIndex-1]=looks)
THEN {
-- change to max
patternLength ← patternLength-1;
psIndex ← psIndex-1;
TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.maxAlphaPattern]]};
}
ELSE {
-- new entry
TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.anyAlphaPattern]]};
finder.stackSize ← finder.stackSize+1;
};
'| => {
TRUSTED {finder.patternArray[psIndex] ←
[pattern[IF psIndex = 0 THEN TextFindPrivate.leftBoundaryPattern ELSE TextFindPrivate.rightBoundaryPattern]]
};
IF psIndex # 0 AND psIndex # patternLength-1 THEN
ERROR MalformedPattern[boundary];
IF psIndex = patternLength-1
THEN {
-- right boundary
finder.lastPatternCharIsNormal ← TRUE; finder.lastPatChar1 ← TextFindPrivate.rightBoundaryPattern;
};
IF psIndex = 0
THEN {
--left boundary
finder.firstPatternCharIsNormal ← TRUE; finder.firstPatChar1 ← TextFindPrivate.leftBoundaryPattern;
}
};
'< => {
nameStart: INT ← RopeReader.GetIndex[finder.ropeReader]; -- index of char after the <
nameLen: INT ← 0;
IF insideNamedPat THEN ERROR MalformedPattern[missingNameEnd];
insideNamedPat ← TRUE;
nameLooks ← looks; -- remember the looks of the <
TRUSTED {finder.patternArray[psIndex] ← [startname[nameCount]]};
DO
SELECT RopeReader.Peek[finder.ropeReader !
RopeReader.ReadOffEnd => GOTO BadName] FROM -- scan to end of name
': => {
-- pattern follows
[] ← RopeReader.Get[finder.ropeReader];
[] ← GetLooks[];
patternLength ← patternLength-(nameLen+1);
EXIT;
};
'> => {
-- no pattern given, so insert a phony *
psIndex ← psIndex + 1;
PatChar['*, looks, ignoreCase]; -- use looks from the '<
patternLength ← patternLength-nameLen+1;
EXIT;
};
ENDCASE => { -- part of the name
nameLen ← nameLen+1;
[] ← RopeReader.Get[finder.ropeReader];
[] ← GetLooks[];
};
ENDLOOP;
nameList ← CONS[Rope.Substr[patternRope, nameStart, nameLen], nameList];
nameLooksList ← CONS[nameLooks, nameLooksList];
EXITS BadName => ERROR MalformedPattern[missingNameEnd]
};
'> => {
IF ~insideNamedPat THEN ERROR MalformedPattern[unmatchedNameEnd];
insideNamedPat ← FALSE;
TRUSTED {finder.patternArray[psIndex] ← [endname[nameCount]]};
nameCount ← nameCount+1;
};
'{ => {
finder.leftBracketSeen ← TRUE;
TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.leftBracketPattern]]};
};
'} => {
IF finder.rightBracketSeen THEN
TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.nopPattern]]} -- use first right Bracket in pattern
ELSE {
finder.rightBracketSeen ← TRUE;
TRUSTED {finder.patternArray[psIndex] ← [pattern[TextFindPrivate.rightBracketPattern]]};
}
};
ENDCASE => {
TRUSTED {finder.patternArray[psIndex] ← [pattern[char]]};
IF psIndex = patternLength-1
THEN {
finder.lastPatternCharIsNormal ← TRUE;
finder.lastPatChar1 ← char;
finder.lastPatChar2 ← 0C;
};
IF psIndex = 0
THEN {
finder.firstPatternCharIsNormal ← TRUE;
finder.firstPatChar1 ← char;
finder.firstPatChar2 ← 0C;
}
}