2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / ada / stylesw.ads
blob862f0262ce592ebd10c6b54dbf8f2f8d11f6b3b9
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S T Y L E S W --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2003, 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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 ------------------------------------------------------------------------------
27 -- This package contains the style switches used for setting style options.
28 -- The only clients of this package are the body of Style and the body of
29 -- Switches. All other style checking issues are handled using the public
30 -- interfaces in the spec of Style.
32 with Types; use Types;
34 package Stylesw is
36 --------------------------
37 -- Style Check Switches --
38 --------------------------
40 -- These flags are used to control the details of the style checking
41 -- options. The default values shown here correspond to no style
42 -- checking. If any of these values is set to a non-default value,
43 -- then Opt.Style_Check is set True to active calls to this package.
45 -- The actual mechanism for setting these switches to other than
46 -- default values is via the Set_Style_Check_Option procedure or
47 -- through a call to Set_Default_Style_Check_Options. They should
48 -- not be set directly in any other manner.
50 Style_Check_Attribute_Casing : Boolean := False;
51 -- This can be set True by using the -gnatg or -gnatya switches. If
52 -- it is True, then attribute names (including keywords such as
53 -- digits used as attribute names) must be in mixed case.
55 Style_Check_Blanks_At_End : Boolean := False;
56 -- This can be set True by using the -gnatg or -gnatyb switches. If
57 -- it is True, then spaces at the end of lines are not permitted.
59 Style_Check_Comments : Boolean := False;
60 -- This can be set True by using the -gnatg or -gnatyc switches. If
61 -- it is True, then comments are style checked as follows:
63 -- All comments must be at the start of the line, or the first
64 -- minus must be preceded by at least one space.
66 -- For a comment that is not at the start of a line, the only
67 -- requirement is that a space follow the comment characters.
69 -- For a coment that is at the start of the line, one of the
70 -- following conditions must hold:
72 -- The comment characters are the only non-blank characters on the line
74 -- The comment characters are followed by an exclamation point (the
75 -- sequence --! is used by gnatprep for marking deleted lines).
77 -- The comment characters are followed by two space characters
79 -- The line consists entirely of minus signs
81 -- The comment characters are followed by a single space, and the
82 -- last two characters on the line are also comment characters.
84 -- Note: the reason for the last two conditions is to allow "boxed"
85 -- comments where only a single space separates the comment characters.
87 Style_Check_End_Labels : Boolean := False;
88 -- This can be set True by using the -gnatg or -gnatye switches. If
89 -- it is True, then optional END labels must always be present.
91 Style_Check_Form_Feeds : Boolean := False;
92 -- This can be set True by using the -gnatg or -gnatyf switches. If
93 -- it is True, then form feeds and vertical tabs are not allowed in
94 -- the source text.
96 Style_Check_Horizontal_Tabs : Boolean := False;
97 -- This can be set True by using the -gnatg or -gnatyh switches. If
98 -- it is True, then horizontal tabs are not allowed in source text.
100 Style_Check_If_Then_Layout : Boolean := False;
101 -- This can be set True by using the -gnatg or -gnatyi switches. If
102 -- it is True, then a THEN keyword may not appear on the line that
103 -- immediately follows the line containing the corresponding IF.
105 -- This permits one of two styles for IF-THEN layout. Either the
106 -- IF and THEN keywords are on the same line, where the condition
107 -- is short enough, or the conditions are continued over to the
108 -- lines following the IF and the THEN stands on its own. For
109 -- example:
111 -- if X > Y then
113 -- if X > Y
114 -- and then Y < Z
115 -- then
117 -- are allowed, but
119 -- if X > Y
120 -- then
122 -- is not allowed.
124 Style_Check_Indentation : Column_Number range 0 .. 9 := 0;
125 -- This can be set non-zero by using the -gnatg or -gnatyn (n a digit)
126 -- switches. If it is non-zero it activates indentation checking with
127 -- the indicated indentation value. A value of zero turns off checking.
128 -- The requirement is that any new statement, line comment, declaration
129 -- or keyword such as END, start on a column that is a multiple of the
130 -- indentiation value.
132 Style_Check_Keyword_Casing : Boolean := False;
133 -- This can be set True by using the -gnatg or -gnatyk switches. If
134 -- it is True, then keywords are required to be in all lower case.
135 -- This rule does not apply to keywords such as digits appearing as
136 -- an attribute name.
138 Style_Check_Max_Line_Length : Boolean := False;
139 -- This can be set True by using the -gnatg or -gnatym/M switches.
140 -- If it is True, it activates checking for a maximum line length of
141 -- Style_Max_Line_Length characters.
143 Style_Check_Pragma_Casing : Boolean := False;
144 -- This can be set True by using the -gnatg or -gnatyp switches. If
145 -- it is True, then pragma names must use mixed case.
147 Style_Check_Layout : Boolean := False;
148 -- This can be set True by using the -gnatg or -gnatyl switches. If
149 -- it is True, it activates checks that constructs are indented as
150 -- suggested by the examples in the RM syntax, e.g. that the ELSE
151 -- keyword must line up with the IF keyword.
153 Style_Check_References : Boolean := False;
154 -- This can be set True by using the -gnatg or -gnatyr switches. If
155 -- it is True, then all references to declared identifiers are
156 -- checked. The requirement is that casing of the reference be the
157 -- same as the casing of the corresponding declaration.
159 Style_Check_Specs : Boolean := False;
160 -- This can be set True by using the -gnatg or -gnatys switches. If
161 -- it is True, then separate specs are required to be present for
162 -- all procedures except parameterless library level procedures.
163 -- The exception means that typical main programs do not require
164 -- separate specs.
166 Style_Check_Standard : Boolean := False;
167 -- This can be set True by using the -gnatg or -gnatyn switches. If
168 -- it is True, then any references to names in Standard have to be
169 -- in mixed case mode (e.g. Integer, Boolean).
171 Style_Check_Tokens : Boolean := False;
172 -- This can be set True by using the -gnatg or -gnatyt switches. If
173 -- it is True, then the style check that requires canonical spacing
174 -- between various punctuation tokens as follows:
176 -- ABS and NOT must be followed by a space
178 -- => must be surrounded by spaces
180 -- <> must be preceded by a space or left paren
182 -- Binary operators other than ** must be surrounded by spaces.
183 -- There is no restriction on the layout of the ** binary operator.
185 -- Colon must be surrounded by spaces
187 -- Colon-equal (assignment) must be surrounded by spaces
189 -- Comma must be the first non-blank character on the line, or be
190 -- immediately preceded by a non-blank character, and must be followed
191 -- by a blank.
193 -- A space must precede a left paren following a digit or letter,
194 -- and a right paren must not be followed by a space (it can be
195 -- at the end of the line).
197 -- A right paren must either be the first non-blank character on
198 -- a line, or it must be preceded by a non-blank character.
200 -- A semicolon must not be preceded by a blank, and must not be
201 -- followed by a non-blank character.
203 -- A unary plus or minus may not be followed by a space
205 -- A vertical bar must be surrounded by spaces
207 -- Note that a requirement that a token be preceded by a space is
208 -- met by placing the token at the start of the line, and similarly
209 -- a requirement that a token be followed by a space is met by
210 -- placing the token at the end of the line. Note that in the case
211 -- where horizontal tabs are permitted, a horizontal tab is acceptable
212 -- for meeting the requirement for a space.
214 Style_Check_Subprogram_Order : Boolean := False;
215 -- This can be set True by using the -gnatg or -gnatyo switch. If it
216 -- is True, then names of subprogram bodies must be in alphabetical
217 -- order (not taking casing into account).
219 Style_Max_Line_Length : Int := 0;
220 -- Value used to check maximum line length. Gets reset as a result of
221 -- use of -gnatym or -gnatyM switches (or by use of -gnatg).
223 -----------------
224 -- Subprograms --
225 -----------------
227 procedure Set_Default_Style_Check_Options;
228 -- This procedure is called to set the default style checking options
229 -- in response to a -gnatg switch or -gnaty with no suboptions.
231 procedure Set_Style_Check_Options
232 (Options : String;
233 OK : out Boolean;
234 Err_Col : out Natural);
235 -- This procedure is called to set the style check options that
236 -- correspond to the characters in the given Options string. If
237 -- all options are valid, they are set in an additive manner:
238 -- any previous options are retained unless overridden. If any
239 -- invalid character is found, then OK is False on exit, and
240 -- Err_Col is the index in options of the bad character. If all
241 -- options are valid, OK is True on return, and Err_Col is set
242 -- to Options'Last + 1.
244 procedure Set_Style_Check_Options (Options : String);
245 -- Like the above procedure, except that the call is simply ignored if
246 -- there are any error conditions, this is for example appopriate for
247 -- calls where the string is known to be valid, e.g. because it was
248 -- obtained by Save_Style_Check_Options.
250 procedure Reset_Style_Check_Options;
251 -- Sets all style check options to off
253 subtype Style_Check_Options is String (1 .. 32);
254 -- Long enough string to hold all options from Save call below
256 procedure Save_Style_Check_Options (Options : out Style_Check_Options);
257 -- Sets Options to represent current selection of options. This
258 -- set can be restored by first calling Reset_Style_Check_Options,
259 -- and then calling Set_Style_Check_Options with the Options string.
261 end Stylesw;