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