annotate gcc/ada/errutil.ads @ 131:84e7813d76e9

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