Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array digraphs (. .) do not work with integer indexes #263

Open
JBontes opened this issue Apr 5, 2018 · 1 comment
Open

Array digraphs (. .) do not work with integer indexes #263

JBontes opened this issue Apr 5, 2018 · 1 comment

Comments

@JBontes
Copy link

JBontes commented Apr 5, 2018

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.

@JBontes
Copy link
Author

JBontes commented Apr 5, 2018

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.

@JBontes JBontes changed the title array digraphs do not work with integer indexes Array digraphs (. .) do not work with integer indexes Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant