codetools: fixed parsing var n:t platform=1

git-svn-id: trunk@44271 -
This commit is contained in:
mattias 2014-02-26 22:42:10 +00:00
parent fd8f2c1da7
commit b641e949dc
2 changed files with 14 additions and 10 deletions

View File

@ -49,6 +49,7 @@ type
cafEdgedBracketOpen, cafEdgedBracketClose, cafEdgedBracketOpen, cafEdgedBracketClose,
cafWord, cafEnd cafWord, cafEnd
); );
TCommonAtomFlags = set of TCommonAtomFlag;
const const
AllCommonAtomWords = [cafWord, cafEnd]; AllCommonAtomWords = [cafWord, cafEnd];

View File

@ -219,7 +219,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; procedure ReadHintModifiers(const AllowedAtomsBehind: TCommonAtomFlags = [cafSemicolon]);
function ReadTilTypeOfProperty(PropertyNode: TCodeTreeNode): boolean; function ReadTilTypeOfProperty(PropertyNode: TCodeTreeNode): boolean;
function ReadTilGetterOfProperty(PropertyNode: TCodeTreeNode): boolean; function ReadTilGetterOfProperty(PropertyNode: TCodeTreeNode): boolean;
procedure ReadGUID; procedure ReadGUID;
@ -3290,7 +3290,12 @@ begin
ReadConstant(true,false,[]); ReadConstant(true,false,[]);
end; end;
end; end;
end;
// optional: hint modifier
ReadHintModifiers([cafSemicolon,cafEqual]);
if (ParentNode.Desc=ctnVarSection) then begin
// optional: initial value // optional: initial value
if CurPos.Flag=cafEqual then if CurPos.Flag=cafEqual then
if ParentNode.Parent.Desc in AllCodeSections+[ctnProcedure] then begin if ParentNode.Parent.Desc in AllCodeSections+[ctnProcedure] then begin
@ -3298,9 +3303,6 @@ begin
end; end;
end; end;
// optional: hint modifier
ReadHintModifiers;
HasSemicolon:=false; HasSemicolon:=false;
if CurPos.Flag=cafSemicolon then begin if CurPos.Flag=cafSemicolon then begin
// read ; // read ;
@ -3378,8 +3380,9 @@ begin
EndChildNode; EndChildNode;
end; end;
procedure TPascalParserTool.ReadHintModifiers; procedure TPascalParserTool.ReadHintModifiers(
// after reading cursor is at next atom const AllowedAtomsBehind: TCommonAtomFlags);
// after reading the cursor is at next atom, e.g. the semicolon
function IsModifier: boolean; function IsModifier: boolean;
var var
@ -3419,7 +3422,7 @@ begin
ReadConstant(true,false,[]); ReadConstant(true,false,[]);
CurNode.EndPos:=CurPos.StartPos; CurNode.EndPos:=CurPos.StartPos;
end; end;
if not (CurPos.Flag in [cafSemicolon,cafRoundBracketClose]) then if not (CurPos.Flag in AllowedAtomsBehind) then
SaveRaiseCharExpectedButAtomFound(';'); SaveRaiseCharExpectedButAtomFound(';');
EndChildNode; EndChildNode;
if CurPos.Flag<>cafSemicolon then if CurPos.Flag<>cafSemicolon then
@ -4590,7 +4593,8 @@ function TPascalParserTool.KeyWordFuncTypeDefault: boolean;
Low(integer)..High(integer) Low(integer)..High(integer)
'a'..'z' 'a'..'z'
} }
var SubRangeOperatorFound: boolean; var
SubRangeOperatorFound: boolean;
procedure ReadTillTypeEnd; procedure ReadTillTypeEnd;
begin begin
@ -4701,7 +4705,6 @@ begin
SaveRaiseException(ctsInvalidType); SaveRaiseException(ctsInvalidType);
end; end;
end; end;
ReadHintModifiers;
EndChildNode; EndChildNode;
Result:=true; Result:=true;
end; end;
@ -4879,7 +4882,7 @@ begin
{$IFDEF VerboseRecordCase} {$IFDEF VerboseRecordCase}
debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase Hint modifier: "',GetAtom,'"']); debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase Hint modifier: "',GetAtom,'"']);
{$ENDIF} {$ENDIF}
ReadHintModifiers; ReadHintModifiers([cafSemicolon,cafRoundBracketClose]);
CurNode.EndPos:=CurPos.EndPos; CurNode.EndPos:=CurPos.EndPos;
EndChildNode; // close variable definition EndChildNode; // close variable definition
end; end;