From f1e1cc8ec13edaf9c519bf957a7a71298c8d2bdb Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 18 Oct 2009 04:38:18 +0000 Subject: [PATCH] codetools: support abstract/sealed class modifiers git-svn-id: trunk@22211 - --- components/codetools/codetree.pas | 3 +++ components/codetools/pascalparsertool.pas | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/components/codetools/codetree.pas b/components/codetools/codetree.pas index 8fb86b5a0b..6e134e2fea 100644 --- a/components/codetools/codetree.pas +++ b/components/codetools/codetree.pas @@ -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]; diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index 9e53935e25..141857216a 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -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: