* gnu/regexp/CharIndexedReader.java: Removed.
[official-gcc.git] / gcc / ada / prj-attr.adb
bloba0588bcb4e146fb9c4ca07355dfd1c089810ac9d
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- P R J . A T T R --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2001-2004 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 with Ada.Characters.Handling; use Ada.Characters.Handling;
28 with Namet; use Namet;
29 with Osint; use Osint;
30 with Output; use Output;
32 package body Prj.Attr is
34 -- Names end with '#'
36 -- Package names are preceded by 'P'
38 -- Attribute names are preceded by two letters
40 -- The first letter is one of
41 -- 'S' for Single
42 -- 's' for Single with optional index
43 -- 'L' for List
44 -- 'l' for List of strings with optional indexes
46 -- The second letter is one of
47 -- 'V' for single variable
48 -- 'A' for associative array
49 -- 'a' for case insensitive associative array
50 -- 'b' for associative array, case insensitive if file names are case
51 -- insensitive
52 -- 'c' same as 'b', with optional index
54 -- End is indicated by two consecutive '#'.
56 Initialization_Data : constant String :=
58 -- project attributes
60 "SVobject_dir#" &
61 "SVexec_dir#" &
62 "LVsource_dirs#" &
63 "LVsource_files#" &
64 "LVlocally_removed_files#" &
65 "SVsource_list_file#" &
66 "SVlibrary_dir#" &
67 "SVlibrary_name#" &
68 "SVlibrary_kind#" &
69 "SVlibrary_version#" &
70 "LVlibrary_interface#" &
71 "SVlibrary_auto_init#" &
72 "LVlibrary_options#" &
73 "SVlibrary_src_dir#" &
74 "SVlibrary_gcc#" &
75 "SVlibrary_symbol_file#" &
76 "SVlibrary_symbol_policy#" &
77 "SVlibrary_reference_symbol_file#" &
78 "lVmain#" &
79 "LVlanguages#" &
80 "SVmain_language#" &
82 -- package Naming
84 "Pnaming#" &
85 "Saspecification_suffix#" &
86 "Saspec_suffix#" &
87 "Saimplementation_suffix#" &
88 "Sabody_suffix#" &
89 "SVseparate_suffix#" &
90 "SVcasing#" &
91 "SVdot_replacement#" &
92 "sAspecification#" &
93 "sAspec#" &
94 "sAimplementation#" &
95 "sAbody#" &
96 "Laspecification_exceptions#" &
97 "Laimplementation_exceptions#" &
99 -- package Compiler
101 "Pcompiler#" &
102 "Ladefault_switches#" &
103 "Lcswitches#" &
104 "SVlocal_configuration_pragmas#" &
106 -- package Builder
108 "Pbuilder#" &
109 "Ladefault_switches#" &
110 "Lcswitches#" &
111 "Scexecutable#" &
112 "SVexecutable_suffix#" &
113 "SVglobal_configuration_pragmas#" &
115 -- package gnatls
117 "Pgnatls#" &
118 "LVswitches#" &
120 -- package Binder
122 "Pbinder#" &
123 "Ladefault_switches#" &
124 "Lcswitches#" &
126 -- package Linker
128 "Plinker#" &
129 "Ladefault_switches#" &
130 "Lcswitches#" &
131 "LVlinker_options#" &
133 -- package Cross_Reference
135 "Pcross_reference#" &
136 "Ladefault_switches#" &
137 "Lbswitches#" &
139 -- package Finder
141 "Pfinder#" &
142 "Ladefault_switches#" &
143 "Lbswitches#" &
145 -- package Pretty_Printer
147 "Ppretty_printer#" &
148 "Ladefault_switches#" &
149 "Lbswitches#" &
151 -- package gnatstub
153 "Pgnatstub#" &
154 "Ladefault_switches#" &
155 "Lbswitches#" &
157 -- package Eliminate
159 "Peliminate#" &
160 "Ladefault_switches#" &
161 "Lbswitches#" &
163 -- package Ide
165 "Pide#" &
166 "Ladefault_switches#" &
167 "SVremote_host#" &
168 "SVprogram_host#" &
169 "SVcommunication_protocol#" &
170 "Sacompiler_command#" &
171 "SVdebugger_command#" &
172 "SVgnatlist#" &
173 "SVvcs_kind#" &
174 "SVvcs_file_check#" &
175 "SVvcs_log_check#" &
177 "#";
179 ----------------
180 -- Initialize --
181 ----------------
183 procedure Initialize is
184 Start : Positive := Initialization_Data'First;
185 Finish : Positive := Start;
186 Current_Package : Package_Node_Id := Empty_Package;
187 Current_Attribute : Attribute_Node_Id := Empty_Attribute;
188 Is_An_Attribute : Boolean := False;
189 Kind_1 : Variable_Kind := Undefined;
190 Optional_Index : Boolean := False;
191 Kind_2 : Attribute_Kind := Single;
192 Package_Name : Name_Id := No_Name;
193 Attribute_Name : Name_Id := No_Name;
194 First_Attribute : Attribute_Node_Id := Attribute_First;
196 begin
197 -- Make sure the two tables are empty
199 Attributes.Init;
200 Package_Attributes.Init;
202 while Initialization_Data (Start) /= '#' loop
203 Is_An_Attribute := True;
204 case Initialization_Data (Start) is
205 when 'P' =>
207 -- New allowed package
209 Start := Start + 1;
211 Finish := Start;
212 while Initialization_Data (Finish) /= '#' loop
213 Finish := Finish + 1;
214 end loop;
216 Name_Len := Finish - Start;
217 Name_Buffer (1 .. Name_Len) :=
218 To_Lower (Initialization_Data (Start .. Finish - 1));
219 Package_Name := Name_Find;
221 for Index in Package_First .. Package_Attributes.Last loop
222 if Package_Name = Package_Attributes.Table (Index).Name then
223 Write_Line ("Duplicate package name """ &
224 Initialization_Data (Start .. Finish - 1) &
225 """ in Prj.Attr body.");
226 raise Program_Error;
227 end if;
228 end loop;
230 Is_An_Attribute := False;
231 Current_Attribute := Empty_Attribute;
232 Package_Attributes.Increment_Last;
233 Current_Package := Package_Attributes.Last;
234 Package_Attributes.Table (Current_Package).Name :=
235 Package_Name;
236 Start := Finish + 1;
238 when 'S' =>
239 Kind_1 := Single;
240 Optional_Index := False;
242 when 's' =>
243 Kind_1 := Single;
244 Optional_Index := True;
246 when 'L' =>
247 Kind_1 := List;
248 Optional_Index := False;
250 when 'l' =>
251 Kind_1 := List;
252 Optional_Index := True;
254 when others =>
255 raise Program_Error;
256 end case;
258 if Is_An_Attribute then
260 -- New attribute
262 Start := Start + 1;
263 case Initialization_Data (Start) is
264 when 'V' =>
265 Kind_2 := Single;
267 when 'A' =>
268 Kind_2 := Associative_Array;
270 when 'a' =>
271 Kind_2 := Case_Insensitive_Associative_Array;
273 when 'b' =>
274 if File_Names_Case_Sensitive then
275 Kind_2 := Associative_Array;
276 else
277 Kind_2 := Case_Insensitive_Associative_Array;
278 end if;
280 when 'c' =>
281 if File_Names_Case_Sensitive then
282 Kind_2 := Optional_Index_Associative_Array;
283 else
284 Kind_2 :=
285 Optional_Index_Case_Insensitive_Associative_Array;
286 end if;
288 when others =>
289 raise Program_Error;
290 end case;
292 Start := Start + 1;
293 Finish := Start;
295 while Initialization_Data (Finish) /= '#' loop
296 Finish := Finish + 1;
297 end loop;
299 Name_Len := Finish - Start;
300 Name_Buffer (1 .. Name_Len) :=
301 To_Lower (Initialization_Data (Start .. Finish - 1));
302 Attribute_Name := Name_Find;
303 Attributes.Increment_Last;
305 if Current_Attribute = Empty_Attribute then
306 First_Attribute := Attributes.Last;
308 if Current_Package /= Empty_Package then
309 Package_Attributes.Table (Current_Package).First_Attribute
310 := Attributes.Last;
311 end if;
313 else
314 -- Check that there are no duplicate attributes
316 for Index in First_Attribute .. Attributes.Last - 1 loop
317 if Attribute_Name =
318 Attributes.Table (Index).Name then
319 Write_Line ("Duplicate attribute name """ &
320 Initialization_Data (Start .. Finish - 1) &
321 """ in Prj.Attr body.");
322 raise Program_Error;
323 end if;
324 end loop;
326 Attributes.Table (Current_Attribute).Next :=
327 Attributes.Last;
328 end if;
330 Current_Attribute := Attributes.Last;
331 Attributes.Table (Current_Attribute) :=
332 (Name => Attribute_Name,
333 Kind_1 => Kind_1,
334 Optional_Index => Optional_Index,
335 Kind_2 => Kind_2,
336 Next => Empty_Attribute);
337 Start := Finish + 1;
338 end if;
339 end loop;
340 end Initialize;
342 end Prj.Attr;