Browse Source

* Parsing of unit-wide properties

git-svn-id: trunk@11054 -
michael 17 years ago
parent
commit
bf482b2a13
2 changed files with 19 additions and 7 deletions
  1. 2 1
      packages/fcl-passrc/src/pastree.pp
  2. 17 6
      packages/fcl-passrc/src/pparser.pp

+ 2 - 1
packages/fcl-passrc/src/pastree.pp

@@ -109,7 +109,7 @@ type
   public
     UsesList: TList;            // TPasUnresolvedTypeRef or TPasModule elements
     Declarations, ResStrings, Types, Consts, Classes,
-      Functions, Variables: TList;
+    Functions, Variables, Properties: TList;
   end;
 
   TPasModule = class(TPasElement)
@@ -645,6 +645,7 @@ begin
   Classes := TList.Create;
   Functions := TList.Create;
   Variables := TList.Create;
+  Properties := TList.Create;
 end;
 
 destructor TPasSection.Destroy;

+ 17 - 6
packages/fcl-passrc/src/pparser.pp

@@ -88,7 +88,7 @@ uses Classes;
 
 type
 
-  TDeclType = (declNone, declConst, declResourcestring, declType, declVar, declThreadvar);
+  TDeclType = (declNone, declConst, declResourcestring, declType, declVar, declThreadvar, declProperty);
 
   TProcType = (ptProcedure, ptFunction, ptOperator);
 
@@ -728,6 +728,8 @@ var
   List: TList;
   i,j: Integer;
   VarEl: TPasVariable;
+  PropEl : TPasProperty;
+  
 begin
   Module := nil;
   Module := TPasModule(CreateElement(TPasModule, ExpectIdentifier,
@@ -760,6 +762,8 @@ begin
         CurBlock := declVar;
       tkThreadVar:
         CurBlock := declThreadVar;
+      tkProperty:
+        CurBlock := declProperty;  
       tkProcedure:
         begin
           AddProcOrFunction(Section, ParseProcedureOrFunctionDecl(Section, ptProcedure));
@@ -770,11 +774,6 @@ begin
           AddProcOrFunction(Section, ParseProcedureOrFunctionDecl(Section, ptFunction));
           CurBlock := declNone;
         end;
-      tkProperty:
-        begin
-          ExpectIdentifier;
-          ParseProperty(CreateElement(TPasProperty, CurTokenString, Section));
-        end;
       tkOperator:
         begin
           AddProcOrFunction(Section, ParseProcedureOrFunctionDecl(Section, ptOperator));
@@ -848,6 +847,18 @@ begin
                   List.Free;
                 end;
               end;
+            declProperty:
+              begin
+              PropEl:=TPasProperty(CreateElement(TPasProperty, CurTokenString, Section));
+              Try
+                ParseProperty(PropEl)
+              except
+                Propel.Free;
+                Raise;
+              end;    
+              Section.Declarations.Add(PropEl);
+              Section.properties.add(PropEl);
+              end;
           else
             ParseExc(SParserSyntaxError);
           end;