OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [ada/] [stylesw.ads] - Blame information for rev 473

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
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-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 the style switches used for setting style options.
27
--  The only clients of this package are the body of Style and the body of
28
--  Switches. All other style checking issues are handled using the public
29
--  interfaces in the spec of Style.
30
 
31
with Types; use Types;
32
 
33
package Stylesw is
34
 
35
   --------------------------
36
   -- Style Check Switches --
37
   --------------------------
38
 
39
   --  These flags are used to control the details of the style checking
40
   --  options. The default values shown here correspond to no style checking.
41
 
42
   --  If any of these values is set to a non-default value, then
43
   --  Opt.Style_Check is set True to active calls to this package.
44
 
45
   --  The actual mechanism for setting these switches to other than default
46
   --  values is via the Set_Style_Check_Option procedure or through a call to
47
   --  Set_Default_Style_Check_Options. They should not be set directly in any
48
   --  other manner.
49
 
50
   Style_Check_Array_Attribute_Index : Boolean := False;
51
   --  This can be set True by using the -gnatyA switch. If it is True then
52
   --  index numbers for array attributes (like Length) are required to be
53
   --  absent for one-dimensional arrays and present for multi-dimensional
54
   --  array attribute references.
55
 
56
   Style_Check_Attribute_Casing : Boolean := False;
57
   --  This can be set True by using the -gnatya switch. If it is True, then
58
   --  attribute names (including keywords such as digits used as attribute
59
   --  names) must be in mixed case.
60
 
61
   Style_Check_Blanks_At_End : Boolean := False;
62
   --  This can be set True by using the -gnatyb switch. If it is True, then
63
   --  spaces at the end of lines are not permitted.
64
 
65
   Style_Check_Blank_Lines : Boolean := False;
66
   --  This can be set True by using the -gnatyu switch. If it is True, then
67
   --  multiple blank lines are not permitted, and there may not be a blank
68
   --  line at the end of the file.
69
 
70
   Style_Check_Boolean_And_Or : Boolean := False;
71
   --  This can be set True by using the -gnatyB switch. If it is True, then
72
   --  the use of AND THEN/OR ELSE rather than AND/OR is required except for
73
   --  the following cases:
74
   --
75
   --     a) Both operands are simple Boolean constants or variables
76
   --     b) Both operands are of a modular type
77
   --     c) Both operands are of an array type
78
 
79
   Style_Check_Comments : Boolean := False;
80
   --  This can be set True by using the -gnatyc switch. If it is True, then
81
   --  comments are style checked as follows:
82
   --
83
   --    All comments must be at the start of the line, or the first minus must
84
   --    be preceded by at least one space.
85
   --
86
   --    For a comment that is not at the start of a line, the only requirement
87
   --    is that a space follow the comment characters.
88
   --
89
   --    For a comment that is at the start of the line, one of the following
90
   --    conditions must hold:
91
   --
92
   --      The comment characters are the only non-blank characters on the line
93
   --
94
   --      The comment characters are followed by an exclamation point (the
95
   --      sequence --! is used by gnatprep for marking deleted lines).
96
   --
97
   --      The comment characters are followed by two space characters
98
   --
99
   --      The line consists entirely of minus signs
100
   --
101
   --      The comment characters are followed by a single space, and the last
102
   --      two characters on the line are also comment characters.
103
   --
104
   --  Note: the reason for the last two conditions is to allow "boxed"
105
   --  comments where only a single space separates the comment characters.
106
 
107
   Style_Check_DOS_Line_Terminator : Boolean := False;
108
   --  This can be set true by using the -gnatyd switch. If it is True, then
109
   --  the line terminator must be a single LF, without an associated CR (e.g.
110
   --  DOS line terminator sequence CR/LF not allowed).
111
 
112
   Style_Check_End_Labels : Boolean := False;
113
   --  This can be set True by using the -gnatye switch. If it is True, then
114
   --  optional END labels must always be present.
115
 
116
   Style_Check_Form_Feeds : Boolean := False;
117
   --  This can be set True by using the -gnatyf switch. If it is True, then
118
   --  form feeds and vertical tabs are not allowed in the source text.
119
 
120
   Style_Check_Horizontal_Tabs : Boolean := False;
121
   --  This can be set True by using the -gnatyh switch. If it is True, then
122
   --  horizontal tabs are not allowed in source text.
123
 
124
   Style_Check_If_Then_Layout : Boolean := False;
125
   --  This can be set True by using the -gnatyi switch. If it is True, then a
126
   --  THEN keyword may not appear on the line that immediately follows the
127
   --  line containing the corresponding IF.
128
   --
129
   --  This permits one of two styles for IF-THEN layout. Either the IF and
130
   --  THEN keywords are on the same line, where the condition is short enough,
131
   --  or the conditions are continued over to the lines following the IF and
132
   --  the THEN stands on its own. For example:
133
   --
134
   --    if X > Y then
135
   --
136
   --    if X > Y
137
   --      and then Y < Z
138
   --    then
139
   --
140
   --  are allowed, but
141
   --
142
   --    if X > Y
143
   --    then
144
   --
145
   --  is not allowed.
146
 
147
   Style_Check_Indentation : Column_Number range 0 .. 9 := 0;
148
   --  This can be set non-zero by using the -gnatyn (n a digit) switch. If
149
   --  it is non-zero it activates indentation checking with the indicated
150
   --  indentation value. A value of zero turns off checking. The requirement
151
   --  is that any new statement, line comment, declaration or keyword such
152
   --  as END, start on a column that is a multiple of the indentation value.
153
 
154
   Style_Check_Keyword_Casing : Boolean := False;
155
   --  This can be set True by using the -gnatyk switch. If it is True, then
156
   --  keywords are required to be in all lower case. This rule does not apply
157
   --  to keywords such as digits appearing as an attribute name.
158
 
159
   Style_Check_Layout : Boolean := False;
160
   --  This can be set True by using the -gnatyl switch. If it is True, it
161
   --  activates checks that constructs are indented as suggested by the
162
   --  examples in the RM syntax, e.g. that the ELSE keyword must line up
163
   --  with the IF keyword.
164
 
165
   Style_Check_Max_Line_Length : Boolean := False;
166
   --  This can be set True by using the -gnatym/M switches. If it is True, it
167
   --  activates checking for a maximum line length of Style_Max_Line_Length
168
   --  characters.
169
 
170
   Style_Check_Max_Nesting_Level : Boolean := False;
171
   --  This can be set True by using -gnatyLnnn with a value other than zero
172
   --  (a value of zero resets it to False). If True, it activates checking
173
   --  the maximum nesting level against Style_Max_Nesting_Level.
174
 
175
   Style_Check_Missing_Overriding : Boolean := False;
176
   --  This can be set True by using the -gnatyO switch. If it is True, then
177
   --  "[not] overriding" is required in subprogram declarations and bodies
178
   --  where appropriate.
179
 
180
   Style_Check_Mode_In : Boolean := False;
181
   --  This can be set True by using -gnatyI. If True, it activates checking
182
   --  that mode IN is not used on its own (since it is the default).
183
 
184
   Style_Check_Order_Subprograms : Boolean := False;
185
   --  This can be set True by using the -gnatyo switch. If it is True, then
186
   --  names of subprogram bodies must be in alphabetical order (not taking
187
   --  casing into account).
188
 
189
   Style_Check_Pragma_Casing : Boolean := False;
190
   --  This can be set True by using the -gnatyp switch. If it is True, then
191
   --  pragma names must use mixed case.
192
 
193
   Style_Check_References : Boolean := False;
194
   --  This can be set True by using the -gnatyr switch. If it is True, then
195
   --  all references to declared identifiers are checked. The requirement
196
   --  is that casing of the reference be the same as the casing of the
197
   --  corresponding declaration.
198
 
199
   Style_Check_Separate_Stmt_Lines : Boolean := False;
200
   --  This can be set True by using the -gnatyS switch. If it is TRUE,
201
   --  then for the case of keywords THEN (not preceded by AND) or ELSE (not
202
   --  preceded by OR) which introduce a conditionally executed statement
203
   --  sequence, there must be no tokens on the same line as the keyword, so
204
   --  that coverage testing can clearly identify execution of the statement
205
   --  sequence. A comment is permitted, as is THEN ABORT or a PRAGMA keyword
206
   --  after ELSE (a common style to specify the condition for the ELSE).
207
 
208
   Style_Check_Specs : Boolean := False;
209
   --  This can be set True by using the -gnatys switches. If it is True, then
210
   --  separate specs are required to be present for all procedures except
211
   --  parameterless library level procedures. The exception means that typical
212
   --  main programs do not require separate specs.
213
 
214
   Style_Check_Standard : Boolean := False;
215
   --  This can be set True by using the -gnatyn switch. If it is True, then
216
   --  any references to names in Standard have to be in mixed case mode (e.g.
217
   --  Integer, Boolean).
218
 
219
   Style_Check_Tokens : Boolean := False;
220
   --  This can be set True by using the -gnatyt switch. If it is True, then
221
   --  the style check that requires canonical spacing between various
222
   --  punctuation tokens as follows:
223
   --
224
   --    ABS and NOT must be followed by a space
225
   --
226
   --    => must be surrounded by spaces
227
   --
228
   --    <> must be preceded by a space or left paren
229
   --
230
   --    Binary operators other than ** must be surrounded by spaces.
231
   --
232
   --    There is no restriction on the layout of the ** binary operator.
233
   --
234
   --    Colon must be surrounded by spaces
235
   --
236
   --    Colon-equal (assignment) must be surrounded by spaces
237
   --
238
   --    Comma must be the first non-blank character on the line, or be
239
   --    immediately preceded by a non-blank character, and must be followed
240
   --    by a blank.
241
   --
242
   --    A space must precede a left paren following a digit or letter, and a
243
   --    right paren must not be followed by a space (it can be at the end of
244
   --    the line).
245
   --
246
   --    A right paren must either be the first non-blank character on a line,
247
   --    or it must be preceded by a non-blank character.
248
   --
249
   --    A semicolon must not be preceded by a blank, and must not be followed
250
   --    by a non-blank character.
251
   --
252
   --    A unary plus or minus may not be followed by a space
253
   --
254
   --    A vertical bar must be surrounded by spaces
255
   --
256
   --  Note that a requirement that a token be preceded by a space is met by
257
   --  placing the token at the start of the line, and similarly a requirement
258
   --  that a token be followed by a space is met by placing the token at
259
   --  the end of the line. Note that in the case where horizontal tabs are
260
   --  permitted, a horizontal tab is acceptable for meeting the requirement
261
   --  for a space.
262
 
263
   Style_Check_Xtra_Parens : Boolean := False;
264
   --  This can be set True by using the -gnatyx switch. If true, then it is
265
   --  not allowed to enclose entire conditional expressions in parentheses
266
   --  (C style).
267
 
268
   Style_Max_Line_Length : Int := 0;
269
   --  Value used to check maximum line length. Gets reset as a result of
270
   --  use of -gnatym or -gnatyMnnn switches. This value is only read if
271
   --  Style_Check_Max_Line_Length is True.
272
 
273
   Style_Max_Nesting_Level : Int := 0;
274
   --  Value used to check maximum nesting level. Gets reset as a result
275
   --  of use of the -gnatyLnnn switch. This value is only read if
276
   --  Style_Check_Max_Nesting_Level is True.
277
 
278
   -----------------
279
   -- Subprograms --
280
   -----------------
281
 
282
   function RM_Column_Check return Boolean;
283
   --  Determines whether style checking is active and the RM column check
284
   --  mode is set requiring checking of RM format layout.
285
 
286
   procedure Set_Default_Style_Check_Options;
287
   --  This procedure is called to set the default style checking options in
288
   --  response to a -gnaty switch with no suboptions or from -gnatyy.
289
 
290
   procedure Set_GNAT_Style_Check_Options;
291
   --  This procedure is called to set the default style checking options for
292
   --  GNAT units (as set by -gnatg or -gnatyg).
293
 
294
   Style_Msg_Buf : String (1 .. 80);
295
   Style_Msg_Len : Natural;
296
   --  Used to return
297
 
298
   procedure Set_Style_Check_Options
299
     (Options  : String;
300
      OK       : out Boolean;
301
      Err_Col  : out Natural);
302
   --  This procedure is called to set the style check options that correspond
303
   --  to the characters in the given Options string. If all options are valid,
304
   --  they are set in an additive manner: any previous options are retained
305
   --  unless overridden, unless a minus is encountered, and then subsequent
306
   --  style switches are subtracted from the current set.
307
   --
308
   --  If all options given are valid, then OK is True, Err_Col is set to
309
   --  Options'Last + 1, and Style_Msg_Buf/Style_Msg_Len are unchanged.
310
   --
311
   --  If an invalid character is found, then OK is False on exit, and Err_Col
312
   --  is the index in options of the bad character. In this case Style_Msg_Len
313
   --  is set and Style_Msg_Buf (1 .. Style_Msg_Len) has a detailed message
314
   --  describing the error.
315
 
316
   procedure Set_Style_Check_Options (Options : String);
317
   --  Like the above procedure, but used when the Options string is known to
318
   --  be valid. This is for example appropriate for calls where the string ==
319
   --  was obtained by Save_Style_Check_Options.
320
 
321
   procedure Reset_Style_Check_Options;
322
   --  Sets all style check options to off
323
 
324
   subtype Style_Check_Options is String (1 .. 64);
325
   --  Long enough string to hold all options from Save call below
326
 
327
   procedure Save_Style_Check_Options (Options : out Style_Check_Options);
328
   --  Sets Options to represent current selection of options. This set can be
329
   --  restored by first calling Reset_Style_Check_Options, and then calling
330
   --  Set_Style_Check_Options with the Options string.
331
 
332
end Stylesw;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.