DelphiAST
DelphiAST copied to clipboard
Indexed node order is right to left instead of left to right
The node order is left to right, but for indexed nodes the order is right to left.
Sample
procedure TestIndexedOrder;
var
F: TFoo;
O: TObject;
begin
F := TFoo.Create;
try
O := F[0][1][2];
finally
F.Free;
end;
end;
Current AST for "F[0][1][2]"
ntExpression
|- ntIndexed
|- ntExpression
|- ntLiteral [anType = numeric Value = 2]
|- ntIndexed
|- ntExpression
|- ntLiteral [anType = numeric Value = 1]
|- ntIndexed
|- ntExpression
|- ntLiteral [anType = numeric Value = 0]
|- ntIdentifier [anName = F]
Expected AST is
ntExpression
|- ntIndexed
|- ntIdentifier [anName = F]
|- ntIndexed
|- ntExpression
|- ntLiteral [anType = numeric Value = 0]
|- ntIndexed
|- ntExpression
|- ntLiteral [anType = numeric Value = 1]
|- ntExpression
|- ntLiteral [anType = numeric Value = 2]
Hm. I don't agree. DelphiAST AST says "[0] applied to F then [1] applied to its result and then [2] applied to its result". Isn't this correct?