mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 15:29:14 +02:00
fcl-passrc: scanner property OnDirective, resourcestrings for IFOpt
git-svn-id: trunk@36161 -
This commit is contained in:
parent
de2aedade2
commit
141238bb90
@ -39,8 +39,8 @@ const
|
|||||||
nLogIFNDefRejected = 1012;
|
nLogIFNDefRejected = 1012;
|
||||||
nLogIFAccepted = 1013;
|
nLogIFAccepted = 1013;
|
||||||
nLogIFRejected = 1014;
|
nLogIFRejected = 1014;
|
||||||
nLogIFOPTIgnored = 1015;
|
nLogIFOptAccepted = 1015;
|
||||||
nLogIFIgnored = 1016;
|
nLogIFOptRejected = 1016;
|
||||||
nErrInvalidMode = 1017;
|
nErrInvalidMode = 1017;
|
||||||
nErrInvalidModeSwitch = 1018;
|
nErrInvalidModeSwitch = 1018;
|
||||||
nErrXExpectedButYFound = 1019;
|
nErrXExpectedButYFound = 1019;
|
||||||
@ -67,8 +67,8 @@ resourcestring
|
|||||||
SLogIFNDefRejected = 'IFNDEF %s found, rejecting.';
|
SLogIFNDefRejected = 'IFNDEF %s found, rejecting.';
|
||||||
SLogIFAccepted = 'IF %s found, accepting.';
|
SLogIFAccepted = 'IF %s found, accepting.';
|
||||||
SLogIFRejected = 'IF %s found, rejecting.';
|
SLogIFRejected = 'IF %s found, rejecting.';
|
||||||
SLogIFOPTIgnored = 'IFOPT %s found, ignoring (rejected).';
|
SLogIFOptAccepted = 'IFOpt %s found, accepting.';
|
||||||
SLogIFIgnored = 'IF %s found, ignoring (rejected).';
|
SLogIFOptRejected = 'IFOpt %s found, rejecting.';
|
||||||
SErrInvalidMode = 'Invalid mode: "%s"';
|
SErrInvalidMode = 'Invalid mode: "%s"';
|
||||||
SErrInvalidModeSwitch = 'Invalid mode switch: "%s"';
|
SErrInvalidModeSwitch = 'Invalid mode switch: "%s"';
|
||||||
SErrUserDefined = 'User defined error: "%s"';
|
SErrUserDefined = 'User defined error: "%s"';
|
||||||
@ -488,6 +488,7 @@ type
|
|||||||
TPScannerLogHandler = Procedure (Sender : TObject; Const Msg : String) of object;
|
TPScannerLogHandler = Procedure (Sender : TObject; Const Msg : String) of object;
|
||||||
TPScannerLogEvent = (sleFile,sleLineNumber,sleConditionals);
|
TPScannerLogEvent = (sleFile,sleLineNumber,sleConditionals);
|
||||||
TPScannerLogEvents = Set of TPScannerLogEvent;
|
TPScannerLogEvents = Set of TPScannerLogEvent;
|
||||||
|
TPScannerDirectiveEvent = function(Sender: TObject; Directive, Param: String): boolean of object;
|
||||||
|
|
||||||
TPascalScanner = class
|
TPascalScanner = class
|
||||||
private
|
private
|
||||||
@ -510,6 +511,7 @@ type
|
|||||||
FMacros,
|
FMacros,
|
||||||
FDefines: TStrings;
|
FDefines: TStrings;
|
||||||
FMacrosOn: boolean;
|
FMacrosOn: boolean;
|
||||||
|
FOnDirective: TPScannerDirectiveEvent;
|
||||||
FOnEvalFunction: TCEEvalFunctionEvent;
|
FOnEvalFunction: TCEEvalFunctionEvent;
|
||||||
FOnEvalVariable: TCEEvalVarEvent;
|
FOnEvalVariable: TCEEvalVarEvent;
|
||||||
FOptions: TPOptions;
|
FOptions: TPOptions;
|
||||||
@ -604,11 +606,12 @@ 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 FMacrosOn write FMacrosOn;
|
property MacrosOn: boolean read FMacrosOn write FMacrosOn;
|
||||||
Property AllowedModeSwitches: TModeSwitches Read FAllowedModeSwitches Write SetAllowedModeSwitches;
|
property OnDirective: TPScannerDirectiveEvent read FOnDirective write FOnDirective;
|
||||||
Property ReadOnlyModeSwitches: TModeSwitches Read FReadOnlyModeSwitches Write SetReadOnlyModeSwitches;// always set, cannot be disabled
|
property AllowedModeSwitches: TModeSwitches Read FAllowedModeSwitches Write SetAllowedModeSwitches;
|
||||||
Property CurrentModeSwitches: TModeSwitches Read FCurrentModeSwitches Write SetCurrentModeSwitches;
|
property ReadOnlyModeSwitches: TModeSwitches Read FReadOnlyModeSwitches Write SetReadOnlyModeSwitches;// always set, cannot be disabled
|
||||||
|
property CurrentModeSwitches: TModeSwitches Read FCurrentModeSwitches Write SetCurrentModeSwitches;
|
||||||
property Options : TPOptions Read FOptions Write SetOptions;
|
property Options : TPOptions Read FOptions Write SetOptions;
|
||||||
Property ForceCaret : Boolean Read FForceCaret;
|
property ForceCaret : Boolean Read FForceCaret;
|
||||||
property LogEvents : TPScannerLogEvents Read FLogEvents Write FLogEvents;
|
property LogEvents : TPScannerLogEvents Read FLogEvents Write FLogEvents;
|
||||||
property OnLog : TPScannerLogHandler Read FOnLog Write FOnLog;
|
property OnLog : TPScannerLogHandler Read FOnLog Write FOnLog;
|
||||||
property ConditionEval: TCondDirectiveEvaluator read FConditionEval;
|
property ConditionEval: TCondDirectiveEvaluator read FConditionEval;
|
||||||
@ -2667,9 +2670,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
If LogEvent(sleConditionals) then
|
If LogEvent(sleConditionals) then
|
||||||
if PPSkipMode=ppSkipElseBranch then
|
if PPSkipMode=ppSkipElseBranch then
|
||||||
DoLog(mtInfo,nLogIFAccepted,sLogIFAccepted,[AParam])
|
DoLog(mtInfo,nLogIFOptAccepted,sLogIFOptAccepted,[AParam])
|
||||||
else
|
else
|
||||||
DoLog(mtInfo,nLogIFRejected,sLogIFRejected,[AParam])
|
DoLog(mtInfo,nLogIFOptRejected,sLogIFOptRejected,[AParam])
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2734,7 +2737,7 @@ begin
|
|||||||
Directive:=Copy(ADirectiveText,2,P-2); // 1 is $
|
Directive:=Copy(ADirectiveText,2,P-2); // 1 is $
|
||||||
Param:=ADirectiveText;
|
Param:=ADirectiveText;
|
||||||
Delete(Param,1,P);
|
Delete(Param,1,P);
|
||||||
Writeln('Directive: "',Directive,'", Param : "',Param,'"');
|
//Writeln('Directive: "',Directive,'", Param : "',Param,'"');
|
||||||
|
|
||||||
Case UpperCase(Directive) of
|
Case UpperCase(Directive) of
|
||||||
'IFDEF':
|
'IFDEF':
|
||||||
@ -2753,6 +2756,10 @@ begin
|
|||||||
HandleENDIF(Param);
|
HandleENDIF(Param);
|
||||||
else
|
else
|
||||||
if PPIsSkipping then exit;
|
if PPIsSkipping then exit;
|
||||||
|
|
||||||
|
if Assigned(OnDirective) then
|
||||||
|
if not OnDirective(Self,Directive,Param) then exit;
|
||||||
|
|
||||||
if (length(Directive)=2)
|
if (length(Directive)=2)
|
||||||
and (Directive[1] in ['a'..'z','A'..'Z'])
|
and (Directive[1] in ['a'..'z','A'..'Z'])
|
||||||
and (Directive[2] in ['-','+']) then
|
and (Directive[2] in ['-','+']) then
|
||||||
@ -2776,8 +2783,6 @@ begin
|
|||||||
HandleError(Param);
|
HandleError(Param);
|
||||||
'UNDEF':
|
'UNDEF':
|
||||||
HandleUnDefine(Param);
|
HandleUnDefine(Param);
|
||||||
else
|
|
||||||
// ToDo: call hook
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user