codetools: fixed parsing deprecated

git-svn-id: trunk@56486 -
This commit is contained in:
mattias 2017-11-24 17:45:42 +00:00
parent da085a91ea
commit cb90757df0

View File

@ -232,7 +232,7 @@ type
function ReadWithStatement(ExceptionOnError, CreateNodes: boolean): boolean; function ReadWithStatement(ExceptionOnError, CreateNodes: boolean): boolean;
function ReadOnStatement(ExceptionOnError, CreateNodes: boolean): boolean; function ReadOnStatement(ExceptionOnError, CreateNodes: boolean): boolean;
procedure ReadVariableType; procedure ReadVariableType;
procedure ReadHintModifiers(const AllowedAtomsBehind: TCommonAtomFlags = [cafSemicolon]); procedure ReadHintModifiers;
function ReadTilTypeOfProperty(PropertyNode: TCodeTreeNode): boolean; function ReadTilTypeOfProperty(PropertyNode: TCodeTreeNode): boolean;
function ReadTilGetterOfProperty(PropertyNode: TCodeTreeNode): boolean; function ReadTilGetterOfProperty(PropertyNode: TCodeTreeNode): boolean;
procedure ReadGUID; procedure ReadGUID;
@ -2468,6 +2468,8 @@ function TPascalParserTool.KeyWordFuncClassProperty: boolean;
SaveRaiseExceptionFmt(20170421195020,ctsSemicolonAfterPropSpecMissing,[s,GetAtom]); SaveRaiseExceptionFmt(20170421195020,ctsSemicolonAfterPropSpecMissing,[s,GetAtom]);
end; end;
var
p: Integer;
begin begin
if (CurNode.Desc in AllClassSubSections) if (CurNode.Desc in AllClassSubSections)
and (CurNode.Parent.Desc in AllClassBaseSections) then begin and (CurNode.Parent.Desc in AllClassBaseSections) then begin
@ -2520,8 +2522,13 @@ begin
end else end else
UndoReadNextAtom; UndoReadNextAtom;
if CurPos.Flag=cafSemicolon then if CurPos.Flag=cafSemicolon then begin
ReadNextAtom;
p:=CurPos.StartPos;
ReadHintModifiers; ReadHintModifiers;
if p=CurPos.StartPos then
UndoReadNextAtom;
end;
end else end else
UndoReadNextAtom; UndoReadNextAtom;
@ -3438,8 +3445,8 @@ begin
end; end;
// optional: hint modifier // optional: hint modifier
if CurPos.Flag<>cafSemicolon then if CurPos.Flag=cafWord then
ReadHintModifiers([cafSemicolon,cafEqual]); ReadHintModifiers;
if (ParentNode.Desc=ctnVarSection) then begin if (ParentNode.Desc=ctnVarSection) then begin
// optional: initial value // optional: initial value
@ -3532,9 +3539,9 @@ begin
EndChildNode; EndChildNode;
end; end;
procedure TPascalParserTool.ReadHintModifiers( procedure TPascalParserTool.ReadHintModifiers;
const AllowedAtomsBehind: TCommonAtomFlags);
// after reading the cursor is at next atom, e.g. the semicolon // after reading the cursor is at next atom, e.g. the semicolon
// e.g. var c: char deprecated;
function IsModifier: boolean; function IsModifier: boolean;
var var
@ -3553,18 +3560,11 @@ procedure TPascalParserTool.ReadHintModifiers(
end; end;
var var
NeedUndo: boolean;
CanHaveString: Boolean; CanHaveString: Boolean;
begin begin
if not (Scanner.CompilerMode in [cmFPC,cmOBJFPC,cmDELPHI,cmDELPHIUNICODE]) then exit; if not (Scanner.CompilerMode in [cmFPC,cmOBJFPC,cmDELPHI,cmDELPHIUNICODE]) then exit;
if CurPos.Flag=cafSemicolon then begin
ReadNextAtom;
NeedUndo:=true;
end else
NeedUndo:=false;
while IsModifier do begin while IsModifier do begin
//debugln(['TPascalParserTool.ReadHintModifier ',CurNode.DescAsString,' ',CleanPosToStr(CurPos.StartPos)]); //debugln(['TPascalParserTool.ReadHintModifier ',CurNode.DescAsString,' ',CleanPosToStr(CurPos.StartPos)]);
NeedUndo:=false;
CreateChildNode; CreateChildNode;
CurNode.Desc:=ctnHintModifier; CurNode.Desc:=ctnHintModifier;
CurNode.EndPos:=CurPos.EndPos; CurNode.EndPos:=CurPos.EndPos;
@ -3575,17 +3575,7 @@ begin
CurNode.EndPos:=CurPos.StartPos; CurNode.EndPos:=CurPos.StartPos;
end; end;
EndChildNode; EndChildNode;
if IsModifier then // support modifiers not separated with semicolons: "faVolumeId = $00000008 platform deprecated;"
continue;
if not (CurPos.Flag in AllowedAtomsBehind) then
SaveRaiseCharExpectedButAtomFound(20170421195636,';');
if CurPos.Flag<>cafSemicolon then
break;
ReadNextAtom;
NeedUndo:=true;
end; end;
if NeedUndo then
UndoReadNextAtom;
end; end;
function TPascalParserTool.KeyWordFuncBeginEnd: boolean; function TPascalParserTool.KeyWordFuncBeginEnd: boolean;
@ -3851,7 +3841,7 @@ begin
SaveRaiseStringExpectedButAtomFound(20170421195704,ctsStringConstant); SaveRaiseStringExpectedButAtomFound(20170421195704,ctsStringConstant);
ReadConstant(true,false,[]); ReadConstant(true,false,[]);
// read hint modifier // read hint modifier
if CurPos.Flag<>cafSemicolon then if CurPos.Flag=cafWord then
ReadHintModifiers; ReadHintModifiers;
// read ; // read ;
if CurPos.Flag<>cafSemicolon then if CurPos.Flag<>cafSemicolon then
@ -3996,7 +3986,7 @@ begin
end; end;
ReadConstExpr; ReadConstExpr;
// optional: hint modifier // optional: hint modifier
if CurPos.Flag<>cafSemicolon then if CurPos.Flag=cafWord then
ReadHintModifiers; ReadHintModifiers;
if CurPos.Flag=cafSemicolon then begin if CurPos.Flag=cafSemicolon then begin
if (CurNode.Parent.Desc=ctnConstSection) if (CurNode.Parent.Desc=ctnConstSection)
@ -4091,7 +4081,7 @@ begin
ReadNextAtom; ReadNextAtom;
ParseType(CurPos.StartPos); ParseType(CurPos.StartPos);
// read hint modifier // read hint modifier
if CurPos.Flag<>cafSemicolon then if CurPos.Flag=cafWord then
ReadHintModifiers; ReadHintModifiers;
// read ; // read ;
if CurPos.Flag<>cafSemicolon then if CurPos.Flag<>cafSemicolon then
@ -4408,6 +4398,7 @@ begin
end; end;
end; end;
// read hint modifier // read hint modifier
if CurPos.Flag=cafWord then
ReadHintModifiers; ReadHintModifiers;
if CurPos.Flag<>cafSemicolon then if CurPos.Flag<>cafSemicolon then
UndoReadNextAtom; UndoReadNextAtom;
@ -4633,6 +4624,7 @@ begin
ReadNextAtom; ReadNextAtom;
end; end;
// read hint modifier // read hint modifier
if CurPos.Flag=cafWord then
ReadHintModifiers; ReadHintModifiers;
if CurPos.Flag=cafSemicolon then if CurPos.Flag=cafSemicolon then
ReadNextAtom; ReadNextAtom;
@ -5197,7 +5189,8 @@ begin
{$IFDEF VerboseRecordCase} {$IFDEF VerboseRecordCase}
debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase Hint modifier: "',GetAtom,'"']); debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase Hint modifier: "',GetAtom,'"']);
{$ENDIF} {$ENDIF}
ReadHintModifiers([cafSemicolon,cafRoundBracketClose]); if CurPos.Flag=cafWord then
ReadHintModifiers;
CurNode.EndPos:=CurPos.EndPos; CurNode.EndPos:=CurPos.EndPos;
EndChildNode; // close variable definition EndChildNode; // close variable definition
end; end;