|
@@ -180,6 +180,7 @@ type
|
|
|
private
|
|
|
FCurModule: TPasModule;
|
|
|
FFileResolver: TBaseFileResolver;
|
|
|
+ FImplicitUses: TStrings;
|
|
|
FLastMsg: string;
|
|
|
FLastMsgArgs: TMessageArgs;
|
|
|
FLastMsgNumber: integer;
|
|
@@ -215,7 +216,6 @@ type
|
|
|
Function SaveComments : String;
|
|
|
Function SaveComments(Const AValue : String) : String;
|
|
|
function LogEvent(E : TPParserLogEvent) : Boolean; inline;
|
|
|
- procedure SetCurMsg(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of const);
|
|
|
Procedure DoLog(MsgType: TMessageType; MsgNumber: integer; Const Msg : String; SkipSourceInfo : Boolean = False);overload;
|
|
|
Procedure DoLog(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of const;SkipSourceInfo : Boolean = False);overload;
|
|
|
function GetProcTypeFromToken(tk: TToken; IsClass: Boolean=False ): TProcType;
|
|
@@ -256,6 +256,7 @@ type
|
|
|
public
|
|
|
constructor Create(AScanner: TPascalScanner; AFileResolver: TBaseFileResolver; AEngine: TPasTreeContainer);
|
|
|
Destructor Destroy; override;
|
|
|
+ procedure SetLastMsg(MsgType: TMessageType; MsgNumber: integer; Const Fmt : String; Args : Array of const);
|
|
|
// General parsing routines
|
|
|
function CurTokenName: String;
|
|
|
function CurTokenText: String;
|
|
@@ -323,6 +324,7 @@ type
|
|
|
Property CurModule : TPasModule Read FCurModule;
|
|
|
Property LogEvents : TPParserLogEvents Read FLogEvents Write FLogEvents;
|
|
|
Property OnLog : TPasParserLogHandler Read FOnLog Write FOnLog;
|
|
|
+ property ImplicitUses: TStrings read FImplicitUses;
|
|
|
property LastMsg: string read FLastMsg write FLastMsg;
|
|
|
property LastMsgNumber: integer read FLastMsgNumber write FLastMsgNumber;
|
|
|
property LastMsgType: TMessageType read FLastMsgType write FLastMsgType;
|
|
@@ -620,7 +622,7 @@ end;
|
|
|
procedure TPasParser.ParseExc(MsgNumber: integer; const Fmt: String;
|
|
|
Args: array of const);
|
|
|
begin
|
|
|
- SetCurMsg(mtError,MsgNumber,Fmt,Args);
|
|
|
+ SetLastMsg(mtError,MsgNumber,Fmt,Args);
|
|
|
raise EParserError.Create(Format(SParserErrorAtToken,
|
|
|
[FLastMsg, CurTokenName, Scanner.CurFilename, Scanner.CurRow, Scanner.CurColumn])
|
|
|
{$ifdef addlocation}+' ('+inttostr(scanner.currow)+' '+inttostr(scanner.curcolumn)+')'{$endif},
|
|
@@ -657,10 +659,13 @@ begin
|
|
|
If FEngine.NeedComments then
|
|
|
FScanner.SkipComments:=Not FEngine.NeedComments;
|
|
|
end;
|
|
|
+ FImplicitUses := TStringList.Create;
|
|
|
+ FImplicitUses.Add('System'); // system always implicitely first.
|
|
|
end;
|
|
|
|
|
|
destructor TPasParser.Destroy;
|
|
|
begin
|
|
|
+ FreeAndNil(FImplicitUses);
|
|
|
FreeAndNil(FCommentsBuffer[0]);
|
|
|
FreeAndNil(FCommentsBuffer[1]);
|
|
|
if Assigned(FEngine) then
|
|
@@ -2310,9 +2315,15 @@ procedure TPasParser.ParseUsesList(ASection: TPasSection);
|
|
|
var
|
|
|
AUnitName: String;
|
|
|
Element: TPasElement;
|
|
|
+ i: Integer;
|
|
|
begin
|
|
|
If not (Asection.ClassType=TImplementationSection) Then // interface,program,library,package
|
|
|
- Element:=CheckUnit('System'); // system always implicitely first.
|
|
|
+ begin
|
|
|
+ // load implicit units, like 'System'
|
|
|
+ for i:=0 to ImplicitUses.Count-1 do
|
|
|
+ CheckUnit(ImplicitUses[i]);
|
|
|
+ end;
|
|
|
+
|
|
|
Repeat
|
|
|
AUnitName := ExpectIdentifier;
|
|
|
NextToken;
|
|
@@ -2674,7 +2685,7 @@ begin
|
|
|
Result:=E in FLogEvents;
|
|
|
end;
|
|
|
|
|
|
-procedure TPasParser.SetCurMsg(MsgType: TMessageType; MsgNumber: integer;
|
|
|
+procedure TPasParser.SetLastMsg(MsgType: TMessageType; MsgNumber: integer;
|
|
|
const Fmt: String; Args: array of const);
|
|
|
begin
|
|
|
FLastMsgType := MsgType;
|
|
@@ -2693,7 +2704,7 @@ end;
|
|
|
procedure TPasParser.DoLog(MsgType: TMessageType; MsgNumber: integer;
|
|
|
const Fmt: String; Args: array of const; SkipSourceInfo: Boolean);
|
|
|
begin
|
|
|
- SetCurMsg(MsgType,MsgNumber,Fmt,Args);
|
|
|
+ SetLastMsg(MsgType,MsgNumber,Fmt,Args);
|
|
|
If Assigned(FOnLog) then
|
|
|
if SkipSourceInfo or not assigned(scanner) then
|
|
|
FOnLog(Self,FLastMsg)
|