DelphiAST icon indicating copy to clipboard operation
DelphiAST copied to clipboard

Indexed node order is right to left instead of left to right

Open uschuster opened this issue 9 years ago • 1 comments

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]

uschuster avatar Sep 17 '16 07:09 uschuster

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?

RomanYankovsky avatar Mar 08 '17 14:03 RomanYankovsky