1 |
706 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT COMPILER COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- E R R U T I L --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 2002-2009, Free Software Foundation, Inc. --
|
10 |
|
|
-- --
|
11 |
|
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
12 |
|
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
13 |
|
|
-- ware Foundation; either version 3, or (at your option) any later ver- --
|
14 |
|
|
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
15 |
|
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
16 |
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
17 |
|
|
-- for more details. You should have received a copy of the GNU General --
|
18 |
|
|
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
|
19 |
|
|
-- http://www.gnu.org/licenses for a complete copy of the license. --
|
20 |
|
|
-- --
|
21 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
22 |
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
23 |
|
|
-- --
|
24 |
|
|
------------------------------------------------------------------------------
|
25 |
|
|
|
26 |
|
|
-- This package contains routines to output error messages and the
|
27 |
|
|
-- corresponding instantiation of Styleg, suitable to instantiate Scng.
|
28 |
|
|
|
29 |
|
|
-- It is not dependent on the GNAT tree packages (Atree, Sinfo, ...)
|
30 |
|
|
|
31 |
|
|
-- It uses the same global variables as Errout, located in package
|
32 |
|
|
-- Err_Vars. Like Errout, it also uses the common variables and routines
|
33 |
|
|
-- in package Erroutc.
|
34 |
|
|
|
35 |
|
|
-- This package is used by the preprocessor (gprep.adb) and the project
|
36 |
|
|
-- manager (prj-err.ads).
|
37 |
|
|
|
38 |
|
|
with Styleg;
|
39 |
|
|
with Types; use Types;
|
40 |
|
|
|
41 |
|
|
package Errutil is
|
42 |
|
|
|
43 |
|
|
---------------------------------------------------------
|
44 |
|
|
-- Error Message Text and Message Insertion Characters --
|
45 |
|
|
---------------------------------------------------------
|
46 |
|
|
|
47 |
|
|
-- Error message text strings are composed of lower case letters, digits
|
48 |
|
|
-- and the special characters space, comma, period, colon and semicolon,
|
49 |
|
|
-- apostrophe and parentheses. Special insertion characters can also
|
50 |
|
|
-- appear which cause the error message circuit to modify the given
|
51 |
|
|
-- string. For a full list of these, see the spec of errout.
|
52 |
|
|
|
53 |
|
|
-----------------------------------------------------
|
54 |
|
|
-- Format of Messages and Manual Quotation Control --
|
55 |
|
|
-----------------------------------------------------
|
56 |
|
|
|
57 |
|
|
-- Messages are generally all in lower case, except for inserted names
|
58 |
|
|
-- and appear in one of the following two forms:
|
59 |
|
|
|
60 |
|
|
-- error: text
|
61 |
|
|
-- warning: text
|
62 |
|
|
|
63 |
|
|
-- The prefixes error and warning are supplied automatically (depending
|
64 |
|
|
-- on the use of the ? insertion character), and the call to the error
|
65 |
|
|
-- message routine supplies the text. The "error: " prefix is omitted
|
66 |
|
|
-- in brief error message formats.
|
67 |
|
|
|
68 |
|
|
-- Reserved keywords in the message are in the default keyword case
|
69 |
|
|
-- (determined from the given source program), surrounded by quotation
|
70 |
|
|
-- marks. This is achieved by spelling the reserved word in upper case
|
71 |
|
|
-- letters, which is recognized as a request for insertion of quotation
|
72 |
|
|
-- marks by the error text processor. Thus for example:
|
73 |
|
|
|
74 |
|
|
-- Error_Msg_AP ("IS expected");
|
75 |
|
|
|
76 |
|
|
-- would result in the output of one of the following:
|
77 |
|
|
|
78 |
|
|
-- error: "is" expected
|
79 |
|
|
-- error: "IS" expected
|
80 |
|
|
-- error: "Is" expected
|
81 |
|
|
|
82 |
|
|
-- the choice between these being made by looking at the casing convention
|
83 |
|
|
-- used for keywords (actually the first compilation unit keyword) in the
|
84 |
|
|
-- source file.
|
85 |
|
|
|
86 |
|
|
-- In the case of names, the default mode for the error text processor
|
87 |
|
|
-- is to surround the name by quotation marks automatically. The case
|
88 |
|
|
-- used for the identifier names is taken from the source program where
|
89 |
|
|
-- possible, and otherwise is the default casing convention taken from
|
90 |
|
|
-- the source file usage.
|
91 |
|
|
|
92 |
|
|
-- In some cases, better control over the placement of quote marks is
|
93 |
|
|
-- required. This is achieved using manual quotation mode. In this mode,
|
94 |
|
|
-- one or more insertion sequences is surrounded by backquote characters.
|
95 |
|
|
-- The backquote characters are output as double quote marks, and normal
|
96 |
|
|
-- automatic insertion of quotes is suppressed between the double quotes.
|
97 |
|
|
-- For example:
|
98 |
|
|
|
99 |
|
|
-- Error_Msg_AP ("`END &;` expected");
|
100 |
|
|
|
101 |
|
|
-- generates a message like
|
102 |
|
|
|
103 |
|
|
-- error: "end Open_Scope;" expected
|
104 |
|
|
|
105 |
|
|
-- where the node specifying the name Open_Scope has been stored in
|
106 |
|
|
-- Error_Msg_Node_1 prior to the call. The great majority of error
|
107 |
|
|
-- messages operates in normal quotation mode.
|
108 |
|
|
|
109 |
|
|
-- Note: the normal automatic insertion of spaces before insertion
|
110 |
|
|
-- sequences (such as those that come from & and %) is suppressed in
|
111 |
|
|
-- manual quotation mode, so blanks, if needed as in the above example,
|
112 |
|
|
-- must be explicitly present.
|
113 |
|
|
|
114 |
|
|
------------------------------
|
115 |
|
|
-- Error Output Subprograms --
|
116 |
|
|
------------------------------
|
117 |
|
|
|
118 |
|
|
procedure Initialize;
|
119 |
|
|
-- Initializes for output of error messages. Must be called for each
|
120 |
|
|
-- file before using any of the other routines in the package.
|
121 |
|
|
|
122 |
|
|
procedure Finalize (Source_Type : String := "project");
|
123 |
|
|
-- Finalize processing of error messages for one file and output message
|
124 |
|
|
-- indicating the number of detected errors.
|
125 |
|
|
-- Source_Type is used in verbose mode to indicate the type of the source
|
126 |
|
|
-- being parsed (project file, definition file or input file for the
|
127 |
|
|
-- preprocessor).
|
128 |
|
|
|
129 |
|
|
procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr);
|
130 |
|
|
-- Output a message at specified location
|
131 |
|
|
|
132 |
|
|
procedure Error_Msg_S (Msg : String);
|
133 |
|
|
-- Output a message at current scan pointer location
|
134 |
|
|
|
135 |
|
|
procedure Error_Msg_SC (Msg : String);
|
136 |
|
|
-- Output a message at the start of the current token, unless we are at
|
137 |
|
|
-- the end of file, in which case we always output the message after the
|
138 |
|
|
-- last real token in the file.
|
139 |
|
|
|
140 |
|
|
procedure Error_Msg_SP (Msg : String);
|
141 |
|
|
-- Output a message at the start of the previous token
|
142 |
|
|
|
143 |
|
|
procedure Set_Ignore_Errors (To : Boolean);
|
144 |
|
|
-- Indicate, when To = True, that all reported errors should
|
145 |
|
|
-- be ignored. By default reported errors are not ignored.
|
146 |
|
|
|
147 |
|
|
package Style is new Styleg
|
148 |
|
|
(Error_Msg => Error_Msg,
|
149 |
|
|
Error_Msg_S => Error_Msg_S,
|
150 |
|
|
Error_Msg_SC => Error_Msg_SC,
|
151 |
|
|
Error_Msg_SP => Error_Msg_SP);
|
152 |
|
|
-- Instantiation of the generic style package, suitable for an
|
153 |
|
|
-- instantiation of Scng.
|
154 |
|
|
|
155 |
|
|
end Errutil;
|