From 86ab5a4fd066ed4e6e81e325d6bc6f5746938ca5 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 16 Aug 2017 08:48:25 +0000 Subject: [PATCH] * Fix error messages, operator keyword starts new section git-svn-id: trunk@36925 - --- packages/fcl-passrc/src/pparser.pp | 14 +++++++++++--- packages/fcl-passrc/src/pscanner.pp | 21 +++++++++++++++++---- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/packages/fcl-passrc/src/pparser.pp b/packages/fcl-passrc/src/pparser.pp index b22445853c..78e24b6f50 100644 --- a/packages/fcl-passrc/src/pparser.pp +++ b/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; diff --git a/packages/fcl-passrc/src/pscanner.pp b/packages/fcl-passrc/src/pscanner.pp index aed5db1d2a..95aa38f378 100644 --- a/packages/fcl-passrc/src/pscanner.pp +++ b/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);