Jelajahi Sumber

* Handle consts in records

git-svn-id: trunk@31229 -
michael 10 tahun lalu
induk
melakukan
66f4d0bc4e
1 mengubah file dengan 10 tambahan dan 0 penghapusan
  1. 10 0
      packages/fcl-passrc/src/pparser.pp

+ 10 - 0
packages/fcl-passrc/src/pparser.pp

@@ -64,6 +64,7 @@ resourcestring
   SParserNoConstructorAllowed = 'Constructors or Destructors are not allowed in Interfaces or Record helpers';
   SParserNoFieldsAllowed = 'Fields are not allowed in Interfaces';
   SParserInvalidRecordVisibility = 'Records can only have public and (strict) private as visibility specifiers';
+  SErrRecordConstantsNotAllowed = 'Record constants not allowed at this location.';
   SErrRecordMethodsNotAllowed = 'Record methods not allowed at this location.';
   SErrRecordPropertiesNotAllowed = 'Record properties not allowed at this location.';
   SErrRecordVisibilityNotAllowed = 'Record visibilities not allowed at this location.';
@@ -3804,6 +3805,7 @@ Var
   Proc: TPasProcedure;
   ProcType: TProcType;
   Prop : TPasProperty;
+  Cons : TPasConst;
   isClass : Boolean;
 
 begin
@@ -3813,6 +3815,14 @@ begin
     begin
     SaveComments;
     Case CurToken of
+      tkConst:
+        begin
+        if Not AllowMethods then
+          ParseExc(SErrRecordConstantsNotAllowed);
+        ExpectToken(tkIdentifier);
+        Cons:=ParseConstDecl(ARec);
+        ARec.members.Add(Cons);
+        end;
       tkClass:
         begin
         if Not AllowMethods then