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
36 -- Package names are preceded by 'P'
37 -- Attribute names are preceded by two capital letters:
38 -- 'S' for Single or 'L' for list, then
39 -- 'V' for single variable, 'A' for associative array, or 'B' for both.
40 -- End is indicated by two consecutive '#'.
42 Initialisation_Data : constant String :=
49 "SVsource_list_file#" &
53 "SVlibrary_elaboration#" &
54 "SVlibrary_version#" &
60 "SVspecification_append#" &
62 "SVseparate_append#" &
64 "SVdot_replacement#" &
72 "SVlocal_configuration_pragmas#" &
78 "SVglobal_configuration_pragmas#" &
101 procedure Initialize is
102 Start : Positive := Initialisation_Data'First;
103 Finish : Positive := Start;
104 Current_Package : Package_Node_Id := Empty_Package;
105 Current_Attribute : Attribute_Node_Id := Empty_Attribute;
106 Is_An_Attribute : Boolean := False;
107 Kind_1 : Variable_Kind := Undefined;
108 Kind_2 : Attribute_Kind := Single;
109 Package_Name : Name_Id := No_Name;
110 Attribute_Name : Name_Id := No_Name;
111 First_Attribute : Attribute_Node_Id := Attribute_First;
114 -- Make sure the two tables are empty
116 Attributes.Set_Last (Attributes.First);
117 Package_Attributes.Set_Last (Package_Attributes.First);
119 while Initialisation_Data (Start) /= '#' loop
120 Is_An_Attribute := True;
121 case Initialisation_Data (Start) is
123 -- New allowed package
126 while Initialisation_Data (Finish) /= '#' loop
127 Finish := Finish + 1;
129 Name_Len := Finish - Start;
130 Name_Buffer (1 .. Name_Len) :=
131 To_Lower (Initialisation_Data (Start .. Finish - 1));
132 Package_Name := Name_Find;
133 for Index in Package_First .. Package_Attributes.Last loop
134 if Package_Name = Package_Attributes.Table (Index).Name then
135 Write_Line ("Duplicate package name """ &
136 Initialisation_Data (Start .. Finish - 1) &
137 """ in Prj.Attr body.");
142 Is_An_Attribute := False;
143 Current_Attribute := Empty_Attribute;
144 Package_Attributes.Increment_Last;
145 Current_Package := Package_Attributes.Last;
146 Package_Attributes.Table (Current_Package).Name :=
157 if Is_An_Attribute then
160 case Initialisation_Data (Start) is
164 Kind_2 := Associative_Array;
172 while Initialisation_Data (Finish) /= '#' loop
173 Finish := Finish + 1;
175 Name_Len := Finish - Start;
176 Name_Buffer (1 .. Name_Len) :=
177 To_Lower (Initialisation_Data (Start .. Finish - 1));
178 Attribute_Name := Name_Find;
179 Attributes.Increment_Last;
180 if Current_Attribute = Empty_Attribute then
181 First_Attribute := Attributes.Last;
182 if Current_Package /= Empty_Package then
183 Package_Attributes.Table (Current_Package).First_Attribute
187 -- Check that there are no duplicate attributes
188 for Index in First_Attribute .. Attributes.Last - 1 loop
190 Attributes.Table (Index).Name then
191 Write_Line ("Duplicate attribute name """ &
192 Initialisation_Data (Start .. Finish - 1) &
193 """ in Prj.Attr body.");
197 Attributes.Table (Current_Attribute).Next :=
200 Current_Attribute := Attributes.Last;
201 Attributes.Table (Current_Attribute) :=
202 (Name => Attribute_Name,
205 Next => Empty_Attribute);