|
@@ -7743,6 +7743,7 @@ begin
|
|
LastToken:=CurToken;
|
|
LastToken:=CurToken;
|
|
while (CurToken<>tkEnd) do
|
|
while (CurToken<>tkEnd) do
|
|
begin
|
|
begin
|
|
|
|
+ haveClass:=LastToken=tkclass;
|
|
//writeln('TPasParser.ParseClassMembers LastToken=',LastToken,' CurToken=',CurToken,' haveClass=',haveClass,' CurSection=',CurSection);
|
|
//writeln('TPasParser.ParseClassMembers LastToken=',LastToken,' CurToken=',CurToken,' haveClass=',haveClass,' CurSection=',CurSection);
|
|
case CurToken of
|
|
case CurToken of
|
|
tkType:
|
|
tkType:
|
|
@@ -7776,18 +7777,17 @@ begin
|
|
CurSection:=stNone;
|
|
CurSection:=stNone;
|
|
end;
|
|
end;
|
|
tkVar:
|
|
tkVar:
|
|
- if not (CurSection in [stVar,stClassVar]) then
|
|
|
|
- begin
|
|
|
|
- if (AType.ObjKind in okWithFields)
|
|
|
|
- or (haveClass and (AType.ObjKind in okAllHelpers)) then
|
|
|
|
- // ok
|
|
|
|
- else
|
|
|
|
- ParseExc(nParserXNotAllowedInY,SParserXNotAllowedInY,['VAR',ObjKindNames[AType.ObjKind]]);
|
|
|
|
- if LastToken=tkClass then
|
|
|
|
- CurSection:=stClassVar
|
|
|
|
- else
|
|
|
|
- CurSection:=stVar;
|
|
|
|
- end;
|
|
|
|
|
|
+ begin
|
|
|
|
+ if (AType.ObjKind in okWithFields)
|
|
|
|
+ or (haveClass and (AType.ObjKind in okAllHelpers)) then
|
|
|
|
+ // ok
|
|
|
|
+ else
|
|
|
|
+ ParseExc(nParserXNotAllowedInY,SParserXNotAllowedInY,['VAR',ObjKindNames[AType.ObjKind]]);
|
|
|
|
+ if haveClass then
|
|
|
|
+ CurSection:=stClassVar
|
|
|
|
+ else
|
|
|
|
+ CurSection:=stVar;
|
|
|
|
+ end;
|
|
tkIdentifier:
|
|
tkIdentifier:
|
|
if CheckVisibility(CurTokenString,CurVisibility,(AType.ObjKind=okObjcProtocol)) then
|
|
if CheckVisibility(CurTokenString,CurVisibility,(AType.ObjKind=okObjcProtocol)) then
|
|
CurSection:=stNone
|
|
CurSection:=stNone
|
|
@@ -7806,17 +7806,15 @@ begin
|
|
begin
|
|
begin
|
|
if not (AType.ObjKind in okWithFields) then
|
|
if not (AType.ObjKind in okWithFields) then
|
|
ParseExc(nParserNoFieldsAllowed,SParserNoFieldsAllowedInX,[ObjKindNames[AType.ObjKind]]);
|
|
ParseExc(nParserNoFieldsAllowed,SParserNoFieldsAllowedInX,[ObjKindNames[AType.ObjKind]]);
|
|
- ParseClassFields(AType,CurVisibility,CurSection=stClassVar);
|
|
|
|
|
|
+ ParseClassFields(AType,CurVisibility,false);
|
|
if Curtoken=tkEnd then // case Ta = Class x : String end;
|
|
if Curtoken=tkEnd then // case Ta = Class x : String end;
|
|
UngetToken;
|
|
UngetToken;
|
|
- HaveClass:=False;
|
|
|
|
end;
|
|
end;
|
|
stClassVar:
|
|
stClassVar:
|
|
begin
|
|
begin
|
|
if not (AType.ObjKind in okWithClassFields) then
|
|
if not (AType.ObjKind in okWithClassFields) then
|
|
ParseExc(nParserNoFieldsAllowed,SParserNoFieldsAllowedInX,[ObjKindNames[AType.ObjKind]]);
|
|
ParseExc(nParserNoFieldsAllowed,SParserNoFieldsAllowedInX,[ObjKindNames[AType.ObjKind]]);
|
|
- ParseClassFields(AType,CurVisibility,CurSection=stClassVar);
|
|
|
|
- HaveClass:=False;
|
|
|
|
|
|
+ ParseClassFields(AType,CurVisibility,true);
|
|
end;
|
|
end;
|
|
else
|
|
else
|
|
Raise Exception.Create('Internal error 201704251415');
|
|
Raise Exception.Create('Internal error 201704251415');
|
|
@@ -7841,7 +7839,6 @@ begin
|
|
ParseExc(nParserXNotAllowedInY,SParserXNotAllowedInY,['destructor',ObjKindNames[AType.ObjKind]]);
|
|
ParseExc(nParserXNotAllowedInY,SParserXNotAllowedInY,['destructor',ObjKindNames[AType.ObjKind]]);
|
|
end;
|
|
end;
|
|
ProcessMethod(AType,HaveClass,CurVisibility,false);
|
|
ProcessMethod(AType,HaveClass,CurVisibility,false);
|
|
- haveClass:=False;
|
|
|
|
end;
|
|
end;
|
|
tkProcedure,tkFunction:
|
|
tkProcedure,tkFunction:
|
|
begin
|
|
begin
|
|
@@ -7870,7 +7867,6 @@ begin
|
|
end
|
|
end
|
|
else
|
|
else
|
|
ProcessMethod(AType,HaveClass,CurVisibility,false);
|
|
ProcessMethod(AType,HaveClass,CurVisibility,false);
|
|
- haveClass:=False;
|
|
|
|
end;
|
|
end;
|
|
tkgeneric:
|
|
tkgeneric:
|
|
begin
|
|
begin
|
|
@@ -7908,7 +7904,6 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
SaveComments;
|
|
SaveComments;
|
|
- HaveClass:=True;
|
|
|
|
curSection:=stNone;
|
|
curSection:=stNone;
|
|
end;
|
|
end;
|
|
tkProperty:
|
|
tkProperty:
|
|
@@ -7920,7 +7915,6 @@ begin
|
|
PropEl:=ParseProperty(AType,CurtokenString,CurVisibility,HaveClass);
|
|
PropEl:=ParseProperty(AType,CurtokenString,CurVisibility,HaveClass);
|
|
AType.Members.Add(PropEl);
|
|
AType.Members.Add(PropEl);
|
|
Engine.FinishScope(stDeclaration,PropEl);
|
|
Engine.FinishScope(stDeclaration,PropEl);
|
|
- HaveClass:=False;
|
|
|
|
end;
|
|
end;
|
|
tkSquaredBraceOpen:
|
|
tkSquaredBraceOpen:
|
|
if msPrefixedAttributes in CurrentModeswitches then
|
|
if msPrefixedAttributes in CurrentModeswitches then
|