mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 04:56:02 +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
|
ctnOnIdentifier =113;// e.g. on E: Exception
|
||||||
ctnOnStatement =114;
|
ctnOnStatement =114;
|
||||||
|
|
||||||
|
ctnClassAbstract =120;
|
||||||
|
ctnClassSealed =121;
|
||||||
|
|
||||||
// combined values
|
// combined values
|
||||||
AllSourceTypes =
|
AllSourceTypes =
|
||||||
@ -165,6 +167,7 @@ const
|
|||||||
[ctnClass,ctnClassInterface,ctnObject,ctnObjCClass,ctnObjCProtocol];
|
[ctnClass,ctnClassInterface,ctnObject,ctnObjCClass,ctnObjCProtocol];
|
||||||
AllClassInterfaces = [ctnClassInterface,ctnObjCProtocol];
|
AllClassInterfaces = [ctnClassInterface,ctnObjCProtocol];
|
||||||
AllClassObjects = [ctnClass,ctnObject,ctnObjCClass];
|
AllClassObjects = [ctnClass,ctnObject,ctnObjCClass];
|
||||||
|
AllClassModifiers = [ctnClassAbstract, ctnClassSealed];
|
||||||
AllDefinitionSections =
|
AllDefinitionSections =
|
||||||
[ctnTypeSection,ctnVarSection,ctnConstSection,ctnResStrSection,
|
[ctnTypeSection,ctnVarSection,ctnConstSection,ctnResStrSection,
|
||||||
ctnLabelSection];
|
ctnLabelSection];
|
||||||
|
@ -153,6 +153,7 @@ type
|
|||||||
function KeyWordFuncProc: boolean;
|
function KeyWordFuncProc: boolean;
|
||||||
function KeyWordFuncBeginEnd: boolean;
|
function KeyWordFuncBeginEnd: boolean;
|
||||||
// class/object elements
|
// class/object elements
|
||||||
|
function KeyWordFuncClassModifier: boolean;
|
||||||
function KeyWordFuncClassSection: boolean;
|
function KeyWordFuncClassSection: boolean;
|
||||||
function KeyWordFuncClassTypeSection: boolean;
|
function KeyWordFuncClassTypeSection: boolean;
|
||||||
function KeyWordFuncClassVarSection: boolean;
|
function KeyWordFuncClassVarSection: boolean;
|
||||||
@ -415,6 +416,8 @@ begin
|
|||||||
if StartPos>SrcLen then exit(false);
|
if StartPos>SrcLen then exit(false);
|
||||||
p:=@Src[StartPos];
|
p:=@Src[StartPos];
|
||||||
case UpChars[p^] of
|
case UpChars[p^] of
|
||||||
|
'A':
|
||||||
|
if CompareSrcIdentifiers(p,'ABSTRACT') then exit(KeyWordFuncClassModifier);
|
||||||
'C':
|
'C':
|
||||||
case UpChars[p[1]] of
|
case UpChars[p[1]] of
|
||||||
'L': if CompareSrcIdentifiers(p,'CLASS') then exit(KeyWordFuncClassMethod);
|
'L': if CompareSrcIdentifiers(p,'CLASS') then exit(KeyWordFuncClassMethod);
|
||||||
@ -447,7 +450,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
'S':
|
'S':
|
||||||
if CompareSrcIdentifiers(p,'STATIC') then exit(KeyWordFuncClassMethod)
|
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':
|
'T':
|
||||||
if CompareSrcIdentifiers(p,'TYPE') then exit(KeyWordFuncClassTypeSection);
|
if CompareSrcIdentifiers(p,'TYPE') then exit(KeyWordFuncClassTypeSection);
|
||||||
'V':
|
'V':
|
||||||
@ -2849,6 +2853,23 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
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;
|
function TPascalParserTool.KeyWordFuncType: boolean;
|
||||||
{ The 'type' keyword is the start of a type section.
|
{ The 'type' keyword is the start of a type section.
|
||||||
examples:
|
examples:
|
||||||
|
Loading…
Reference in New Issue
Block a user