Skip to content

Commit

Permalink
refractor codetools includes
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Dec 19, 2023
1 parent 240dab3 commit ec97b8b
Show file tree
Hide file tree
Showing 17 changed files with 381 additions and 525 deletions.
4 changes: 2 additions & 2 deletions Source/codetools/mpaslex.pas
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,12 @@ procedure TmwBasePasLex.BraceOpenProc;
end;
tokIncludeDirect, tokIncludeOnceDirect:
begin
if Assigned(fOnIncludeDirect) and (FDefineStack = 0) then
if Assigned(fOnIncludeDirect) and (FDefineStack = 0) and (not IsJunk) then
fOnIncludeDirect(Self);
end;
tokLibraryDirect:
begin
if Assigned(fOnLibraryDirect) and (FDefineStack = 0) then
if Assigned(fOnLibraryDirect) and (FDefineStack = 0) and (not IsJunk) then
fOnLibraryDirect(Self);
end;
tokUndefDirect:
Expand Down
23 changes: 4 additions & 19 deletions Source/codetools/msimplepaspar.pas
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,8 @@ TmwSimplePasPar = class(TObject)

procedure Assign(From: TObject); virtual;

procedure SetScript(Script: String; FileName: String = ''; Defines: TStringArray = nil); virtual;
procedure SetFile(FileName: String; Defines: TStringArray = nil); virtual;

function HasFile(FileName: String): Boolean;
procedure SetScript(Script: String; FileName: String = ''); virtual;
procedure SetFile(FileName: String); virtual;

procedure Reset; virtual;
procedure Run; virtual;
Expand Down Expand Up @@ -592,29 +590,16 @@ procedure TmwSimplePasPar.Reset;
fLexerStack.Clear();
end;

procedure TmwSimplePasPar.SetScript(Script: String; FileName: String; Defines: TStringArray);
procedure TmwSimplePasPar.SetScript(Script: String; FileName: String);
begin
Reset();
PushLexer(TmwPasLex.Create(Script, FileName));
fLexer.Defines.AddStrings(Defines);
end;

procedure TmwSimplePasPar.SetFile(FileName: String; Defines: TStringArray);
procedure TmwSimplePasPar.SetFile(FileName: String);
begin
Reset();
PushLexer(TmwPasLex.CreateFromFile(FileName));
fLexer.Defines.AddStrings(Defines);
end;

function TmwSimplePasPar.HasFile(FileName: String): Boolean;
var
I: Integer;
begin
for I := 0 to fLexers.Count - 1 do
if (fLexers[I].FileName = FileName) then
Exit(True);

Result := False;
end;

procedure TmwSimplePasPar.ParseFile;
Expand Down
Loading

0 comments on commit ec97b8b

Please sign in to comment.