2009-10-01 Tobias Burnus <burnus@net-b.de>
[official-gcc/alias-decl.git] / gcc / ada / prj-tree.ads
blob96a28279c32a6708aa4b165a6153578cddf0ea4b
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- P R J . T R E E --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2001-2009, 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 3, 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 COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 -- This package defines the structure of the Project File tree
28 with GNAT.Dynamic_HTables;
29 with GNAT.Dynamic_Tables;
31 with Table;
33 with Prj.Attr; use Prj.Attr;
35 package Prj.Tree is
37 type Project_Node_Tree_Data;
38 type Project_Node_Tree_Ref is access all Project_Node_Tree_Data;
39 -- Type to designate a project node tree, so that several project node
40 -- trees can coexist in memory.
42 Project_Nodes_Initial : constant := 1_000;
43 Project_Nodes_Increment : constant := 100;
44 -- Allocation parameters for initializing and extending number
45 -- of nodes in table Tree_Private_Part.Project_Nodes
47 Project_Node_Low_Bound : constant := 0;
48 Project_Node_High_Bound : constant := 099_999_999;
49 -- Range of values for project node id's (in practice infinite)
51 type Project_Node_Id is range
52 Project_Node_Low_Bound .. Project_Node_High_Bound;
53 -- The index of table Tree_Private_Part.Project_Nodes
55 Empty_Node : constant Project_Node_Id := Project_Node_Low_Bound;
56 -- Designates no node in table Project_Nodes
58 First_Node_Id : constant Project_Node_Id := Project_Node_Low_Bound + 1;
60 subtype Variable_Node_Id is Project_Node_Id;
61 -- Used to designate a node whose expected kind is one of
62 -- N_Typed_Variable_Declaration, N_Variable_Declaration or
63 -- N_Variable_Reference.
65 subtype Package_Declaration_Id is Project_Node_Id;
66 -- Used to designate a node whose expected kind is N_Project_Declaration
68 type Project_Node_Kind is
69 (N_Project,
70 N_With_Clause,
71 N_Project_Declaration,
72 N_Declarative_Item,
73 N_Package_Declaration,
74 N_String_Type_Declaration,
75 N_Literal_String,
76 N_Attribute_Declaration,
77 N_Typed_Variable_Declaration,
78 N_Variable_Declaration,
79 N_Expression,
80 N_Term,
81 N_Literal_String_List,
82 N_Variable_Reference,
83 N_External_Value,
84 N_Attribute_Reference,
85 N_Case_Construction,
86 N_Case_Item,
87 N_Comment_Zones,
88 N_Comment);
89 -- Each node in the tree is of a Project_Node_Kind. For the signification
90 -- of the fields in each node of Project_Node_Kind, look at package
91 -- Tree_Private_Part.
93 function Present (Node : Project_Node_Id) return Boolean;
94 pragma Inline (Present);
95 -- Return True if Node /= Empty_Node
97 function No (Node : Project_Node_Id) return Boolean;
98 pragma Inline (No);
99 -- Return True if Node = Empty_Node
101 procedure Initialize (Tree : Project_Node_Tree_Ref);
102 -- Initialize the Project File tree: empty the Project_Nodes table
103 -- and reset the Projects_Htable.
105 function Default_Project_Node
106 (In_Tree : Project_Node_Tree_Ref;
107 Of_Kind : Project_Node_Kind;
108 And_Expr_Kind : Variable_Kind := Undefined) return Project_Node_Id;
109 -- Returns a Project_Node_Record with the specified Kind and Expr_Kind. All
110 -- the other components have default nil values.
111 -- To create a node for a project itself, see Create_Project below instead
113 function Hash (N : Project_Node_Id) return Header_Num;
114 -- Used for hash tables where the key is a Project_Node_Id
116 function Imported_Or_Extended_Project_Of
117 (Project : Project_Node_Id;
118 In_Tree : Project_Node_Tree_Ref;
119 With_Name : Name_Id) return Project_Node_Id;
120 -- Return the node of a project imported or extended by project Project and
121 -- whose name is With_Name. Return Empty_Node if there is no such project.
123 --------------
124 -- Comments --
125 --------------
127 type Comment_State is private;
128 -- A type to store the values of several global variables related to
129 -- comments.
131 procedure Save (S : out Comment_State);
132 -- Save in variable S the comment state. Called before scanning a new
133 -- project file.
135 procedure Restore_And_Free (S : in out Comment_State);
136 -- Restore the comment state to a previously saved value. Called after
137 -- scanning a project file. Frees the memory occupied by S
139 procedure Reset_State;
140 -- Set the comment state to its initial value. Called before scanning a
141 -- new project file.
143 function There_Are_Unkept_Comments return Boolean;
144 -- Indicates that some of the comments in a project file could not be
145 -- stored in the parse tree.
147 procedure Set_Previous_Line_Node (To : Project_Node_Id);
148 -- Indicate the node on the previous line. If there are comments
149 -- immediately following this line, then they should be associated with
150 -- this node.
152 procedure Set_Previous_End_Node (To : Project_Node_Id);
153 -- Indicate that on the previous line the "end" belongs to node To.
154 -- If there are comments immediately following this "end" line, they
155 -- should be associated with this node.
157 procedure Set_End_Of_Line (To : Project_Node_Id);
158 -- Indicate the node on the current line. If there is an end of line
159 -- comment, then it should be associated with this node.
161 procedure Set_Next_End_Node (To : Project_Node_Id);
162 -- Put node To on the top of the end node stack. When an END line is found
163 -- with this node on the top of the end node stack, the comments, if any,
164 -- immediately preceding this "end" line will be associated with this node.
166 procedure Remove_Next_End_Node;
167 -- Remove the top of the end node stack
169 ------------------------
170 -- Comment Processing --
171 ------------------------
173 type Comment_Data is record
174 Value : Name_Id := No_Name;
175 Follows_Empty_Line : Boolean := False;
176 Is_Followed_By_Empty_Line : Boolean := False;
177 end record;
178 -- Component type for Comments Table below
180 package Comments is new Table.Table
181 (Table_Component_Type => Comment_Data,
182 Table_Index_Type => Natural,
183 Table_Low_Bound => 1,
184 Table_Initial => 10,
185 Table_Increment => 100,
186 Table_Name => "Prj.Tree.Comments");
187 -- A table to store the comments that may be stored is the tree
189 procedure Scan (In_Tree : Project_Node_Tree_Ref);
190 -- Scan the tokens and accumulate comments
192 type Comment_Location is
193 (Before, After, Before_End, After_End, End_Of_Line);
194 -- Used in call to Add_Comments below
196 procedure Add_Comments
197 (To : Project_Node_Id;
198 In_Tree : Project_Node_Tree_Ref;
199 Where : Comment_Location);
200 -- Add comments to this node
202 ----------------------
203 -- Access Functions --
204 ----------------------
206 -- The following query functions are part of the abstract interface
207 -- of the Project File tree. They provide access to fields of a project.
209 -- The access functions should be called only with valid arguments.
210 -- For each function the condition of validity is specified. If an access
211 -- function is called with invalid arguments, then exception
212 -- Assertion_Error is raised if assertions are enabled, otherwise the
213 -- behaviour is not defined and may result in a crash.
215 function Name_Of
216 (Node : Project_Node_Id;
217 In_Tree : Project_Node_Tree_Ref) return Name_Id;
218 pragma Inline (Name_Of);
219 -- Valid for all non empty nodes. May return No_Name for nodes that have
220 -- no names.
222 function Kind_Of
223 (Node : Project_Node_Id;
224 In_Tree : Project_Node_Tree_Ref) return Project_Node_Kind;
225 pragma Inline (Kind_Of);
226 -- Valid for all non empty nodes
228 function Location_Of
229 (Node : Project_Node_Id;
230 In_Tree : Project_Node_Tree_Ref) return Source_Ptr;
231 pragma Inline (Location_Of);
232 -- Valid for all non empty nodes
234 function First_Comment_After
235 (Node : Project_Node_Id;
236 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
237 -- Valid only for N_Comment_Zones nodes
239 function First_Comment_After_End
240 (Node : Project_Node_Id;
241 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
242 -- Valid only for N_Comment_Zones nodes
244 function First_Comment_Before
245 (Node : Project_Node_Id;
246 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
247 -- Valid only for N_Comment_Zones nodes
249 function First_Comment_Before_End
250 (Node : Project_Node_Id;
251 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
252 -- Valid only for N_Comment_Zones nodes
254 function Next_Comment
255 (Node : Project_Node_Id;
256 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
257 -- Valid only for N_Comment nodes
259 function End_Of_Line_Comment
260 (Node : Project_Node_Id;
261 In_Tree : Project_Node_Tree_Ref) return Name_Id;
262 -- Valid only for non empty nodes
264 function Follows_Empty_Line
265 (Node : Project_Node_Id;
266 In_Tree : Project_Node_Tree_Ref) return Boolean;
267 -- Valid only for N_Comment nodes
269 function Is_Followed_By_Empty_Line
270 (Node : Project_Node_Id;
271 In_Tree : Project_Node_Tree_Ref) return Boolean;
272 -- Valid only for N_Comment nodes
274 function Parent_Project_Of
275 (Node : Project_Node_Id;
276 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
277 pragma Inline (Parent_Project_Of);
278 -- Valid only for N_Project nodes
280 function Project_File_Includes_Unkept_Comments
281 (Node : Project_Node_Id;
282 In_Tree : Project_Node_Tree_Ref) return Boolean;
283 -- Valid only for N_Project nodes
285 function Directory_Of
286 (Node : Project_Node_Id;
287 In_Tree : Project_Node_Tree_Ref) return Path_Name_Type;
288 pragma Inline (Directory_Of);
289 -- Returns the directory that contains the project file. This always ends
290 -- with a directory separator. Only valid for N_Project nodes.
292 function Expression_Kind_Of
293 (Node : Project_Node_Id;
294 In_Tree : Project_Node_Tree_Ref) return Variable_Kind;
295 pragma Inline (Expression_Kind_Of);
296 -- Only valid for N_Literal_String, N_Attribute_Declaration,
297 -- N_Variable_Declaration, N_Typed_Variable_Declaration, N_Expression,
298 -- N_Term, N_Variable_Reference or N_Attribute_Reference nodes.
300 function Is_Extending_All
301 (Node : Project_Node_Id;
302 In_Tree : Project_Node_Tree_Ref) return Boolean;
303 pragma Inline (Is_Extending_All);
304 -- Only valid for N_Project and N_With_Clause
306 function Is_Not_Last_In_List
307 (Node : Project_Node_Id;
308 In_Tree : Project_Node_Tree_Ref) return Boolean;
309 pragma Inline (Is_Not_Last_In_List);
310 -- Only valid for N_With_Clause
312 function First_Variable_Of
313 (Node : Project_Node_Id;
314 In_Tree : Project_Node_Tree_Ref) return Variable_Node_Id;
315 pragma Inline (First_Variable_Of);
316 -- Only valid for N_Project or N_Package_Declaration nodes
318 function First_Package_Of
319 (Node : Project_Node_Id;
320 In_Tree : Project_Node_Tree_Ref) return Package_Declaration_Id;
321 pragma Inline (First_Package_Of);
322 -- Only valid for N_Project nodes
324 function Package_Id_Of
325 (Node : Project_Node_Id;
326 In_Tree : Project_Node_Tree_Ref) return Package_Node_Id;
327 pragma Inline (Package_Id_Of);
328 -- Only valid for N_Package_Declaration nodes
330 function Path_Name_Of
331 (Node : Project_Node_Id;
332 In_Tree : Project_Node_Tree_Ref) return Path_Name_Type;
333 pragma Inline (Path_Name_Of);
334 -- Only valid for N_Project and N_With_Clause nodes
336 function String_Value_Of
337 (Node : Project_Node_Id;
338 In_Tree : Project_Node_Tree_Ref) return Name_Id;
339 pragma Inline (String_Value_Of);
340 -- Only valid for N_With_Clause, N_Literal_String nodes or N_Comment.
341 -- For a N_With_Clause created automatically for a virtual extending
342 -- project, No_Name is returned.
344 function Source_Index_Of
345 (Node : Project_Node_Id;
346 In_Tree : Project_Node_Tree_Ref) return Int;
347 pragma Inline (Source_Index_Of);
348 -- Only valid for N_Literal_String and N_Attribute_Declaration nodes
350 function First_With_Clause_Of
351 (Node : Project_Node_Id;
352 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
353 pragma Inline (First_With_Clause_Of);
354 -- Only valid for N_Project nodes
356 function Project_Declaration_Of
357 (Node : Project_Node_Id;
358 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
359 pragma Inline (Project_Declaration_Of);
360 -- Only valid for N_Project nodes
362 function Project_Qualifier_Of
363 (Node : Project_Node_Id;
364 In_Tree : Project_Node_Tree_Ref) return Project_Qualifier;
365 pragma Inline (Project_Qualifier_Of);
366 -- Only valid for N_Project nodes
368 function Extending_Project_Of
369 (Node : Project_Node_Id;
370 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
371 pragma Inline (Extending_Project_Of);
372 -- Only valid for N_Project_Declaration nodes
374 function First_String_Type_Of
375 (Node : Project_Node_Id;
376 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
377 pragma Inline (First_String_Type_Of);
378 -- Only valid for N_Project nodes
380 function Extended_Project_Path_Of
381 (Node : Project_Node_Id;
382 In_Tree : Project_Node_Tree_Ref) return Path_Name_Type;
383 pragma Inline (Extended_Project_Path_Of);
384 -- Only valid for N_With_Clause nodes
386 function Project_Node_Of
387 (Node : Project_Node_Id;
388 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
389 pragma Inline (Project_Node_Of);
390 -- Only valid for N_With_Clause, N_Variable_Reference and
391 -- N_Attribute_Reference nodes.
393 function Non_Limited_Project_Node_Of
394 (Node : Project_Node_Id;
395 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
396 pragma Inline (Non_Limited_Project_Node_Of);
397 -- Only valid for N_With_Clause nodes. Returns Empty_Node for limited
398 -- imported project files, otherwise returns the same result as
399 -- Project_Node_Of.
401 function Next_With_Clause_Of
402 (Node : Project_Node_Id;
403 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
404 pragma Inline (Next_With_Clause_Of);
405 -- Only valid for N_With_Clause nodes
407 function First_Declarative_Item_Of
408 (Node : Project_Node_Id;
409 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
410 pragma Inline (First_Declarative_Item_Of);
411 -- Only valid for N_With_Clause nodes
413 function Extended_Project_Of
414 (Node : Project_Node_Id;
415 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
416 pragma Inline (Extended_Project_Of);
417 -- Only valid for N_Project_Declaration nodes
419 function Current_Item_Node
420 (Node : Project_Node_Id;
421 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
422 pragma Inline (Current_Item_Node);
423 -- Only valid for N_Declarative_Item nodes
425 function Next_Declarative_Item
426 (Node : Project_Node_Id;
427 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
428 pragma Inline (Next_Declarative_Item);
429 -- Only valid for N_Declarative_Item node
431 function Project_Of_Renamed_Package_Of
432 (Node : Project_Node_Id;
433 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
434 pragma Inline (Project_Of_Renamed_Package_Of);
435 -- Only valid for N_Package_Declaration nodes. May return Empty_Node.
437 function Next_Package_In_Project
438 (Node : Project_Node_Id;
439 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
440 pragma Inline (Next_Package_In_Project);
441 -- Only valid for N_Package_Declaration nodes
443 function First_Literal_String
444 (Node : Project_Node_Id;
445 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
446 pragma Inline (First_Literal_String);
447 -- Only valid for N_String_Type_Declaration nodes
449 function Next_String_Type
450 (Node : Project_Node_Id;
451 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
452 pragma Inline (Next_String_Type);
453 -- Only valid for N_String_Type_Declaration nodes
455 function Next_Literal_String
456 (Node : Project_Node_Id;
457 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
458 pragma Inline (Next_Literal_String);
459 -- Only valid for N_Literal_String nodes
461 function Expression_Of
462 (Node : Project_Node_Id;
463 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
464 pragma Inline (Expression_Of);
465 -- Only valid for N_Attribute_Declaration, N_Typed_Variable_Declaration
466 -- or N_Variable_Declaration nodes
468 function Associative_Project_Of
469 (Node : Project_Node_Id;
470 In_Tree : Project_Node_Tree_Ref)
471 return Project_Node_Id;
472 pragma Inline (Associative_Project_Of);
473 -- Only valid for N_Attribute_Declaration nodes
475 function Associative_Package_Of
476 (Node : Project_Node_Id;
477 In_Tree : Project_Node_Tree_Ref)
478 return Project_Node_Id;
479 pragma Inline (Associative_Package_Of);
480 -- Only valid for N_Attribute_Declaration nodes
482 function Value_Is_Valid
483 (For_Typed_Variable : Project_Node_Id;
484 In_Tree : Project_Node_Tree_Ref;
485 Value : Name_Id) return Boolean;
486 pragma Inline (Value_Is_Valid);
487 -- Only valid for N_Typed_Variable_Declaration. Returns True if Value is
488 -- in the list of allowed strings for For_Typed_Variable. False otherwise.
490 function Associative_Array_Index_Of
491 (Node : Project_Node_Id;
492 In_Tree : Project_Node_Tree_Ref) return Name_Id;
493 pragma Inline (Associative_Array_Index_Of);
494 -- Only valid for N_Attribute_Declaration and N_Attribute_Reference.
495 -- Returns No_String for non associative array attributes.
497 function Next_Variable
498 (Node : Project_Node_Id;
499 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
500 pragma Inline (Next_Variable);
501 -- Only valid for N_Typed_Variable_Declaration or N_Variable_Declaration
502 -- nodes.
504 function First_Term
505 (Node : Project_Node_Id;
506 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
507 pragma Inline (First_Term);
508 -- Only valid for N_Expression nodes
510 function Next_Expression_In_List
511 (Node : Project_Node_Id;
512 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
513 pragma Inline (Next_Expression_In_List);
514 -- Only valid for N_Expression nodes
516 function Current_Term
517 (Node : Project_Node_Id;
518 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
519 pragma Inline (Current_Term);
520 -- Only valid for N_Term nodes
522 function Next_Term
523 (Node : Project_Node_Id;
524 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
525 pragma Inline (Next_Term);
526 -- Only valid for N_Term nodes
528 function First_Expression_In_List
529 (Node : Project_Node_Id;
530 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
531 pragma Inline (First_Expression_In_List);
532 -- Only valid for N_Literal_String_List nodes
534 function Package_Node_Of
535 (Node : Project_Node_Id;
536 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
537 pragma Inline (Package_Node_Of);
538 -- Only valid for N_Variable_Reference or N_Attribute_Reference nodes.
539 -- May return Empty_Node.
541 function String_Type_Of
542 (Node : Project_Node_Id;
543 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
544 pragma Inline (String_Type_Of);
545 -- Only valid for N_Variable_Reference or N_Typed_Variable_Declaration
546 -- nodes.
548 function External_Reference_Of
549 (Node : Project_Node_Id;
550 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
551 pragma Inline (External_Reference_Of);
552 -- Only valid for N_External_Value nodes
554 function External_Default_Of
555 (Node : Project_Node_Id;
556 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
557 pragma Inline (External_Default_Of);
558 -- Only valid for N_External_Value nodes
560 function Case_Variable_Reference_Of
561 (Node : Project_Node_Id;
562 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
563 pragma Inline (Case_Variable_Reference_Of);
564 -- Only valid for N_Case_Construction nodes
566 function First_Case_Item_Of
567 (Node : Project_Node_Id;
568 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
569 pragma Inline (First_Case_Item_Of);
570 -- Only valid for N_Case_Construction nodes
572 function First_Choice_Of
573 (Node : Project_Node_Id;
574 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
575 pragma Inline (First_Choice_Of);
576 -- Return the first choice in a N_Case_Item, or Empty_Node if
577 -- this is when others.
579 function Next_Case_Item
580 (Node : Project_Node_Id;
581 In_Tree : Project_Node_Tree_Ref) return Project_Node_Id;
582 pragma Inline (Next_Case_Item);
583 -- Only valid for N_Case_Item nodes
585 function Case_Insensitive
586 (Node : Project_Node_Id;
587 In_Tree : Project_Node_Tree_Ref) return Boolean;
588 -- Only valid for N_Attribute_Declaration and N_Attribute_Reference nodes
590 -----------------------
591 -- Create procedures --
592 -----------------------
593 -- The following procedures are used to edit a project file tree. They are
594 -- slightly higher-level than the Set_* procedures below
596 function Create_Project
597 (In_Tree : Project_Node_Tree_Ref;
598 Name : Name_Id;
599 Full_Path : Path_Name_Type;
600 Is_Config_File : Boolean := False) return Project_Node_Id;
601 -- Create a new node for a project and register it in the tree so that it
602 -- can be retrieved later on.
604 function Create_Package
605 (Tree : Project_Node_Tree_Ref;
606 Project : Project_Node_Id;
607 Pkg : String) return Project_Node_Id;
608 -- Create a new package in Project. If the package already exists, it is
609 -- returned. The name of the package *must* be lower-cases, or none of its
610 -- attributes will be recognized.
612 function Create_Attribute
613 (Tree : Project_Node_Tree_Ref;
614 Prj_Or_Pkg : Project_Node_Id;
615 Name : Name_Id;
616 Index_Name : Name_Id := No_Name;
617 Kind : Variable_Kind := List;
618 At_Index : Integer := 0) return Project_Node_Id;
619 -- Create a new attribute. The new declaration is added at the end of the
620 -- declarative item list for Prj_Or_Pkg (a project or a package), but
621 -- before any package declaration). No addition is done if Prj_Or_Pkg is
622 -- Empty_Node. If Index_Name is not "", then if creates an attribute value
623 -- for a specific index. At_Index is used for the " at <idx>" in the naming
624 -- exceptions. Use Set_Expression_Of to set the value of the attribute (in
625 -- which case Enclose_In_Expression might be useful)
627 function Create_Literal_String
628 (Str : Namet.Name_Id;
629 Tree : Project_Node_Tree_Ref) return Project_Node_Id;
630 -- Create a literal string whose value is Str
632 procedure Add_At_End
633 (Tree : Project_Node_Tree_Ref;
634 Parent : Project_Node_Id;
635 Expr : Project_Node_Id;
636 Add_Before_First_Pkg : Boolean := False;
637 Add_Before_First_Case : Boolean := False);
638 -- Add a new declarative item in the list in Parent. This new declarative
639 -- item will contain Expr (unless Expr is already a declarative item, in
640 -- which case it is added directly to the list). The new item is inserted
641 -- at the end of the list, unless Add_Before_First_Pkg is True. In the
642 -- latter case, it is added just before the first case construction is
643 -- seen, or before the first package (this assumes that all packages are
644 -- found at the end of the project, which isn't true in the general case
645 -- unless you have normalized the project to match this description).
647 function Enclose_In_Expression
648 (Node : Project_Node_Id;
649 Tree : Project_Node_Tree_Ref) return Project_Node_Id;
650 -- Enclose the Node inside a N_Expression node, and return this expression
652 --------------------
653 -- Set Procedures --
654 --------------------
656 -- The following procedures are part of the abstract interface of the
657 -- Project File tree.
659 -- Each Set_* procedure is valid only for the same Project_Node_Kind
660 -- nodes as the corresponding query function above.
661 -- These are very low-level, and manipulate the tree itself directly. You
662 -- should look at the Create_* procedure instead if you want to use higher
663 -- level constructs
665 procedure Set_Name_Of
666 (Node : Project_Node_Id;
667 In_Tree : Project_Node_Tree_Ref;
668 To : Name_Id);
669 pragma Inline (Set_Name_Of);
671 procedure Set_Kind_Of
672 (Node : Project_Node_Id;
673 In_Tree : Project_Node_Tree_Ref;
674 To : Project_Node_Kind);
675 pragma Inline (Set_Kind_Of);
677 procedure Set_Location_Of
678 (Node : Project_Node_Id;
679 In_Tree : Project_Node_Tree_Ref;
680 To : Source_Ptr);
681 pragma Inline (Set_Location_Of);
683 procedure Set_First_Comment_After
684 (Node : Project_Node_Id;
685 In_Tree : Project_Node_Tree_Ref;
686 To : Project_Node_Id);
687 pragma Inline (Set_First_Comment_After);
689 procedure Set_First_Comment_After_End
690 (Node : Project_Node_Id;
691 In_Tree : Project_Node_Tree_Ref;
692 To : Project_Node_Id);
693 pragma Inline (Set_First_Comment_After_End);
695 procedure Set_First_Comment_Before
696 (Node : Project_Node_Id;
697 In_Tree : Project_Node_Tree_Ref;
698 To : Project_Node_Id);
699 pragma Inline (Set_First_Comment_Before);
701 procedure Set_First_Comment_Before_End
702 (Node : Project_Node_Id;
703 In_Tree : Project_Node_Tree_Ref;
704 To : Project_Node_Id);
705 pragma Inline (Set_First_Comment_Before_End);
707 procedure Set_Next_Comment
708 (Node : Project_Node_Id;
709 In_Tree : Project_Node_Tree_Ref;
710 To : Project_Node_Id);
711 pragma Inline (Set_Next_Comment);
713 procedure Set_Parent_Project_Of
714 (Node : Project_Node_Id;
715 In_Tree : Project_Node_Tree_Ref;
716 To : Project_Node_Id);
718 procedure Set_Project_File_Includes_Unkept_Comments
719 (Node : Project_Node_Id;
720 In_Tree : Project_Node_Tree_Ref;
721 To : Boolean);
723 procedure Set_Directory_Of
724 (Node : Project_Node_Id;
725 In_Tree : Project_Node_Tree_Ref;
726 To : Path_Name_Type);
727 pragma Inline (Set_Directory_Of);
729 procedure Set_Expression_Kind_Of
730 (Node : Project_Node_Id;
731 In_Tree : Project_Node_Tree_Ref;
732 To : Variable_Kind);
733 pragma Inline (Set_Expression_Kind_Of);
735 procedure Set_Is_Extending_All
736 (Node : Project_Node_Id;
737 In_Tree : Project_Node_Tree_Ref);
738 pragma Inline (Set_Is_Extending_All);
740 procedure Set_Is_Not_Last_In_List
741 (Node : Project_Node_Id;
742 In_Tree : Project_Node_Tree_Ref);
743 pragma Inline (Set_Is_Not_Last_In_List);
745 procedure Set_First_Variable_Of
746 (Node : Project_Node_Id;
747 In_Tree : Project_Node_Tree_Ref;
748 To : Variable_Node_Id);
749 pragma Inline (Set_First_Variable_Of);
751 procedure Set_First_Package_Of
752 (Node : Project_Node_Id;
753 In_Tree : Project_Node_Tree_Ref;
754 To : Package_Declaration_Id);
755 pragma Inline (Set_First_Package_Of);
757 procedure Set_Package_Id_Of
758 (Node : Project_Node_Id;
759 In_Tree : Project_Node_Tree_Ref;
760 To : Package_Node_Id);
761 pragma Inline (Set_Package_Id_Of);
763 procedure Set_Path_Name_Of
764 (Node : Project_Node_Id;
765 In_Tree : Project_Node_Tree_Ref;
766 To : Path_Name_Type);
767 pragma Inline (Set_Path_Name_Of);
769 procedure Set_String_Value_Of
770 (Node : Project_Node_Id;
771 In_Tree : Project_Node_Tree_Ref;
772 To : Name_Id);
773 pragma Inline (Set_String_Value_Of);
775 procedure Set_First_With_Clause_Of
776 (Node : Project_Node_Id;
777 In_Tree : Project_Node_Tree_Ref;
778 To : Project_Node_Id);
779 pragma Inline (Set_First_With_Clause_Of);
781 procedure Set_Project_Declaration_Of
782 (Node : Project_Node_Id;
783 In_Tree : Project_Node_Tree_Ref;
784 To : Project_Node_Id);
785 pragma Inline (Set_Project_Declaration_Of);
787 procedure Set_Project_Qualifier_Of
788 (Node : Project_Node_Id;
789 In_Tree : Project_Node_Tree_Ref;
790 To : Project_Qualifier);
791 pragma Inline (Set_Project_Qualifier_Of);
793 procedure Set_Extending_Project_Of
794 (Node : Project_Node_Id;
795 In_Tree : Project_Node_Tree_Ref;
796 To : Project_Node_Id);
797 pragma Inline (Set_Extending_Project_Of);
799 procedure Set_First_String_Type_Of
800 (Node : Project_Node_Id;
801 In_Tree : Project_Node_Tree_Ref;
802 To : Project_Node_Id);
803 pragma Inline (Set_First_String_Type_Of);
805 procedure Set_Extended_Project_Path_Of
806 (Node : Project_Node_Id;
807 In_Tree : Project_Node_Tree_Ref;
808 To : Path_Name_Type);
809 pragma Inline (Set_Extended_Project_Path_Of);
811 procedure Set_Project_Node_Of
812 (Node : Project_Node_Id;
813 In_Tree : Project_Node_Tree_Ref;
814 To : Project_Node_Id;
815 Limited_With : Boolean := False);
816 pragma Inline (Set_Project_Node_Of);
818 procedure Set_Next_With_Clause_Of
819 (Node : Project_Node_Id;
820 In_Tree : Project_Node_Tree_Ref;
821 To : Project_Node_Id);
822 pragma Inline (Set_Next_With_Clause_Of);
824 procedure Set_First_Declarative_Item_Of
825 (Node : Project_Node_Id;
826 In_Tree : Project_Node_Tree_Ref;
827 To : Project_Node_Id);
828 pragma Inline (Set_First_Declarative_Item_Of);
830 procedure Set_Extended_Project_Of
831 (Node : Project_Node_Id;
832 In_Tree : Project_Node_Tree_Ref;
833 To : Project_Node_Id);
834 pragma Inline (Set_Extended_Project_Of);
836 procedure Set_Current_Item_Node
837 (Node : Project_Node_Id;
838 In_Tree : Project_Node_Tree_Ref;
839 To : Project_Node_Id);
840 pragma Inline (Set_Current_Item_Node);
842 procedure Set_Next_Declarative_Item
843 (Node : Project_Node_Id;
844 In_Tree : Project_Node_Tree_Ref;
845 To : Project_Node_Id);
846 pragma Inline (Set_Next_Declarative_Item);
848 procedure Set_Project_Of_Renamed_Package_Of
849 (Node : Project_Node_Id;
850 In_Tree : Project_Node_Tree_Ref;
851 To : Project_Node_Id);
852 pragma Inline (Set_Project_Of_Renamed_Package_Of);
854 procedure Set_Next_Package_In_Project
855 (Node : Project_Node_Id;
856 In_Tree : Project_Node_Tree_Ref;
857 To : Project_Node_Id);
858 pragma Inline (Set_Next_Package_In_Project);
860 procedure Set_First_Literal_String
861 (Node : Project_Node_Id;
862 In_Tree : Project_Node_Tree_Ref;
863 To : Project_Node_Id);
864 pragma Inline (Set_First_Literal_String);
866 procedure Set_Next_String_Type
867 (Node : Project_Node_Id;
868 In_Tree : Project_Node_Tree_Ref;
869 To : Project_Node_Id);
870 pragma Inline (Set_Next_String_Type);
872 procedure Set_Next_Literal_String
873 (Node : Project_Node_Id;
874 In_Tree : Project_Node_Tree_Ref;
875 To : Project_Node_Id);
876 pragma Inline (Set_Next_Literal_String);
878 procedure Set_Expression_Of
879 (Node : Project_Node_Id;
880 In_Tree : Project_Node_Tree_Ref;
881 To : Project_Node_Id);
882 pragma Inline (Set_Expression_Of);
884 procedure Set_Associative_Project_Of
885 (Node : Project_Node_Id;
886 In_Tree : Project_Node_Tree_Ref;
887 To : Project_Node_Id);
888 pragma Inline (Set_Associative_Project_Of);
890 procedure Set_Associative_Package_Of
891 (Node : Project_Node_Id;
892 In_Tree : Project_Node_Tree_Ref;
893 To : Project_Node_Id);
894 pragma Inline (Set_Associative_Package_Of);
896 procedure Set_Associative_Array_Index_Of
897 (Node : Project_Node_Id;
898 In_Tree : Project_Node_Tree_Ref;
899 To : Name_Id);
900 pragma Inline (Set_Associative_Array_Index_Of);
902 procedure Set_Next_Variable
903 (Node : Project_Node_Id;
904 In_Tree : Project_Node_Tree_Ref;
905 To : Project_Node_Id);
906 pragma Inline (Set_Next_Variable);
908 procedure Set_First_Term
909 (Node : Project_Node_Id;
910 In_Tree : Project_Node_Tree_Ref;
911 To : Project_Node_Id);
912 pragma Inline (Set_First_Term);
914 procedure Set_Next_Expression_In_List
915 (Node : Project_Node_Id;
916 In_Tree : Project_Node_Tree_Ref;
917 To : Project_Node_Id);
918 pragma Inline (Set_Next_Expression_In_List);
920 procedure Set_Current_Term
921 (Node : Project_Node_Id;
922 In_Tree : Project_Node_Tree_Ref;
923 To : Project_Node_Id);
924 pragma Inline (Set_Current_Term);
926 procedure Set_Next_Term
927 (Node : Project_Node_Id;
928 In_Tree : Project_Node_Tree_Ref;
929 To : Project_Node_Id);
930 pragma Inline (Set_Next_Term);
932 procedure Set_First_Expression_In_List
933 (Node : Project_Node_Id;
934 In_Tree : Project_Node_Tree_Ref;
935 To : Project_Node_Id);
936 pragma Inline (Set_First_Expression_In_List);
938 procedure Set_Package_Node_Of
939 (Node : Project_Node_Id;
940 In_Tree : Project_Node_Tree_Ref;
941 To : Project_Node_Id);
942 pragma Inline (Set_Package_Node_Of);
944 procedure Set_Source_Index_Of
945 (Node : Project_Node_Id;
946 In_Tree : Project_Node_Tree_Ref;
947 To : Int);
948 pragma Inline (Set_Source_Index_Of);
950 procedure Set_String_Type_Of
951 (Node : Project_Node_Id;
952 In_Tree : Project_Node_Tree_Ref;
953 To : Project_Node_Id);
954 pragma Inline (Set_String_Type_Of);
956 procedure Set_External_Reference_Of
957 (Node : Project_Node_Id;
958 In_Tree : Project_Node_Tree_Ref;
959 To : Project_Node_Id);
960 pragma Inline (Set_External_Reference_Of);
962 procedure Set_External_Default_Of
963 (Node : Project_Node_Id;
964 In_Tree : Project_Node_Tree_Ref;
965 To : Project_Node_Id);
966 pragma Inline (Set_External_Default_Of);
968 procedure Set_Case_Variable_Reference_Of
969 (Node : Project_Node_Id;
970 In_Tree : Project_Node_Tree_Ref;
971 To : Project_Node_Id);
972 pragma Inline (Set_Case_Variable_Reference_Of);
974 procedure Set_First_Case_Item_Of
975 (Node : Project_Node_Id;
976 In_Tree : Project_Node_Tree_Ref;
977 To : Project_Node_Id);
978 pragma Inline (Set_First_Case_Item_Of);
980 procedure Set_First_Choice_Of
981 (Node : Project_Node_Id;
982 In_Tree : Project_Node_Tree_Ref;
983 To : Project_Node_Id);
984 pragma Inline (Set_First_Choice_Of);
986 procedure Set_Next_Case_Item
987 (Node : Project_Node_Id;
988 In_Tree : Project_Node_Tree_Ref;
989 To : Project_Node_Id);
990 pragma Inline (Set_Next_Case_Item);
992 procedure Set_Case_Insensitive
993 (Node : Project_Node_Id;
994 In_Tree : Project_Node_Tree_Ref;
995 To : Boolean);
997 -------------------------------
998 -- Restricted Access Section --
999 -------------------------------
1001 package Tree_Private_Part is
1003 -- This is conceptually in the private part. However, for efficiency,
1004 -- some packages are accessing it directly.
1006 type Project_Node_Record is record
1008 Kind : Project_Node_Kind;
1010 Qualifier : Project_Qualifier := Unspecified;
1012 Location : Source_Ptr := No_Location;
1014 Directory : Path_Name_Type := No_Path;
1015 -- Only for N_Project
1017 Expr_Kind : Variable_Kind := Undefined;
1018 -- See below for what Project_Node_Kind it is used
1020 Variables : Variable_Node_Id := Empty_Node;
1021 -- First variable in a project or a package
1023 Packages : Package_Declaration_Id := Empty_Node;
1024 -- First package declaration in a project
1026 Pkg_Id : Package_Node_Id := Empty_Package;
1027 -- Only used for N_Package_Declaration
1029 -- The component Pkg_Id is an entry into the table Package_Attributes
1030 -- (in Prj.Attr). It is used to indicate all the attributes of the
1031 -- package with their characteristics.
1033 -- The tables Prj.Attr.Attributes and Prj.Attr.Package_Attributes
1034 -- are built once and for all through a call (from Prj.Initialize)
1035 -- to procedure Prj.Attr.Initialize. It is never modified after that.
1037 Name : Name_Id := No_Name;
1038 -- See below for what Project_Node_Kind it is used
1040 Src_Index : Int := 0;
1041 -- Index of a unit in a multi-unit source.
1042 -- Only for some N_Attribute_Declaration and N_Literal_String.
1044 Path_Name : Path_Name_Type := No_Path;
1045 -- See below for what Project_Node_Kind it is used
1047 Value : Name_Id := No_Name;
1048 -- See below for what Project_Node_Kind it is used
1050 Field1 : Project_Node_Id := Empty_Node;
1051 -- See below the meaning for each Project_Node_Kind
1053 Field2 : Project_Node_Id := Empty_Node;
1054 -- See below the meaning for each Project_Node_Kind
1056 Field3 : Project_Node_Id := Empty_Node;
1057 -- See below the meaning for each Project_Node_Kind
1059 Field4 : Project_Node_Id := Empty_Node;
1060 -- See below the meaning for each Project_Node_Kind
1062 Flag1 : Boolean := False;
1063 -- This flag is significant only for:
1065 -- N_Attribute_Declaration and N_Attribute_Reference
1066 -- Indicates for an associative array attribute, that the
1067 -- index is case insensitive.
1069 -- N_Comment
1070 -- Indicates that the comment is preceded by an empty line.
1072 -- N_Project
1073 -- Indicates that there are comments in the project source that
1074 -- cannot be kept in the tree.
1076 -- N_Project_Declaration
1077 -- Indicates that there are unkept comments in the project.
1079 -- N_With_Clause
1080 -- Indicates that this is not the last with in a with clause.
1081 -- Set for "A", but not for "B" in with "B"; and with "A", "B";
1083 Flag2 : Boolean := False;
1084 -- This flag is significant only for:
1086 -- N_Project
1087 -- Indicates that the project "extends all" another project.
1089 -- N_Comment
1090 -- Indicates that the comment is followed by an empty line.
1092 -- N_With_Clause
1093 -- Indicates that the originally imported project is an extending
1094 -- all project.
1096 Comments : Project_Node_Id := Empty_Node;
1097 -- For nodes other that N_Comment_Zones or N_Comment, designates the
1098 -- comment zones associated with the node.
1100 -- For N_Comment_Zones, designates the comment after the "end" of
1101 -- the construct.
1103 -- For N_Comment, designates the next comment, if any.
1105 end record;
1107 -- type Project_Node_Kind is
1109 -- (N_Project,
1110 -- -- Name: project name
1111 -- -- Path_Name: project path name
1112 -- -- Expr_Kind: Undefined
1113 -- -- Field1: first with clause
1114 -- -- Field2: project declaration
1115 -- -- Field3: first string type
1116 -- -- Field4: parent project, if any
1117 -- -- Value: extended project path name (if any)
1119 -- N_With_Clause,
1120 -- -- Name: imported project name
1121 -- -- Path_Name: imported project path name
1122 -- -- Expr_Kind: Undefined
1123 -- -- Field1: project node
1124 -- -- Field2: next with clause
1125 -- -- Field3: project node or empty if "limited with"
1126 -- -- Field4: not used
1127 -- -- Value: literal string withed
1129 -- N_Project_Declaration,
1130 -- -- Name: not used
1131 -- -- Path_Name: not used
1132 -- -- Expr_Kind: Undefined
1133 -- -- Field1: first declarative item
1134 -- -- Field2: extended project
1135 -- -- Field3: extending project
1136 -- -- Field4: not used
1137 -- -- Value: not used
1139 -- N_Declarative_Item,
1140 -- -- Name: not used
1141 -- -- Path_Name: not used
1142 -- -- Expr_Kind: Undefined
1143 -- -- Field1: current item node
1144 -- -- Field2: next declarative item
1145 -- -- Field3: not used
1146 -- -- Field4: not used
1147 -- -- Value: not used
1149 -- N_Package_Declaration,
1150 -- -- Name: package name
1151 -- -- Path_Name: not used
1152 -- -- Expr_Kind: Undefined
1153 -- -- Field1: project of renamed package (if any)
1154 -- -- Field2: first declarative item
1155 -- -- Field3: next package in project
1156 -- -- Field4: not used
1157 -- -- Value: not used
1159 -- N_String_Type_Declaration,
1160 -- -- Name: type name
1161 -- -- Path_Name: not used
1162 -- -- Expr_Kind: Undefined
1163 -- -- Field1: first literal string
1164 -- -- Field2: next string type
1165 -- -- Field3: not used
1166 -- -- Field4: not used
1167 -- -- Value: not used
1169 -- N_Literal_String,
1170 -- -- Name: not used
1171 -- -- Path_Name: not used
1172 -- -- Expr_Kind: Single
1173 -- -- Field1: next literal string
1174 -- -- Field2: not used
1175 -- -- Field3: not used
1176 -- -- Field4: not used
1177 -- -- Value: string value
1179 -- N_Attribute_Declaration,
1180 -- -- Name: attribute name
1181 -- -- Path_Name: not used
1182 -- -- Expr_Kind: attribute kind
1183 -- -- Field1: expression
1184 -- -- Field2: project of full associative array
1185 -- -- Field3: package of full associative array
1186 -- -- Field4: not used
1187 -- -- Value: associative array index
1188 -- -- (if an associative array element)
1190 -- N_Typed_Variable_Declaration,
1191 -- -- Name: variable name
1192 -- -- Path_Name: not used
1193 -- -- Expr_Kind: Single
1194 -- -- Field1: expression
1195 -- -- Field2: type of variable (N_String_Type_Declaration)
1196 -- -- Field3: next variable
1197 -- -- Field4: not used
1198 -- -- Value: not used
1200 -- N_Variable_Declaration,
1201 -- -- Name: variable name
1202 -- -- Path_Name: not used
1203 -- -- Expr_Kind: variable kind
1204 -- -- Field1: expression
1205 -- -- Field2: not used
1206 -- -- Field3 is used for next variable, instead of Field2,
1207 -- -- so that it is the same field for
1208 -- -- N_Variable_Declaration and
1209 -- -- N_Typed_Variable_Declaration
1210 -- -- Field3: next variable
1211 -- -- Field4: not used
1212 -- -- Value: not used
1214 -- N_Expression,
1215 -- -- Name: not used
1216 -- -- Path_Name: not used
1217 -- -- Expr_Kind: expression kind
1218 -- -- Field1: first term
1219 -- -- Field2: next expression in list
1220 -- -- Field3: not used
1221 -- -- Value: not used
1223 -- N_Term,
1224 -- -- Name: not used
1225 -- -- Path_Name: not used
1226 -- -- Expr_Kind: term kind
1227 -- -- Field1: current term
1228 -- -- Field2: next term in the expression
1229 -- -- Field3: not used
1230 -- -- Field4: not used
1231 -- -- Value: not used
1233 -- N_Literal_String_List,
1234 -- -- Designates a list of string expressions between brackets
1235 -- -- separated by commas. The string expressions are not necessarily
1236 -- -- literal strings.
1237 -- -- Name: not used
1238 -- -- Path_Name: not used
1239 -- -- Expr_Kind: List
1240 -- -- Field1: first expression
1241 -- -- Field2: not used
1242 -- -- Field3: not used
1243 -- -- Field4: not used
1244 -- -- Value: not used
1246 -- N_Variable_Reference,
1247 -- -- Name: variable name
1248 -- -- Path_Name: not used
1249 -- -- Expr_Kind: variable kind
1250 -- -- Field1: project (if specified)
1251 -- -- Field2: package (if specified)
1252 -- -- Field3: type of variable (N_String_Type_Declaration), if any
1253 -- -- Field4: not used
1254 -- -- Value: not used
1256 -- N_External_Value,
1257 -- -- Name: not used
1258 -- -- Path_Name: not used
1259 -- -- Expr_Kind: Single
1260 -- -- Field1: Name of the external reference (literal string)
1261 -- -- Field2: Default (literal string)
1262 -- -- Field3: not used
1263 -- -- Value: not used
1265 -- N_Attribute_Reference,
1266 -- -- Name: attribute name
1267 -- -- Path_Name: not used
1268 -- -- Expr_Kind: attribute kind
1269 -- -- Field1: project
1270 -- -- Field2: package (if attribute of a package)
1271 -- -- Field3: not used
1272 -- -- Field4: not used
1273 -- -- Value: associative array index
1274 -- -- (if an associative array element)
1276 -- N_Case_Construction,
1277 -- -- Name: not used
1278 -- -- Path_Name: not used
1279 -- -- Expr_Kind: Undefined
1280 -- -- Field1: case variable reference
1281 -- -- Field2: first case item
1282 -- -- Field3: not used
1283 -- -- Field4: not used
1284 -- -- Value: not used
1286 -- N_Case_Item
1287 -- -- Name: not used
1288 -- -- Path_Name: not used
1289 -- -- Expr_Kind: not used
1290 -- -- Field1: first choice (literal string), or Empty_Node
1291 -- -- for when others
1292 -- -- Field2: first declarative item
1293 -- -- Field3: next case item
1294 -- -- Field4: not used
1295 -- -- Value: not used
1297 -- N_Comment_zones
1298 -- -- Name: not used
1299 -- -- Path_Name: not used
1300 -- -- Expr_Kind: not used
1301 -- -- Field1: comment before the construct
1302 -- -- Field2: comment after the construct
1303 -- -- Field3: comment before the "end" of the construct
1304 -- -- Value: end of line comment
1305 -- -- Field4: not used
1306 -- -- Comments: comment after the "end" of the construct
1308 -- N_Comment
1309 -- -- Name: not used
1310 -- -- Path_Name: not used
1311 -- -- Expr_Kind: not used
1312 -- -- Field1: not used
1313 -- -- Field2: not used
1314 -- -- Field3: not used
1315 -- -- Field4: not used
1316 -- -- Value: comment
1317 -- -- Flag1: comment is preceded by an empty line
1318 -- -- Flag2: comment is followed by an empty line
1319 -- -- Comments: next comment
1321 package Project_Node_Table is new
1322 GNAT.Dynamic_Tables
1323 (Table_Component_Type => Project_Node_Record,
1324 Table_Index_Type => Project_Node_Id,
1325 Table_Low_Bound => First_Node_Id,
1326 Table_Initial => Project_Nodes_Initial,
1327 Table_Increment => Project_Nodes_Increment);
1328 -- Table contains the syntactic tree of project data from project files
1330 type Project_Name_And_Node is record
1331 Name : Name_Id;
1332 -- Name of the project
1334 Display_Name : Name_Id;
1335 -- The name of the project as it appears in the .gpr file
1337 Node : Project_Node_Id;
1338 -- Node of the project in table Project_Nodes
1340 Canonical_Path : Path_Name_Type;
1341 -- Resolved and canonical path of a real project file.
1342 -- No_Name in case of virtual projects.
1344 Extended : Boolean;
1345 -- True when the project is being extended by another project
1347 Proj_Qualifier : Project_Qualifier;
1348 -- The project qualifier of the project, if any
1349 end record;
1351 No_Project_Name_And_Node : constant Project_Name_And_Node :=
1352 (Name => No_Name,
1353 Display_Name => No_Name,
1354 Node => Empty_Node,
1355 Canonical_Path => No_Path,
1356 Extended => True,
1357 Proj_Qualifier => Unspecified);
1359 package Projects_Htable is new GNAT.Dynamic_HTables.Simple_HTable
1360 (Header_Num => Header_Num,
1361 Element => Project_Name_And_Node,
1362 No_Element => No_Project_Name_And_Node,
1363 Key => Name_Id,
1364 Hash => Hash,
1365 Equal => "=");
1366 -- This hash table contains a mapping of project names to project nodes.
1367 -- Note that this hash table contains only the nodes whose Kind is
1368 -- N_Project. It is used to find the node of a project from its name,
1369 -- and to verify if a project has already been parsed, knowing its name.
1371 end Tree_Private_Part;
1373 package Name_To_Name_HTable is new GNAT.Dynamic_HTables.Simple_HTable
1374 (Header_Num => Header_Num,
1375 Element => Name_Id,
1376 No_Element => No_Name,
1377 Key => Name_Id,
1378 Hash => Hash,
1379 Equal => "=");
1380 -- General type for htables associating name_id to name_id.
1381 -- This is in particular used to store the values of external references
1383 type Project_Node_Tree_Data is record
1384 Project_Nodes : Tree_Private_Part.Project_Node_Table.Instance;
1385 Projects_HT : Tree_Private_Part.Projects_Htable.Instance;
1387 External_References : Name_To_Name_HTable.Instance;
1388 -- External references are stored in this hash table (and manipulated
1389 -- through subprogrames in prj-ext.ads). External references are
1390 -- project-tree specific so that one can load the same tree twice but
1391 -- have two views of it, for instance.
1393 Project_Path : String_Access;
1394 -- The project path, manipulated through subprograms in prj-ext.ads.
1395 -- As a special case, if the first character is '#:" or this variable is
1396 -- unset, this means that the PATH has not been fully initialized yet
1397 -- (although subprograms prj-ext.ads will properly take care of that).
1399 -- The project path is tree specific, since we might want to load
1400 -- simultaneously multiple projects, each with its own search path, in
1401 -- particular when using different compilers with different default
1402 -- search directories.
1403 end record;
1405 procedure Free (Proj : in out Project_Node_Tree_Ref);
1406 -- Free memory used by Prj
1408 private
1409 type Comment_Array is array (Positive range <>) of Comment_Data;
1410 type Comments_Ptr is access Comment_Array;
1412 type Comment_State is record
1413 End_Of_Line_Node : Project_Node_Id := Empty_Node;
1414 Previous_Line_Node : Project_Node_Id := Empty_Node;
1415 Previous_End_Node : Project_Node_Id := Empty_Node;
1416 Unkept_Comments : Boolean := False;
1417 Comments : Comments_Ptr := null;
1418 end record;
1420 end Prj.Tree;