Browse Source

fcl-passrc: scanner: sleLineNumbers: show last parsed line of each file

git-svn-id: trunk@39299 -
Mattias Gaertner 7 years ago
parent
commit
2b12c34c0d
2 changed files with 34 additions and 12 deletions
  1. 16 8
      packages/fcl-passrc/src/pparser.pp
  2. 18 4
      packages/fcl-passrc/src/pscanner.pp

+ 16 - 8
packages/fcl-passrc/src/pparser.pp

@@ -339,6 +339,7 @@ type
     function AddUseUnit(ASection: TPasSection; const NamePos: TPasSourcePos;
       AUnitName : string; NameExpr: TPasExpr; InFileExpr: TPrimitiveExpr): TPasElement;
     procedure CheckImplicitUsedUnits(ASection: TPasSection);
+    procedure FinishedModule; virtual;
     // Overload handling
     procedure AddProcOrFunction(Decs: TPasDeclarations; AProc: TPasProcedure);
     function  CheckIfOverloaded(AParent: TPasElement; const AName: String): TPasElement;
@@ -2786,7 +2787,7 @@ begin
       {$ENDIF}
       end;
     if HasFinished then
-      Engine.FinishScope(stModule,Module);
+      FinishedModule;
   finally
     if HasFinished then
       FCurModule:=nil; // clear module if there is an error or finished parsing
@@ -2883,7 +2884,7 @@ begin
     if Section.PendingUsedIntf<>nil then
       HasFinished:=false;
     if HasFinished then
-      Engine.FinishScope(stModule,CurModule);
+      FinishedModule;
   finally
     if HasFinished then
       FCurModule:=nil; // clear module if there is an error or finished parsing
@@ -2966,7 +2967,7 @@ begin
       exit;
       end;
     ParseDeclarations(Section);
-    Engine.FinishScope(stModule,Module);
+    FinishedModule;
   finally
     if HasFinished then
       FCurModule:=nil; // clear module if there is an error or finished parsing
@@ -3014,7 +3015,7 @@ begin
     if not HasFinished then
       exit;
     ParseDeclarations(Section);
-    Engine.FinishScope(stModule,Module);
+    FinishedModule;
   finally
     if HasFinished then
       FCurModule:=nil; // clear module if there is an error or finished parsing
@@ -3573,6 +3574,13 @@ begin
     end;
 end;
 
+procedure TPasParser.FinishedModule;
+begin
+  if Scanner<>nil then
+    Scanner.FinishedModule;
+  Engine.FinishScope(stModule,CurModule);
+end;
+
 // Starts after the "uses" token
 procedure TPasParser.ParseUsesList(ASection: TPasSection);
 var
@@ -4076,9 +4084,9 @@ begin
   s:=LowerCase(CurTokenText);
   if s='external' then
     ExtMod:=vmExternal
-  else if (s='public') and not externalclass then
+  else if (s='public') and not ExternalClass then
     ExtMod:=vmPublic
-  else if (s='export') and not externalclass then
+  else if (s='export') and not ExternalClass then
     ExtMod:=vmExport
   else
     begin
@@ -4178,10 +4186,10 @@ begin
     if (VarList.Count>OldListCount+1) then
       begin
       // multiple variables
-      if Value<>nil then
-        ParseExc(nParserOnlyOneVariableCanBeAbsolute,SParserOnlyOneVariableCanBeAbsolute);
       if Value<>nil then
         ParseExc(nParserOnlyOneVariableCanBeInitialized,SParserOnlyOneVariableCanBeInitialized);
+      if AbsoluteExpr<>nil then
+        ParseExc(nParserOnlyOneVariableCanBeAbsolute,SParserOnlyOneVariableCanBeAbsolute);
       end;
     TPasVariable(VarList[OldListCount]).Expr:=Value;
     Value:=nil;

+ 18 - 4
packages/fcl-passrc/src/pscanner.pp

@@ -621,8 +621,8 @@ type
     FCurToken: TToken;
     FCurTokenString: string;
     FCurLine: string;
-    FMacros,
-    FDefines: TStrings;
+    FModuleRow: Integer;
+    FMacros, FDefines: TStrings;
     FNonTokens: TTokens;
     FOnDirective: TPScannerDirectiveEvent;
     FOnEvalFunction: TCEEvalFunctionEvent;
@@ -710,6 +710,7 @@ type
     constructor Create(AFileResolver: TBaseFileResolver);
     destructor Destroy; override;
     procedure OpenFile(AFilename: string);
+    procedure FinishedModule; virtual;
     function FormatPath(const aFilename: string): string; virtual;
     Procedure SetNonToken(aToken : TToken);
     Procedure UnsetNonToken(aToken : TToken);
@@ -740,6 +741,7 @@ type
     property CurTokenString: string read FCurTokenString;
     property CurTokenPos: TPasSourcePos read FCurTokenPos;
     Property PreviousToken : TToken Read FPreviousToken;
+    property ModuleRow: Integer read FModuleRow;
     Property NonTokens : TTokens Read FNonTokens;
     Property TokenOptions : TTokenOptions Read FTokenOptions Write FTokenOptions;
     property Defines: TStrings read FDefines;
@@ -2383,6 +2385,7 @@ begin
   FIncludeStack.Clear;
   FreeAndNil(FCurSourceFile);
   FFiles.Clear;
+  FModuleRow:=0;
 end;
 
 procedure TPascalScanner.ClearMacros;
@@ -2412,6 +2415,14 @@ begin
     DoLog(mtInfo,nLogOpeningFile,SLogOpeningFile,[FormatPath(AFileName)],True);
 end;
 
+procedure TPascalScanner.FinishedModule;
+begin
+  if (sleLineNumber in LogEvents)
+      and (not CurSourceFile.IsEOF)
+      and ((FCurRow Mod 100) > 0) then
+    DoLog(mtInfo,nLogLineNumber,SLogLineNumber,[CurRow],True);
+end;
+
 function TPascalScanner.FormatPath(const aFilename: string): string;
 begin
   if Assigned(OnFormatPath) then
@@ -3982,7 +3993,6 @@ begin
   FReadOnlyValueSwitches:=AValue;
 end;
 
-
 function TPascalScanner.FetchLine: boolean;
 begin
   if CurSourceFile.IsEOF then
@@ -3992,6 +4002,7 @@ begin
       FCurLine := '';
       FTokenStr := nil;
       inc(FCurRow); // set CurRow to last line+1
+      inc(FModuleRow);
       end;
     Result := false;
   end else
@@ -4000,7 +4011,10 @@ begin
     FTokenStr := PChar(CurLine);
     Result := true;
     Inc(FCurRow);
-    if LogEvent(sleLineNumber) and ((FCurRow Mod 100) = 0) then
+    inc(FModuleRow);
+    if LogEvent(sleLineNumber)
+        and (((FCurRow Mod 100) = 0)
+          or CurSourceFile.IsEOF) then
       DoLog(mtInfo,nLogLineNumber,SLogLineNumber,[FCurRow],True);
   end;
 end;