1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-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 ------------------------------------------------------------------------------
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
36 -- Package names are preceded by 'P'
38 -- Attribute names are preceded by two letters
40 -- The first letter is one of
42 -- 's' for Single with optional index
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
52 -- 'c' same as 'b', with optional index
54 -- End is indicated by two consecutive '#'.
56 Initialization_Data : constant String :=
64 "LVlocally_removed_files#" &
65 "SVsource_list_file#" &
69 "SVlibrary_version#" &
70 "LVlibrary_interface#" &
71 "SVlibrary_auto_init#" &
72 "LVlibrary_options#" &
73 "SVlibrary_src_dir#" &
75 "SVlibrary_symbol_file#" &
76 "SVlibrary_symbol_policy#" &
77 "SVlibrary_reference_symbol_file#" &
85 "Saspecification_suffix#" &
87 "Saimplementation_suffix#" &
89 "SVseparate_suffix#" &
91 "SVdot_replacement#" &
96 "Laspecification_exceptions#" &
97 "Laimplementation_exceptions#" &
102 "Ladefault_switches#" &
104 "SVlocal_configuration_pragmas#" &
109 "Ladefault_switches#" &
112 "SVexecutable_suffix#" &
113 "SVglobal_configuration_pragmas#" &
123 "Ladefault_switches#" &
129 "Ladefault_switches#" &
131 "LVlinker_options#" &
133 -- package Cross_Reference
135 "Pcross_reference#" &
136 "Ladefault_switches#" &
142 "Ladefault_switches#" &
145 -- package Pretty_Printer
148 "Ladefault_switches#" &
154 "Ladefault_switches#" &
160 "Ladefault_switches#" &
166 "Ladefault_switches#" &
172 "Ladefault_switches#" &
175 "SVcommunication_protocol#" &
176 "Sacompiler_command#" &
177 "SVdebugger_command#" &
180 "SVvcs_file_check#" &
189 procedure Initialize is
190 Start : Positive := Initialization_Data'First;
191 Finish : Positive := Start;
192 Current_Package : Package_Node_Id := Empty_Package;
193 Current_Attribute : Attribute_Node_Id := Empty_Attribute;
194 Is_An_Attribute : Boolean := False;
195 Kind_1 : Variable_Kind := Undefined;
196 Optional_Index : Boolean := False;
197 Kind_2 : Attribute_Kind := Single;
198 Package_Name : Name_Id := No_Name;
199 Attribute_Name : Name_Id := No_Name;
200 First_Attribute : Attribute_Node_Id := Attribute_First;
203 -- Make sure the two tables are empty
206 Package_Attributes.Init;
208 while Initialization_Data (Start) /= '#' loop
209 Is_An_Attribute := True;
210 case Initialization_Data (Start) is
213 -- New allowed package
218 while Initialization_Data (Finish) /= '#' loop
219 Finish := Finish + 1;
222 Name_Len := Finish - Start;
223 Name_Buffer (1 .. Name_Len) :=
224 To_Lower (Initialization_Data (Start .. Finish - 1));
225 Package_Name := Name_Find;
227 for Index in Package_First .. Package_Attributes.Last loop
228 if Package_Name = Package_Attributes.Table (Index).Name then
229 Write_Line ("Duplicate package name """ &
230 Initialization_Data (Start .. Finish - 1) &
231 """ in Prj.Attr body.");
236 Is_An_Attribute := False;
237 Current_Attribute := Empty_Attribute;
238 Package_Attributes.Increment_Last;
239 Current_Package := Package_Attributes.Last;
240 Package_Attributes.Table (Current_Package).Name :=
246 Optional_Index := False;
250 Optional_Index := True;
254 Optional_Index := False;
258 Optional_Index := True;
264 if Is_An_Attribute then
269 case Initialization_Data (Start) is
274 Kind_2 := Associative_Array;
277 Kind_2 := Case_Insensitive_Associative_Array;
280 if File_Names_Case_Sensitive then
281 Kind_2 := Associative_Array;
283 Kind_2 := Case_Insensitive_Associative_Array;
287 if File_Names_Case_Sensitive then
288 Kind_2 := Optional_Index_Associative_Array;
291 Optional_Index_Case_Insensitive_Associative_Array;
301 while Initialization_Data (Finish) /= '#' loop
302 Finish := Finish + 1;
305 Name_Len := Finish - Start;
306 Name_Buffer (1 .. Name_Len) :=
307 To_Lower (Initialization_Data (Start .. Finish - 1));
308 Attribute_Name := Name_Find;
309 Attributes.Increment_Last;
311 if Current_Attribute = Empty_Attribute then
312 First_Attribute := Attributes.Last;
314 if Current_Package /= Empty_Package then
315 Package_Attributes.Table (Current_Package).First_Attribute
320 -- Check that there are no duplicate attributes
322 for Index in First_Attribute .. Attributes.Last - 1 loop
324 Attributes.Table (Index).Name then
325 Write_Line ("Duplicate attribute name """ &
326 Initialization_Data (Start .. Finish - 1) &
327 """ in Prj.Attr body.");
332 Attributes.Table (Current_Attribute).Next :=
336 Current_Attribute := Attributes.Last;
337 Attributes.Table (Current_Attribute) :=
338 (Name => Attribute_Name,
340 Optional_Index => Optional_Index,
342 Next => Empty_Attribute);