From 5d55835b0d24fc02a25007dd481538f75b6b38bf Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 26 Dec 2011 12:52:46 +0000 Subject: [PATCH] codetools: started &keyword identifiers git-svn-id: trunk@34428 - --- components/codetools/basiccodetools.pas | 19 +++++++++++++++---- components/codetools/customcodetool.pas | 12 +++++++++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/components/codetools/basiccodetools.pas b/components/codetools/basiccodetools.pas index 7b57699a70..31c9265508 100644 --- a/components/codetools/basiccodetools.pas +++ b/components/codetools/basiccodetools.pas @@ -1896,11 +1896,16 @@ begin while IsHexNumberChar[Src^] do inc(Src); end; - '&': // octal constant + '&': // octal constant or keyword as identifier (e.g. &label) begin inc(Src); - while (Src^ in ['0'..'7']) do - inc(Src); + if Src^ in ['0'..'7'] then begin + while Src^ in ['0'..'7'] do + inc(Src); + end else begin + while IsIdentChar[Src^] do + inc(Src); + end; end; '{': // compiler directive begin @@ -3892,7 +3897,13 @@ end; function GetIdentifier(Identifier: PChar): string; var len: integer; begin - if (Identifier<>nil) and IsIdentStartChar[Identifier^] then begin + if (Identifier=nil) then begin + Result:=''; + exit; + end; + if (Identifier^='&') and (IsIdentChar[Identifier[1]]) then + inc(Identifier); + if IsIdentStartChar[Identifier^] then begin len:=0; while (IsIdentChar[Identifier[len]]) do inc(len); SetLength(Result,len); diff --git a/components/codetools/customcodetool.pas b/components/codetools/customcodetool.pas index a7622d537c..3e8cc6f7ae 100644 --- a/components/codetools/customcodetool.pas +++ b/components/codetools/customcodetool.pas @@ -1192,11 +1192,17 @@ begin inc(p); CurPos.EndPos:=p-PChar(Src)+1; end; - '&': // octal number + '&': // octal number or keyword as identifier begin inc(p); - while p^ in ['0'..'7'] do - inc(p); + if p^ in ['0'..'7'] then begin + while p^ in ['0'..'7'] do + inc(p); + end else if IsIdentChar[p^] then begin + CurPos.Flag:=cafWord; + while IsIdentChar[p^] do + inc(p); + end; CurPos.EndPos:=p-PChar(Src)+1; end; '$': // hex number