codetools: c parser: fixed parsing at end of code

git-svn-id: trunk@31299 -
This commit is contained in:
mattias 2011-06-20 14:55:18 +00:00
parent e6ada195c2
commit a7b67263cd
2 changed files with 10 additions and 2 deletions

View File

@ -835,8 +835,10 @@ begin
ReadDefinition(false);
if CurNode.LastChild.Desc<>ccnFunction then begin
ReadNextAtom;
debugln(['TCCodeParserTool.OtherToken ',GetAtom,' SrcPos=',SrcPos,' AtomStart=',AtomStart,' SrcLen=',SrcLen]);
if not AtomIsChar(';') then
RaiseExpectedButAtomFound(';');
debugln(['TCCodeParserTool.OtherToken AAA1']);
end;
end else
RaiseException('unexpected token '+GetAtom);
@ -1863,7 +1865,7 @@ end;
function TCCodeParserTool.AtomIsChar(const c: char): boolean;
begin
if SrcPos-AtomStart<>1 then exit(false);
if SrcPos>SrcLen then exit(false);
if AtomStart>SrcLen then exit(false);
if Src[AtomStart]<>c then exit(false);
Result:=true;
end;

View File

@ -124,7 +124,13 @@ begin
try
Header1:=CodeToolBoss.CreateFile('header1.h');
PasCode:=CodeToolBoss.CreateFile('header1.pas');
Header1.Source:='int i;';
Tool.Convert(Header1,PasCode);
Tool.WriteH2PNodeReport;
Tool.WriteH2PDirectivesNodeReport;
writeln;
writeln('=============================================');
writeln(PasCode.Source);
finally
Tool.Free;
end;