diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index fd1814a677..f0cd7000ef 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -240,7 +240,7 @@ type function ReadWithStatement(ExceptionOnError, CreateNodes: boolean): boolean; function ReadOnStatement(ExceptionOnError, CreateNodes: boolean): boolean; procedure ReadVariableType; - procedure ReadHintModifiers; + procedure ReadHintModifiers(AllowSemicolonSep: boolean); function ReadTilTypeOfProperty(PropertyNode: TCodeTreeNode): boolean; function ReadTilGetterOfProperty(PropertyNode: TCodeTreeNode): boolean; procedure ReadGUID; @@ -2606,7 +2606,7 @@ begin if CurPos.Flag=cafSemicolon then begin ReadNextAtom; p:=CurPos.StartPos; - ReadHintModifiers; + ReadHintModifiers(true); if p=CurPos.StartPos then UndoReadNextAtom; end; @@ -3519,7 +3519,7 @@ begin // optional: hint modifier if CurPos.Flag=cafWord then - ReadHintModifiers; + ReadHintModifiers(false); if (ParentNode.Desc=ctnVarSection) then begin // optional: initial value @@ -3612,7 +3612,7 @@ begin EndChildNode; end; -procedure TPascalParserTool.ReadHintModifiers; +procedure TPascalParserTool.ReadHintModifiers(AllowSemicolonSep: boolean); // after reading the cursor is at next atom, e.g. the semicolon // e.g. var c: char deprecated; @@ -3648,6 +3648,13 @@ begin CurNode.EndPos:=CurPos.StartPos; end; EndChildNode; + if AllowSemicolonSep and (CurPos.Flag=cafSemicolon) then begin + ReadNextAtom; + if not IsModifier then begin + UndoReadNextAtom; + exit; + end; + end; end; end; @@ -3931,7 +3938,7 @@ begin ReadConstant(true,false,[]); // read hint modifier if CurPos.Flag=cafWord then - ReadHintModifiers; + ReadHintModifiers(false); // read ; if CurPos.Flag<>cafSemicolon then SaveRaiseCharExpectedButAtomFound(20170421195707,';'); @@ -4103,7 +4110,7 @@ begin ReadConstExpr; // optional: hint modifier if CurPos.Flag=cafWord then - ReadHintModifiers; + ReadHintModifiers(false); if CurPos.Flag=cafSemicolon then begin if (CurNode.Parent.Desc=ctnConstSection) and (CurNode.Parent.Parent.Desc in AllCodeSections) then begin @@ -4200,7 +4207,7 @@ begin ParseType(CurPos.StartPos); // read hint modifier if CurPos.Flag=cafWord then - ReadHintModifiers; + ReadHintModifiers(false); // read ; if CurPos.Flag<>cafSemicolon then SaveRaiseCharExpectedButAtomFound(20170421195736,';'); @@ -4519,7 +4526,7 @@ begin end; // read hint modifier if CurPos.Flag=cafWord then - ReadHintModifiers; + ReadHintModifiers(false); if CurPos.Flag<>cafSemicolon then UndoReadNextAtom; end; @@ -4757,7 +4764,7 @@ begin end; // read hint modifier if CurPos.Flag=cafWord then - ReadHintModifiers; + ReadHintModifiers(false); if CurPos.Flag=cafSemicolon then ReadNextAtom; // read post modifiers @@ -5322,7 +5329,7 @@ begin debugln(['TPascalParserTool.KeyWordFuncTypeRecordCase Hint modifier: "',GetAtom,'"']); {$ENDIF} if CurPos.Flag=cafWord then - ReadHintModifiers; + ReadHintModifiers(false); CurNode.EndPos:=CurPos.EndPos; EndChildNode; // close variable definition end;