* config/arm/elf.h (ASM_OUTPUT_ALIGNED_COMMON): Remove definition.
[official-gcc.git] / gcc / ada / prj.ads
blob3ac425ffacecb764d2d7b5a2662ac5abe010e148
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- P R J --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2001-2002 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 -- The following package declares the data types for GNAT project.
28 -- These data types may be used by GNAT Project-aware tools.
30 -- Children of these package implements various services on these data types.
31 -- See in particular Prj.Pars and Prj.Env.
33 with Casing; use Casing;
34 with GNAT.OS_Lib; use GNAT.OS_Lib;
35 with Scans; use Scans;
36 with Table;
37 with Types; use Types;
39 package Prj is
41 Project_File_Extension : String := ".gpr";
42 -- The standard project file name extension.
43 -- It is not a constant, because Canonical_Case_File_Name is called
44 -- on this variable in the body of Prj.
46 Default_Ada_Spec_Suffix : Name_Id;
47 -- The Name_Id for the standard GNAT suffix for Ada spec source file
48 -- name ".ads". Initialized by Prj.Initialize.
50 Default_Ada_Impl_Suffix : Name_Id;
51 -- The Name_Id for the standard GNAT suffix for Ada body source file
52 -- name ".adb". Initialized by Prj.Initialize.
54 type Verbosity is (Default, Medium, High);
55 -- Verbosity when parsing GNAT Project Files
56 -- Default is default (very quiet, if no errors).
57 -- Medium is more verbose.
58 -- High is extremely verbose.
60 type Lib_Kind is (Static, Dynamic, Relocatable);
62 function Empty_String return String_Id;
64 type String_List_Id is new Nat;
65 Nil_String : constant String_List_Id := 0;
66 type String_Element is record
67 Value : String_Id := No_String;
68 Location : Source_Ptr := No_Location;
69 Next : String_List_Id := Nil_String;
70 end record;
71 -- To hold values for string list variables and array elements
73 package String_Elements is new Table.Table
74 (Table_Component_Type => String_Element,
75 Table_Index_Type => String_List_Id,
76 Table_Low_Bound => 1,
77 Table_Initial => 200,
78 Table_Increment => 100,
79 Table_Name => "Prj.String_Elements");
80 -- The table for string elements in string lists
82 type Variable_Kind is (Undefined, List, Single);
83 -- Different kinds of variables
85 type Variable_Value (Kind : Variable_Kind := Undefined) is record
86 Location : Source_Ptr := No_Location;
87 Default : Boolean := False;
88 case Kind is
89 when Undefined =>
90 null;
91 when List =>
92 Values : String_List_Id := Nil_String;
93 when Single =>
94 Value : String_Id := No_String;
95 end case;
96 end record;
97 -- Values for variables and array elements.
98 -- Default is True if the current value is the default one for the variable
100 Nil_Variable_Value : constant Variable_Value :=
101 (Kind => Undefined,
102 Location => No_Location,
103 Default => False);
104 -- Value of a non existing variable or array element
106 type Variable_Id is new Nat;
107 No_Variable : constant Variable_Id := 0;
108 type Variable is record
109 Next : Variable_Id := No_Variable;
110 Name : Name_Id;
111 Value : Variable_Value;
112 end record;
113 -- To hold the list of variables in a project file and in packages
115 package Variable_Elements is new Table.Table
116 (Table_Component_Type => Variable,
117 Table_Index_Type => Variable_Id,
118 Table_Low_Bound => 1,
119 Table_Initial => 200,
120 Table_Increment => 100,
121 Table_Name => "Prj.Variable_Elements");
122 -- The table of variable in list of variables
124 type Array_Element_Id is new Nat;
125 No_Array_Element : constant Array_Element_Id := 0;
126 type Array_Element is record
127 Index : Name_Id;
128 Value : Variable_Value;
129 Next : Array_Element_Id := No_Array_Element;
130 end record;
131 -- Each Array_Element represents an array element and is linked (Next)
132 -- to the next array element, if any, in the array.
134 package Array_Elements is new Table.Table
135 (Table_Component_Type => Array_Element,
136 Table_Index_Type => Array_Element_Id,
137 Table_Low_Bound => 1,
138 Table_Initial => 200,
139 Table_Increment => 100,
140 Table_Name => "Prj.Array_Elements");
141 -- The table that contains all array elements
143 type Array_Id is new Nat;
144 No_Array : constant Array_Id := 0;
145 type Array_Data is record
146 Name : Name_Id := No_Name;
147 Value : Array_Element_Id := No_Array_Element;
148 Next : Array_Id := No_Array;
149 end record;
150 -- Each Array_Data value represents an array.
151 -- Value is the id of the first element.
152 -- Next is the id of the next array in the project file or package.
154 package Arrays is new Table.Table
155 (Table_Component_Type => Array_Data,
156 Table_Index_Type => Array_Id,
157 Table_Low_Bound => 1,
158 Table_Initial => 200,
159 Table_Increment => 100,
160 Table_Name => "Prj.Arrays");
161 -- The table that contains all arrays
163 type Package_Id is new Nat;
164 No_Package : constant Package_Id := 0;
165 type Declarations is record
166 Variables : Variable_Id := No_Variable;
167 Attributes : Variable_Id := No_Variable;
168 Arrays : Array_Id := No_Array;
169 Packages : Package_Id := No_Package;
170 end record;
172 No_Declarations : constant Declarations :=
173 (Variables => No_Variable,
174 Attributes => No_Variable,
175 Arrays => No_Array,
176 Packages => No_Package);
177 -- Declarations. Used in project structures and packages (what for???)
179 type Package_Element is record
180 Name : Name_Id := No_Name;
181 Decl : Declarations := No_Declarations;
182 Parent : Package_Id := No_Package;
183 Next : Package_Id := No_Package;
184 end record;
185 -- A package. Includes declarations that may include other packages.
187 package Packages is new Table.Table
188 (Table_Component_Type => Package_Element,
189 Table_Index_Type => Package_Id,
190 Table_Low_Bound => 1,
191 Table_Initial => 100,
192 Table_Increment => 100,
193 Table_Name => "Prj.Packages");
194 -- The table that contains all packages.
196 function Image (Casing : Casing_Type) return String;
197 -- Similar to 'Image (but avoid use of this attribute in compiler)
199 function Value (Image : String) return Casing_Type;
200 -- Similar to 'Value (but avoid use of this attribute in compiler)
201 -- Raises Constraint_Error if not a Casing_Type image.
203 type Naming_Data is record
204 Current_Language : Name_Id := No_Name;
205 -- The programming language being currently considered
207 Dot_Replacement : Name_Id := No_Name;
208 -- The string to replace '.' in the source file name (for Ada).
210 Dot_Repl_Loc : Source_Ptr := No_Location;
211 -- The position in the project file source where
212 -- Dot_Replacement is defined.
214 Casing : Casing_Type := All_Lower_Case;
215 -- The casing of the source file name (for Ada).
217 Specification_Suffix : Array_Element_Id := No_Array_Element;
218 -- The string to append to the unit name for the
219 -- source file name of a specification.
220 -- Indexed by the programming language.
222 Current_Spec_Suffix : Name_Id := No_Name;
223 -- The specification suffix of the current programming language
225 Spec_Suffix_Loc : Source_Ptr := No_Location;
226 -- The position in the project file source where
227 -- Current_Spec_Suffix is defined.
229 Implementation_Suffix : Array_Element_Id := No_Array_Element;
230 -- The string to append to the unit name for the
231 -- source file name of a body.
232 -- Indexed by the programming language.
234 Current_Impl_Suffix : Name_Id := No_Name;
235 -- The implementation suffix of the current programming language
237 Impl_Suffix_Loc : Source_Ptr := No_Location;
238 -- The position in the project file source where
239 -- Current_Impl_Suffix is defined.
241 Separate_Suffix : Name_Id := No_Name;
242 -- The string to append to the unit name for the
243 -- source file name of an Ada subunit.
245 Sep_Suffix_Loc : Source_Ptr := No_Location;
246 -- The position in the project file source where
247 -- Separate_Suffix is defined.
249 Specifications : Array_Element_Id := No_Array_Element;
250 -- An associative array mapping individual specifications
251 -- to source file names. Specific to Ada.
253 Bodies : Array_Element_Id := No_Array_Element;
254 -- An associative array mapping individual bodies
255 -- to source file names. Specific to Ada.
257 Specification_Exceptions : Array_Element_Id := No_Array_Element;
258 -- An associative array mapping individual specifications
259 -- to source file names. Indexed by the programming language name.
261 Implementation_Exceptions : Array_Element_Id := No_Array_Element;
262 -- An associative array mapping individual bodies
263 -- to source file names. Indexed by the programming language name.
265 end record;
266 -- A naming scheme.
268 function Standard_Naming_Data return Naming_Data;
269 pragma Inline (Standard_Naming_Data);
270 -- The standard GNAT naming scheme.
272 function Same_Naming_Scheme
273 (Left, Right : Naming_Data)
274 return Boolean;
275 -- Returns True if Left and Right are the same naming scheme
276 -- not considering Specifications and Bodies.
278 type Project_Id is new Nat;
279 No_Project : constant Project_Id := 0;
280 -- Id of a Project File
282 type Project_List is new Nat;
283 Empty_Project_List : constant Project_List := 0;
284 -- A list of project files.
286 type Project_Element is record
287 Project : Project_Id := No_Project;
288 Next : Project_List := Empty_Project_List;
289 end record;
290 -- Element in a list of project file.
291 -- Next is the id of the next project file in the list.
293 package Project_Lists is new Table.Table
294 (Table_Component_Type => Project_Element,
295 Table_Index_Type => Project_List,
296 Table_Low_Bound => 1,
297 Table_Initial => 100,
298 Table_Increment => 100,
299 Table_Name => "Prj.Project_Lists");
300 -- The table that contains the lists of project files.
302 type Project_Data is record
303 First_Referred_By : Project_Id := No_Project;
304 -- The project, if any, that was the first to be known
305 -- as importing or extending this project.
306 -- Set by Prj.Proc.Process.
308 Name : Name_Id := No_Name;
309 -- The name of the project.
310 -- Set by Prj.Proc.Process.
312 Path_Name : Name_Id := No_Name;
313 -- The path name of the project file.
314 -- Set by Prj.Proc.Process.
316 Location : Source_Ptr := No_Location;
317 -- The location in the project file source of the
318 -- reserved word project.
319 -- Set by Prj.Proc.Process.
321 Directory : Name_Id := No_Name;
322 -- The directory where the project file resides.
323 -- Set by Prj.Proc.Process.
325 Library : Boolean := False;
326 -- True if this is a library project.
327 -- Set by Prj.Nmsc.Check_Naming_Scheme.
329 Library_Dir : Name_Id := No_Name;
330 -- If a library project, directory where resides the library
331 -- Set by Prj.Nmsc.Check_Naming_Scheme.
333 Library_Name : Name_Id := No_Name;
334 -- If a library project, name of the library
335 -- Set by Prj.Nmsc.Check_Naming_Scheme.
337 Library_Kind : Lib_Kind := Static;
338 -- If a library project, kind of library
339 -- Set by Prj.Nmsc.Check_Naming_Scheme.
341 Lib_Internal_Name : Name_Id := No_Name;
342 -- If a library project, internal name store inside the library
343 -- Set by Prj.Nmsc.Check_Naming_Scheme.
345 Lib_Elaboration : Boolean := False;
346 -- If a library project, indicate if <lib>init and <lib>final
347 -- procedures need to be defined.
348 -- Set by Prj.Nmsc.Check_Naming_Scheme.
350 Sources_Present : Boolean := True;
351 -- A flag that indicates if there are sources in this project file.
352 -- There are no sources if 1) Source_Dirs is specified as an
353 -- empty list, 2) Source_Files is specified as an empty list, or
354 -- 3) the current language is not in the list of the specified
355 -- Languages.
357 Sources : String_List_Id := Nil_String;
358 -- The list of all the source file names.
359 -- Set by Prj.Nmsc.Check_Naming_Scheme.
361 Source_Dirs : String_List_Id := Nil_String;
362 -- The list of all the source directories.
363 -- Set by Prj.Nmsc.Check_Naming_Scheme.
365 Object_Directory : Name_Id := No_Name;
366 -- The object directory of this project file.
367 -- Set by Prj.Nmsc.Check_Naming_Scheme.
369 Exec_Directory : Name_Id := No_Name;
370 -- The exec directory of this project file.
371 -- Default is equal to Object_Directory.
372 -- Set by Prj.Nmsc.Check_Naming_Scheme.
374 Modifies : Project_Id := No_Project;
375 -- The reference of the project file, if any, that this
376 -- project file modifies.
377 -- Set by Prj.Proc.Process.
379 Modified_By : Project_Id := No_Project;
380 -- The reference of the project file, if any, that
381 -- modifies this project file.
382 -- Set by Prj.Proc.Process.
384 Naming : Naming_Data := Standard_Naming_Data;
385 -- The naming scheme of this project file.
386 -- Set by Prj.Nmsc.Check_Naming_Scheme.
388 Decl : Declarations := No_Declarations;
389 -- The declarations (variables, attributes and packages)
390 -- of this project file.
391 -- Set by Prj.Proc.Process.
393 Imported_Projects : Project_List := Empty_Project_List;
394 -- The list of all directly imported projects, if any.
395 -- Set by Prj.Proc.Process.
397 Include_Path : String_Access := null;
398 -- The cached value of ADA_INCLUDE_PATH for this project file.
399 -- Set by gnatmake (Prj.Env.Set_Ada_Paths).
400 -- Do not use this field directly outside of the compiler, use
401 -- Prj.Env.Ada_Source_Path instead.
403 Objects_Path : String_Access := null;
404 -- The cached value of ADA_OBJECTS_PATH for this project file.
405 -- Set by gnatmake (Prj.Env.Set_Ada_Paths).
406 -- Do not use this field directly outside of the compiler, use
407 -- Prj.Env.Ada_Objects_Path instead.
409 Config_File_Name : Name_Id := No_Name;
410 -- The name of the configuration pragmas file, if any.
411 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
413 Config_File_Temp : Boolean := False;
414 -- An indication that the configuration pragmas file is
415 -- a temporary file that must be deleted at the end.
416 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
418 Config_Checked : Boolean := False;
419 -- A flag to avoid checking repetitively the configuration pragmas file.
420 -- Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
422 Language_Independent_Checked : Boolean := False;
423 -- A flag that indicates that the project file has been checked
424 -- for language independent features: Object_Directory,
425 -- Source_Directories, Library, non empty Naming Suffixs.
427 Checked : Boolean := False;
428 -- A flag to avoid checking repetitively the naming scheme of
429 -- this project file.
430 -- Set by Prj.Nmsc.Check_Naming_Scheme.
432 Seen : Boolean := False;
433 Flag1 : Boolean := False;
434 Flag2 : Boolean := False;
435 -- Various flags that are used in an ad hoc manner
436 -- That's really not a good enough comment ??? we need to know what
437 -- these flags are used for, and give them proper names. If Flag1
438 -- and Flag2 have multiple uses, then either we use multiple fields
439 -- or a renaming scheme.
441 end record;
442 -- Project File representation.
444 function Empty_Project return Project_Data;
445 -- Return the representation of an empty project.
447 package Projects is new Table.Table (
448 Table_Component_Type => Project_Data,
449 Table_Index_Type => Project_Id,
450 Table_Low_Bound => 1,
451 Table_Initial => 100,
452 Table_Increment => 100,
453 Table_Name => "Prj.Projects");
454 -- The set of all project files.
456 type Put_Line_Access is access procedure
457 (Line : String;
458 Project : Project_Id);
459 -- Use to customize error reporting in Prj.Proc and Prj.Nmsc.
461 procedure Expect (The_Token : Token_Type; Token_Image : String);
462 -- Check that the current token is The_Token. If it is not, then
463 -- output an error message.
465 procedure Initialize;
466 -- This procedure must be called before using any services from the Prj
467 -- hierarchy. Namet.Initialize must be called before Prj.Initialize.
469 procedure Reset;
470 -- This procedure resets all the tables that are used when processing a
471 -- project file tree. Initialize must be called before the call to Reset.
473 procedure Register_Default_Naming_Scheme
474 (Language : Name_Id;
475 Default_Spec_Suffix : Name_Id;
476 Default_Impl_Suffix : Name_Id);
477 -- Register the default suffixs for a given language. These extensions
478 -- will be ignored if the user has specified a new naming scheme in a
479 -- project file.
480 -- Otherwise, this information will be automatically added to Naming_Data
481 -- when a project is processed, in the lists Specification_Suffix and
482 -- Implementation_Suffix.
484 generic
485 type State is limited private;
486 with procedure Action
487 (Project : Project_Id;
488 With_State : in out State);
489 procedure For_Every_Project_Imported
490 (By : Project_Id;
491 With_State : in out State);
492 -- Call Action for each project imported directly or indirectly by project
493 -- By. Action is called according to the order of importation: if A
494 -- imports B, directly or indirectly, Action will be called for A before
495 -- it is called for B. With_State may be used by Action to choose a
496 -- behavior or to report some global result.
498 private
500 procedure Scan;
501 -- Calls Scn.Scan and change any Operator_Symbol to String_Literal
503 end Prj;