Browse Source

* Fix error messages, operator keyword starts new section

git-svn-id: trunk@36925 -
michael 8 years ago
parent
commit
86ab5a4fd0
2 changed files with 28 additions and 7 deletions
  1. 11 3
      packages/fcl-passrc/src/pparser.pp
  2. 17 4
      packages/fcl-passrc/src/pscanner.pp

+ 11 - 3
packages/fcl-passrc/src/pparser.pp

@@ -2895,7 +2895,7 @@ begin
   CurBlock := declNone;
   while True do
   begin
-    if CurBlock=DeclNone then
+    if CurBlock in [DeclNone,declConst] then
       Scanner.SetTokenOption(toOperatorToken)
     else
       Scanner.UnSetTokenOption(toOperatorToken);
@@ -3874,13 +3874,21 @@ end;
 
 procedure TPasParser.DoLog(MsgType: TMessageType; MsgNumber: integer;
   const Fmt: String; Args: array of const; SkipSourceInfo: Boolean);
+
+Var
+  Msg : String;
+
 begin
   SetLastMsg(MsgType,MsgNumber,Fmt,Args);
   If Assigned(FOnLog) then
+    begin
+    Msg:=MessageTypeNames[MsgType]+': ';
     if SkipSourceInfo or not assigned(scanner) then
-      FOnLog(Self,FLastMsg)
+      Msg:=Msg+FLastMsg
     else
-      FOnLog(Self,Format('%s(%d) : %s',[Scanner.CurFilename,Scanner.CurRow,FLastMsg]));
+      Msg:=Msg+Format('%s(%d,%d) : %s',[Scanner.CurFilename,Scanner.CurRow,Scanner.CurColumn,FLastMsg]);
+    FOnLog(Self,Msg);
+    end;
 end;
 
 procedure TPasParser.ParseInlineVarDecl(Parent: TPasElement; List: TFPList;

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

@@ -843,6 +843,11 @@ const
 const
   AllLanguageModes = [msFPC,msObjFPC,msDelphi,msTP7,msMac,msISO,msExtPas];
 
+Const
+  MessageTypeNames : Array[TMessageType] of string = (
+    'Fatal','Error','Warning','Note','Hint','Info','Debug'
+  );
+
 const
   // all mode switches supported by FPC
   msAllFPCModeSwitches = [low(TModeSwitch)..High(TModeSwitch)];
@@ -2403,14 +2408,14 @@ end;
 procedure TPascalScanner.Error(MsgNumber: integer; const Msg: string);
 begin
   SetCurMsg(mtError,MsgNumber,Msg,[]);
-  raise EScannerError.Create(FLastMsg);
+  raise EScannerError.CreateFmt('Error: %s(%d,%d) : %s',[CurFilename,CurRow,CurColumn,FLastMsg]);
 end;
 
 procedure TPascalScanner.Error(MsgNumber: integer; const Fmt: string;
   Args: array of const);
 begin
   SetCurMsg(mtError,MsgNumber,Fmt,Args);
-  raise EScannerError.Create(FLastMsg);
+  raise EScannerError.CreateFmt('Error: %s(%d,%d) : %s',[CurFilename,CurRow,CurColumn,FLastMsg]);
 end;
 
 function TPascalScanner.DoFetchTextToken:TToken;
@@ -3531,13 +3536,21 @@ end;
 
 procedure TPascalScanner.DoLog(MsgType: TMessageType; MsgNumber: integer;
   const Fmt: String; Args: array of const; SkipSourceInfo: Boolean);
+
+Var
+  Msg : String;
+
 begin
   SetCurMsg(MsgType,MsgNumber,Fmt,Args);
   If Assigned(FOnLog) then
+    begin
+    Msg:=MessageTypeNames[MsgType]+': ';
     if SkipSourceInfo then
-      FOnLog(Self,FLastMsg)
+      Msg:=Msg+FLastMsg
     else
-      FOnLog(Self,Format('%s(%d) : %s',[FCurFileName,FCurRow,FLastMsg]));
+      Msg:=Msg+Format('%s(%d,%d) : %s',[FCurFileName,CurRow,CurColumn,FLastMsg]);
+    FOnLog(Self,Msg);
+    end;
 end;
 
 procedure TPascalScanner.SetOptions(AValue: TPOptions);