1------------------------------------------------------------------------------ 2-- -- 3-- GPR PROJECT MANAGER -- 4-- -- 5-- Copyright (C) 2001-2015, Free Software Foundation, Inc. -- 6-- -- 7-- This library is free software; you can redistribute it and/or modify it -- 8-- under terms of the GNU General Public License as published by the Free -- 9-- Software Foundation; either version 3, or (at your option) any later -- 10-- version. This library is distributed in the hope that it will be useful, -- 11-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- 12-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- 13-- -- 14-- As a special exception under Section 7 of GPL version 3, you are granted -- 15-- additional permissions described in the GCC Runtime Library Exception, -- 16-- version 3.1, as published by the Free Software Foundation. -- 17-- -- 18-- You should have received a copy of the GNU General Public License and -- 19-- a copy of the GCC Runtime Library Exception along with this program; -- 20-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- 21-- <http://www.gnu.org/licenses/>. -- 22-- -- 23------------------------------------------------------------------------------ 24 25-- This package contains the routines to output error messages and the scanner 26-- for the project files. It replaces Errout and Scn. It is not dependent on 27-- the GNAT tree packages (Atree, Sinfo, ...). It uses exactly the same global 28-- variables as Errout, located in package Err_Vars. Like Errout, it also uses 29-- the common variables and routines in package Erroutc. 30-- 31-- Parameters are set through Err_Vars.Error_Msg_File_* or 32-- Err_Vars.Error_Msg_Name_*, and replaced automatically in the messages 33-- ("{{" for files, "%%" for names). 34-- 35-- However, in this package you can configure the error messages to be sent 36-- to your own callback by setting Report_Error in the flags. This ensures 37-- that applications can control where error messages are displayed. 38 39package GPR.Err is 40 41 ------------------------------ 42 -- Error Output Subprograms -- 43 ------------------------------ 44 45 procedure Initialize; 46 -- Initializes for output of error messages. Must be called for each 47 -- file before using any of the other routines in the package. 48 49 procedure Finalize; 50 -- Finalize processing of error messages for one file and output message 51 -- indicating the number of detected errors. 52 53 procedure Error_Msg 54 (Flags : Processing_Flags; 55 Msg : String; 56 Location : Source_Ptr := No_Location; 57 Project : Project_Id := null); 58 -- Output an error message, either through Flags.Error_Report or through 59 -- Errutil. The location defaults to the project's location ("project" 60 -- in the source code). If Msg starts with "?", this is a warning, and 61 -- Warning: is added at the beginning. If Msg starts with "<", see comment 62 -- for Err_Vars.Error_Msg_Warn. 63 64 procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr); 65 -- Output a message at specified location 66 67 ------------- 68 -- Scanner -- 69 ------------- 70 71 package Scanner is 72 type Language is (Ada, Project); 73 74 procedure Initialize_Scanner 75 (Index : Source_File_Index; 76 Lang : Language); 77 -- Initialize lexical scanner for scanning a new file referenced by 78 -- Index. Initialize_Scanner does not call Scan. 79 80 procedure Scan; 81 -- Scan scans out the next token, and advances the scan state 82 -- accordingly (see package Scan_State for details). If the scan 83 -- encounters an illegal token, then an error message is issued pointing 84 -- to the bad character, and Scan returns a reasonable substitute token 85 -- of some kind. For tokens Char_Literal, Identifier, Real_Literal, 86 -- Integer_Literal, String_Literal and Operator_Symbol, Post_Scan is 87 -- called after scanning. 88 89 procedure Set_End_Of_Line_As_Token (Value : Boolean); 90 -- Indicate if End_Of_Line is a token or not. 91 -- By default, End_Of_Line is not a token. 92 93 procedure Set_Comment_As_Token (Value : Boolean); 94 -- Indicate if a comment is a token or not. 95 -- By default, a comment is not a token. 96 97 procedure Set_Special_Character (C : Character); 98 -- Indicate that one of the following character '#', '$', '?', '@', '`', 99 -- '\', '^', '_' or '~', when found is a Special token. 100 101 procedure Reset_Special_Characters; 102 -- Indicate that there is no characters that are Special tokens., which 103 -- is the default. 104 105 end Scanner; 106 107end GPR.Err; 108