mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-25 10:31:47 +02:00
* TPasParser.ParseAdhocExpression implemented + test
git-svn-id: trunk@46933 -
This commit is contained in:
parent
dfc485c4f4
commit
69b1d61a76
@ -440,6 +440,7 @@ type
|
||||
procedure ParseFinalization;
|
||||
procedure ParseDeclarations(Declarations: TPasDeclarations);
|
||||
procedure ParseStatement(Parent: TPasImplBlock; out NewImplElement: TPasImplElement);
|
||||
procedure ParseAdhocExpression(out NewExprElement: TPasExpr);
|
||||
procedure ParseLabels(AParent: TPasElement);
|
||||
procedure ParseProcBeginBlock(Parent: TProcedureBody);
|
||||
procedure ParseProcAsmBlock(Parent: TProcedureBody);
|
||||
@ -7800,6 +7801,11 @@ begin
|
||||
Result.Kind:=pekListOfExp;
|
||||
end;
|
||||
|
||||
procedure TPasParser.ParseAdhocExpression(out NewExprElement: TPasExpr);
|
||||
begin
|
||||
NewExprElement := DoParseExpression(nil);
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$IFDEF HASFS}
|
||||
DefaultFileResolverClass:=TFileResolver;
|
||||
|
@ -150,6 +150,8 @@ type
|
||||
Procedure TestExpCaret;
|
||||
Procedure TestArrayAccess;
|
||||
Procedure TestHelperOnLiteral;
|
||||
|
||||
procedure TestParseAdhocExpression;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -1316,6 +1318,22 @@ begin
|
||||
AssertExpression('right AS b',AsExpr.right,pekIdent,'b');
|
||||
end;
|
||||
|
||||
procedure TTestExpressions.TestParseAdhocExpression;
|
||||
var
|
||||
ExprElement: TPasExpr;
|
||||
BinaryExpression: TBinaryExpr;
|
||||
begin
|
||||
// Unlike the other tests, this is not about the parser, but about the
|
||||
// ability to parse an expression on it's own. Without any further context.
|
||||
Add('True=False');
|
||||
StartParsing;
|
||||
Parser.NextToken;
|
||||
Parser.ParseAdhocExpression(ExprElement);
|
||||
BinaryExpression := AssertExpression('Some expression, parsed separately',ExprElement,pekBinary,TBinaryExpr) as TBinaryExpr;
|
||||
AssertExpression('Some expression, parsed separately, left part', BinaryExpression.left, pekBoolConst, TBoolConstExpr);
|
||||
AssertExpression('Some expression, parsed separately, right part',BinaryExpression.right, pekBoolConst, TBoolConstExpr);
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
RegisterTest(TTestExpressions);
|
||||
|
@ -4,10 +4,10 @@ program testpassrc;
|
||||
|
||||
uses
|
||||
//MemCheck,
|
||||
Classes, consoletestrunner, tcscanner, tctypeparser, tcstatements,
|
||||
tcbaseparser, tcmoduleparser, tconstparser, tcvarparser, tcclasstype,
|
||||
tcexprparser, tcprocfunc, tcpassrcutil, tcresolver, tcgenerics,
|
||||
tcuseanalyzer, pasresolveeval, tcresolvegenerics;
|
||||
Classes, consoletestrunner,{ tcscanner, tctypeparser, tcstatements,
|
||||
tcbaseparser, tcmoduleparser, tconstparser, tcvarparser, tcclasstype,}
|
||||
tcexprparser{, tcprocfunc, tcpassrcutil, tcresolver, tcgenerics,
|
||||
tcuseanalyzer, pasresolveeval, tcresolvegenerics};
|
||||
|
||||
type
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user