|
@@ -684,8 +684,8 @@ type
|
|
TPScannerLogHandler = Procedure (Sender : TObject; Const Msg : String) of object;
|
|
TPScannerLogHandler = Procedure (Sender : TObject; Const Msg : String) of object;
|
|
TPScannerLogEvent = (sleFile,sleLineNumber,sleConditionals,sleDirective);
|
|
TPScannerLogEvent = (sleFile,sleLineNumber,sleConditionals,sleDirective);
|
|
TPScannerLogEvents = Set of TPScannerLogEvent;
|
|
TPScannerLogEvents = Set of TPScannerLogEvent;
|
|
- TPScannerDirectiveEvent = procedure(Sender: TObject; Directive, Param: String;
|
|
|
|
- var Handled: boolean) of object;
|
|
|
|
|
|
+ TPScannerDirectiveEvent = procedure(Sender: TObject; Directive, Param: String; var Handled: boolean) of object;
|
|
|
|
+ TPScannerCommentEvent = procedure(Sender: TObject; aComment : String) of object;
|
|
TPScannerFormatPathEvent = function(const aPath: string): string of object;
|
|
TPScannerFormatPathEvent = function(const aPath: string): string of object;
|
|
TPScannerWarnEvent = procedure(Sender: TObject; Identifier: string; State: TWarnMsgState; var Handled: boolean) of object;
|
|
TPScannerWarnEvent = procedure(Sender: TObject; Identifier: string; State: TWarnMsgState; var Handled: boolean) of object;
|
|
TPScannerModeDirective = procedure(Sender: TObject; NewMode: TModeSwitch; Before: boolean; var Handled: boolean) of object;
|
|
TPScannerModeDirective = procedure(Sender: TObject; NewMode: TModeSwitch; Before: boolean; var Handled: boolean) of object;
|
|
@@ -734,6 +734,7 @@ type
|
|
FMacros: TStrings; // Objects are TMacroDef
|
|
FMacros: TStrings; // Objects are TMacroDef
|
|
FDefines: TStrings;
|
|
FDefines: TStrings;
|
|
FNonTokens: TTokens;
|
|
FNonTokens: TTokens;
|
|
|
|
+ FOnComment: TPScannerCommentEvent;
|
|
FOnDirective: TPScannerDirectiveEvent;
|
|
FOnDirective: TPScannerDirectiveEvent;
|
|
FOnEvalFunction: TCEEvalFunctionEvent;
|
|
FOnEvalFunction: TCEEvalFunctionEvent;
|
|
FOnEvalVariable: TCEEvalVarEvent;
|
|
FOnEvalVariable: TCEEvalVarEvent;
|
|
@@ -799,6 +800,7 @@ type
|
|
function HandleDirective(const ADirectiveText: String): TToken; virtual;
|
|
function HandleDirective(const ADirectiveText: String): TToken; virtual;
|
|
function HandleLetterDirective(Letter: char; Enable: boolean): TToken; virtual;
|
|
function HandleLetterDirective(Letter: char; Enable: boolean): TToken; virtual;
|
|
procedure HandleBoolDirective(bs: TBoolSwitch; const Param: String); virtual;
|
|
procedure HandleBoolDirective(bs: TBoolSwitch; const Param: String); virtual;
|
|
|
|
+ procedure DoHandleComment(Sender: TObject; const aComment : string); virtual;
|
|
procedure DoHandleDirective(Sender: TObject; Directive, Param: String;
|
|
procedure DoHandleDirective(Sender: TObject; Directive, Param: String;
|
|
var Handled: boolean); virtual;
|
|
var Handled: boolean); virtual;
|
|
procedure HandleIFDEF(const AParam: String);
|
|
procedure HandleIFDEF(const AParam: String);
|
|
@@ -882,7 +884,6 @@ type
|
|
property Defines: TStrings read FDefines;
|
|
property Defines: TStrings read FDefines;
|
|
property Macros: TStrings read FMacros;
|
|
property Macros: TStrings read FMacros;
|
|
property MacrosOn: boolean read GetMacrosOn write SetMacrosOn;
|
|
property MacrosOn: boolean read GetMacrosOn write SetMacrosOn;
|
|
- property OnDirective: TPScannerDirectiveEvent read FOnDirective write FOnDirective;
|
|
|
|
property AllowedModeSwitches: TModeSwitches read FAllowedModeSwitches Write SetAllowedModeSwitches;
|
|
property AllowedModeSwitches: TModeSwitches read FAllowedModeSwitches Write SetAllowedModeSwitches;
|
|
property ReadOnlyModeSwitches: TModeSwitches read FReadOnlyModeSwitches Write SetReadOnlyModeSwitches;// always set, cannot be disabled
|
|
property ReadOnlyModeSwitches: TModeSwitches read FReadOnlyModeSwitches Write SetReadOnlyModeSwitches;// always set, cannot be disabled
|
|
property CurrentModeSwitches: TModeSwitches read FCurrentModeSwitches Write SetCurrentModeSwitches;
|
|
property CurrentModeSwitches: TModeSwitches read FCurrentModeSwitches Write SetCurrentModeSwitches;
|
|
@@ -908,6 +909,9 @@ type
|
|
property OnEvalFunction: TCEEvalFunctionEvent read FOnEvalFunction write FOnEvalFunction;
|
|
property OnEvalFunction: TCEEvalFunctionEvent read FOnEvalFunction write FOnEvalFunction;
|
|
property OnWarnDirective: TPScannerWarnEvent read FOnWarnDirective write FOnWarnDirective;
|
|
property OnWarnDirective: TPScannerWarnEvent read FOnWarnDirective write FOnWarnDirective;
|
|
property OnModeChanged: TPScannerModeDirective read FOnModeChanged write FOnModeChanged; // set by TPasParser
|
|
property OnModeChanged: TPScannerModeDirective read FOnModeChanged write FOnModeChanged; // set by TPasParser
|
|
|
|
+ property OnDirective: TPScannerDirectiveEvent read FOnDirective write FOnDirective;
|
|
|
|
+ property OnComment: TPScannerCommentEvent read FOnComment write FOnComment;
|
|
|
|
+
|
|
|
|
|
|
property LastMsg: string read FLastMsg write FLastMsg;
|
|
property LastMsg: string read FLastMsg write FLastMsg;
|
|
property LastMsgNumber: integer read FLastMsgNumber write FLastMsgNumber;
|
|
property LastMsgNumber: integer read FLastMsgNumber write FLastMsgNumber;
|
|
@@ -4094,11 +4098,17 @@ begin
|
|
CurrentBoolSwitches:=CurrentBoolSwitches-[bs];
|
|
CurrentBoolSwitches:=CurrentBoolSwitches-[bs];
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TPascalScanner.DoHandleComment(Sender: TObject; const aComment: string);
|
|
|
|
+begin
|
|
|
|
+ if Assigned(OnComment) then
|
|
|
|
+ OnComment(Sender,aComment);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TPascalScanner.DoHandleDirective(Sender: TObject; Directive,
|
|
procedure TPascalScanner.DoHandleDirective(Sender: TObject; Directive,
|
|
Param: String; var Handled: boolean);
|
|
Param: String; var Handled: boolean);
|
|
begin
|
|
begin
|
|
if Assigned(OnDirective) then
|
|
if Assigned(OnDirective) then
|
|
- OnDirective(Self,Directive,Param,Handled);
|
|
|
|
|
|
+ OnDirective(Sender,Directive,Param,Handled);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TPascalScanner.DoFetchToken: TToken;
|
|
function TPascalScanner.DoFetchToken: TToken;
|
|
@@ -4299,7 +4309,9 @@ begin
|
|
Inc(FTokenPos, 2);
|
|
Inc(FTokenPos, 2);
|
|
Result := tkComment;
|
|
Result := tkComment;
|
|
if Copy(CurTokenString,1,1)='$' then
|
|
if Copy(CurTokenString,1,1)='$' then
|
|
- Result := HandleDirective(CurTokenString);
|
|
|
|
|
|
+ Result := HandleDirective(CurTokenString)
|
|
|
|
+ else
|
|
|
|
+ DoHandleComment(Self,CurTokenString);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
')':
|
|
')':
|
|
@@ -4600,7 +4612,9 @@ begin
|
|
Inc(FTokenPos);
|
|
Inc(FTokenPos);
|
|
Result := tkComment;
|
|
Result := tkComment;
|
|
if (Copy(CurTokenString,1,1)='$') then
|
|
if (Copy(CurTokenString,1,1)='$') then
|
|
- Result:=HandleDirective(CurTokenString);
|
|
|
|
|
|
+ Result:=HandleDirective(CurTokenString)
|
|
|
|
+ else
|
|
|
|
+ DoHandleComment(Self, CurTokenString)
|
|
end;
|
|
end;
|
|
'A'..'Z', 'a'..'z', '_':
|
|
'A'..'Z', 'a'..'z', '_':
|
|
begin
|
|
begin
|