codetools: added "is nested" procedure modifier, bug #17310

git-svn-id: trunk@27312 -
This commit is contained in:
mattias 2010-09-11 18:07:15 +00:00
parent 2940387350
commit 1e799a4678
3 changed files with 33 additions and 15 deletions

View File

@ -843,6 +843,7 @@ begin
Add('VARARGS' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('VARARGS' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('EXPERIMENTAL' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('EXPERIMENTAL' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('LIBRARY' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('LIBRARY' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('IS' ,{$ifdef FPC}@{$endif}AllwaysTrue);
end; end;
IsKeyWordCallingConvention:=TKeyWordFunctionList.Create; IsKeyWordCallingConvention:=TKeyWordFunctionList.Create;
@ -854,7 +855,7 @@ begin
Add('EXTDECL' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('EXTDECL' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('MWPASCAL' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('MWPASCAL' ,{$ifdef FPC}@{$endif}AllwaysTrue);
Add('POPSTACK' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('POPSTACK' ,{$ifdef FPC}@{$endif}AllwaysTrue);
// Note: inline is not a calling specifier // Note: 'inline' and 'is nested' are not a calling specifiers
end; end;
IsKeyWordProcedureBracketSpecifier:=TKeyWordFunctionList.Create; IsKeyWordProcedureBracketSpecifier:=TKeyWordFunctionList.Create;

View File

@ -148,7 +148,8 @@ type
cmsDefault_inline, cmsDefault_inline,
cmsExcept, cmsExcept,
cmsObjectiveC1, cmsObjectiveC1,
cmsObjectiveC2 cmsObjectiveC2,
cmsNestedProcVars
); );
TPascalCompiler = (pcFPC, pcDelphi); TPascalCompiler = (pcFPC, pcDelphi);
@ -521,7 +522,7 @@ const
'POINTERTOPROCVAR', 'AUTODEREF', 'INITFINAL', 'POINTERARITHMETICS', 'POINTERTOPROCVAR', 'AUTODEREF', 'INITFINAL', 'POINTERARITHMETICS',
'ANSISTRINGS', 'OUT', 'DEFAULTPARAMETERS', 'HINTDIRECTIVE', 'ANSISTRINGS', 'OUT', 'DEFAULTPARAMETERS', 'HINTDIRECTIVE',
'DUPLICATELOCALS', 'PROPERTIES', 'ALLOWINLINE', 'EXCEPTIONS', 'DUPLICATELOCALS', 'PROPERTIES', 'ALLOWINLINE', 'EXCEPTIONS',
'OBJECTIVEC1', 'OBJECTIVEC2'); 'OBJECTIVEC1', 'OBJECTIVEC2', 'NESTEDPROCVARS');
PascalCompilerNames: array[TPascalCompiler] of shortstring=( PascalCompilerNames: array[TPascalCompiler] of shortstring=(
'FPC', 'DELPHI' 'FPC', 'DELPHI'

View File

@ -1677,6 +1677,9 @@ begin
if (pphIsMethod in ParseAttr) then if (pphIsMethod in ParseAttr) then
IsSpecifier:=IsKeyWordMethodSpecifier.DoItCaseInsensitive(Src, IsSpecifier:=IsKeyWordMethodSpecifier.DoItCaseInsensitive(Src,
CurPos.StartPos,CurPos.EndPos-CurPos.StartPos) CurPos.StartPos,CurPos.EndPos-CurPos.StartPos)
else if pphIsType in ParseAttr then
IsSpecifier:=IsKeyWordProcedureTypeSpecifier.DoItCaseInsensitive(Src,
CurPos.StartPos,CurPos.EndPos-CurPos.StartPos)
else else
IsSpecifier:=IsKeyWordProcedureSpecifier.DoItCaseInsensitive(Src, IsSpecifier:=IsKeyWordProcedureSpecifier.DoItCaseInsensitive(Src,
CurPos.StartPos,CurPos.EndPos-CurPos.StartPos); CurPos.StartPos,CurPos.EndPos-CurPos.StartPos);
@ -1688,6 +1691,11 @@ begin
ReadNextAtom; ReadNextAtom;
if not (CurPos.Flag in [cafSemicolon,cafEND]) then if not (CurPos.Flag in [cafSemicolon,cafEND]) then
ReadConstant(true,false,[]); ReadConstant(true,false,[]);
end else if UpAtomIs('IS') then begin
ReadNextAtom;
if not UpAtomIs('NESTED') then
RaiseStringExpectedButAtomFound('nested');
ReadNextAtom;
end else if UpAtomIs('EXTERNAL') or UpAtomIs('WEAKEXTERNAL') or UpAtomIs('PUBLIC') then begin end else if UpAtomIs('EXTERNAL') or UpAtomIs('WEAKEXTERNAL') or UpAtomIs('PUBLIC') then begin
HasForwardModifier:=UpAtomIs('EXTERNAL') or UpAtomIs('WEAKEXTERNAL'); HasForwardModifier:=UpAtomIs('EXTERNAL') or UpAtomIs('WEAKEXTERNAL');
ReadNextAtom; ReadNextAtom;
@ -4040,20 +4048,28 @@ begin
begin begin
UndoReadNextAtom; UndoReadNextAtom;
break; break;
end else begin end;
if UpAtomIs('IS') then begin
ReadNextAtom; ReadNextAtom;
if CurPos.Flag<>cafSemicolon then begin if not UpAtomIs('NESTED') then
if (CurPos.Flag=cafEqual) then begin RaiseStringExpectedButAtomFound('nested');
break; end else if UpAtomIs('OF') then begin
end; ReadNextAtom;
// delphi/fpc allow proc modifiers without semicolons if not UpAtomIs('OBJECT') then
if not IsKeyWordProcedureTypeSpecifier.DoItCaseInsensitive(Src, RaiseStringExpectedButAtomFound('object');
CurPos.StartPos,CurPos.EndPos-CurPos.StartPos) then end;
begin ReadNextAtom;
RaiseCharExpectedButAtomFound(';'); if CurPos.Flag<>cafSemicolon then begin
end; if (CurPos.Flag=cafEqual) then begin
UndoReadNextAtom; break;
end; end;
// delphi/fpc allow proc modifiers without semicolons
if not IsKeyWordProcedureTypeSpecifier.DoItCaseInsensitive(Src,
CurPos.StartPos,CurPos.EndPos-CurPos.StartPos) then
begin
RaiseCharExpectedButAtomFound(';');
end;
UndoReadNextAtom;
end; end;
ReadNextAtom; ReadNextAtom;
until false; until false;