소스 검색

Handle ; inside for expression lists.

Martijn Laan 7 년 전
부모
커밋
e8c4cad688
1개의 변경된 파일14개의 추가작업 그리고 6개의 파일을 삭제
  1. 14 6
      Components/ScintStylerInnoSetup.pas

+ 14 - 6
Components/ScintStylerInnoSetup.pas

@@ -936,7 +936,7 @@ var
   S: TScintRawString;
   S: TScintRawString;
   StartIndex, I: Integer;
   StartIndex, I: Integer;
   C: AnsiChar;
   C: AnsiChar;
-  NeedIspp: Boolean;
+  NeedIspp, ForDirectiveExpressionsNext: Boolean;
 begin
 begin
   StartIndex := CurIndex;
   StartIndex := CurIndex;
   if InlineDirective then begin
   if InlineDirective then begin
@@ -944,6 +944,7 @@ begin
     NeedIspp := True;
     NeedIspp := True;
   end else
   end else
     NeedIspp := False; { Might be updated later to True later }
     NeedIspp := False; { Might be updated later to True later }
+  ForDirectiveExpressionsNext := False;
   ConsumeChar('#');
   ConsumeChar('#');
   CommitStyle(stCompilerDirective);
   CommitStyle(stCompilerDirective);
 
 
@@ -958,6 +959,7 @@ begin
     for I := Low(ISPPDirectives) to High(ISPPDirectives) do
     for I := Low(ISPPDirectives) to High(ISPPDirectives) do
       if SameRawText(S, ISPPDirectives[I].Name) then begin
       if SameRawText(S, ISPPDirectives[I].Name) then begin
         NeedIspp := not SameRawText(S, 'include'); { Built-in preprocessor only supports '#include' }
         NeedIspp := not SameRawText(S, 'include'); { Built-in preprocessor only supports '#include' }
+        ForDirectiveExpressionsNext := SameRawText(S, 'for'); { #for uses ';' as an expressions list separator so we need to remember that ';' doesn't start a comment until the list is done }
         Inc(OpenCount, ISPPDirectives[I].OpenCountChange);
         Inc(OpenCount, ISPPDirectives[I].OpenCountChange);
         if OpenCount < 0 then begin
         if OpenCount < 0 then begin
           CommitStyleSq(stCompilerDirective, True);
           CommitStyleSq(stCompilerDirective, True);
@@ -1008,6 +1010,8 @@ begin
         '?', ':', ',', '.', '~', '(', '[', '{', ')', ']', '}', '@',
         '?', ':', ',', '.', '~', '(', '[', '{', ')', ']', '}', '@',
         '#':
         '#':
           begin
           begin
+            if (C = '}') and ForDirectiveExpressionsNext then
+              ForDirectiveExpressionsNext := False;
             if (C = '/') and ConsumeChar('*') then
             if (C = '/') and ConsumeChar('*') then
               FinishConsumingStarComment
               FinishConsumingStarComment
             else if InlineDirective and (C = '}') then
             else if InlineDirective and (C = '}') then
@@ -1017,11 +1021,15 @@ begin
           end;
           end;
         ';':
         ';':
           begin
           begin
-            if not InlineDirective then
-              ConsumeAllRemaining
-            else
-              ConsumeCharsNot(['}']);
-            CommitStyle(stComment);
+            if ForDirectiveExpressionsNext then
+              CommitStyle(stSymbol)
+            else begin
+              if not InlineDirective then
+                ConsumeAllRemaining
+              else
+                ConsumeCharsNot(['}']);
+              CommitStyle(stComment);
+            end;
           end;
           end;
         '''', '"':
         '''', '"':
           begin
           begin