* Fix nested comments (* *) style

git-svn-id: trunk@35625 -
This commit is contained in:
michael 2017-03-19 09:44:58 +00:00
parent d831c57883
commit 051f8568b3
2 changed files with 17 additions and 1 deletions

View File

@ -1983,7 +1983,8 @@ begin
TokenStart := TokenStr; TokenStart := TokenStr;
FCurTokenString := ''; FCurTokenString := '';
OldLength := 0; OldLength := 0;
while (TokenStr[0] <> '*') or (TokenStr[1] <> ')') do NestingLevel:=0;
while (TokenStr[0] <> '*') or (TokenStr[1] <> ')') or (NestingLevel>0) do
begin begin
if TokenStr[0] = #0 then if TokenStr[0] = #0 then
begin begin
@ -2002,8 +2003,17 @@ begin
TokenStart:=TokenStr; TokenStart:=TokenStr;
end end
else else
begin
If (msNestedComment in CurrentModeSwitches) then
begin
if (TokenStr[0] = '(') and (TokenStr[1] = '*') then
Inc(NestingLevel)
else if (TokenStr[0] = '*') and (TokenStr[1] = ')') and not PPIsSkipping then
Dec(NestingLevel);
end;
Inc(TokenStr); Inc(TokenStr);
end; end;
end;
SectionLength := TokenStr - TokenStart; SectionLength := TokenStr - TokenStart;
SetLength(FCurTokenString, OldLength + SectionLength); SetLength(FCurTokenString, OldLength + SectionLength);
if SectionLength > 0 then if SectionLength > 0 then

View File

@ -81,6 +81,7 @@ type
procedure TestNestedComment2; procedure TestNestedComment2;
procedure TestNestedComment3; procedure TestNestedComment3;
procedure TestNestedComment4; procedure TestNestedComment4;
procedure TestNestedComment5;
procedure TestIdentifier; procedure TestIdentifier;
procedure TestSelf; procedure TestSelf;
procedure TestSelfNoToken; procedure TestSelfNoToken;
@ -542,6 +543,11 @@ begin
TestToken(tkComment,'{ (* comment *) }'); TestToken(tkComment,'{ (* comment *) }');
end; end;
procedure TTestScanner.TestNestedComment5;
begin
TestToken(tkComment,'(* (* comment *) *)');
end;
procedure TTestScanner.TestIdentifier; procedure TTestScanner.TestIdentifier;