From e2538d01bcf2fc5041e532f0f79b3853afc74f22 Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 28 May 2010 18:47:50 +0000 Subject: [PATCH] codetools: removed cafBegin git-svn-id: trunk@25737 - --- components/codetools/codeatom.pas | 6 +++--- components/codetools/customcodetool.pas | 19 +++++------------ components/codetools/identcompletiontool.pas | 8 ++++--- components/codetools/keywordfunclists.pas | 22 +++++++++++++++++++- components/codetools/pascalparsertool.pas | 11 +++++----- components/codetools/stdcodetools.pas | 6 +++--- 6 files changed, 43 insertions(+), 29 deletions(-) diff --git a/components/codetools/codeatom.pas b/components/codetools/codeatom.pas index 61943609f3..b9ddaccf1e 100644 --- a/components/codetools/codeatom.pas +++ b/components/codetools/codeatom.pas @@ -59,18 +59,18 @@ type cafSemicolon, cafEqual, cafColon, cafComma, cafPoint, cafRoundBracketOpen, cafRoundBracketClose, cafEdgedBracketOpen, cafEdgedBracketClose, - cafWord, cafEnd, cafRecord, cafBegin + cafWord, cafEnd, cafRecord ); const CleanCodeXYPosition: TCodeXYPosition = (X:0; Y:0; Code:nil); - AllCommonAtomWords = [cafWord, cafEnd, cafRecord, cafBegin]; + AllCommonAtomWords = [cafWord, cafEnd, cafRecord]; CommonAtomFlagNames: array[TCommonAtomFlag] of shortstring = ( 'None', 'Semicolon', 'Equal', 'Colon', 'Comma', 'Point', 'RoundBracketOpen', 'RoundBracketClose', 'EdgedBracketOpen', 'EdgedBracketClose', - 'Word', 'End', 'Record', 'Begin' + 'Word', 'End', 'Record' ); type diff --git a/components/codetools/customcodetool.pas b/components/codetools/customcodetool.pas index 900af019d4..217313d375 100644 --- a/components/codetools/customcodetool.pas +++ b/components/codetools/customcodetool.pas @@ -984,11 +984,6 @@ begin CurPos.Flag:=cafWord; CurPos.EndPos:=p-PChar(Src)+1; case c1 of - 'b','B': - if (CurPos.EndPos-CurPos.StartPos=5) - and UpAtomIs('BEGIN') - then - CurPos.Flag:=cafBegin; 'e','E': if (CurPos.EndPos-CurPos.StartPos=3) and (Src[CurPos.StartPos+1] in ['n','N']) @@ -1413,11 +1408,6 @@ begin CurPos.Flag:=cafEnd else CurPos.Flag:=cafWord; - 'B': - if CompareSrcIdentifiers(CurPos.StartPos,'BEGIN') then - CurPos.Flag:=cafBegin - else - CurPos.Flag:=cafWord; 'R': if CompareSrcIdentifiers(CurPos.StartPos,'RECORD') then CurPos.Flag:=cafRecord @@ -1534,9 +1524,6 @@ begin 'E': if CompareSrcIdentifiers(CurPos.StartPos,'END') then CurPos.Flag:=cafEnd; - 'B': - if CompareSrcIdentifiers(CurPos.StartPos,'BEGIN') then - CurPos.Flag:=cafBegin; 'R': if CompareSrcIdentifiers(CurPos.StartPos,'RECORD') then CurPos.Flag:=cafRecord; @@ -1672,7 +1659,11 @@ begin ReadPriorAtom; if (CurPos.Flag=OpenBracket) then break; if (CurPos.StartPos<1) - or (CurPos.Flag in [AntiOpenBracket,cafEND,cafBegin]) then begin + or (CurPos.Flag in [AntiOpenBracket,cafEND]) + or ((CurPos.Flag=cafWord) + and UnexpectedKeyWordInBrackets.DoItCaseInsensitive(Src, + CurPos.StartPos,CurPos.EndPos-CurPos.StartPos)) + then begin CurPos:=Start; if ExceptionOnNotFound then RaiseBracketNotFound; diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index c1d7ac6f9e..025fae4228 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -1973,7 +1973,8 @@ begin if (ilcfStartInStatement in CurrentIdentifierList.ContextFlags) then begin // check if LValue - if (CurPos.Flag in [cafSemicolon,cafBegin,cafEnd]) + if (CurPos.Flag in [cafSemicolon,cafEnd]) + or UpAtomIs('BEGIN') or UpAtomIs('TRY') or UpAtomIs('FINALLY') or UpAtomIs('EXCEPT') or UpAtomIs('FOR') or UpAtomIs('DO') or UpAtomIs('REPEAT') or UpAtomIs('ASM') or UpAtomIs('ELSE') @@ -2028,7 +2029,7 @@ begin and (not (ilcfStartOfStatement in CurrentIdentifierList.ContextFlags)) then begin // check if a semicolon is needed at the end - if (CurPos.Flag in [cafEnd,cafBegin]) + if (CurPos.Flag in [cafEnd]) or WordIsBlockKeyWord.DoItCaseInsensitive(Src, CurPos.StartPos,CurPos.EndPos-CurPos.StartPos) or ((CurPos.Flag=cafWord) @@ -2101,8 +2102,9 @@ var begin MoveCursorToAtomPos(ProcNameAtom); ReadPriorAtom; - if (CurPos.Flag in [cafEnd,cafSemicolon,cafBegin,cafColon, + if (CurPos.Flag in [cafEnd,cafSemicolon,cafColon, cafRoundBracketOpen,cafEdgedBracketOpen]) + or UpAtomIs('BEGIN') or UpAtomIs('TRY') or UpAtomIs('FINALLY') or UpAtomIs('EXCEPT') or UpAtomIs('REPEAT') or UpAtomIs('ASM') then begin // see fpc/compiler/psystem.pp diff --git a/components/codetools/keywordfunclists.pas b/components/codetools/keywordfunclists.pas index bad738d6fa..97b2e4a24f 100644 --- a/components/codetools/keywordfunclists.pas +++ b/components/codetools/keywordfunclists.pas @@ -149,7 +149,9 @@ var WordIsPredefinedFPCIdentifier, WordIsPredefinedDelphiIdentifier, UnexpectedKeyWordInBeginBlock, - UnexpectedKeyWordInAsmBlock: TKeyWordFunctionList; + UnexpectedKeyWordInAsmBlock, + UnexpectedKeyWordInBrackets + : TKeyWordFunctionList; UpChars: array[char] of char; IsSpaceChar, @@ -1232,6 +1234,24 @@ begin Add('VAR',{$ifdef FPC}@{$endif}AllwaysTrue); end; + UnexpectedKeyWordInBrackets:=TKeyWordFunctionList.Create; + KeyWordLists.Add(UnexpectedKeyWordInBrackets); + with UnexpectedKeyWordInBrackets do begin + Add('BEGIN',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('THEN',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('TRY',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('WHILE',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('REPEAT',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('UNTIL',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('FINALLY',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('EXCEPT',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('DO',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('FOR',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('TO',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('DOWNTO',{$ifdef FPC}@{$endif}AllwaysTrue); + Add('END',{$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 844f254a17..b1d13a5c82 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -813,7 +813,7 @@ begin // set CursorPos on 'begin' MoveCursorToNodeStart(BeginNode); ReadNextAtom; - if CurPos.Flag<>cafBEGIN then + if not UpAtomIs('BEGIN') then RaiseBeginExpected; if BeginNode.EndPosbtAsm then begin - if UpAtomIs('TRY') then + if UpAtomIs('BEGIN') then + BeginBlock(Stack,btBegin,CurPos.StartPos) + else if UpAtomIs('TRY') then BeginBlock(Stack,btTry,CurPos.StartPos) else if UpAtomIs('FINALLY') then begin if TopBlockType(Stack)=btTry then