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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [ada/] [stylesw.ads] - Blame information for rev 27

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

Line No. Rev Author Line
1 12 jlechner
------------------------------------------------------------------------------
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-2005, 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 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.
31
 
32
with Types; use Types;
33
 
34
package Stylesw is
35
 
36
   --------------------------
37
   -- Style Check Switches --
38
   --------------------------
39
 
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.
44
 
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.
49
 
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.
54
 
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.
58
 
59
   Style_Check_Blank_Lines : Boolean := False;
60
   --  This can be set True by using the -gnatg or -gnatyu switches. If
61
   --  it is True, then multiple blank lines are not permitted, and there
62
   --  may not be a blank line at the end of the file.
63
 
64
   Style_Check_Comments : Boolean := False;
65
   --  This can be set True by using the -gnatg or -gnatyc switches. If
66
   --  it is True, then comments are style checked as follows:
67
   --
68
   --    All comments must be at the start of the line, or the first
69
   --    minus must be preceded by at least one space.
70
   --
71
   --    For a comment that is not at the start of a line, the only
72
   --    requirement is that a space follow the comment characters.
73
   --
74
   --    For a coment that is at the start of the line, one of the
75
   --    following conditions must hold:
76
   --
77
   --      The comment characters are the only non-blank characters on the line
78
   --
79
   --      The comment characters are followed by an exclamation point (the
80
   --      sequence --! is used by gnatprep for marking deleted lines).
81
   --
82
   --      The comment characters are followed by two space characters
83
   --
84
   --      The line consists entirely of minus signs
85
   --
86
   --      The comment characters are followed by a single space, and the
87
   --      last two characters on the line are also comment characters.
88
   --
89
   --  Note: the reason for the last two conditions is to allow "boxed"
90
   --  comments where only a single space separates the comment characters.
91
 
92
   Style_Check_DOS_Line_Terminator : Boolean := False;
93
   --  This can be set true by using the -gnatg or -gnatyd switches. If
94
   --  it is True, then the line terminator must be a single LF, without an
95
   --  associated CR (e.g. DOS line terminator sequence CR/LF not allowed).
96
 
97
   Style_Check_End_Labels : Boolean := False;
98
   --  This can be set True by using the -gnatg or -gnatye switches. If
99
   --  it is True, then optional END labels must always be present.
100
 
101
   Style_Check_Form_Feeds : Boolean := False;
102
   --  This can be set True by using the -gnatg or -gnatyf switches. If
103
   --  it is True, then form feeds and vertical tabs are not allowed in
104
   --  the source text.
105
 
106
   Style_Check_Horizontal_Tabs : Boolean := False;
107
   --  This can be set True by using the -gnatg or -gnatyh switches. If
108
   --  it is True, then horizontal tabs are not allowed in source text.
109
 
110
   Style_Check_If_Then_Layout : Boolean := False;
111
   --  This can be set True by using the -gnatg or -gnatyi switches. If
112
   --  it is True, then a THEN keyword may not appear on the line that
113
   --  immediately follows the line containing the corresponding IF.
114
   --
115
   --  This permits one of two styles for IF-THEN layout. Either the
116
   --  IF and THEN keywords are on the same line, where the condition
117
   --  is short enough, or the conditions are continued over to the
118
   --  lines following the IF and the THEN stands on its own. For
119
   --  example:
120
   --
121
   --    if X > Y then
122
   --
123
   --    if X > Y
124
   --      and then Y < Z
125
   --    then
126
   --
127
   --  are allowed, but
128
   --
129
   --    if X > Y
130
   --    then
131
   --
132
   --  is not allowed.
133
 
134
   Style_Check_Indentation : Column_Number range 0 .. 9 := 0;
135
   --  This can be set non-zero by using the -gnatg or -gnatyn (n a digit)
136
   --  switches. If it is non-zero it activates indentation checking with
137
   --  the indicated indentation value. A value of zero turns off checking.
138
   --  The requirement is that any new statement, line comment, declaration
139
   --  or keyword such as END, start on a column that is a multiple of the
140
   --  indentiation value.
141
 
142
   Style_Check_Keyword_Casing : Boolean := False;
143
   --  This can be set True by using the -gnatg or -gnatyk switches. If
144
   --  it is True, then keywords are required to be in all lower case.
145
   --  This rule does not apply to keywords such as digits appearing as
146
   --  an attribute name.
147
 
148
   Style_Check_Max_Line_Length : Boolean := False;
149
   --  This can be set True by using the -gnatg or -gnatym/M switches.
150
   --  If it is True, it activates checking for a maximum line length of
151
   --  Style_Max_Line_Length characters.
152
 
153
   Style_Check_Max_Nesting_Level : Boolean := False;
154
   --  This can be set True by using -gnatyLnnn with a value other than
155
   --  zero (a value of zero resets it to False). If True, it activates
156
   --  checking the maximum nesting level against Style_Max_Nesting_Level.
157
 
158
   Style_Check_Order_Subprograms : Boolean := False;
159
   --  This can be set True by using the -gnatg or -gnatyo switch. If it
160
   --  is True, then names of subprogram bodies must be in alphabetical
161
   --  order (not taking casing into account).
162
 
163
   Style_Check_Pragma_Casing : Boolean := False;
164
   --  This can be set True by using the -gnatg or -gnatyp switches. If
165
   --  it is True, then pragma names must use mixed case.
166
 
167
   Style_Check_Layout : Boolean := False;
168
   --  This can be set True by using the -gnatg or -gnatyl switches. If
169
   --  it is True, it activates checks that constructs are indented as
170
   --  suggested by the examples in the RM syntax, e.g. that the ELSE
171
   --  keyword must line up with the IF keyword.
172
 
173
   Style_Check_References : Boolean := False;
174
   --  This can be set True by using the -gnatg or -gnatyr switches. If
175
   --  it is True, then all references to declared identifiers are
176
   --  checked. The requirement is that casing of the reference be the
177
   --  same as the casing of the corresponding declaration.
178
 
179
   Style_Check_Specs : Boolean := False;
180
   --  This can be set True by using the -gnatg or -gnatys switches. If
181
   --  it is True, then separate specs are required to be present for
182
   --  all procedures except parameterless library level procedures.
183
   --  The exception means that typical main programs do not require
184
   --  separate specs.
185
 
186
   Style_Check_Standard : Boolean := False;
187
   --  This can be set True by using the -gnatg or -gnatyn switches. If
188
   --  it is True, then any references to names in Standard have to be
189
   --  in mixed case mode (e.g. Integer, Boolean).
190
 
191
   Style_Check_Tokens : Boolean := False;
192
   --  This can be set True by using the -gnatg or -gnatyt switches. If
193
   --  it is True, then the style check that requires canonical spacing
194
   --  between various punctuation tokens as follows:
195
   --
196
   --    ABS and NOT must be followed by a space
197
   --
198
   --    => must be surrounded by spaces
199
   --
200
   --    <> must be preceded by a space or left paren
201
   --
202
   --    Binary operators other than ** must be surrounded by spaces.
203
   --    There is no restriction on the layout of the ** binary operator.
204
   --
205
   --    Colon must be surrounded by spaces
206
   --
207
   --    Colon-equal (assignment) must be surrounded by spaces
208
   --
209
   --    Comma must be the first non-blank character on the line, or be
210
   --    immediately preceded by a non-blank character, and must be followed
211
   --    by a blank.
212
   --
213
   --    A space must precede a left paren following a digit or letter,
214
   --    and a right paren must not be followed by a space (it can be
215
   --    at the end of the line).
216
   --
217
   --    A right paren must either be the first non-blank character on
218
   --    a line, or it must be preceded by a non-blank character.
219
   --
220
   --    A semicolon must not be preceded by a blank, and must not be
221
   --    followed by a non-blank character.
222
   --
223
   --    A unary plus or minus may not be followed by a space
224
   --
225
   --    A vertical bar must be surrounded by spaces
226
   --
227
   --  Note that a requirement that a token be preceded by a space is
228
   --  met by placing the token at the start of the line, and similarly
229
   --  a requirement that a token be followed by a space is met by
230
   --  placing the token at the end of the line. Note that in the case
231
   --  where horizontal tabs are permitted, a horizontal tab is acceptable
232
   --  for meeting the requirement for a space.
233
 
234
   Style_Check_Xtra_Parens : Boolean := False;
235
   --  This can be set True by using the -gnatg or -gnatyx switch. If true,
236
   --  then it is not allowed to enclose entire conditional expressions
237
   --  in parentheses (C style).
238
 
239
   Style_Max_Line_Length : Int := 0;
240
   --  Value used to check maximum line length. Gets reset as a result of
241
   --  use of -gnatym or -gnatyMnnn switches (or by use of -gnatg). This
242
   --  value is only read if Style_Check_Max_Line_Length is True.
243
 
244
   Style_Max_Nesting_Level : Int := 0;
245
   --  Value used to check maximum nesting level. Gets reset as a result
246
   --  of use of the -gnatyLnnn switch. This value is only read if
247
   --  Style_Check_Max_Nesting_Level is True.
248
 
249
   -----------------
250
   -- Subprograms --
251
   -----------------
252
 
253
   procedure Set_Default_Style_Check_Options;
254
   --  This procedure is called to set the default style checking options
255
   --  in response to a -gnaty switch with no suboptions.
256
 
257
   procedure Set_Style_Check_Options
258
     (Options  : String;
259
      OK       : out Boolean;
260
      Err_Col  : out Natural);
261
   --  This procedure is called to set the style check options that
262
   --  correspond to the characters in the given Options string. If
263
   --  all options are valid, they are set in an additive manner:
264
   --  any previous options are retained unless overridden. If any
265
   --  invalid character is found, then OK is False on exit, and
266
   --  Err_Col is the index in options of the bad character. If all
267
   --  options are valid, OK is True on return, and Err_Col is set
268
   --  to Options'Last + 1.
269
 
270
   procedure Set_Style_Check_Options (Options : String);
271
   --  Like the above procedure, except that the call is simply ignored if
272
   --  there are any error conditions, this is for example appopriate for
273
   --  calls where the string is known to be valid, e.g. because it was
274
   --  obtained by Save_Style_Check_Options.
275
 
276
   procedure Reset_Style_Check_Options;
277
   --  Sets all style check options to off
278
 
279
   subtype Style_Check_Options is String (1 .. 64);
280
   --  Long enough string to hold all options from Save call below
281
 
282
   procedure Save_Style_Check_Options (Options : out Style_Check_Options);
283
   --  Sets Options to represent current selection of options. This
284
   --  set can be restored by first calling Reset_Style_Check_Options,
285
   --  and then calling Set_Style_Check_Options with the Options string.
286
 
287
end Stylesw;

powered by: WebSVN 2.1.0

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