codetools: parse generic class method

git-svn-id: trunk@57638 -
This commit is contained in:
mattias 2018-04-10 18:59:30 +00:00
parent f029765fd9
commit aca4d3b81b
2 changed files with 22 additions and 0 deletions

View File

@ -203,6 +203,7 @@ type
function KeyWordFuncClassClass: boolean;
function KeyWordFuncClassFinal: boolean;
function KeyWordFuncClassMethod: boolean;
function KeyWordFuncClassGenericMember: boolean;
function KeyWordFuncClassProperty: boolean;
function KeyWordFuncClassIdentifier: boolean;
// keyword lists
@ -519,6 +520,8 @@ begin
'I': if CompareSrcIdentifiers(p,'FINAL') and Scanner.Values.IsDefined('CPUJVM')
then exit(KeyWordFuncClassFinal);
end;
'G':
if CompareSrcIdentifiers(p,'GENERIC') then exit(KeyWordFuncClassGenericMember);
'P':
case UpChars[p[1]] of
'R':
@ -1374,6 +1377,21 @@ begin
Result:=true;
end;
function TPascalParserTool.KeyWordFuncClassGenericMember: boolean;
var
p: PChar;
begin
ReadNextAtom;
if CurPos.Flag=cafNone then
SaveRaiseStringExpectedButAtomFound(20180410195348,'class');
p:=@Src[CurPos.StartPos];
case UpChars[p^] of
'C':
if CompareSrcIdentifiers(p,'CLASS') then exit(KeyWordFuncClassClass);
end;
SaveRaiseStringExpectedButAtomFound(20180410195349,'class');
end;
function TPascalParserTool.ReadParamList(ExceptionOnError, Extract: boolean;
const Attr: TProcHeadAttributes): boolean;
{ parse parameter list

View File

@ -421,6 +421,7 @@ begin
' TBird<B> = class(TAnimal<B>)',
' procedure DoIt;', // normal proc inside generic class
' procedure DoSome<T>;', // generic proc inside generic class
' generic class procedure DoGen<P>(i: P);',
' end;',
'procedure TRec.Proc<T>;', // generic proc inside normal record
'begin',
@ -431,6 +432,9 @@ begin
'procedure TBird<B>.DoSome<T>;', // generic proc inside generic class
'begin',
'end;',
'generic class procedure TBird<B>.DoGen<P>(i: P);',
'begin',
'end;',
'begin']);
ParseModule;
end;