MG: fixed find property

git-svn-id: trunk@1655 -
This commit is contained in:
lazarus 2002-05-01 06:36:25 +00:00
parent 06faefdcf7
commit 4567f3e78d
2 changed files with 212 additions and 208 deletions

View File

@ -595,6 +595,8 @@ procedure TCustomCodeTool.ReadNextAtom;
var c1, c2: char;
CommentLvl: integer;
begin
{$IFOPT R+}{$DEFINE RangeChecking}{$ENDIF}
{$R-}
if (CurPos.StartPos<CurPos.EndPos) then
LastAtoms.Add(CurPos);
if NextPos.StartPos>=1 then begin
@ -604,51 +606,55 @@ begin
end;
CurPos.StartPos:=CurPos.EndPos;
CurPos.Flag:=cafNone;
if CurPos.StartPos>SrcLen then
exit;
// Skip all spaces and comments
CommentLvl:=0;
while CurPos.StartPos<=SrcLen do begin
if IsCommentStartChar[Src[CurPos.StartPos]] then begin
case Src[CurPos.StartPos] of
'{': // pascal comment
begin
CommentLvl:=1;
inc(CurPos.StartPos);
while (CurPos.StartPos<=SrcLen) and (CommentLvl>0) do begin
case Src[CurPos.StartPos] of
'{': if Scanner.NestedComments then inc(CommentLvl);
'}': dec(CommentLvl);
end;
inc(CurPos.StartPos);
end;
end;
'/': // Delphi comment
if (CurPos.StartPos<SrcLen) and (Src[CurPos.StartPos+1]='/') then begin
inc(CurPos.StartPos,2);
while (CurPos.StartPos<=SrcLen)
and (not (Src[CurPos.StartPos] in [#10,#13])) do
inc(CurPos.StartPos);
inc(CurPos.StartPos);
if (CurPos.StartPos<=SrcLen) and (Src[CurPos.StartPos] in [#10,#13])
and (Src[CurPos.StartPos-1]<>Src[CurPos.StartPos]) then
inc(CurPos.StartPos);
end else
break;
'(': // old turbo pascal comment
if (CurPos.StartPos<SrcLen) and (Src[CurPos.StartPos+1]='*') then begin
inc(CurPos.StartPos,3);
while (CurPos.StartPos<=SrcLen)
and ((Src[CurPos.StartPos-1]<>'*') or (Src[CurPos.StartPos]<>')')) do
inc(CurPos.StartPos);
inc(CurPos.StartPos);
end else
break;
end;
end else if IsSpaceChar[Src[CurPos.StartPos]] then begin
repeat
while true do begin
case Src[CurPos.StartPos] of
#0:
if CurPos.StartPos>SrcLen then
break
else
inc(CurPos.StartPos);
until (CurPos.StartPos>SrcLen)
or (not (IsSpaceChar[Src[CurPos.StartPos]]));
end else begin
#1..#32:
inc(CurPos.StartPos);
'{': // pascal comment
begin
CommentLvl:=1;
inc(CurPos.StartPos);
while (CurPos.StartPos<=SrcLen) and (CommentLvl>0) do begin
case Src[CurPos.StartPos] of
'{': if Scanner.NestedComments then inc(CommentLvl);
'}': dec(CommentLvl);
end;
inc(CurPos.StartPos);
end;
end;
'/': // Delphi comment
if (Src[CurPos.StartPos+1]<>'/') then begin
break;
end else begin
inc(CurPos.StartPos,2);
while (CurPos.StartPos<=SrcLen)
and (not (Src[CurPos.StartPos] in [#10,#13])) do
inc(CurPos.StartPos);
inc(CurPos.StartPos);
if (CurPos.StartPos<=SrcLen) and (Src[CurPos.StartPos] in [#10,#13])
and (Src[CurPos.StartPos-1]<>Src[CurPos.StartPos]) then
inc(CurPos.StartPos);
end;
'(': // old turbo pascal comment
if (Src[CurPos.StartPos+1]<>'*') then begin
break;
end else begin
inc(CurPos.StartPos,3);
while (CurPos.StartPos<=SrcLen)
and ((Src[CurPos.StartPos-1]<>'*') or (Src[CurPos.StartPos]<>')')) do
inc(CurPos.StartPos);
inc(CurPos.StartPos);
end;
else
break;
end;
end;
@ -658,190 +664,188 @@ begin
// read atom
c1:=UpperSrc[CurPos.EndPos];
case c1 of
'_','A'..'Z':
begin
'_','A'..'Z':
begin
inc(CurPos.EndPos);
while (IsIdentChar[UpperSrc[CurPos.EndPos]]) do
inc(CurPos.EndPos);
while (CurPos.EndPos<=SrcLen)
and (IsIdentChar[UpperSrc[CurPos.EndPos]]) do
inc(CurPos.EndPos);
CurPos.Flag:=cafWord;
case UpperSrc[CurPos.StartPos] of
'B':
if (CurPos.EndPos-CurPos.StartPos=5)
and UpAtomIs('BEGIN')
then
CurPos.Flag:=cafBegin;
'E':
if (CurPos.EndPos-CurPos.StartPos=3)
and (UpperSrc[CurPos.StartPos+1]='N')
and (UpperSrc[CurPos.StartPos+2]='D')
then
CurPos.Flag:=cafEnd;
'R':
if (CurPos.EndPos-CurPos.StartPos=7)
and UpAtomIs('RECORD')
then
CurPos.Flag:=cafRecord;
end;
CurPos.Flag:=cafWord;
case c1 of
'B':
if (CurPos.EndPos-CurPos.StartPos=5)
and UpAtomIs('BEGIN')
then
CurPos.Flag:=cafBegin;
'E':
if (CurPos.EndPos-CurPos.StartPos=3)
and (UpperSrc[CurPos.StartPos+1]='N')
and (UpperSrc[CurPos.StartPos+2]='D')
then
CurPos.Flag:=cafEnd;
'R':
if (CurPos.EndPos-CurPos.StartPos=7)
and UpAtomIs('RECORD')
then
CurPos.Flag:=cafRecord;
end;
'''','#':
begin
while (CurPos.EndPos<=SrcLen) do begin
case (Src[CurPos.EndPos]) of
'#':
begin
inc(CurPos.EndPos);
if (CurPos.EndPos<=SrcLen) then begin
if (IsNumberChar[Src[CurPos.EndPos]]) then begin
// decimal
repeat
inc(CurPos.EndPos);
until (CurPos.EndPos>SrcLen)
or (not IsNumberChar[Src[CurPos.EndPos]]);
end else if Src[CurPos.EndPos]='$' then begin
// hexadecimal
repeat
inc(CurPos.EndPos);
until (CurPos.EndPos>SrcLen)
or (not IsHexNumberChar[Src[CurPos.EndPos]]);
end;
end;
end;
'''':
begin
inc(CurPos.EndPos);
while (CurPos.EndPos<=SrcLen) do begin
case Src[CurPos.EndPos] of
'''':
begin
inc(CurPos.EndPos);
break;
end;
#10,#13:
break;
else
end;
'''','#':
begin
while (CurPos.EndPos<=SrcLen) do begin
case (Src[CurPos.EndPos]) of
'#':
begin
inc(CurPos.EndPos);
if (CurPos.EndPos<=SrcLen) then begin
if (IsNumberChar[Src[CurPos.EndPos]]) then begin
// decimal
repeat
inc(CurPos.EndPos);
end;
until (CurPos.EndPos>SrcLen)
or (not IsNumberChar[Src[CurPos.EndPos]]);
end else if Src[CurPos.EndPos]='$' then begin
// hexadecimal
repeat
inc(CurPos.EndPos);
until (CurPos.EndPos>SrcLen)
or (not IsHexNumberChar[Src[CurPos.EndPos]]);
end;
end;
else
break;
end;
'''':
begin
inc(CurPos.EndPos);
while (CurPos.EndPos<=SrcLen) do begin
case Src[CurPos.EndPos] of
'''':
begin
inc(CurPos.EndPos);
break;
end;
#10,#13:
break;
else
inc(CurPos.EndPos);
end;
end;
end;
else
break;
end;
end;
'0'..'9':
begin
end;
'0'..'9':
begin
inc(CurPos.EndPos);
while (CurPos.EndPos<=SrcLen) and (IsNumberChar[Src[CurPos.EndPos]]) do
inc(CurPos.EndPos);
while (CurPos.EndPos<=SrcLen) and (IsNumberChar[Src[CurPos.EndPos]]) do
if (CurPos.EndPos<SrcLen)
and (Src[CurPos.EndPos]='.') and (Src[CurPos.EndPos+1]<>'.') then begin
// real type number
inc(CurPos.EndPos);
while (CurPos.EndPos<=SrcLen) and (IsNumberChar[Src[CurPos.EndPos]])
do
inc(CurPos.EndPos);
if (CurPos.EndPos<SrcLen)
and (Src[CurPos.EndPos]='.') and (Src[CurPos.EndPos+1]<>'.') then begin
// real type number
if (CurPos.EndPos<=SrcLen) and (UpperSrc[CurPos.EndPos]='E') then
begin
// read exponent
inc(CurPos.EndPos);
if (CurPos.EndPos<=SrcLen) and (Src[CurPos.EndPos] in ['-','+'])
then inc(CurPos.EndPos);
while (CurPos.EndPos<=SrcLen) and (IsNumberChar[Src[CurPos.EndPos]])
do
inc(CurPos.EndPos);
if (CurPos.EndPos<=SrcLen) and (UpperSrc[CurPos.EndPos]='E') then
begin
// read exponent
inc(CurPos.EndPos);
if (CurPos.EndPos<=SrcLen) and (Src[CurPos.EndPos] in ['-','+'])
then inc(CurPos.EndPos);
while (CurPos.EndPos<=SrcLen) and (IsNumberChar[Src[CurPos.EndPos]])
do
inc(CurPos.EndPos);
end;
end;
end;
'%':
begin
inc(CurPos.EndPos);
while (CurPos.EndPos<=SrcLen) and (Src[CurPos.EndPos] in ['0'..'1']) do
inc(CurPos.EndPos);
end;
'$':
begin
inc(CurPos.EndPos);
while (CurPos.EndPos<=SrcLen)
and (IsHexNumberChar[UpperSrc[CurPos.EndPos]]) do
inc(CurPos.EndPos);
end;
';':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafSemicolon;
end;
',':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafComma;
end;
'=':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafEqual;
end;
'(':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafRoundBracketOpen;
end;
')':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafRoundBracketClose;
end;
'[':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafEdgedBracketOpen;
end;
']':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafEdgedBracketClose;
end;
':':
begin
inc(CurPos.EndPos);
if (CurPos.EndPos>SrcLen) or (Src[CurPos.EndPos]<>'=') then begin
CurPos.Flag:=cafColon;
end else begin
// :=
inc(CurPos.EndPos);
end;
end;
'.':
begin
inc(CurPos.EndPos);
if (CurPos.EndPos>SrcLen) or (Src[CurPos.EndPos]<>'.') then begin
CurPos.Flag:=cafPoint;
end else begin
// ..
inc(CurPos.EndPos);
end;
end;
else
end;
'%':
begin
inc(CurPos.EndPos);
if CurPos.EndPos<=SrcLen then begin
c2:=Src[CurPos.EndPos];
// test for double char operators :=, +=, -=, /=, *=, <>, <=, >=, **, ><
if ((c2='=') and (IsEqualOperatorStartChar[c1]))
or ((c1='<') and (c2='>')) // not equal
or ((c1='>') and (c2='<'))
or ((c1='.') and (c2='.')) // subrange
or ((c1='*') and (c2='*'))
then inc(CurPos.EndPos);
if ((c1='@') and (c2='@')) then begin
repeat
inc(CurPos.EndPos);
until (CurPos.EndPos>SrcLen) or (not IsIdentChar[Src[CurPos.EndPos]]);
end;
while (CurPos.EndPos<=SrcLen) and (Src[CurPos.EndPos] in ['0'..'1']) do
inc(CurPos.EndPos);
end;
'$':
begin
inc(CurPos.EndPos);
while (CurPos.EndPos<=SrcLen)
and (IsHexNumberChar[UpperSrc[CurPos.EndPos]]) do
inc(CurPos.EndPos);
end;
';':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafSemicolon;
end;
',':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafComma;
end;
'=':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafEqual;
end;
'(':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafRoundBracketOpen;
end;
')':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafRoundBracketClose;
end;
'[':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafEdgedBracketOpen;
end;
']':
begin
inc(CurPos.EndPos);
CurPos.Flag:=cafEdgedBracketClose;
end;
':':
begin
inc(CurPos.EndPos);
if (Src[CurPos.EndPos]<>'=') then begin
CurPos.Flag:=cafColon;
end else begin
// :=
inc(CurPos.EndPos);
end;
end;
'.':
begin
inc(CurPos.EndPos);
if (Src[CurPos.EndPos]<>'.') then begin
CurPos.Flag:=cafPoint;
end else begin
// ..
inc(CurPos.EndPos);
end;
end;
else
inc(CurPos.EndPos);
c2:=Src[CurPos.EndPos];
// test for double char operators :=, +=, -=, /=, *=, <>, <=, >=, **, ><
if ((c2='=') and (IsEqualOperatorStartChar[c1]))
or ((c1='<') and (c2='>')) // not equal
or ((c1='>') and (c2='<'))
or ((c1='.') and (c2='.')) // subrange
or ((c1='*') and (c2='*'))
then inc(CurPos.EndPos);
if ((c1='@') and (c2='@')) then begin
repeat
inc(CurPos.EndPos);
until (CurPos.EndPos>SrcLen) or (not IsIdentChar[Src[CurPos.EndPos]]);
end;
end;
{$IFDEF RangeChecking}{$R+}{$ENDIF}
end;
procedure TCustomCodeTool.ReadPriorAtom;

View File

@ -1793,7 +1793,7 @@ begin
// this is an indexed property
exit;
end;
if CurPos.Flag=cafPoint then begin
if CurPos.Flag=cafColon then begin
ReadNextAtom;
AtomIsIdentifier(true);
OldPos:=CurPos.StartPos;