codetools: fixed parsing (* comments

git-svn-id: trunk@14115 -
This commit is contained in:
mattias 2008-02-12 17:51:41 +00:00
parent ac191520f1
commit 746753524e
2 changed files with 24 additions and 23 deletions

View File

@ -1626,7 +1626,7 @@ begin
end; end;
end; end;
'/': // comment or real division '/': // comment or real division
if (Position<Len) and (Source[Position]='/') then begin if (Position<Len) and (Source[Position+1]='/') then begin
// comment start -> read til line end // comment start -> read til line end
inc(Position); inc(Position);
while (Position<=Len) and (not (Source[Position] in [#10,#13])) do while (Position<=Len) and (not (Source[Position] in [#10,#13])) do
@ -1634,7 +1634,7 @@ begin
end else end else
break; break;
'(': // comment, bracket or compiler directive '(': // comment, bracket or compiler directive
if (Position<Len) and (Source[Position]='*') then begin if (Position<Len) and (Source[Position+1]='*') then begin
if (Position+2<=Len) and (Source[Position]='$') then if (Position+2<=Len) and (Source[Position]='$') then
// compiler directive // compiler directive
break break

View File

@ -1371,7 +1371,7 @@ procedure TCompilerDirectivesTree.DisableIfNode(Node: TCodeTreeNode;
procedure RaiseImpossible; procedure RaiseImpossible;
begin begin
raise ECDirectiveParserException.Create(Self,'TCompilerDirectivesTree.DisableIfNode'); raise ECDirectiveParserException.Create(Self,'TCompilerDirectivesTree.DisableIfNode impossible');
end; end;
function GetExpr(ExprNode: TCodeTreeNode; out Negated: boolean): string; function GetExpr(ExprNode: TCodeTreeNode; out Negated: boolean): string;
@ -1616,15 +1616,14 @@ var
procedure CheckNode; procedure CheckNode;
begin begin
//DebugLn(['CheckNode ',Node.Desc=cdnIf,' ',(Node.NextBrother<>nil),' ',(Node.FirstChild=nil),' ',GetDirective(Node)]);
case Node.Desc of case Node.Desc of
cdnIf,cdnElse,cdnElseIf: ; cdnIf,cdnElseIf,cdnElse:
else exit; if (Node.NextBrother<>nil) and (Node.FirstChild=nil) then begin
end;
if (Node.NextBrother=nil) or (Node.FirstChild<>nil) then exit;
case Node.NextBrother.Desc of case Node.NextBrother.Desc of
cdnEnd,cdnElse,cdnElseIf: cdnEnd,cdnElseIf,cdnElse:
if Node.FirstChild=nil then begin begin
//DebugLn(['CheckNode Checking if empty ...']);
MoveCursorToPos(Node.StartPos); MoveCursorToPos(Node.StartPos);
// skip directive // skip directive
ReadNextAtom; ReadNextAtom;
@ -1641,6 +1640,8 @@ var
end; end;
end; end;
end; end;
end;
end;
begin begin
//DebugLn(['TCompilerDirectivesTree.RemoveEmptyNodes ']); //DebugLn(['TCompilerDirectivesTree.RemoveEmptyNodes ']);