ce_dlang, fix #24, problem with nested comments

This commit is contained in:
Basile Burg 2016-03-01 05:21:58 +01:00
parent 2b53620a94
commit bb4bf42ccd
1 changed files with 22 additions and 3 deletions

View File

@ -351,6 +351,7 @@ procedure lex(const aText: string; aList: TLexTokenList; aCallBack: TLexFoundEve
var var
reader: TReaderHead; reader: TReaderHead;
identifier: string; identifier: string;
nestedCom: integer;
function isOutOfBound: boolean; function isOutOfBound: boolean;
begin begin
@ -446,11 +447,29 @@ begin
begin begin
if (reader.Next^ = '+') then if (reader.Next^ = '+') then
begin begin
nestedCom := 1;
if isOutOfBound then if isOutOfBound then
exit; exit;
while (reader.head^ <> '+') or (reader.Next^ <> '/') do repeat
if isOutOfBound then while ((reader.head^ <> '+') or (reader.head^ <> '/')) or
exit; ((reader.next^ <> '/') or (reader.head^ <> '+')) do
begin
if isOutOfBound then
exit;
if (reader.previous^ = '/') and (reader.next^ = '+') then
begin
nestedCom += 1;
break;
end;
if (reader.previous^ = '+') and (reader.next^ = '/') then
begin
nestedCom -= 1;
break;
end;
if isOutOfBound then
exit;
end;
until nestedCom = 0;
reader.Next; reader.Next;
addToken(ltkComment); addToken(ltkComment);
if callBackDoStop then if callBackDoStop then