codetools: anonymous functions in pas2js

git-svn-id: trunk@59832 -
This commit is contained in:
mattias 2018-12-17 11:57:09 +00:00
parent 7a3b00d295
commit 07ff5d447e

View File

@ -251,6 +251,7 @@ type
function ReadClosure(ExceptionOnError, CreateNodes: boolean): boolean;
function WordIsPropertyEnd: boolean;
function AllowAttributes: boolean; inline;
function AllowClosures: boolean; inline;
public
CurSection: TCodeTreeNodeDesc;
@ -1045,8 +1046,7 @@ begin
SaveRaiseEndOfSourceExpected(20170421195401);
end else if UpAtomIs('WITH') then
ReadWithStatement(true,true)
else if (UpAtomIs('PROCEDURE') or UpAtomIs('FUNCTION'))
and (cmsClosures in Scanner.CompilerModeSwitches) then
else if (UpAtomIs('PROCEDURE') or UpAtomIs('FUNCTION')) and AllowClosures then
ReadClosure(true,true);
until false;
except
@ -2994,7 +2994,7 @@ begin
and (TryType=ttExcept) then begin
ReadOnStatement(true,CreateNodes);
end else if (UpAtomIs('PROCEDURE') or UpAtomIs('FUNCTION'))
and (cmsClosures in Scanner.CompilerModeSwitches) then begin
and AllowClosures then begin
ReadClosure(true,CreateNodes);
end else begin
// check for unexpected keywords
@ -6188,6 +6188,12 @@ begin
Result:=Scanner.CompilerMode in [cmDELPHI,cmDELPHIUNICODE,cmOBJFPC];
end;
function TPascalParserTool.AllowClosures: boolean;
begin
Result:=(cmsClosures in Scanner.CompilerModeSwitches)
or (Scanner.PascalCompiler=pcPas2js);
end;
procedure TPascalParserTool.ValidateToolDependencies;
begin