mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-20 07:59:37 +01:00
fixed nested comments for fpc sources
git-svn-id: trunk@3764 -
This commit is contained in:
parent
14db153343
commit
f17bd32429
@ -32,7 +32,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
|
||||
|
||||
ResourceString
|
||||
// codetree
|
||||
ctsUnknownSubDescriptor = '(unknown subdescriptor %s)';
|
||||
@ -159,6 +159,7 @@ ResourceString
|
||||
'Source filenames for the standard fpc units';
|
||||
ctsFreePascalSourceDir = 'Free Pascal Source Directory';
|
||||
ctsSrcPathInitialization = 'SrcPath Initialization';
|
||||
ctsNestedCommentsOn = 'Nested Comments On';
|
||||
ctsCompiler = 'Compiler';
|
||||
ctsRuntimeLibrary = 'Runtime library';
|
||||
ctsProcessorSpecific = 'processor specific';
|
||||
|
||||
@ -2320,6 +2320,10 @@ begin
|
||||
DefTempl:=TDefineTemplate.Create('Reset SrcPath',
|
||||
ctsSrcPathInitialization,ExternalMacroStart+'SrcPath','',da_DefineRecurse);
|
||||
MainDir.AddChild(DefTempl);
|
||||
// turn Nested comments on
|
||||
DefTempl:=TDefineTemplate.Create('Nested Comments',
|
||||
ctsNestedCommentsOn,ExternalMacroStart+'NestedComments','',da_DefineRecurse);
|
||||
MainDir.AddChild(DefTempl);
|
||||
|
||||
// compiler
|
||||
CompilerDir:=TDefineTemplate.Create('Compiler',ctsCompiler,'','compiler',
|
||||
@ -2422,7 +2426,10 @@ begin
|
||||
ExternalMacroStart+'IncPath',
|
||||
'include;include'+ds+TargetOS,
|
||||
da_Define));
|
||||
|
||||
// turn Nested comments on
|
||||
MainDir.AddChild(TDefineTemplate.Create('Nested Comments',
|
||||
ctsNestedCommentsOn,ExternalMacroStart+'NestedComments','',da_DefineRecurse));
|
||||
|
||||
// examples
|
||||
DirTempl:=TDefineTemplate.Create('Examples',
|
||||
Format(ctsNamedDirectory,['Examples']),
|
||||
|
||||
@ -53,6 +53,8 @@ const
|
||||
{$endif}
|
||||
|
||||
function CompareFilenames(const Filename1, Filename2: string): integer;
|
||||
function CompareFileExt(const Filename, Ext: string;
|
||||
CaseSensitive: boolean): integer;
|
||||
function DirectoryExists(DirectoryName: string): boolean;
|
||||
function ExtractFileNameOnly(const AFilename: string): string;
|
||||
function FilenameIsAbsolute(TheFilename: string):boolean;
|
||||
@ -69,8 +71,6 @@ function SearchFileInPath(const Filename, BasePath, SearchPath,
|
||||
Delimiter: string; SearchLoUpCase: boolean): string;
|
||||
function FilenameIsMatching(const Mask, Filename: string;
|
||||
MatchExactly: boolean): boolean;
|
||||
function CompareFileExt(const Filename, Ext: string;
|
||||
CaseSensitive: boolean): integer;
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
@ -49,6 +49,8 @@ uses
|
||||
|
||||
const
|
||||
PascalCompilerDefine = ExternalMacroStart+'Compiler';
|
||||
NestedCompilerDefine = ExternalMacroStart+'NestedComments';
|
||||
|
||||
MissingIncludeFileCode = 1;
|
||||
|
||||
type
|
||||
@ -217,6 +219,7 @@ type
|
||||
FSkipIfLevel: integer;
|
||||
FCompilerMode: TCompilerMode;
|
||||
FPascalCompiler: TPascalCompiler;
|
||||
procedure SetCompilerMode(const AValue: TCompilerMode);
|
||||
procedure SkipTillEndifElse;
|
||||
function SkipIfDirective: boolean;
|
||||
function IfdefDirective: boolean;
|
||||
@ -272,6 +275,8 @@ type
|
||||
|
||||
EndOfInterfaceFound: boolean;
|
||||
EndOfSourceFound: boolean;
|
||||
|
||||
function MainFilename: string;
|
||||
|
||||
// links
|
||||
property Links[Index: integer]: TSourceLink read GetLinks write SetLinks;
|
||||
@ -349,7 +354,8 @@ type
|
||||
property IncludeFileIsMissing: boolean
|
||||
read GetIncludeFileIsMissing;
|
||||
property NestedComments: boolean read FNestedComments;
|
||||
property CompilerMode: TCompilerMode read FCompilerMode write FCompilerMode;
|
||||
property CompilerMode: TCompilerMode
|
||||
read FCompilerMode write SetCompilerMode;
|
||||
property PascalCompiler: TPascalCompiler
|
||||
read FPascalCompiler write FPascalCompiler;
|
||||
property ScanTillInterfaceEnd: boolean
|
||||
@ -961,6 +967,7 @@ begin
|
||||
EndOfSourceFound:=false;
|
||||
CommentStyle:=CommentNone;
|
||||
CommentLevel:=0;
|
||||
FNestedComments:=false;
|
||||
CompilerMode:=cmFPC;
|
||||
PascalCompiler:=pcFPC;
|
||||
IfLevel:=0;
|
||||
@ -969,15 +976,25 @@ begin
|
||||
FInitValues.Assign(FOnGetInitValues(FMainCode,FInitValuesChangeStep));
|
||||
//writeln('TLinkScanner.Scan D --------');
|
||||
Values.Assign(FInitValues);
|
||||
for cm:=Low(TCompilerMode) to High(TCompilerMode) do
|
||||
if FInitValues.IsDefined(CompilerModeVars[cm]) then begin
|
||||
CompilerMode:=cm;
|
||||
end;
|
||||
|
||||
// compiler
|
||||
s:=FInitValues.Variables[PascalCompilerDefine];
|
||||
for pc:=Low(TPascalCompiler) to High(TPascalCompiler) do
|
||||
if (s=PascalCompilerNames[pc]) then begin
|
||||
if (s=PascalCompilerNames[pc]) then
|
||||
PascalCompiler:=pc;
|
||||
end;
|
||||
|
||||
// compiler mode
|
||||
for cm:=Low(TCompilerMode) to High(TCompilerMode) do
|
||||
if FInitValues.IsDefined(CompilerModeVars[cm]) then
|
||||
CompilerMode:=cm;
|
||||
|
||||
// nested comments
|
||||
if (PascalCompiler=pcFPC) and (CompilerMode in [cmFPC,cmOBJFPC])
|
||||
and ((FInitValues.IsDefined(NestedCompilerDefine))
|
||||
or (CompareFileExt(MainFilename,'pp',false)=0))
|
||||
then
|
||||
FNestedComments:=true;
|
||||
|
||||
//writeln(Values.AsString);
|
||||
//writeln('TLinkScanner.Scan E --------');
|
||||
FMacrosOn:=(Values.Variables['MACROS']<>'0');
|
||||
@ -2475,6 +2492,14 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLinkScanner.SetCompilerMode(const AValue: TCompilerMode);
|
||||
begin
|
||||
if FCompilerMode=AValue then exit;
|
||||
FCompilerMode:=AValue;
|
||||
FNestedComments:=(PascalCompiler=pcFPC)
|
||||
and (FCompilerMode in [cmFPC,cmOBJFPC]);
|
||||
end;
|
||||
|
||||
function TLinkScanner.SkipIfDirective: boolean;
|
||||
begin
|
||||
inc(IfLevel);
|
||||
@ -2720,6 +2745,14 @@ begin
|
||||
RaiseExceptionClass('Abort',ELinkScannerAbort);
|
||||
end;
|
||||
|
||||
function TLinkScanner.MainFilename: string;
|
||||
begin
|
||||
if Assigned(OnGetFileName) and (Code<>nil) then
|
||||
Result:=OnGetFileName(Self,Code)
|
||||
else
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
{ ELinkScannerError }
|
||||
|
||||
constructor ELinkScannerError.Create(ASender: TLinkScanner;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user