DelphiAST
DelphiAST copied to clipboard
Array digraphs (. .) do not work with integer indexes
The following code will not process correctly
unit TestAST;
interface
implementation
procedure test;
var
x: array of string;
begin
x[10]:= 'test';
x(.11.):= 'test2';
end;
end.
The 11 will be seen as a float number.
The fix is as follows:
procedure TmwBasePasLex.NumberProc;
begin
Inc(FBuffer.Run);
FTokenID := ptIntegerConst;
while CharInSet(FBuffer.Buf[FBuffer.Run], ['0'..'9', '.', 'e', 'E']) do
begin
case FBuffer.Buf[FBuffer.Run] of
'.':
if FBuffer.Buf[FBuffer.Run + 1] in ['.',')'] then //(. .) digraph
Break
else
FTokenID := ptFloat
end;
Inc(FBuffer.Run);
end;
end;
Will do a pull request if I find more issues.