Browse Source

* mixed patches from Dmitry B, that fix the doc generation it seems.

git-svn-id: trunk@15687 -
marco 15 years ago
parent
commit
281f0f2a8c

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

@@ -67,7 +67,7 @@ resourcestring
   SPasTreeDestructorImpl = 'destructor implementation';
   SPasTreeDestructorImpl = 'destructor implementation';
 
 
 type
 type
-  TPasExprKind = (pekIdent, pekNumber, pekString, pekSet, pekBoolConst, pekRange,
+  TPasExprKind = (pekIdent, pekNumber, pekString, pekSet, pekNil, pekBoolConst, pekRange,
      pekUnary, pekBinary, pekFuncParams, pekArrayParams, pekListOfExp);
      pekUnary, pekBinary, pekFuncParams, pekArrayParams, pekListOfExp);
 
 
   TExprOpCode = (eopNone,
   TExprOpCode = (eopNone,
@@ -77,7 +77,7 @@ type
                  eopEqual, eopNotEqual,  // Logical
                  eopEqual, eopNotEqual,  // Logical
                  eopLessThan,eopGreaterThan, eopLessthanEqual,eopGreaterThanEqual, // ordering
                  eopLessThan,eopGreaterThan, eopLessthanEqual,eopGreaterThanEqual, // ordering
                  eopIn,eopIs,eopAs, eopSymmetricaldifference, // Specials
                  eopIn,eopIs,eopAs, eopSymmetricaldifference, // Specials
-                 eopAddress,
+                 eopAddress, eopDeref, // Pointers
                  eopSubIdent); // SomeRec.A, A is subIdent of SomeRec
                  eopSubIdent); // SomeRec.A, A is subIdent of SomeRec
   
   
   { TPasExpr }
   { TPasExpr }
@@ -114,6 +114,13 @@ type
     constructor Create(AKind: TPasExprKind; const ABoolValue : Boolean);
     constructor Create(AKind: TPasExprKind; const ABoolValue : Boolean);
   end;
   end;
 
 
+  { TNilExpr }
+
+  TNilExpr = class(TPasExpr)
+    Value     : Boolean;
+    constructor Create;
+  end;
+
   { TParamsExpr }
   { TParamsExpr }
 
 
   TParamsExpr = class(TPasExpr)
   TParamsExpr = class(TPasExpr)
@@ -2500,4 +2507,11 @@ begin
   Values[i]:=AValue;
   Values[i]:=AValue;
 end;
 end;
 
 
+{ TNilExpr }
+
+constructor TNilExpr.Create;
+begin
+  inherited Create(pekNil, eopNone);
+end;
+
 end.
 end.

+ 48 - 24
packages/fcl-passrc/src/pparser.pp

@@ -143,7 +143,7 @@ type
     function ParseComplexType(Parent : TPasElement = Nil): TPasType;
     function ParseComplexType(Parent : TPasElement = Nil): TPasType;
     procedure ParseArrayType(Element: TPasArrayType);
     procedure ParseArrayType(Element: TPasArrayType);
     procedure ParseFileType(Element: TPasFileType);
     procedure ParseFileType(Element: TPasFileType);
-    function DoParseExpression: TPasExpr;
+    function DoParseExpression(InitExpr: TPasExpr=nil): TPasExpr;
     function DoParseConstValueExpression: TPasExpr;
     function DoParseConstValueExpression: TPasExpr;
     function ParseExpression: String;
     function ParseExpression: String;
     function ParseCommand: String; // single, not compound command like begin..end
     function ParseCommand: String; // single, not compound command like begin..end
@@ -721,6 +721,7 @@ begin
     tkNot                   : Result:=eopNot;
     tkNot                   : Result:=eopNot;
     tkIn                    : Result:=eopIn;
     tkIn                    : Result:=eopIn;
     tkDot                   : Result:=eopSubIdent;
     tkDot                   : Result:=eopSubIdent;
+    tkCaret                 : Result:=eopDeref;
   else
   else
     ParseExc(format('Not an operand: (%d : %s)',[AToken,TokenInfos[AToken]]));
     ParseExc(format('Not an operand: (%d : %s)',[AToken,TokenInfos[AToken]]));
   end;
   end;
@@ -741,6 +742,7 @@ begin
     tkNumber:           x:=TPrimitiveExpr.Create(pekNumber, CurTokenString);
     tkNumber:           x:=TPrimitiveExpr.Create(pekNumber, CurTokenString);
     tkIdentifier:       x:=TPrimitiveExpr.Create(pekIdent, CurTokenText);
     tkIdentifier:       x:=TPrimitiveExpr.Create(pekIdent, CurTokenText);
     tkfalse, tktrue:    x:=TBoolConstExpr.Create(pekBoolConst, CurToken=tktrue);
     tkfalse, tktrue:    x:=TBoolConstExpr.Create(pekBoolConst, CurToken=tktrue);
+    tknil:              x:=TNilExpr.Create;
     tkSquaredBraceOpen: x:=ParseParams(pekSet);
     tkSquaredBraceOpen: x:=ParseParams(pekSet);
   else
   else
     ParseExc(SParserExpectedIdentifier);
     ParseExc(SParserExpectedIdentifier);
@@ -809,7 +811,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-function TPasParser.DoParseExpression: TPasExpr;
+function TPasParser.DoParseExpression(InitExpr: TPasExpr): TPasExpr;
 var
 var
   expstack  : TList;
   expstack  : TList;
   opstack   : TList;
   opstack   : TList;
@@ -868,28 +870,50 @@ begin
     repeat
     repeat
       AllowEnd:=True;
       AllowEnd:=True;
       pcount:=0;
       pcount:=0;
-      while CurToken in PrefixSym do begin
-        PushOper(CurToken);
-        inc(pcount);
-        NextToken;
-      end;
 
 
-      if CurToken = tkBraceOpen then begin
-        NextToken;
-        x:=DoParseExpression();
-        if CurToken<>tkBraceClose then Exit;
-        NextToken;
-      end else begin
-        x:=ParseExpIdent;
-      end;
+      if not Assigned(InitExpr) then
+      begin
+        // the first part of the expression has been parsed externally.
+        // this is used by Constant Expresion parser (CEP) parsing only,
+        // whenever it makes a false assuming on constant expression type.
+        // i.e: SI_PAD_SIZE = ((128/sizeof(longint)) - 3);
+        //
+        // CEP assumes that it's array or record, because the expression
+        // starts with "(". After the first part is parsed, the CEP meets "-"
+        // that assures, it's not an array expression. The CEP should give the
+        // first partback to the expression parser, to get the correct
+        // token tree according to the operations priority.
+        //
+        // quite ugly. type information is required for CEP to work clean
+
+        while CurToken in PrefixSym do begin
+          PushOper(CurToken);
+          inc(pcount);
+          NextToken;
+        end;
 
 
-      if not Assigned(x) then Exit;
-      expstack.Add(x);
-      for i:=1 to pcount do
-        begin
-        tempop:=PopOper;
-        expstack.Add( TUnaryExpr.Create( PopExp, TokenToExprOp(tempop) ));
+        if CurToken = tkBraceOpen then begin
+          NextToken;
+          x:=DoParseExpression();
+          if CurToken<>tkBraceClose then Exit;
+          NextToken;
+        end else begin
+          x:=ParseExpIdent;
         end;
         end;
+
+        if not Assigned(x) then Exit;
+        expstack.Add(x);
+        for i:=1 to pcount do begin
+          tempop:=PopOper;
+          expstack.Add( TUnaryExpr.Create( PopExp, TokenToExprOp(tempop) ));
+        end;
+
+      end else
+      begin
+        expstack.Add(InitExpr);
+        InitExpr:=nil;
+      end;
+
       if not (CurToken in EndExprToken) then begin
       if not (CurToken in EndExprToken) then begin
         // Adjusting order of the operations
         // Adjusting order of the operations
         AllowEnd:=False;
         AllowEnd:=False;
@@ -1020,7 +1044,8 @@ begin
           Result:=r;
           Result:=r;
         end;
         end;
     else
     else
-      Result:=x;
+      // Binary expression!  ((128 div sizeof(longint)) - 3);       ;
+      Result:=DoParseExpression(x);
     end;
     end;
     if CurToken<>tkBraceClose then ParseExc(SParserExpectedCommaRBracket);
     if CurToken<>tkBraceClose then ParseExc(SParserExpectedCommaRBracket);
     NextToken;
     NextToken;
@@ -3130,8 +3155,7 @@ begin
       if (s = 'sealed') or (s = 'abstract') then begin
       if (s = 'sealed') or (s = 'abstract') then begin
         TPasClassType(Result).Modifiers.Add(s);
         TPasClassType(Result).Modifiers.Add(s);
         NextToken;
         NextToken;
-      end else
-        ExpectToken(tkSemicolon);
+      end;
     end;
     end;
 
 
     // Parse ancestor list
     // Parse ancestor list

+ 1 - 1
packages/fcl-passrc/src/pscanner.pp

@@ -632,7 +632,7 @@ begin
           Inc(TokenStr);
           Inc(TokenStr);
           repeat
           repeat
             Inc(TokenStr);
             Inc(TokenStr);
-          until not (TokenStr[0] in ['0'..'9', 'A'..'F', 'a'..'F']);
+          until not (TokenStr[0] in ['0'..'9', 'A'..'F', 'a'..'f']);
         end else
         end else
           repeat
           repeat
             Inc(TokenStr);
             Inc(TokenStr);