mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-01 05:32:35 +02:00
codetools: support abstract/sealed class modifiers
git-svn-id: trunk@22211 -
This commit is contained in:
parent
63838ba0cf
commit
f1e1cc8ec1
@ -143,6 +143,8 @@ const
|
||||
ctnOnIdentifier =113;// e.g. on E: Exception
|
||||
ctnOnStatement =114;
|
||||
|
||||
ctnClassAbstract =120;
|
||||
ctnClassSealed =121;
|
||||
|
||||
// combined values
|
||||
AllSourceTypes =
|
||||
@ -165,6 +167,7 @@ const
|
||||
[ctnClass,ctnClassInterface,ctnObject,ctnObjCClass,ctnObjCProtocol];
|
||||
AllClassInterfaces = [ctnClassInterface,ctnObjCProtocol];
|
||||
AllClassObjects = [ctnClass,ctnObject,ctnObjCClass];
|
||||
AllClassModifiers = [ctnClassAbstract, ctnClassSealed];
|
||||
AllDefinitionSections =
|
||||
[ctnTypeSection,ctnVarSection,ctnConstSection,ctnResStrSection,
|
||||
ctnLabelSection];
|
||||
|
@ -153,6 +153,7 @@ type
|
||||
function KeyWordFuncProc: boolean;
|
||||
function KeyWordFuncBeginEnd: boolean;
|
||||
// class/object elements
|
||||
function KeyWordFuncClassModifier: boolean;
|
||||
function KeyWordFuncClassSection: boolean;
|
||||
function KeyWordFuncClassTypeSection: boolean;
|
||||
function KeyWordFuncClassVarSection: boolean;
|
||||
@ -415,6 +416,8 @@ begin
|
||||
if StartPos>SrcLen then exit(false);
|
||||
p:=@Src[StartPos];
|
||||
case UpChars[p^] of
|
||||
'A':
|
||||
if CompareSrcIdentifiers(p,'ABSTRACT') then exit(KeyWordFuncClassModifier);
|
||||
'C':
|
||||
case UpChars[p[1]] of
|
||||
'L': if CompareSrcIdentifiers(p,'CLASS') then exit(KeyWordFuncClassMethod);
|
||||
@ -447,7 +450,8 @@ begin
|
||||
end;
|
||||
'S':
|
||||
if CompareSrcIdentifiers(p,'STATIC') then exit(KeyWordFuncClassMethod)
|
||||
else if CompareSrcIdentifiers(p,'STRICT') then exit(KeyWordFuncClassSection);
|
||||
else if CompareSrcIdentifiers(p,'STRICT') then exit(KeyWordFuncClassSection)
|
||||
else if CompareSrcIdentifiers(p,'SEALED') then exit(KeyWordFuncClassModifier);
|
||||
'T':
|
||||
if CompareSrcIdentifiers(p,'TYPE') then exit(KeyWordFuncClassTypeSection);
|
||||
'V':
|
||||
@ -2849,6 +2853,23 @@ begin
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TPascalParserTool.KeyWordFuncClassModifier: boolean;
|
||||
// change class modifier (abstract, sealed)
|
||||
begin
|
||||
// end last section
|
||||
CurNode.EndPos:=CurPos.StartPos;
|
||||
EndChildNode;
|
||||
// start modifier
|
||||
CreateChildNode;
|
||||
if UpAtomIs('ABSTRACT') then
|
||||
CurNode.Desc:=ctnClassAbstract
|
||||
else if UpAtomIs('SEALED') then
|
||||
CurNode.Desc:=ctnClassSealed
|
||||
else
|
||||
RaiseStringExpectedButAtomFound('abstract/sealed');
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TPascalParserTool.KeyWordFuncType: boolean;
|
||||
{ The 'type' keyword is the start of a type section.
|
||||
examples:
|
||||
|
Loading…
Reference in New Issue
Block a user