1、* TIParser *constructor TIParser.Create;begininherited Create;FHistory := TStringList.Create;HistorySize := 10;Style := psPascal;end;destructor TIParser.Destroy;beginFHistory.Free;inherited Destroy;end;function TIParser.Token: string;varP, F: PChar;const$IFDEF RA_DStSkip = , #10, #13;$ENDIF RA_D$IFD
2、EF RA_BStSkip = #10#13;$ENDIF RA_Bprocedure SkipComments;begincase P0 of:if FStyle = psPascal thenbeginF := 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 (P1
3、= *) thenbeginF := P + 2;while true dobeginF := StrScan(F, *);if F = nil then IParserError(ieBadRemark, P - FpcProgram);if F1 = ) thenbegininc(F);break;end;inc(F);end;P := F + 1;end;*:if FStyle = psPascal thenbeginif (P1 = ) thenIParserError(ieBadRemark, P - FpcProgram)endelse if FStyle = psCpp then
4、if (P1 = /) then IParserError(ieBadRemark, P - FpcProgram);/:if (FStyle in psPascal, psCpp) and (P1 = /) thenbeginF := StrScan(P + 1, #13);if F = nil then F := StrEnd(P + 1);P := F;endelse if (FStyle = psCpp) and (P1 = *) thenbeginF := P + 2;while true dobeginF := StrScan(F, *);if F = nil then IPars
5、erError(ieBadRemark, P - FpcProgram);if F1 = / thenbegininc(F);break;end;inc(F);end;P := F + 1;end;#:if (FStyle in psPython, psPerl) and(P = FpcProgram) or (P-1 in #10, #13) thenbeginF := StrScan(P + 1, #13);if F = nil then F := StrEnd(P + 1);P := F;end;:if FStyle = psVB thenbeginF := StrScan(P + 1, #13);if F = nil then F := StrEnd(P + 1);P := F;end;end;end;