pastojs+pparser: fixed copying last line of asm..block with option po_asmwhole

git-svn-id: trunk@36650 -
This commit is contained in:
Mattias Gaertner 2017-07-05 20:33:48 +00:00
parent 8cd56fb9be
commit 5e409ff349
3 changed files with 19 additions and 9 deletions

View File

@ -4655,7 +4655,7 @@ begin
repeat
Scanner.ReadNonPascalTillEndToken(true);
case Scanner.CurToken of
tkLineEnding:
tkLineEnding,tkWhitespace:
AsmBlock.Tokens.Add(Scanner.CurTokenString);
tkend:
begin
@ -4687,7 +4687,6 @@ begin
NextToken;
end;
end;
// NextToken; // Eat end.
// Do not consume end. Current token will normally be end;
end;

View File

@ -2325,6 +2325,14 @@ begin
begin
// 'end' found
Add;
if FCurTokenString<>'' then
begin
// return characters in front of 'end'
Result:=tkWhitespace;
FCurToken:=Result;
exit;
end;
// return 'end'
Result := tkend;
SetLength(FCurTokenString, 3);
Move(TokenStr^, FCurTokenString[1], 3);

View File

@ -2407,19 +2407,22 @@ end;
procedure TTestModule.TestProc_Asm;
begin
StartProgram(false);
Add('function DoIt: longint;');
Add('begin;');
Add(' asm');
Add(' { a:{ b:{}, c:[]}, d:''1'' };');
Add(' end;');
Add('end;');
Add('begin');
Add([
'function DoIt: longint;',
'begin;',
' asm',
' { a:{ b:{}, c:[]}, d:''1'' };',
' end;',
' asm console.log(); end;',
'end;',
'begin']);
ConvertProgram;
CheckSource('TestProcedureAsm',
LinesToStr([ // statements
'this.DoIt = function () {',
' var Result = 0;',
' { a:{ b:{}, c:[]}, d:''1'' };',
' console.log();',
' return Result;',
'};'
]),