From deb076e47da05c095fcf4eb512c751d97190d615 Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 29 Feb 2008 19:29:41 +0000 Subject: [PATCH] codetools: implemented parsing pointer to function git-svn-id: trunk@14328 - --- components/codetools/ccodeparsertool.pas | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/components/codetools/ccodeparsertool.pas b/components/codetools/ccodeparsertool.pas index d777a37e92..89879fb81f 100644 --- a/components/codetools/ccodeparsertool.pas +++ b/components/codetools/ccodeparsertool.pas @@ -82,6 +82,7 @@ type function DirectiveToken: boolean; function EnumToken: boolean; function ExternToken: boolean; + function CurlyBracketCloseToken: boolean; function TypedefToken: boolean; function StructToken: boolean; procedure InitKeyWordList; @@ -249,6 +250,12 @@ begin RaiseExpectedButAtomFound('{'); end; +function TCCodeParserTool.CurlyBracketCloseToken: boolean; +begin + Result:=true; + +end; + procedure TCCodeParserTool.ReadEnum; (* For example: enum { @@ -400,6 +407,7 @@ begin with FDefaultTokenList do begin Add('#',{$ifdef FPC}@{$endif}DirectiveToken); Add('extern',{$ifdef FPC}@{$endif}ExternToken); + Add('}',{$ifdef FPC}@{$endif}CurlyBracketCloseToken); Add('enum',{$ifdef FPC}@{$endif}EnumToken); Add('typedef',{$ifdef FPC}@{$endif}TypedefToken); Add('struct',{$ifdef FPC}@{$endif}StructToken); @@ -550,6 +558,20 @@ begin if not IsCCodeCustomOperator.DoItCaseSensitive(Src,AtomStart,SrcPos-AtomStart) then RaiseExpectedButAtomFound('operator'); + end else if AtomIsChar('(') then begin + // example: int (*fp)(char*); + // pointer to function taking a char* argument; returns an int + ReadNextAtom; + while AtomIsChar('*') do begin + // pointer + ReadNextAtom; + end; + DebugLn(['TCCodeParserTool.ReadVariable name=',GetAtom]); + if not AtomIsIdentifier then + RaiseExpectedButAtomFound('identifier'); + ReadNextAtom; + if not AtomIsChar(')') then + RaiseExpectedButAtomFound(')'); end else begin while AtomIsChar('*') do begin // pointer