Quellcode durchsuchen

fcl-passrc: fixed parse untyped vars

mattias vor 1 Jahr
Ursprung
Commit
3a5cd0760a
1 geänderte Dateien mit 14 neuen und 4 gelöschten Zeilen
  1. 14 4
      packages/fcl-passrc/src/pparser.pp

+ 14 - 4
packages/fcl-passrc/src/pparser.pp

@@ -384,7 +384,7 @@ type
     procedure HandleProcedureTypeModifier(ProcType: TPasProcedureType; ptm : TProcTypeModifier);
     procedure HandleProcedureTypeModifier(ProcType: TPasProcedureType; ptm : TProcTypeModifier);
     procedure ParseMembersLocalConsts(AType: TPasMembersType; AVisibility: TPasMemberVisibility);
     procedure ParseMembersLocalConsts(AType: TPasMembersType; AVisibility: TPasMemberVisibility);
     procedure ParseMembersLocalTypes(AType: TPasMembersType; AVisibility: TPasMemberVisibility);
     procedure ParseMembersLocalTypes(AType: TPasMembersType; AVisibility: TPasMemberVisibility);
-    procedure ParseVarList(Parent: TPasElement; VarList: TFPList; AVisibility: TPasMemberVisibility; varParseType : TDeclParseType);
+    procedure ParseVarList(Parent: TPasElement; VarList: TFPList; AVisibility: TPasMemberVisibility; VarParseType : TDeclParseType);
     procedure SetOptions(AValue: TPOptions);
     procedure SetOptions(AValue: TPOptions);
     procedure OnScannerModeChanged(Sender: TObject; NewMode: TModeSwitch;
     procedure OnScannerModeChanged(Sender: TObject; NewMode: TModeSwitch;
       Before: boolean; var Handled: boolean);
       Before: boolean; var Handled: boolean);
@@ -4850,7 +4850,7 @@ end;
 
 
 // Full means that a full variable declaration is being parsed.
 // Full means that a full variable declaration is being parsed.
 procedure TPasParser.ParseVarList(Parent: TPasElement; VarList: TFPList; AVisibility: TPasMemberVisibility;
 procedure TPasParser.ParseVarList(Parent: TPasElement; VarList: TFPList; AVisibility: TPasMemberVisibility;
-  varParseType: TDeclParseType);
+  VarParseType: TDeclParseType);
 // on Exception the VarList is restored, no need to Release the new elements
 // on Exception the VarList is restored, no need to Release the new elements
 
 
 var
 var
@@ -4876,6 +4876,8 @@ begin
   try
   try
     D:=SaveComments; // This means we support only one comment per 'list'.
     D:=SaveComments; // This means we support only one comment per 'list'.
     VarEl:=nil;
     VarEl:=nil;
+
+    // read attributes
     while CurToken=tkSquaredBraceOpen do
     while CurToken=tkSquaredBraceOpen do
       begin
       begin
       if msPrefixedAttributes in CurrentModeswitches then
       if msPrefixedAttributes in CurrentModeswitches then
@@ -4886,6 +4888,8 @@ begin
       else
       else
         CheckToken(tkIdentifier);
         CheckToken(tkIdentifier);
       end;
       end;
+
+    // read names
     Repeat
     Repeat
       VarEl:=TPasVariable(CreateElement(TPasVariable,CurTokenString,Parent,
       VarEl:=TPasVariable(CreateElement(TPasVariable,CurTokenString,Parent,
                                         AVisibility,CurTokenPos));
                                         AVisibility,CurTokenPos));
@@ -4897,7 +4901,7 @@ begin
       tkComma: ExpectIdentifier;
       tkComma: ExpectIdentifier;
       tkAssign :
       tkAssign :
         begin
         begin
-        if varParseType<>dptInline then
+        if VarParseType<>dptInline then
           ParseExc(nParserExpectedCommaColon,SParserExpectedCommaColon);
           ParseExc(nParserExpectedCommaColon,SParserExpectedCommaColon);
         UnGetToken; // Value parsing starts with NextToken
         UnGetToken; // Value parsing starts with NextToken
         IsUnTyped:=True;
         IsUnTyped:=True;
@@ -4907,6 +4911,9 @@ begin
         ParseExc(nParserExpectedCommaColon,SParserExpectedCommaColon);
         ParseExc(nParserExpectedCommaColon,SParserExpectedCommaColon);
       end;
       end;
     Until (CurToken=tkColon);
     Until (CurToken=tkColon);
+
+    // read type
+    VarType:=nil;
     if CurToken=tkColon then
     if CurToken=tkColon then
       begin
       begin
       OldForceCaret:=Scanner.SetForceCaret(True);
       OldForceCaret:=Scanner.SetForceCaret(True);
@@ -4924,8 +4931,10 @@ begin
         //VarType.Parent := VarEl; // this is wrong for references
         //VarType.Parent := VarEl; // this is wrong for references
         end;
         end;
       end;
       end;
+    // read hints
     H:=CheckHint(Nil,False);
     H:=CheckHint(Nil,False);
-    If varParseType in [dptFull,dptInline]then
+    // read value and location
+    If VarParseType in [dptFull,dptInline]then
       GetVariableValueAndLocation(VarEl,IsUnTyped,Value,AbsoluteExpr,AbsoluteLocString);
       GetVariableValueAndLocation(VarEl,IsUnTyped,Value,AbsoluteExpr,AbsoluteLocString);
     if VarCnt>1 then
     if VarCnt>1 then
       begin
       begin
@@ -4942,6 +4951,7 @@ begin
     ExternalStruct:=(msExternalClass in CurrentModeSwitches)
     ExternalStruct:=(msExternalClass in CurrentModeSwitches)
                     and (Parent is TPasMembersType);
                     and (Parent is TPasMembersType);
 
 
+    // read modifiers
     H:=H+CheckHint(Nil,False);
     H:=H+CheckHint(Nil,False);
     if (VarParseType=dptFull) or ExternalStruct then
     if (VarParseType=dptFull) or ExternalStruct then
       begin
       begin