mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-10 22:09:18 +02:00
* Support for escaped keywords using & ( bug ID #31708)
git-svn-id: trunk@35951 -
This commit is contained in:
parent
f5b8292b6e
commit
5d75dd6a32
@ -1942,10 +1942,18 @@ begin
|
||||
Inc(TokenStr);
|
||||
until not (TokenStr[0] in ['0'..'7']);
|
||||
SectionLength := TokenStr - TokenStart;
|
||||
SetLength(FCurTokenString, SectionLength);
|
||||
if SectionLength > 0 then
|
||||
Move(TokenStart^, FCurTokenString[1], SectionLength);
|
||||
Result := tkNumber;
|
||||
if (SectionLength=1) then // &Keyword
|
||||
begin
|
||||
DoFetchToken();
|
||||
Result:=tkIdentifier;
|
||||
end
|
||||
else
|
||||
begin
|
||||
SetLength(FCurTokenString, SectionLength);
|
||||
if SectionLength > 0 then
|
||||
Move(TokenStart^, FCurTokenString[1], SectionLength);
|
||||
Result := tkNumber;
|
||||
end;
|
||||
end;
|
||||
'$':
|
||||
begin
|
||||
|
@ -194,6 +194,7 @@ type
|
||||
procedure TestXor;
|
||||
procedure TestLineEnding;
|
||||
procedure TestTab;
|
||||
Procedure TestEscapedKeyWord;
|
||||
Procedure TestTokenSeries;
|
||||
Procedure TestTokenSeriesNoWhiteSpace;
|
||||
Procedure TestTokenSeriesComments;
|
||||
@ -407,6 +408,8 @@ begin
|
||||
FResolver.AddStream('afile.pp',TStringStream.Create(Source));
|
||||
Writeln('// '+TestName);
|
||||
Writeln(Source);
|
||||
// FreeAndNil(FScanner);
|
||||
// FScanner:=TTestingPascalScanner.Create(FResolver);
|
||||
FScanner.OpenFile('afile.pp');
|
||||
end;
|
||||
|
||||
@ -426,7 +429,8 @@ begin
|
||||
if (tk=tkLineEnding) and not (t in [tkEOF,tkLineEnding]) then
|
||||
tk:=FScanner.FetchToken;
|
||||
AssertEquals('EOF reached.',tkEOF,FScanner.FetchToken);
|
||||
end;
|
||||
end
|
||||
|
||||
end;
|
||||
|
||||
procedure TTestScanner.TestToken(t: TToken; const ASource: String;
|
||||
@ -1320,6 +1324,11 @@ begin
|
||||
TestToken(tkTab,#9);
|
||||
end;
|
||||
|
||||
procedure TTestScanner.TestEscapedKeyWord;
|
||||
begin
|
||||
TestToken(tkIdentifier,'&xor');
|
||||
end;
|
||||
|
||||
procedure TTestScanner.TestTokenSeries;
|
||||
begin
|
||||
TestTokens([tkin,tkWhitespace,tkOf,tkWhiteSpace,tkthen,tkWhiteSpace,tkIdentifier],'in of then aninteger')
|
||||
|
@ -162,6 +162,7 @@ type
|
||||
Procedure TestInvalidColon;
|
||||
Procedure TestTypeHelper;
|
||||
procedure TestPointerReference;
|
||||
Procedure TestPointerKeyWord;
|
||||
end;
|
||||
|
||||
{ TTestRecordTypeParser }
|
||||
@ -3326,6 +3327,15 @@ begin
|
||||
AssertEquals('object definition count',1,Declarations.Classes.Count);
|
||||
end;
|
||||
|
||||
procedure TTestTypeParser.TestPointerKeyWord;
|
||||
begin
|
||||
Add('type');
|
||||
Add(' &file = object');
|
||||
Add(' end;');
|
||||
ParseDeclarations;
|
||||
AssertEquals('object definition count',1,Declarations.Classes.Count);
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
RegisterTests([TTestTypeParser,TTestRecordTypeParser,TTestProcedureTypeParser]);
|
||||
|
Loading…
Reference in New Issue
Block a user