Fix in Scripting
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user