Skip to content

Commit

Permalink
Fix RomanYankovsky#134: Fails to parse code with ^\
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanYankovsky committed Oct 10, 2015
1 parent 983dda2 commit 2a4ce1f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Source/SimpleParser/SimpleParser.Lexer.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1861,13 +1861,17 @@ procedure TmwBasePasLex.PlusProc;
end;

procedure TmwBasePasLex.PointerSymbolProc;
const
PointerChars = ['a'..'z', 'A'..'Z', '\', '!', '"', '#', '$', '%', '&', '''', '(', ')',
'*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '@', '[',
']', '^', '_', '`', '{', '|', '}', '~'];
begin
Inc(Run);
FTokenID := ptPointerSymbol;

//This is a wierd Pascal construct that rarely appears, but needs to be
//supported. ^M is a valid char reference (#13, in this case)
if CharInSet(FOrigin[Run], ['a'..'z','A'..'Z']) and not IsIdentifiers(FOrigin[Run+1]) then
if CharInSet(FOrigin[Run], PointerChars) and not IsIdentifiers(FOrigin[Run+1]) then
begin
Inc(Run);
FTokenID := ptAsciiChar;
Expand Down
25 changes: 25 additions & 0 deletions Test/Snippets/pointerchars.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
unit pointerchars;

interface

implementation

procedure FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = ^\ then
begin
//some code
end;

if Key = ^M then
begin
//some code
end;

if Key = ^] then
begin
//some code
end;
end;

end.

0 comments on commit 2a4ce1f

Please sign in to comment.