OSDN Git Service

Add Fariborz to my last change.
[pf3gnuchains/gcc-fork.git] / gcc / ada / prj.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                                  P R J                                   --
6 --                                                                          --
7 --                                 S p e c                                  --
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 ------------------------------------------------------------------------------
26
27 --  The following package declares the data types for GNAT project.
28 --  These data types may be used by GNAT Project-aware tools.
29
30 --  Children of these package implements various services on these data types.
31 --  See in particular Prj.Pars and Prj.Env.
32
33 with Casing; use Casing;
34 with Scans;  use Scans;
35 with Table;
36 with Types;  use Types;
37
38 with GNAT.OS_Lib; use GNAT.OS_Lib;
39
40 package Prj is
41
42    Empty_Name : Name_Id;
43    --  Name_Id for an empty name (no characters). Initialized by the call
44    --  to procedure Initialize.
45
46    All_Packages : constant String_List_Access := null;
47    --  Default value of parameter Packages of procedures Parse, in Prj.Pars and
48    --  Prj.Part, indicating that all packages should be checked.
49
50    Virtual_Prefix : constant String := "v$";
51    --  The prefix for virtual extending projects. Because of the '$', which is
52    --  normally forbidden for project names, there cannot be any name clash.
53
54    Project_File_Extension : String := ".gpr";
55    --  The standard project file name extension. It is not a constant, because
56    --  Canonical_Case_File_Name is called on this variable in the body of Prj.
57
58    Default_Ada_Spec_Suffix : Name_Id;
59    --  The Name_Id for the standard GNAT suffix for Ada spec source file
60    --  name ".ads". Initialized by Prj.Initialize.
61
62    Default_Ada_Body_Suffix : Name_Id;
63    --  The Name_Id for the standard GNAT suffix for Ada body source file
64    --  name ".adb". Initialized by Prj.Initialize.
65
66    Slash : Name_Id;
67    --  "/", used as the path of locally removed files
68
69    type Languages_Processed is (Ada_Language, Other_Languages, All_Languages);
70    --  To specify how to process project files
71
72    type Programming_Language is
73      (Lang_Ada, Lang_C, Lang_C_Plus_Plus);
74    --  The set of languages supported
75
76    subtype Other_Programming_Language is
77      Programming_Language range Lang_C .. Programming_Language'Last;
78    --  The set of non-Ada languages supported
79
80    type Languages_In_Project is array (Programming_Language) of Boolean;
81    --  Set of supported languages used in a project
82
83    No_Languages : constant Languages_In_Project := (others => False);
84    --  No supported languages are used
85
86    type Impl_Suffix_Array is array (Programming_Language) of Name_Id;
87    --  Suffixes for the non spec sources of the different supported languages
88    --  in a project.
89
90    No_Impl_Suffixes : constant Impl_Suffix_Array := (others => No_Name);
91    --  A default value for the non spec source suffixes
92
93    Lang_Ada_Name         : aliased String := "ada";
94    Lang_C_Name           : aliased String := "c";
95    Lang_C_Plus_Plus_Name : aliased String := "c++";
96    Lang_Names : constant array (Programming_Language) of String_Access :=
97      (Lang_Ada         => Lang_Ada_Name        'Access,
98       Lang_C           => Lang_C_Name          'Access,
99       Lang_C_Plus_Plus => Lang_C_Plus_Plus_Name'Access);
100    --  Names of the supported programming languages, to be used after switch
101    --  -x when using a GCC compiler.
102
103    Lang_Name_Ids : array (Programming_Language) of Name_Id;
104    --  Same as Lang_Names, but using Name_Id, instead of String_Access.
105    --  Initialized by Prj.Initialize.
106
107    Lang_Ada_Display_Name         : aliased String := "Ada";
108    Lang_C_Display_Name           : aliased String := "C";
109    Lang_C_Plus_Plus_Display_Name : aliased String := "C++";
110    Lang_Display_Names :
111      constant array (Programming_Language) of String_Access :=
112        (Lang_Ada         => Lang_Ada_Display_Name        'Access,
113         Lang_C           => Lang_C_Display_Name          'Access,
114         Lang_C_Plus_Plus => Lang_C_Plus_Plus_Display_Name'Access);
115    --  Names of the supported programming languages, to be used for display
116    --  purposes.
117
118    Ada_Impl_Suffix         : aliased String := ".adb";
119    C_Impl_Suffix           : aliased String := ".c";
120    C_Plus_Plus_Impl_Suffix : aliased String := ".cc";
121    Lang_Suffixes : constant array (Programming_Language) of String_Access :=
122      (Lang_Ada         => Ada_Impl_Suffix        'Access,
123       Lang_C           => C_Impl_Suffix          'Access,
124       Lang_C_Plus_Plus => C_Plus_Plus_Impl_Suffix'Access);
125    --  Default extension of the sources of the different languages.
126
127    Lang_Suffix_Ids         : array (Programming_Language) of Name_Id;
128    --  Same as Lang_Suffixes, but using Name_Id, instead of String_Access.
129    --  Initialized by Prj.Initialize.
130
131    Gnatmake_String    : aliased String := "gnatmake";
132    Gcc_String         : aliased String := "gcc";
133    G_Plus_Plus_String : aliased String := "g++";
134    Default_Compiler_Names  :
135      constant array (Programming_Language) of String_Access :=
136      (Lang_Ada         => Gnatmake_String   'Access,
137       Lang_C           => Gcc_String        'Access,
138       Lang_C_Plus_Plus => G_Plus_Plus_String'Access);
139    --  Default names of the compilers for the supported languages.
140    --  Used when no IDE'Compiler_Command is specified for a language.
141    --  For Ada, specify the gnatmake executable.
142
143    Ada_Args_Strings        : aliased String := "";
144    C_Args_String           : aliased String := "c";
145    C_Plus_Plus_Args_String : aliased String := "xx";
146    Lang_Args : constant array (Programming_Language) of String_Access :=
147      (Lang_Ada         => Ada_Args_Strings       'Access,
148       Lang_C           => C_Args_String          'Access,
149       Lang_C_Plus_Plus => C_Plus_Plus_Args_String'Access);
150    --  For each supported language, the string between "-c" and "args" to
151    --  be used in the gprmake switch for the start of the compiling switch
152    --  section for each supported language. For example, "-ccargs" indicates
153    --  the start of the C compiler switch section.
154
155    type Other_Source_Id is new Nat;
156    No_Other_Source : constant Other_Source_Id := 0;
157    type Other_Source is record
158       Language         : Programming_Language; --  language of the source
159       File_Name        : Name_Id;              --  source file simple name
160       Path_Name        : Name_Id;              --  source full path name
161       Source_TS        : Time_Stamp_Type;      --  source file time stamp
162       Object_Name      : Name_Id;              --  object file simple name
163       Object_Path      : Name_Id;              --  object full path name
164       Object_TS        : Time_Stamp_Type;      --  object file time stamp
165       Dep_Name         : Name_Id;              --  dependency file simple name
166       Dep_Path         : Name_Id;              --  dependency full path name
167       Dep_TS           : Time_Stamp_Type;      --  dependency file time stamp
168       Naming_Exception : Boolean := False;     --  True if a naming exception
169       Next             : Other_Source_Id := No_Other_Source;
170    end record;
171    --  Data for a source in a language other than Ada
172
173    package Other_Sources is new Table.Table
174      (Table_Component_Type => Other_Source,
175       Table_Index_Type     => Other_Source_Id,
176       Table_Low_Bound      => 1,
177       Table_Initial        => 200,
178       Table_Increment      => 100,
179       Table_Name           => "Prj.Other_Sources");
180    --  The table for sources of languages other than Ada
181
182    type Verbosity is (Default, Medium, High);
183    --  Verbosity when parsing GNAT Project Files
184    --    Default is default (very quiet, if no errors).
185    --    Medium is more verbose.
186    --    High is extremely verbose.
187
188    type Lib_Kind is (Static, Dynamic, Relocatable);
189    type Policy is (Autonomous, Compliant, Controlled, Restricted);
190    --  Type to specify the symbol policy, when symbol control is supported.
191    --  See full explanation about this type in package Symbols.
192    --  Autonomous: Create a symbol file without considering any reference
193    --  Compliant: Try to be as compatible as possible with an existing ref
194    --  Controlled: Fail if symbols are not the same as those in the reference
195    --  Restricted: Restrict the symbols to those in the symbol file
196
197    type Symbol_Record is record
198       Symbol_File   : Name_Id := No_Name;
199       Reference     : Name_Id := No_Name;
200       Symbol_Policy : Policy  := Autonomous;
201    end record;
202    --  Type to keep the symbol data to be used when building a shared library
203
204    No_Symbols : Symbol_Record :=
205      (Symbol_File   => No_Name,
206       Reference     => No_Name,
207       Symbol_Policy => Autonomous);
208    --  The default value of the symbol data
209
210    function Empty_String return Name_Id;
211    --  Return the Name_Id for an empty string ""
212
213    type Project_Id is new Nat;
214    No_Project : constant Project_Id := 0;
215    --  Id of a Project File
216
217    type String_List_Id is new Nat;
218    Nil_String : constant String_List_Id := 0;
219    type String_Element is record
220       Value    : Name_Id        := No_Name;
221       Index    : Int            := 0;
222       Display_Value : Name_Id   := No_Name;
223       Location : Source_Ptr     := No_Location;
224       Flag     : Boolean        := False;
225       Next     : String_List_Id := Nil_String;
226    end record;
227    --  To hold values for string list variables and array elements.
228    --  Component Flag may be used for various purposes. For source
229    --  directories, it indicates if the directory contains Ada source(s).
230
231    package String_Elements is new Table.Table
232      (Table_Component_Type => String_Element,
233       Table_Index_Type     => String_List_Id,
234       Table_Low_Bound      => 1,
235       Table_Initial        => 200,
236       Table_Increment      => 100,
237       Table_Name           => "Prj.String_Elements");
238    --  The table for string elements in string lists
239
240    type Variable_Kind is (Undefined, List, Single);
241    --  Different kinds of variables
242
243    subtype Defined_Variable_Kind is Variable_Kind range List .. Single;
244    --  The defined kinds of variables
245
246    Ignored : constant Variable_Kind := Single;
247    --  Used to indicate that a package declaration must be ignored
248    --  while processing the project tree (unknown package name).
249
250    type Variable_Value (Kind : Variable_Kind := Undefined) is record
251       Project  : Project_Id := No_Project;
252       Location : Source_Ptr := No_Location;
253       Default  : Boolean    := False;
254       case Kind is
255          when Undefined =>
256             null;
257          when List =>
258             Values : String_List_Id := Nil_String;
259          when Single =>
260             Value : Name_Id := No_Name;
261             Index : Int     := 0;
262       end case;
263    end record;
264    --  Values for variables and array elements. Default is True if the
265    --  current value is the default one for the variable
266
267    Nil_Variable_Value : constant Variable_Value :=
268      (Project  => No_Project,
269       Kind     => Undefined,
270       Location => No_Location,
271       Default  => False);
272    --  Value of a non existing variable or array element
273
274    type Variable_Id is new Nat;
275    No_Variable : constant Variable_Id := 0;
276    type Variable is record
277       Next     : Variable_Id := No_Variable;
278       Name     : Name_Id;
279       Value    : Variable_Value;
280    end record;
281    --  To hold the list of variables in a project file and in packages
282
283    package Variable_Elements is new Table.Table
284      (Table_Component_Type => Variable,
285       Table_Index_Type     => Variable_Id,
286       Table_Low_Bound      => 1,
287       Table_Initial        => 200,
288       Table_Increment      => 100,
289       Table_Name           => "Prj.Variable_Elements");
290    --  The table of variable in list of variables
291
292    type Array_Element_Id is new Nat;
293    No_Array_Element : constant Array_Element_Id := 0;
294    type Array_Element is record
295       Index                : Name_Id;
296       Src_Index            : Int := 0;
297       Index_Case_Sensitive : Boolean := True;
298       Value                : Variable_Value;
299       Next                 : Array_Element_Id := No_Array_Element;
300    end record;
301    --  Each Array_Element represents an array element and is linked (Next)
302    --  to the next array element, if any, in the array.
303
304    package Array_Elements is new Table.Table
305      (Table_Component_Type => Array_Element,
306       Table_Index_Type     => Array_Element_Id,
307       Table_Low_Bound      => 1,
308       Table_Initial        => 200,
309       Table_Increment      => 100,
310       Table_Name           => "Prj.Array_Elements");
311    --  The table that contains all array elements
312
313    type Array_Id is new Nat;
314    No_Array : constant Array_Id := 0;
315    type Array_Data is record
316       Name  : Name_Id          := No_Name;
317       Value : Array_Element_Id := No_Array_Element;
318       Next  : Array_Id         := No_Array;
319    end record;
320    --  Each Array_Data value represents an array.
321    --  Value is the id of the first element.
322    --  Next is the id of the next array in the project file or package.
323
324    package Arrays is new Table.Table
325      (Table_Component_Type => Array_Data,
326       Table_Index_Type     => Array_Id,
327       Table_Low_Bound      => 1,
328       Table_Initial        => 200,
329       Table_Increment      => 100,
330       Table_Name           => "Prj.Arrays");
331    --  The table that contains all arrays
332
333    type Package_Id is new Nat;
334    No_Package : constant Package_Id := 0;
335    type Declarations is record
336       Variables  : Variable_Id := No_Variable;
337       Attributes : Variable_Id := No_Variable;
338       Arrays     : Array_Id    := No_Array;
339       Packages   : Package_Id  := No_Package;
340    end record;
341    --  Contains the declarations (variables, single and array attributes,
342    --  packages) for a project or a package in a project.
343
344    No_Declarations : constant Declarations :=
345      (Variables  => No_Variable,
346       Attributes => No_Variable,
347       Arrays     => No_Array,
348       Packages   => No_Package);
349    --  Default value of Declarations: indicates that there is no declarations.
350
351    type Package_Element is record
352       Name   : Name_Id      := No_Name;
353       Decl   : Declarations := No_Declarations;
354       Parent : Package_Id   := No_Package;
355       Next   : Package_Id   := No_Package;
356    end record;
357    --  A package. Includes declarations that may include other packages.
358
359    package Packages is new Table.Table
360      (Table_Component_Type => Package_Element,
361       Table_Index_Type     => Package_Id,
362       Table_Low_Bound      => 1,
363       Table_Initial        => 100,
364       Table_Increment      => 100,
365       Table_Name           => "Prj.Packages");
366    --  The table that contains all packages.
367
368    function Image (Casing : Casing_Type) return String;
369    --  Similar to 'Image (but avoid use of this attribute in compiler)
370
371    function Value (Image : String) return Casing_Type;
372    --  Similar to 'Value (but avoid use of this attribute in compiler)
373    --  Raises Constraint_Error if not a Casing_Type image.
374
375    --  The following record contains data for a naming scheme
376
377    type Naming_Data is record
378       Current_Language : Name_Id := No_Name;
379       --  The programming language being currently considered
380
381       Dot_Replacement : Name_Id := No_Name;
382       --  The string to replace '.' in the source file name (for Ada).
383
384       Dot_Repl_Loc : Source_Ptr := No_Location;
385       --  The position in the project file source where
386       --  Dot_Replacement is defined.
387
388       Casing : Casing_Type := All_Lower_Case;
389       --  The casing of the source file name (for Ada).
390
391       Spec_Suffix : Array_Element_Id := No_Array_Element;
392       --  The string to append to the unit name for the
393       --  source file name of a spec.
394       --  Indexed by the programming language.
395
396       Current_Spec_Suffix : Name_Id := No_Name;
397       --  The "spec" suffix of the current programming language
398
399       Spec_Suffix_Loc : Source_Ptr := No_Location;
400       --  The position in the project file source where
401       --  Current_Spec_Suffix is defined.
402
403       Body_Suffix : Array_Element_Id := No_Array_Element;
404       --  The string to append to the unit name for the
405       --  source file name of a body.
406       --  Indexed by the programming language.
407
408       Current_Body_Suffix : Name_Id := No_Name;
409       --  The "body" suffix of the current programming language
410
411       Body_Suffix_Loc : Source_Ptr := No_Location;
412       --  The position in the project file source where
413       --  Current_Body_Suffix is defined.
414
415       Separate_Suffix : Name_Id := No_Name;
416       --  String to append to unit name for source file name of an Ada subunit.
417
418       Sep_Suffix_Loc : Source_Ptr := No_Location;
419       --  Position in the project file source where Separate_Suffix is defined.
420
421       Specs : Array_Element_Id := No_Array_Element;
422       --  An associative array mapping individual specs to source file names.
423       --  This is specific to Ada.
424
425       Bodies : Array_Element_Id := No_Array_Element;
426       --  An associative array mapping individual bodies to source file names.
427       --  This is specific to Ada.
428
429       Specification_Exceptions : Array_Element_Id := No_Array_Element;
430       --  An associative array listing spec file names that do not have the
431       --  spec suffix. Not used by Ada. Indexed by programming language name.
432
433       Implementation_Exceptions : Array_Element_Id := No_Array_Element;
434       --  An associative array listing body file names that do not have the
435       --  body suffix. Not used by Ada. Indexed by programming language name.
436
437    end record;
438
439    function Standard_Naming_Data return Naming_Data;
440    pragma Inline (Standard_Naming_Data);
441    --  The standard GNAT naming scheme
442
443    function Same_Naming_Scheme
444      (Left, Right : Naming_Data)
445       return        Boolean;
446    --  Returns True if Left and Right are the same naming scheme
447    --  not considering Specs and Bodies.
448
449    type Project_List is new Nat;
450    Empty_Project_List : constant Project_List := 0;
451    --  A list of project files
452
453    type Project_Element is record
454       Project : Project_Id   := No_Project;
455       Next    : Project_List := Empty_Project_List;
456    end record;
457    --  Element in a list of project files. Next is the id of the next
458    --  project file in the list.
459
460    package Project_Lists is new Table.Table
461      (Table_Component_Type => Project_Element,
462       Table_Index_Type     => Project_List,
463       Table_Low_Bound      => 1,
464       Table_Initial        => 100,
465       Table_Increment      => 100,
466       Table_Name           => "Prj.Project_Lists");
467    --  The table that contains the lists of project files
468
469    --  The following record describes a project file representation
470
471    type Project_Data is record
472       Languages : Languages_In_Project := No_Languages;
473       --  Indicate the different languages of the source of this project
474
475       Impl_Suffixes : Impl_Suffix_Array := No_Impl_Suffixes;
476       --  The source suffixes of the different languages other than Ada
477
478       First_Referred_By  : Project_Id := No_Project;
479       --  The project, if any, that was the first to be known
480       --  as importing or extending this project.
481       --  Set by Prj.Proc.Process.
482
483       Name : Name_Id := No_Name;
484       --  The name of the project. Set by Prj.Proc.Process.
485
486       Path_Name : Name_Id := No_Name;
487       --  The path name of the project file. Set by Prj.Proc.Process.
488
489       Display_Path_Name : Name_Id := No_Name;
490       --  The path name used for display purposes. May be different from
491       --  Path_Name for platforms where the file names are case-insensitive.
492
493       Virtual : Boolean := False;
494       --  True for virtual extending projects
495
496       Location : Source_Ptr := No_Location;
497       --  The location in the project file source of the reserved word
498       --  project. Set by Prj.Proc.Process.
499
500       Mains : String_List_Id := Nil_String;
501       --  List of mains specified by attribute Main. Set by Prj.Nmsc.Ada_Check.
502
503       Directory : Name_Id := No_Name;
504       --  Directory where the project file resides. Set by Prj.Proc.Process.
505
506       Display_Directory : Name_Id := No_Name;
507
508       Dir_Path : String_Access;
509       --  Same as Directory, but as an access to String.
510       --  Set by Make.Compile_Sources.Collect_Arguments_And_Compile.
511
512       Library : Boolean := False;
513       --  True if this is a library project.
514       --  Set by Prj.Nmsc.Language_Independent_Check.
515
516       Library_Dir : Name_Id := No_Name;
517       --  If a library project, directory where resides the library
518       --  Set by Prj.Nmsc.Language_Independent_Check.
519
520       Display_Library_Dir : Name_Id := No_Name;
521       --  The name of the library directory, for display purposes.
522       --  May be different from Library_Dir for platforms where the file names
523       --  are case-insensitive.
524
525       Library_Src_Dir : Name_Id := No_Name;
526       --  If a library project, directory where the sources and the ALI files
527       --  of the library are copied. By default, if attribute Library_Src_Dir
528       --  is not specified, sources are not copied anywhere and ALI files are
529       --  copied in the Library Directory.
530       --  Set by Prj.Nmsc.Language_Independent_Check.
531
532       Display_Library_Src_Dir : Name_Id := No_Name;
533       --  The name of the library source directory, for display purposes.
534       --  May be different from Library_Src_Dir for platforms where the file
535       --  names are case-insensitive.
536
537       Library_Name : Name_Id := No_Name;
538       --  If a library project, name of the library
539       --  Set by Prj.Nmsc.Language_Independent_Check.
540
541       Library_Kind : Lib_Kind := Static;
542       --  If a library project, kind of library
543       --  Set by Prj.Nmsc.Language_Independent_Check.
544
545       Lib_Internal_Name : Name_Id := No_Name;
546       --  If a library project, internal name store inside the library
547       --  Set by Prj.Nmsc.Language_Independent_Check.
548
549       Standalone_Library : Boolean := False;
550       --  Indicate that this is a Standalone Library Project File.
551       --  Set by Prj.Nmsc.Ada_Check.
552
553       Lib_Interface_ALIs : String_List_Id := Nil_String;
554       --  For Standalone Library Project Files, indicate the list
555       --  of Interface ALI files. Set by Prj.Nmsc.Ada_Check.
556
557       Lib_Auto_Init : Boolean := False;
558       --  For non static Standalone Library Project Files, indicate if
559       --  the library initialisation should be automatic.
560
561       Symbol_Data : Symbol_Record := No_Symbols;
562       --  Symbol file name, reference symbol file name, symbol policy
563
564       Ada_Sources_Present : Boolean := True;
565       --  A flag that indicates if there are Ada sources in this project file.
566       --  There are no sources if any of the following is true:
567       --    1) Source_Dirs is specified as an empty list
568       --    2) Source_Files is specified as an empty list
569       --    3) Ada is not in the list of the specified Languages
570
571       Other_Sources_Present : Boolean := True;
572       --  A flag that indicates that there are non-Ada sources in this project
573
574       Sources : String_List_Id := Nil_String;
575       --  The list of all the source file names. Set by
576       --  Prj.Nmsc.Check_Ada_Naming_Scheme.
577
578       First_Other_Source : Other_Source_Id := No_Other_Source;
579       Last_Other_Source  : Other_Source_Id := No_Other_Source;
580       --  Head and tail of the list of sources of languages other than Ada
581
582       Imported_Directories_Switches : Argument_List_Access := null;
583       --  List of the -I switches to be used when compiling sources of
584       --  languages other than Ada.
585
586       Include_Path : String_Access := null;
587       --  Value to be used as CPATH, when using a GCC, instead of a list of
588       --  -I switches.
589
590       Include_Data_Set : Boolean := False;
591       --  Set True when Imported_Directories_Switches or Include_Path are set
592
593       Source_Dirs : String_List_Id := Nil_String;
594       --  The list of all the source directories.
595       --  Set by Prj.Nmsc.Language_Independent_Check.
596
597       Known_Order_Of_Source_Dirs : Boolean := True;
598       --  False, if there is any /** in the Source_Dirs, because in this case
599       --  the ordering of the source subdirs depend on the OS. If True,
600       --  duplicate file names in the same project file are allowed.
601
602       Object_Directory : Name_Id := No_Name;
603       --  The object directory of this project file.
604       --  Set by Prj.Nmsc.Language_Independent_Check.
605
606       Display_Object_Dir : Name_Id := No_Name;
607       --  The name of the object directory, for display purposes.
608       --  May be different from Object_Directory for platforms where the file
609       --  names are case-insensitive.
610
611       Exec_Directory : Name_Id := No_Name;
612       --  The exec directory of this project file. Default is equal to
613       --  Object_Directory. Set by Prj.Nmsc.Language_Independent_Check.
614
615       Display_Exec_Dir : Name_Id := No_Name;
616       --  The name of the exec directory, for display purposes.
617       --  May be different from Exec_Directory for platforms where the file
618       --  names are case-insensitive.
619
620       Extends : Project_Id := No_Project;
621       --  The reference of the project file, if any, that this
622       --  project file extends. Set by Prj.Proc.Process.
623
624       Extended_By : Project_Id := No_Project;
625       --  The reference of the project file, if any, that
626       --  extends this project file. Set by Prj.Proc.Process.
627
628       Naming : Naming_Data := Standard_Naming_Data;
629       --  The naming scheme of this project file.
630       --  Set by Prj.Nmsc.Check_Naming_Scheme.
631
632       Decl : Declarations := No_Declarations;
633       --  The declarations (variables, attributes and packages) of this
634       --  project file. Set by Prj.Proc.Process.
635
636       Imported_Projects : Project_List := Empty_Project_List;
637       --  The list of all directly imported projects, if any.
638       --  Set by Prj.Proc.Process.
639
640       Ada_Include_Path : String_Access := null;
641       --  The cached value of ADA_INCLUDE_PATH for this project file.
642       --  Do not use this field directly outside of the compiler, use
643       --  Prj.Env.Ada_Include_Path instead. Set by Prj.Env.Ada_Include_Path.
644
645       Ada_Objects_Path : String_Access := null;
646       --  The cached value of ADA_OBJECTS_PATH for this project file.
647       --  Do not use this field directly outside of the compiler, use
648       --  Prj.Env.Ada_Objects_Path instead. Set by Prj.Env.Ada_Objects_Path
649
650       Include_Path_File : Name_Id := No_Name;
651       --  The cached value of the source path temp file for this project file.
652       --  Set by gnatmake (Prj.Env.Set_Ada_Paths).
653
654       Objects_Path_File_With_Libs : Name_Id := No_Name;
655       --  The cached value of the object path temp file (including library
656       --  dirs) for this project file. Set by gnatmake (Prj.Env.Set_Ada_Paths).
657
658       Objects_Path_File_Without_Libs : Name_Id := No_Name;
659       --  The cached value of the object path temp file (excluding library
660       --  dirs) for this project file. Set by gnatmake (Prj.Env.Set_Ada_Paths).
661
662       Config_File_Name : Name_Id := No_Name;
663       --  The name of the configuration pragmas file, if any.
664       --  Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
665
666       Config_File_Temp : Boolean := False;
667       --  An indication that the configuration pragmas file is
668       --  a temporary file that must be deleted at the end.
669       --  Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
670
671       Config_Checked : Boolean := False;
672       --  A flag to avoid checking repetitively the configuration pragmas file.
673       --  Set by gnatmake (Prj.Env.Create_Config_Pragmas_File).
674
675       Language_Independent_Checked : Boolean := False;
676       --  A flag that indicates that the project file has been checked
677       --  for language independent features: Object_Directory,
678       --  Source_Directories, Library, non empty Naming Suffixs.
679
680       Checked : Boolean := False;
681       --  A flag to avoid checking repetitively the naming scheme of
682       --  this project file. Set by Prj.Nmsc.Check_Ada_Naming_Scheme.
683
684       Seen                           : Boolean := False;
685       --  A flag to mark a project as "visited" to avoid processing the same
686       --  project several time.
687
688       Need_To_Build_Lib : Boolean := False;
689       --  Indicates that the library of a Library Project needs to be built or
690       --  rebuilt.
691
692       Depth : Natural := 0;
693       --  The maximum depth of a project in the project graph.
694       --  Depth of main project is 0.
695
696       Unkept_Comments : Boolean := False;
697       --  True if there are comments in the project sources that cannot
698       --  be kept in the project tree.
699
700    end record;
701
702    function Empty_Project return Project_Data;
703    --  Return the representation of an empty project
704
705    package Projects is new Table.Table (
706      Table_Component_Type => Project_Data,
707      Table_Index_Type     => Project_Id,
708      Table_Low_Bound      => 1,
709      Table_Initial        => 100,
710      Table_Increment      => 100,
711      Table_Name           => "Prj.Projects");
712    --  The set of all project files
713
714    type Put_Line_Access is access procedure
715      (Line    : String;
716       Project : Project_Id);
717    --  Use to customize error reporting in Prj.Proc and Prj.Nmsc
718
719    procedure Expect (The_Token : Token_Type; Token_Image : String);
720    --  Check that the current token is The_Token. If it is not, then
721    --  output an error message.
722
723    procedure Initialize;
724    --  This procedure must be called before using any services from the Prj
725    --  hierarchy. Namet.Initialize must be called before Prj.Initialize.
726
727    procedure Reset;
728    --  This procedure resets all the tables that are used when processing a
729    --  project file tree. Initialize must be called before the call to Reset.
730
731    procedure Register_Default_Naming_Scheme
732      (Language            : Name_Id;
733       Default_Spec_Suffix : Name_Id;
734       Default_Body_Suffix : Name_Id);
735    --  Register the default suffixs for a given language. These extensions
736    --  will be ignored if the user has specified a new naming scheme in a
737    --  project file.
738    --
739    --  Otherwise, this information will be automatically added to Naming_Data
740    --  when a project is processed, in the lists Spec_Suffix and Body_Suffix.
741
742    generic
743       type State is limited private;
744       with procedure Action
745         (Project    : Project_Id;
746          With_State : in out State);
747    procedure For_Every_Project_Imported
748      (By         : Project_Id;
749       With_State : in out State);
750    --  Call Action for each project imported directly or indirectly by project
751    --  By. Action is called according to the order of importation: if A
752    --  imports B, directly or indirectly, Action will be called for A before
753    --  it is called for B. With_State may be used by Action to choose a
754    --  behavior or to report some global result.
755
756 private
757
758    Initial_Buffer_Size : constant := 100;
759    --  Initial size for extensible buffer used below
760
761    Buffer : String_Access := new String (1 .. Initial_Buffer_Size);
762    --  An extensible character buffer to store names. Used in Prj.Part and
763    --  Prj.Strt.
764
765    Buffer_Last : Natural := 0;
766    --  The index of the last character in the Buffer
767
768    Current_Packages_To_Check : String_List_Access := All_Packages;
769    --  Global variable, set by Prj.Part.Parse, used by Prj.Dect.
770
771    procedure Add_To_Buffer (S : String);
772    --  Append a String to the Buffer
773
774 end Prj;