{ TDelphiUnitParser }
function TDelphiUnitParser.CheckSectionBreak : Boolean ;
begin
with Parser do begin
Result := ( Token = toSymbol ) and
( Compare( 'Var' ) or
Compare( 'Const' ) or
Compare( 'Type' ) or
'Implementation' ) or
Compare( 'Procedure' ) or
Compare( 'Function' ) ) ;
end ;
end ;
procedure TDelphiUnitParser.ParseParameterList ;
begin
with Parser do begin
{ пропускаем '(' }
NextToken ;
while Token <> ')' do NextToken ;
NextToken ;
end ;
end ;
procedure TDelphiUnitParser.ParseRecord ;
begin
with Parser do begin
{ пропускаем 'record' }
NextToken ;
while ( Token <> toSymbol ) or not Compare( 'End' ) do
begin
if Token = 'Record' then ParseRecord else NextToken ;
end ;
end ;
end ;
procedure TDelphiUnitParser.ParseDeclaration ;
begin
with Parser do begin
while Token <> ';' do begin
if Token = '(' then ParseParameterList else
if ( Token = toSymbol ) and Compare( 'Record' ) then
ParseRecord else
NextToken ;
end ;
end ;
end ;
procedure TDelphiUnitParser.ParseConst ;
var AString : String ;
AStart : PChar ;
EndOfConsts : Boolean ;
begin
with Parser do begin
NextToken ;
repeat
if Token <> toSymbol then ErrorStr( 'Неопознанный идентификатор' ) ;
AString := TokenString ;
AStart := FSourcePtr ;
NextToken ;
if not( Token in [ '=', ':' ] ) then ErrorStr( '''='' or '':''
ожидалось' ) ;
ParseDeclaration ;
FindToken( ';' ) ;
until CheckSectionBreak ;
end ;
end ;