codetools: removed cafBegin

git-svn-id: trunk@25737 -
This commit is contained in:
mattias 2010-05-28 18:47:50 +00:00
parent 5aeebfa0f3
commit e2538d01bc
6 changed files with 43 additions and 29 deletions

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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.EndPos<SrcLen then
Maxpos:=BeginNode.EndPos
@ -2369,7 +2369,7 @@ begin
Result:=true;
TryType:=ttNone;
Desc:=ctnNone;
if CurPos.Flag=cafBEGIN then begin
if UpAtomIs('BEGIN') then begin
BlockType:=ebtBegin;
Desc:=ctnBeginBlock;
end else if UpAtomIs('REPEAT') then
@ -2530,7 +2530,8 @@ begin
begin
if (CurPos.Flag=cafEND) or (UpAtomIs('UNTIL')) then begin
ReadBackTilBlockEnd(false);
end else if (CurPos.Flag in [cafBEGIN,cafRECORD]) or UpAtomIs('ASM')
end else if UpAtomIs('BEGIN') or (CurPos.Flag in [cafRECORD])
or UpAtomIs('ASM')
then begin
if BlockType=ebtBegin then
break
@ -2949,10 +2950,10 @@ begin
[ctnProcedure,ctnProgram,ctnLibrary,ctnImplementation]))
then
RaiseStringExpectedButAtomFound('end');
ChildNodeCreated:=(CurPos.Flag=cafBEGIN) or UpAtomIs('ASM');
ChildNodeCreated:=UpAtomIs('BEGIN') or UpAtomIs('ASM');
if ChildNodeCreated then begin
CreateChildNode;
if CurPos.Flag=cafBEGIN then
if UpAtomIs('BEGIN') then
CurNode.Desc:=ctnBeginBlock
else
CurNode.Desc:=ctnAsmBlock;

View File

@ -5768,11 +5768,11 @@ var
while TopBlockType(Stack) in [btCaseColon,btIf,btIfElse] do begin
if not EndBlockIsOk then exit;
end;
cafBegin:
BeginBlock(Stack,btBegin,CurPos.StartPos);
cafWord:
if TopBlockType(Stack)<>btAsm 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