소스 검색

* Fix bug #31523

git-svn-id: trunk@35591 -
michael 8 년 전
부모
커밋
3d95f39686
3개의 변경된 파일28개의 추가작업 그리고 7개의 파일을 삭제
  1. 8 6
      packages/fcl-passrc/src/pparser.pp
  2. 19 0
      packages/fcl-passrc/tests/tcexprparser.pas
  3. 1 1
      packages/fcl-passrc/tests/tcgenerics.pp

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

@@ -1587,7 +1587,7 @@ function TPasParser.ParseExpIdent(AParent: TPasElement): TPasExpr;
   end;
   end;
 
 
 var
 var
-  Last    , Expr: TPasExpr;
+  Last,func, Expr: TPasExpr;
   prm     : TParamsExpr;
   prm     : TParamsExpr;
   b       : TBinaryExpr;
   b       : TBinaryExpr;
   optk    : TToken;
   optk    : TToken;
@@ -1661,7 +1661,8 @@ begin
   end;
   end;
 
 
   Result:=Last;
   Result:=Last;
-
+  func:=Last;
+  
   if Last.Kind<>pekSet then NextToken;
   if Last.Kind<>pekSet then NextToken;
 
 
   ok:=false;
   ok:=false;
@@ -1673,8 +1674,9 @@ begin
         NextToken;
         NextToken;
         if CurToken in [tkIdentifier,tktrue,tkfalse] then // true and false are also identifiers
         if CurToken in [tkIdentifier,tktrue,tkfalse] then // true and false are also identifiers
           begin
           begin
-          AddToBinaryExprChain(Result,Last,
-            CreatePrimitiveExpr(AParent,pekIdent,CurTokenString), eopSubIdent);
+          expr:=CreatePrimitiveExpr(AParent,pekIdent,CurTokenString);
+          AddToBinaryExprChain(Result,Last,expr,eopSubIdent);
+          func:=expr;
           NextToken;
           NextToken;
           end
           end
         else
         else
@@ -1683,12 +1685,12 @@ begin
           ParseExcExpectedIdentifier;
           ParseExcExpectedIdentifier;
           end;
           end;
         end;
         end;
-      repeat
+       repeat
         case CurToken of
         case CurToken of
           tkBraceOpen,tkSquaredBraceOpen:
           tkBraceOpen,tkSquaredBraceOpen:
             begin
             begin
             if CurToken=tkBraceOpen then
             if CurToken=tkBraceOpen then
-              prm:=ParseParams(AParent,pekFuncParams,isWriteOrStr(Last))
+              prm:=ParseParams(AParent,pekFuncParams,isWriteOrStr(func))
             else
             else
               prm:=ParseParams(AParent,pekArrayParams);
               prm:=ParseParams(AParent,pekArrayParams);
             if not Assigned(prm) then Exit;
             if not Assigned(prm) then Exit;

+ 19 - 0
packages/fcl-passrc/tests/tcexprparser.pas

@@ -103,6 +103,7 @@ type
     Procedure TestFunctionCall;
     Procedure TestFunctionCall;
     Procedure TestFunctionCall2args;
     Procedure TestFunctionCall2args;
     Procedure TestFunctionCallNoArgs;
     Procedure TestFunctionCallNoArgs;
+    Procedure ParseStrWithFormatFullyQualified;
     Procedure TestRange;
     Procedure TestRange;
     Procedure TestBracketsTotal;
     Procedure TestBracketsTotal;
     Procedure TestBracketsLeft;
     Procedure TestBracketsLeft;
@@ -1031,6 +1032,24 @@ begin
   AssertNotNull('Have left',AOperand);
   AssertNotNull('Have left',AOperand);
 end;
 end;
 
 
+Procedure TTestExpressions.ParseStrWithFormatFullyQualified;
+
+Var
+  P : TParamsExpr;
+  B : TBinaryExpr;
+
+begin
+  DeclareVar('string','a');
+  DeclareVar('integer','i');
+  ParseExpression('system.str(i:0:3,a)');
+  B:=TBinaryExpr(AssertExpression('Binary identifier',theExpr,pekBinary,TBinaryExpr));
+  P:=TParamsExpr(AssertExpression('Simple identifier',B.Right,pekFuncParams,TParamsExpr));
+  AssertExpression('Name of function',P.Value,pekIdent,'str');
+  AssertEquals('2 argument',2,Length(p.params));
+  AssertExpression('Simple identifier',p.params[0],pekIdent,'i');
+  AssertExpression('Simple identifier',p.params[1],pekIdent,'a');
+end;
+
 initialization
 initialization
 
 
   RegisterTest(TTestExpressions);
   RegisterTest(TTestExpressions);

+ 1 - 1
packages/fcl-passrc/tests/tcgenerics.pp

@@ -5,7 +5,7 @@ unit tcgenerics;
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils, fpcunit, pparser, pastree, testregistry, tctypeparser;
+  Classes, SysUtils, fpcunit, pastree, testregistry, tctypeparser;
 
 
 Type
 Type