Fix in Scripting
This commit is contained in:
@@ -322,7 +322,19 @@ begin
|
|||||||
begin
|
begin
|
||||||
// Handle special forms
|
// Handle special forms
|
||||||
if SameText(head.Token.Text, 'if') then
|
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))
|
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
|
else if SameText(head.Token.Text, 'def') then
|
||||||
begin
|
begin
|
||||||
if tailTokens[0].Kind <> tkIdentifier then
|
if tailTokens[0].Kind <> tkIdentifier then
|
||||||
@@ -531,7 +543,7 @@ end;
|
|||||||
|
|
||||||
function TPrettyPrintVisitor.VisitTernaryExpression(const Node: ITernaryExpressionNode): TDataValue;
|
function TPrettyPrintVisitor.VisitTernaryExpression(const Node: ITernaryExpressionNode): TDataValue;
|
||||||
begin
|
begin
|
||||||
Append('(if ');
|
Append('(? ');
|
||||||
Node.Condition.Accept(Self);
|
Node.Condition.Accept(Self);
|
||||||
Indent;
|
Indent;
|
||||||
NewLine;
|
NewLine;
|
||||||
|
|||||||
Reference in New Issue
Block a user