1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 2001 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
27 ------------------------------------------------------------------------------
29 with Ada.Characters.Handling; use Ada.Characters.Handling;
30 with Namet; use Namet;
31 with Output; use Output;
33 package body Prj.Attr is
37 -- Package names are preceded by 'P'
39 -- Attribute names are preceded by two letters
41 -- The first letter is one of
45 -- The second letter is one of
46 -- 'V' for single variable
47 -- 'A' for associative array
48 -- 'a' for case insensitive associative array
50 -- End is indicated by two consecutive '#'.
52 Initialisation_Data : constant String :=
59 "SVsource_list_file#" &
63 "SVlibrary_elaboration#" &
64 "SVlibrary_version#" &
71 "Saspecification_suffix#" &
72 "Saimplementation_suffix#" &
73 "SVseparate_suffix#" &
75 "SVdot_replacement#" &
78 "LAspecification_exceptions#" &
79 "LAimplementation_exceptions#" &
84 "Ladefault_switches#" &
86 "SVlocal_configuration_pragmas#" &
91 "Ladefault_switches#" &
93 "SVglobal_configuration_pragmas#" &
103 "Ladefault_switches#" &
109 "Ladefault_switches#" &
112 -- package Cross_Reference
114 "Pcross_reference#" &
115 "Ladefault_switches#" &
121 "Ladefault_switches#" &
130 procedure Initialize is
131 Start : Positive := Initialisation_Data'First;
132 Finish : Positive := Start;
133 Current_Package : Package_Node_Id := Empty_Package;
134 Current_Attribute : Attribute_Node_Id := Empty_Attribute;
135 Is_An_Attribute : Boolean := False;
136 Kind_1 : Variable_Kind := Undefined;
137 Kind_2 : Attribute_Kind := Single;
138 Package_Name : Name_Id := No_Name;
139 Attribute_Name : Name_Id := No_Name;
140 First_Attribute : Attribute_Node_Id := Attribute_First;
143 -- Make sure the two tables are empty
145 Attributes.Set_Last (Attributes.First);
146 Package_Attributes.Set_Last (Package_Attributes.First);
148 while Initialisation_Data (Start) /= '#' loop
149 Is_An_Attribute := True;
150 case Initialisation_Data (Start) is
153 -- New allowed package
158 while Initialisation_Data (Finish) /= '#' loop
159 Finish := Finish + 1;
162 Name_Len := Finish - Start;
163 Name_Buffer (1 .. Name_Len) :=
164 To_Lower (Initialisation_Data (Start .. Finish - 1));
165 Package_Name := Name_Find;
167 for Index in Package_First .. Package_Attributes.Last loop
168 if Package_Name = Package_Attributes.Table (Index).Name then
169 Write_Line ("Duplicate package name """ &
170 Initialisation_Data (Start .. Finish - 1) &
171 """ in Prj.Attr body.");
176 Is_An_Attribute := False;
177 Current_Attribute := Empty_Attribute;
178 Package_Attributes.Increment_Last;
179 Current_Package := Package_Attributes.Last;
180 Package_Attributes.Table (Current_Package).Name :=
194 if Is_An_Attribute then
199 case Initialisation_Data (Start) is
203 Kind_2 := Associative_Array;
205 Kind_2 := Case_Insensitive_Associative_Array;
213 while Initialisation_Data (Finish) /= '#' loop
214 Finish := Finish + 1;
217 Name_Len := Finish - Start;
218 Name_Buffer (1 .. Name_Len) :=
219 To_Lower (Initialisation_Data (Start .. Finish - 1));
220 Attribute_Name := Name_Find;
221 Attributes.Increment_Last;
222 if Current_Attribute = Empty_Attribute then
223 First_Attribute := Attributes.Last;
225 if Current_Package /= Empty_Package then
226 Package_Attributes.Table (Current_Package).First_Attribute
231 -- Check that there are no duplicate attributes
233 for Index in First_Attribute .. Attributes.Last - 1 loop
235 Attributes.Table (Index).Name then
236 Write_Line ("Duplicate attribute name """ &
237 Initialisation_Data (Start .. Finish - 1) &
238 """ in Prj.Attr body.");
243 Attributes.Table (Current_Attribute).Next :=
247 Current_Attribute := Attributes.Last;
248 Attributes.Table (Current_Attribute) :=
249 (Name => Attribute_Name,
252 Next => Empty_Attribute);