From ec66ae883a5726510dc522756a8f8843e7f3abe2 Mon Sep 17 00:00:00 2001 From: mattias Date: Tue, 31 Jan 2012 02:25:25 +0000 Subject: [PATCH] codetools: parse class helper git-svn-id: trunk@35047 - --- components/codetools/codetree.pas | 26 +++++++++++--------- components/codetools/pascalparsertool.pas | 29 ++++++++++++++++++++++- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/components/codetools/codetree.pas b/components/codetools/codetree.pas index 4c6708111d..d2a31a3a78 100644 --- a/components/codetools/codetree.pas +++ b/components/codetools/codetree.pas @@ -95,17 +95,19 @@ const ctnClassAbstract = 40; ctnClassSealed = 41; ctnClassExternal = 42; - ctnClassInheritance = 43; - ctnClassGUID = 44; - ctnClassClassVar = 45; // child of visibility section - ctnClassPrivate = 46; // child of AllClassObjects - ctnClassProtected = 47; - ctnClassPublic = 48; - ctnClassPublished = 49; - ctnClassRequired = 50; - ctnClassOptional = 51; - ctnProperty = 52; // child of visibility section or AllClassInterfaces - ctnMethodMap = 53; // child of visibility section or AllClassInterfaces + ctnClassHelper = 43; + ctnClassInheritance = 44; + ctnClassHelperFor = 45; + ctnClassGUID = 46; + ctnClassClassVar = 47; // child of visibility section + ctnClassPrivate = 48; // child of AllClassObjects + ctnClassProtected = 49; + ctnClassPublic = 50; + ctnClassPublished = 51; + ctnClassRequired = 52; + ctnClassOptional = 53; + ctnProperty = 54; // child of visibility section or AllClassInterfaces + ctnMethodMap = 55; // child of visibility section or AllClassInterfaces ctnProcedure = 60; // children: ctnProcedureHead, sections, ctnBeginBlock/ctnAsmBlock ctnProcedureHead = 61; // children: ctnParameterList, operator: ctnVarDefinition, operator/function: ctnIdentifier @@ -371,6 +373,8 @@ begin ctnClassAbstract: Result:='abstract'; ctnClassSealed: Result:='sealed'; ctnClassExternal: Result:='external'; + ctnClassHelper: Result:='helper'; + ctnClassHelperFor: Result:='(helper) for'; ctnProcedure: Result:='Procedure'; ctnProcedureHead: Result:='ProcedureHead'; diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index 68dcac1b7f..2c8f3262b3 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -3851,6 +3851,7 @@ var IsForward: Boolean; ClassDesc: TCodeTreeNodeDesc; ClassNode: TCodeTreeNode; + IsHelper: Boolean; begin //debugln(['TPascalParserTool.KeyWordFuncTypeClass ',GetAtom,' ',CleanPosToStr(CurPos.StartPos)]); // class or 'class of' start found @@ -3887,8 +3888,10 @@ begin CurNode.Desc:=ClassDesc; CurNode.StartPos:=ClassAtomPos.StartPos; IsForward:=true; + IsHelper:=false; ReadNextAtom; if (ClassDesc=ctnClass) and UpAtomIs('OF') then begin + // class of IsForward:=false; CurNode.Desc:=ctnClassOfType; ReadNextAtom; @@ -3936,6 +3939,13 @@ begin CurNode.EndPos:=CurPos.StartPos; EndChildNode; end; + end else if UpAtomIs('HELPER') then begin + IsHelper:=true; + CreateChildNode; + CurNode.Desc:=ctnClassHelper; + CurNode.EndPos:=CurPos.EndPos; + EndChildNode; + ReadNextAtom; end; end; if (CurPos.Flag=cafRoundBracketOpen) then begin @@ -3944,6 +3954,19 @@ begin ReadClassInheritance(true); ReadNextAtom; end; + if IsHelper then begin + if not UpAtomIs('FOR') then + RaiseStringExpectedButAtomFound('for'); + CreateChildNode; + CurNode.Desc:=ctnClassHelperFor; + repeat + ReadNextAtom; + AtomIsIdentifier(true); + CurNode.EndPos:=CurPos.EndPos; + ReadNextAtom; + until CurPos.Flag<>cafPoint; + EndChildNode; + end; end; if CurPos.Flag=cafSemicolon then begin if (ClassDesc in AllClassObjects) then @@ -4647,8 +4670,12 @@ begin end; procedure TPascalParserTool.RaiseCharExpectedButAtomFound(c: char); +var + a: String; begin - SaveRaiseExceptionFmt(ctsStrExpectedButAtomFound,[c,GetAtom]); + a:=GetAtom; + if a='' then a:=ctsEndOfFile; + SaveRaiseExceptionFmt(ctsStrExpectedButAtomFound,[c,a]); end; procedure TPascalParserTool.RaiseStringExpectedButAtomFound(const s: string);