{*************************** TIParser ****************************}
constructor TIParser.Create;
begin
inherited Create;
FHistory := TStringList.Create;
HistorySize := 10;
Style := psPascal;
end;
destructor TIParser.Destroy;
begin
FHistory.Free;
inherited Destroy;
end;
function TIParser.Token: string;
var
P, F: PChar;
const
{$IFDEF RA_D}
StSkip = [' ', #10, #13];
{$ENDIF RA_D}
{$IFDEF RA_B}
StSkip = ' '#10#13;
{$ENDIF RA_B}
procedure SkipComments;
begin
case P[0] of
'{':
if FStyle = psPascal then
begin
F := StrScan(P + 1, '}');
if F = nil then IParserError(ieBadRemark, P - FpcProgram);
P := F + 1;
end;
'}':
if FStyle = psPascal then IParserError(ieBadRemark, P - FpcProgram);
'(':
if (FStyle = psPascal) and (P[1] = '*') then
begin
F := P + 2;
while true do
begin
F := StrScan(F, '*');
if F = nil then IParserError(ieBadRemark, P - FpcProgram);
if F[1] = ')' then
begin
inc(F);
break;
end;
inc(F);
end;
P := F + 1;
end;
'*':
if FStyle = psPascal then
begin
if (P[1] = ')') then
IParserError(ieBadRemark, P - FpcProgram)
end
else if FStyle = psCpp then
if (P[1] = '/') then IParserError(ieBadRemark, P - FpcProgram);
'/':
if (FStyle in [psPascal, psCpp]) and (P[1] = '/') then
begin
F := StrScan(P + 1, #13);
if F = nil then F := StrEnd(P + 1);
P := F;
end
else if (FStyle = psCpp) and (P[1] = '*') then
begin
F := P + 2;
while true do
begin
F := StrScan(F, '*');
if F = nil then IParserError(ieBadRemark, P - FpcProgram);
if F[1] = '/' then
begin
inc(F);
break;
end;
inc(F);
end;
P := F + 1;
end;
'#':
if (FStyle in [psPython, psPerl]) { and
((P = FpcProgram) or (P[-1] in [#10, #13])) } then
begin
F := StrScan(P + 1, #13);
if F = nil then F := StrEnd(P + 1);
P := F;
end;
'''':
if FStyle = psVB then
begin
F := StrScan(P + 1, #13);
if F = nil then F := StrEnd(P + 1);
P := F;
end;
end;
end;