OSDN Git Service

2007-04-20 Robert Dewar <dewar@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / errutil.ads
1 ------------------------------------------------------------------------------
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-2007, 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 2,  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 COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 --  This package contains routines to output error messages and the
28 --  corresponding instantiation of Styleg, suitable to instantiate Scng.
29
30 --  It is not dependent on the GNAT tree packages (Atree, Sinfo, ...)
31
32 --  It uses the same global variables as Errout, located in package
33 --  Err_Vars. Like Errout, it also uses the common variables and routines
34 --  in package Erroutc.
35
36 --  This package is used by the preprocessor (gprep.adb) and the project
37 --  manager (prj-err.ads).
38
39 with Styleg;
40 with Types; use Types;
41
42 package Errutil is
43
44    ---------------------------------------------------------
45    -- Error Message Text and Message Insertion Characters --
46    ---------------------------------------------------------
47
48    --  Error message text strings are composed of lower case letters, digits
49    --  and the special characters space, comma, period, colon and semicolon,
50    --  apostrophe and parentheses. Special insertion characters can also
51    --  appear which cause the error message circuit to modify the given
52    --  string. For a full list of these, see the spec of errout.
53
54    -----------------------------------------------------
55    -- Format of Messages and Manual Quotation Control --
56    -----------------------------------------------------
57
58    --  Messages are generally all in lower case, except for inserted names
59    --  and appear in one of the following two forms:
60
61    --    error: text
62    --    warning: text
63
64    --  The prefixes error and warning are supplied automatically (depending
65    --  on the use of the ? insertion character), and the call to the error
66    --  message routine supplies the text. The "error: " prefix is omitted
67    --  in brief error message formats.
68
69    --  Reserved keywords in the message are in the default keyword case
70    --  (determined from the given source program), surrounded by quotation
71    --  marks. This is achieved by spelling the reserved word in upper case
72    --  letters, which is recognized as a request for insertion of quotation
73    --  marks by the error text processor. Thus for example:
74
75    --    Error_Msg_AP ("IS expected");
76
77    --  would result in the output of one of the following:
78
79    --    error: "is" expected
80    --    error: "IS" expected
81    --    error: "Is" expected
82
83    --  the choice between these being made by looking at the casing convention
84    --  used for keywords (actually the first compilation unit keyword) in the
85    --  source file.
86
87    --  In the case of names, the default mode for the error text processor
88    --  is to surround the name by quotation marks automatically. The case
89    --  used for the identifier names is taken from the source program where
90    --  possible, and otherwise is the default casing convention taken from
91    --  the source file usage.
92
93    --  In some cases, better control over the placement of quote marks is
94    --  required. This is achieved using manual quotation mode. In this mode,
95    --  one or more insertion sequences is surrounded by backquote characters.
96    --  The backquote characters are output as double quote marks, and normal
97    --  automatic insertion of quotes is suppressed between the double quotes.
98    --  For example:
99
100    --    Error_Msg_AP ("`END &;` expected");
101
102    --  generates a message like
103
104    --    error: "end Open_Scope;" expected
105
106    --  where the node specifying the name Open_Scope has been stored in
107    --  Error_Msg_Node_1 prior to the call. The great majority of error
108    --  messages operates in normal quotation mode.
109
110    --  Note: the normal automatic insertion of spaces before insertion
111    --  sequences (such as those that come from & and %) is suppressed in
112    --  manual quotation mode, so blanks, if needed as in the above example,
113    --  must be explicitly present.
114
115    ------------------------------
116    -- Error Output Subprograms --
117    ------------------------------
118
119    procedure Initialize;
120    --  Initializes for output of error messages. Must be called for each
121    --  file before using any of the other routines in the package.
122
123    procedure Finalize (Source_Type : String := "project");
124    --  Finalize processing of error messages for one file and output message
125    --  indicating the number of detected errors.
126    --  Source_Type is used in verbose mode to indicate the type of the source
127    --  being parsed (project file, definition file or input file for the
128    --  preprocessor).
129
130    procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr);
131    --  Output a message at specified location
132
133    procedure Error_Msg_S (Msg : String);
134    --  Output a message at current scan pointer location
135
136    procedure Error_Msg_SC (Msg : String);
137    --  Output a message at the start of the current token, unless we are at
138    --  the end of file, in which case we always output the message after the
139    --  last real token in the file.
140
141    procedure Error_Msg_SP (Msg : String);
142    --  Output a message at the start of the previous token
143
144    procedure Set_Ignore_Errors (To : Boolean);
145    --  Indicate, when To = True, that all reported errors should
146    --  be ignored. By default reported errors are not ignored.
147
148    package Style is new Styleg
149      (Error_Msg    => Error_Msg,
150       Error_Msg_S  => Error_Msg_S,
151       Error_Msg_SC => Error_Msg_SC,
152       Error_Msg_SP => Error_Msg_SP);
153    --  Instantiation of the generic style package, suitable for an
154    --  instantiation of Scng.
155
156 end Errutil;