From 55c9353c30433d84066cccd8830cf5ad00e0c0d0 Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 21 Sep 2003 14:13:36 +0000 Subject: [PATCH] added Delphi7 source template and language features git-svn-id: trunk@4657 - --- components/codetools/keywordfunclists.pas | 26 ++++++++++++++++++++++- components/codetools/pascalparsertool.pas | 22 +++++++++++-------- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/components/codetools/keywordfunclists.pas b/components/codetools/keywordfunclists.pas index b45eb6c3c7..dbaf0ea813 100644 --- a/components/codetools/keywordfunclists.pas +++ b/components/codetools/keywordfunclists.pas @@ -113,7 +113,8 @@ var WordIsNumberOperator, WordIsPredefinedFPCIdentifier, WordIsPredefinedDelphiIdentifier, - UnexpectedKeyWordInBeginBlock: TKeyWordFunctionList; + UnexpectedKeyWordInBeginBlock, + UnexpectedKeyWordInAsmBlock: TKeyWordFunctionList; UpChars: array[char] of char; function UpperCaseStr(const s: string): string; @@ -963,6 +964,29 @@ begin Add('VAR',{$ifdef FPC}@{$endif}AllwaysTrue); end; + UnexpectedKeyWordInAsmBlock:=TKeyWordFunctionList.Create; + KeyWordLists.Add(UnexpectedKeyWordInAsmBlock); + with UnexpectedKeyWordInAsmBlock do begin + Add('CLASS',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('CONST',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('CONSTRUCTOR',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('DESTRUCTOR',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('FINALIZATION',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('FUNCTION',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('IMPLEMENTATION',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('INITIALIZATION',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('INTERFACE',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('LIBRARY',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('PROCEDURE',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('PROGRAM',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('RECORD',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('RESOURCESTRING',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('SET',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('THREADVAR',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('UNIT',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('VAR',{$ifdef FPC}@{$endif}AllwaysTrue); + end; + WordIsLogicalBlockStart:=TKeyWordFunctionList.Create; KeyWordLists.Add(WordIsLogicalBlockStart); with WordIsLogicalBlockStart do begin diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index bc78b6cd76..92a0918572 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -1337,14 +1337,13 @@ begin exit; end; end; - if CurPos.Flag<>cafSemicolon then begin + // check semicolon + if CurPos.Flag=cafSemicolon then begin + ReadNextAtom; + end else begin + // Delphi allows procs without ending semicolon if (Scanner.CompilerMode<>cmDelphi) then RaiseCharExpectedButAtomFound(';'); - // Delphi allows procs without ending semicolon - UndoReadNextAtom; // unread unknown atom - if CurPos.Flag=cafSemicolon then - UndoReadNextAtom; // unread semicolon - break; end; end else begin // current atom does not belong to procedure/method declaration @@ -1353,7 +1352,6 @@ begin UndoReadNextAtom; // unread semicolon break; end; - ReadNextAtom; until false; end; @@ -1903,12 +1901,18 @@ begin // check for unexpected keywords case BlockType of - ebtBegin,ebtAsm,ebtTry,ebtCase,ebtRepeat: + ebtBegin,ebtTry,ebtCase,ebtRepeat: if UnexpectedKeyWordInBeginBlock.DoItUppercase(UpperSrc, CurPos.StartPos,CurPos.EndPos-CurPos.StartPos) then RaiseUnexpectedKeyWordInBeginEndBlock; + ebtAsm: + if UnexpectedKeyWordInAsmBlock.DoItUppercase(UpperSrc, + CurPos.StartPos,CurPos.EndPos-CurPos.StartPos) + then + RaiseUnexpectedKeyWordInBeginEndBlock; + end; end; until false; @@ -3014,7 +3018,7 @@ begin CurNode.EndPos:=CurPos.EndPos; EndChildNode; // close record ReadNextAtom; - if UpAtomIs('PLATFORM') then ReadNextAtom; + if UpAtomIs('PLATFORM') or UpAtomIs('DEPRECATED') then ReadNextAtom; Result:=true; end;