mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 18:29:21 +02:00
codetools: pascal parser: var i: byte = 3; create ctnConstant, patch #18515
git-svn-id: trunk@30454 -
This commit is contained in:
parent
62833f223a
commit
8bfe9b6371
@ -145,6 +145,7 @@ type
|
|||||||
function KeyWordFuncLabel: boolean;
|
function KeyWordFuncLabel: boolean;
|
||||||
function KeyWordFuncProperty: boolean;
|
function KeyWordFuncProperty: boolean;
|
||||||
procedure ReadConst;
|
procedure ReadConst;
|
||||||
|
procedure ReadConstExpr;
|
||||||
// types
|
// types
|
||||||
procedure ReadTypeNameAndDefinition;
|
procedure ReadTypeNameAndDefinition;
|
||||||
procedure ReadTypeReference;
|
procedure ReadTypeReference;
|
||||||
@ -3063,20 +3064,8 @@ begin
|
|||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
ReadConstant(true,false,[]);
|
ReadConstant(true,false,[]);
|
||||||
end;
|
end;
|
||||||
if CurPos.Flag=cafEqual then begin
|
if CurPos.Flag=cafEqual then
|
||||||
// read constant
|
ReadConstExpr; // read constant
|
||||||
repeat
|
|
||||||
ReadNextAtom;
|
|
||||||
if (CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen]) then
|
|
||||||
ReadTilBracketClose(true);
|
|
||||||
if (CurPos.Flag in AllCommonAtomWords)
|
|
||||||
and (not IsKeyWordInConstAllowed.DoItCaseInsensitive(Src,
|
|
||||||
CurPos.StartPos,CurPos.EndPos-CurPos.StartPos))
|
|
||||||
and AtomIsKeyWord
|
|
||||||
then
|
|
||||||
RaiseCharExpectedButAtomFound(';');
|
|
||||||
until (CurPos.Flag=cafSemicolon) or (CurPos.StartPos>SrcLen);
|
|
||||||
end;
|
|
||||||
if UpAtomIs('DEPRECATED') then
|
if UpAtomIs('DEPRECATED') then
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
if CurPos.Flag=cafSemicolon then begin
|
if CurPos.Flag=cafSemicolon then begin
|
||||||
@ -3534,26 +3523,7 @@ begin
|
|||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
ParseType(CurPos.StartPos,CurPos.EndPos-CurPos.StartPos);
|
ParseType(CurPos.StartPos,CurPos.EndPos-CurPos.StartPos);
|
||||||
end;
|
end;
|
||||||
if (CurPos.Flag<>cafEqual) then
|
ReadConstExpr;
|
||||||
RaiseCharExpectedButAtomFound('=');
|
|
||||||
// read constant
|
|
||||||
ReadNextAtom;
|
|
||||||
CreateChildNode;
|
|
||||||
CurNode.Desc:=ctnConstant;
|
|
||||||
repeat
|
|
||||||
if (CurPos.Flag in [cafRoundBracketOpen,cafEdgedBracketOpen]) then
|
|
||||||
ReadTilBracketClose(true);
|
|
||||||
if (CurPos.Flag in AllCommonAtomWords)
|
|
||||||
and (not IsKeyWordInConstAllowed.DoItCaseInsensitive(Src,
|
|
||||||
CurPos.StartPos,CurPos.EndPos-CurPos.StartPos))
|
|
||||||
and AtomIsKeyWord then
|
|
||||||
RaiseStringExpectedButAtomFound('constant');
|
|
||||||
if (CurPos.Flag=cafSemicolon) then break;
|
|
||||||
CurNode.EndPos:=CurPos.EndPos;
|
|
||||||
ReadNextAtom;
|
|
||||||
until (CurPos.StartPos>SrcLen);
|
|
||||||
// close ctnConstant node
|
|
||||||
EndChildNode;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TPascalParserTool.ReadTypeNameAndDefinition;
|
procedure TPascalParserTool.ReadTypeNameAndDefinition;
|
||||||
@ -4448,6 +4418,30 @@ begin
|
|||||||
SaveRaiseExceptionFmt(ctsEndofSourceExpectedButAtomFound,[GetAtom]);
|
SaveRaiseExceptionFmt(ctsEndofSourceExpectedButAtomFound,[GetAtom]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TPascalParserTool.ReadConstExpr;
|
||||||
|
begin
|
||||||
|
if (CurPos.Flag <> cafEqual) then
|
||||||
|
RaiseCharExpectedButAtomFound('=');
|
||||||
|
// read constant
|
||||||
|
ReadNextAtom;
|
||||||
|
CreateChildNode;
|
||||||
|
CurNode.Desc := ctnConstant;
|
||||||
|
repeat
|
||||||
|
if (CurPos.Flag in [cafRoundBracketOpen, cafEdgedBracketOpen]) then
|
||||||
|
ReadTilBracketClose(true);
|
||||||
|
if (CurPos.Flag in AllCommonAtomWords)
|
||||||
|
and (not IsKeyWordInConstAllowed.DoItCaseInsensitive(Src,
|
||||||
|
CurPos.StartPos, CurPos.EndPos - CurPos.StartPos))
|
||||||
|
and AtomIsKeyWord then
|
||||||
|
RaiseStringExpectedButAtomFound('constant');
|
||||||
|
if (CurPos.Flag = cafSemicolon) then break;
|
||||||
|
CurNode.EndPos := CurPos.EndPos;
|
||||||
|
ReadNextAtom;
|
||||||
|
until (CurPos.StartPos > SrcLen);
|
||||||
|
// close ctnConstant node
|
||||||
|
EndChildNode;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TPascalParserTool.InitExtraction;
|
procedure TPascalParserTool.InitExtraction;
|
||||||
begin
|
begin
|
||||||
if ExtractMemStream=nil then
|
if ExtractMemStream=nil then
|
||||||
|
Loading…
Reference in New Issue
Block a user