1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
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. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
29 package body Stylesw
is
31 -------------------------------
32 -- Reset_Style_Check_Options --
33 -------------------------------
35 procedure Reset_Style_Check_Options
is
37 Style_Check_Indentation
:= 0;
38 Style_Check_Attribute_Casing
:= False;
39 Style_Check_Blanks_At_End
:= False;
40 Style_Check_Comments
:= False;
41 Style_Check_End_Labels
:= False;
42 Style_Check_Form_Feeds
:= False;
43 Style_Check_Horizontal_Tabs
:= False;
44 Style_Check_If_Then_Layout
:= False;
45 Style_Check_Keyword_Casing
:= False;
46 Style_Check_Layout
:= False;
47 Style_Check_Max_Line_Length
:= False;
48 Style_Check_Max_Nesting_Level
:= False;
49 Style_Check_Order_Subprograms
:= False;
50 Style_Check_Pragma_Casing
:= False;
51 Style_Check_References
:= False;
52 Style_Check_Specs
:= False;
53 Style_Check_Standard
:= False;
54 Style_Check_Tokens
:= False;
55 Style_Check_Xtra_Parens
:= False;
56 end Reset_Style_Check_Options
;
58 ------------------------------
59 -- Save_Style_Check_Options --
60 ------------------------------
62 procedure Save_Style_Check_Options
(Options
: out Style_Check_Options
) is
65 procedure Add
(C
: Character; S
: Boolean);
66 -- Add given character C to string if switch S is true
68 procedure Add_Nat
(N
: Nat
);
69 -- Add given natural number to string
75 procedure Add
(C
: Character; S
: Boolean) is
87 procedure Add_Nat
(N
: Nat
) is
94 Options
(P
) := Character'Val (Character'Pos ('0') + N
mod 10);
97 -- Start of processing for Save_Style_Check_Options
100 for K
in Options
'Range loop
104 Add
(Character'Val (Style_Check_Indentation
+ Character'Pos ('0')),
105 Style_Check_Indentation
/= 0);
107 Add
('a', Style_Check_Attribute_Casing
);
108 Add
('b', Style_Check_Blanks_At_End
);
109 Add
('c', Style_Check_Comments
);
110 Add
('e', Style_Check_End_Labels
);
111 Add
('f', Style_Check_Form_Feeds
);
112 Add
('h', Style_Check_Horizontal_Tabs
);
113 Add
('i', Style_Check_If_Then_Layout
);
114 Add
('k', Style_Check_Keyword_Casing
);
115 Add
('l', Style_Check_Layout
);
116 Add
('n', Style_Check_Standard
);
117 Add
('o', Style_Check_Order_Subprograms
);
118 Add
('p', Style_Check_Pragma_Casing
);
119 Add
('r', Style_Check_References
);
120 Add
('s', Style_Check_Specs
);
121 Add
('t', Style_Check_Tokens
);
122 Add
('x', Style_Check_Xtra_Parens
);
124 if Style_Check_Max_Line_Length
then
127 Add_Nat
(Style_Max_Line_Length
);
130 if Style_Check_Max_Nesting_Level
then
133 Add_Nat
(Style_Max_Nesting_Level
);
136 pragma Assert
(P
<= Options
'Last);
138 while P
< Options
'Last loop
142 end Save_Style_Check_Options
;
144 -------------------------------------
145 -- Set_Default_Style_Check_Options --
146 -------------------------------------
148 procedure Set_Default_Style_Check_Options
is
150 Reset_Style_Check_Options
;
151 Set_Style_Check_Options
("3abcefhiklmnprst");
152 end Set_Default_Style_Check_Options
;
154 -----------------------------
155 -- Set_Style_Check_Options --
156 -----------------------------
158 -- Version used when no error checking is required
160 procedure Set_Style_Check_Options
(Options
: String) is
164 Set_Style_Check_Options
(Options
, OK
, EC
);
165 end Set_Style_Check_Options
;
167 -- Normal version with error checking
169 procedure Set_Style_Check_Options
172 Err_Col
: out Natural)
179 while J
<= Options
'Last loop
185 Style_Check_Indentation
186 := Character'Pos (C
) - Character'Pos ('0');
189 Style_Check_Attribute_Casing
:= True;
192 Style_Check_Blanks_At_End
:= True;
195 Style_Check_Comments
:= True;
198 Style_Check_End_Labels
:= True;
201 Style_Check_Form_Feeds
:= True;
204 Style_Check_Horizontal_Tabs
:= True;
207 Style_Check_If_Then_Layout
:= True;
210 Style_Check_Keyword_Casing
:= True;
213 Style_Check_Layout
:= True;
216 Style_Max_Nesting_Level
:= 0;
219 or else Options
(J
) not in '0' .. '9'
227 Style_Max_Nesting_Level
:=
228 Style_Max_Nesting_Level
* 10 +
229 Character'Pos (Options
(J
)) - Character'Pos ('0');
231 if Style_Max_Nesting_Level
> 999 then
238 exit when J
> Options
'Last
239 or else Options
(J
) not in '0' .. '9';
242 Style_Check_Max_Nesting_Level
:= Style_Max_Nesting_Level
/= 0;
245 Style_Check_Max_Line_Length
:= True;
246 Style_Max_Line_Length
:= 79;
249 Style_Check_Standard
:= True;
252 Reset_Style_Check_Options
;
255 Style_Max_Line_Length
:= 0;
258 or else Options
(J
) not in '0' .. '9'
266 Style_Max_Line_Length
:=
267 Style_Max_Line_Length
* 10 +
268 Character'Pos (Options
(J
)) - Character'Pos ('0');
270 if Style_Max_Line_Length
> Int
(Column_Number
'Last) then
277 exit when J
> Options
'Last
278 or else Options
(J
) not in '0' .. '9';
281 Style_Check_Max_Line_Length
:= Style_Max_Line_Length
/= 0;
284 Style_Check_Order_Subprograms
:= True;
287 Style_Check_Pragma_Casing
:= True;
290 Style_Check_References
:= True;
293 Style_Check_Specs
:= True;
296 Style_Check_Tokens
:= True;
299 Style_Check_Xtra_Parens
:= True;
313 Err_Col
:= Options
'Last + 1;
314 end Set_Style_Check_Options
;