LazUtils: Masks: move the logic of #a9457c2f2bd1412ef2c8ed9dc7e468eff6453bf4 to CompileAnyCharOrNone.

This commit is contained in:
Bart 2022-01-02 13:20:25 +01:00
parent c8feb2d0e8
commit 9b61164125

View File

@ -818,7 +818,9 @@ var
lCharsGroupInsertSize, lFirstRange, lSecondRange: integer; lCharsGroupInsertSize, lFirstRange, lSecondRange: integer;
begin begin
//writeln('CompileRange: fMask[fMaskInd]=',fMask[fMaskInd]); //writeln('CompileRange: fMask[fMaskInd]=',fMask[fMaskInd]);
if (mocAnyCharOrNone in fMaskOpcodesAllowed) and (fMaskInd<fMaskLimit) and (fMask[fMaskInd+1]='?') then begin if ([mocSet,mocRange,mocAnyCharOrNone]*fMaskOpCodesAllowed = [mocAnyCharOrNone]) or
((mocAnyCharOrNone in fMaskOpcodesAllowed) and (fMaskInd<fMaskLimit) and (fMask[fMaskInd+1]='?'))
then begin
CompileAnyCharOrNone('?', True); CompileAnyCharOrNone('?', True);
end else begin//not AnyCharOrNone end else begin//not AnyCharOrNone
fLastOC:=TMaskParsedCode.CharsGroupBegin; fLastOC:=TMaskParsedCode.CharsGroupBegin;
@ -941,9 +943,9 @@ begin
//in this case the '[' always mus be the start of a Range, a Set or AnyCharOrNone //in this case the '[' always mus be the start of a Range, a Set or AnyCharOrNone
then then
begin //it's just a bit easier later on if we handle this before we call CompileRange begin //it's just a bit easier later on if we handle this before we call CompileRange
if ([mocSet,mocRange]*fMaskOpCodesAllowed = []) {only mocAnyCharOrNone enabled} //if ([mocSet,mocRange]*fMaskOpCodesAllowed = []) {only mocAnyCharOrNone enabled}
and (fMaskInd<fMaskLimit) and (fMask[fMaskInd+1]<>'?') {next char is not '?'} then // and (fMaskInd<fMaskLimit) and (fMask[fMaskInd+1]<>'?') {next char is not '?'} then
Exception_InvalidCharMask(fMask[fMaskInd+1], fMaskInd+1); // Exception_InvalidCharMask(fMask[fMaskInd+1], fMaskInd+1);
CompileRange; CompileRange;
end end
else begin //mocSet,MocRange and mocAnyCharOrNone are all disabled else begin //mocSet,MocRange and mocAnyCharOrNone are all disabled
@ -980,15 +982,18 @@ var
begin begin
//if any of the 2 conditions is true, this procedure should not have been called. //if any of the 2 conditions is true, this procedure should not have been called.
{$IFDEF debug_anycharornone} {$IFDEF debug_anycharornone}
if BracketsRequired and (fMask[fMaskInd]<>'[') then writeln('CompileAnyCharOrNone: QChar=#',Ord(QChar),', BracketsRequired=',BracketsRequired,', fMask[fMaskInd]=',fMask[fMaskInd]);
Exception_InternalError(); if (BracketsRequired and (fMask[fMaskInd]<>'[')) or ((not BracketsRequired) and (fMask[fMaskInd]<>QChar)) then
Exception_InternalError();
{$ENDIF} {$ENDIF}
if BracketsRequired then if BracketsRequired then
begin
Inc(fMaskInd); //consume the '[' Inc(fMaskInd); //consume the '['
{$IFDEF debug_anycharornone} //the following happens when mocSet amd mocRange are disabled and the first char after the bracket is not a '?'
if fMask[fMaskInd]<>QChar then if fMask[fMaskInd]<>QChar then
Exception_InternalError(); Exception_InvalidCharMask(fMask[fMaskInd], fMaskInd);
{$ENDIF} end;
QCount:=1; QCount:=1;
while (fMaskInd+QCount<=fMaskLimit) and (fMask[fMaskInd+QCount]=QChar) do Inc(QCount); while (fMaskInd+QCount<=fMaskLimit) and (fMask[fMaskInd+QCount]=QChar) do Inc(QCount);