mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 16:09:31 +02:00
parent
a4b096e9da
commit
3d95f39686
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -5,7 +5,7 @@ unit tcgenerics;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpcunit, pparser, pastree, testregistry, tctypeparser;
|
||||
Classes, SysUtils, fpcunit, pastree, testregistry, tctypeparser;
|
||||
|
||||
Type
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user