From 3d95f3968670834af315fe562d6618c752dddf12 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 15 Mar 2017 14:20:18 +0000 Subject: [PATCH] * Fix bug #31523 git-svn-id: trunk@35591 - --- packages/fcl-passrc/src/pparser.pp | 14 ++++++++------ packages/fcl-passrc/tests/tcexprparser.pas | 19 +++++++++++++++++++ packages/fcl-passrc/tests/tcgenerics.pp | 2 +- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/packages/fcl-passrc/src/pparser.pp b/packages/fcl-passrc/src/pparser.pp index 841c2f4fe3..888a9cfaab 100644 --- a/packages/fcl-passrc/src/pparser.pp +++ b/packages/fcl-passrc/src/pparser.pp @@ -1587,7 +1587,7 @@ function TPasParser.ParseExpIdent(AParent: TPasElement): TPasExpr; end; var - Last , Expr: TPasExpr; + Last,func, Expr: TPasExpr; prm : TParamsExpr; b : TBinaryExpr; optk : TToken; @@ -1661,7 +1661,8 @@ begin end; Result:=Last; - + func:=Last; + if Last.Kind<>pekSet then NextToken; ok:=false; @@ -1673,8 +1674,9 @@ begin NextToken; if CurToken in [tkIdentifier,tktrue,tkfalse] then // true and false are also identifiers begin - AddToBinaryExprChain(Result,Last, - CreatePrimitiveExpr(AParent,pekIdent,CurTokenString), eopSubIdent); + expr:=CreatePrimitiveExpr(AParent,pekIdent,CurTokenString); + AddToBinaryExprChain(Result,Last,expr,eopSubIdent); + func:=expr; NextToken; end else @@ -1683,12 +1685,12 @@ begin ParseExcExpectedIdentifier; end; end; - repeat + repeat case CurToken of tkBraceOpen,tkSquaredBraceOpen: begin if CurToken=tkBraceOpen then - prm:=ParseParams(AParent,pekFuncParams,isWriteOrStr(Last)) + prm:=ParseParams(AParent,pekFuncParams,isWriteOrStr(func)) else prm:=ParseParams(AParent,pekArrayParams); if not Assigned(prm) then Exit; diff --git a/packages/fcl-passrc/tests/tcexprparser.pas b/packages/fcl-passrc/tests/tcexprparser.pas index 2f1b7ebabb..a9a5c21733 100644 --- a/packages/fcl-passrc/tests/tcexprparser.pas +++ b/packages/fcl-passrc/tests/tcexprparser.pas @@ -103,6 +103,7 @@ type Procedure TestFunctionCall; Procedure TestFunctionCall2args; Procedure TestFunctionCallNoArgs; + Procedure ParseStrWithFormatFullyQualified; Procedure TestRange; Procedure TestBracketsTotal; Procedure TestBracketsLeft; @@ -1031,6 +1032,24 @@ begin AssertNotNull('Have left',AOperand); 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 RegisterTest(TTestExpressions); diff --git a/packages/fcl-passrc/tests/tcgenerics.pp b/packages/fcl-passrc/tests/tcgenerics.pp index c836bb5a1a..0a73a83548 100644 --- a/packages/fcl-passrc/tests/tcgenerics.pp +++ b/packages/fcl-passrc/tests/tcgenerics.pp @@ -5,7 +5,7 @@ unit tcgenerics; interface uses - Classes, SysUtils, fpcunit, pparser, pastree, testregistry, tctypeparser; + Classes, SysUtils, fpcunit, pastree, testregistry, tctypeparser; Type