Comment in AST script

This commit is contained in:
Michael Schimmel
2025-10-03 11:53:02 +02:00
parent ecbe39abac
commit d47c1417f5
3 changed files with 39 additions and 13 deletions
+20 -3
View File
@@ -178,8 +178,26 @@ end;
function TLexer.GetNextToken: TToken;
begin
while (FCurrentPos <= Length(FSource)) and FSource[FCurrentPos].IsWhiteSpace do
Advance;
// Skip whitespace and comments
while FCurrentPos <= Length(FSource) do
begin
if FSource[FCurrentPos].IsWhiteSpace then
begin
Advance;
continue;
end;
if FSource[FCurrentPos] = ';' then
begin
// Comment found, skip to the end of the line
while (FCurrentPos <= Length(FSource)) and (not CharInSet(FSource[FCurrentPos], [#10, #13])) do
Advance;
continue;
end;
// No whitespace or comment, so break out and process the token
break;
end;
if FCurrentPos > Length(FSource) then
begin
@@ -445,7 +463,6 @@ begin
end;
{ TPrettyPrintVisitor }
// ... (Implementation of TPrettyPrintVisitor is unchanged and correct) ...
constructor TPrettyPrintVisitor.Create;
begin
inherited Create;