Fix in Scripting

This commit is contained in:
Michael Schimmel
2025-09-23 10:32:14 +02:00
parent c573628fe5
commit 2f2c93d56e
+13 -1
View File
@@ -322,7 +322,19 @@ begin
begin
// Handle special forms
if SameText(head.Token.Text, 'if') then
begin
if not (Length(tailNodes) in [2, 3]) then
raise Exception.Create('Syntax Error in if statement.');
Result := TAst.IfExpr(tailNodes[0], tailNodes[1], IfThen(Length(tailNodes) > 2, tailNodes[2], nil))
end
else if SameText(head.Token.Text, '?') then
begin
if Length(tailNodes) <> 3 then
raise Exception.Create('Syntax Error in ternary statement.');
Result := TAst.TernaryExpr(tailNodes[0], tailNodes[1], tailNodes[2]);
end
else if SameText(head.Token.Text, 'def') then
begin
if tailTokens[0].Kind <> tkIdentifier then
@@ -531,7 +543,7 @@ end;
function TPrettyPrintVisitor.VisitTernaryExpression(const Node: ITernaryExpressionNode): TDataValue;
begin
Append('(if ');
Append('(? ');
Node.Condition.Accept(Self);
Indent;
NewLine;