Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / gcc / ada / prj-tree.ads
blobe50be5d78783eb0f41eff8d38bfc34acfeff7bcb
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-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 ------------------------------------------------------------------------------
27 -- This package defines the structure of the Project File tree
29 with GNAT.HTable;
31 with Prj.Attr; use Prj.Attr;
32 with Table; use Table;
33 with Types; use Types;
35 package Prj.Tree is
37 Project_Nodes_Initial : constant := 1_000;
38 Project_Nodes_Increment : constant := 100;
39 -- Allocation parameters for initializing and extending number
40 -- of nodes in table Tree_Private_Part.Project_Nodes
42 Project_Node_Low_Bound : constant := 0;
43 Project_Node_High_Bound : constant := 099_999_999;
44 -- Range of values for project node id's (in practice infinite)
46 type Project_Node_Id is range
47 Project_Node_Low_Bound .. Project_Node_High_Bound;
48 -- The index of table Tree_Private_Part.Project_Nodes
50 Empty_Node : constant Project_Node_Id := Project_Node_Low_Bound;
51 -- Designates no node in table Project_Nodes
53 First_Node_Id : constant Project_Node_Id := Project_Node_Low_Bound + 1;
55 subtype Variable_Node_Id is Project_Node_Id;
56 -- Used to designate a node whose expected kind is one of
57 -- N_Typed_Variable_Declaration, N_Variable_Declaration or
58 -- N_Variable_Reference.
60 subtype Package_Declaration_Id is Project_Node_Id;
61 -- Used to designate a node whose expected kind is N_Proect_Declaration
63 type Project_Node_Kind is
64 (N_Project,
65 N_With_Clause,
66 N_Project_Declaration,
67 N_Declarative_Item,
68 N_Package_Declaration,
69 N_String_Type_Declaration,
70 N_Literal_String,
71 N_Attribute_Declaration,
72 N_Typed_Variable_Declaration,
73 N_Variable_Declaration,
74 N_Expression,
75 N_Term,
76 N_Literal_String_List,
77 N_Variable_Reference,
78 N_External_Value,
79 N_Attribute_Reference,
80 N_Case_Construction,
81 N_Case_Item,
82 N_Comment_Zones,
83 N_Comment);
84 -- Each node in the tree is of a Project_Node_Kind
85 -- For the signification of the fields in each node of a
86 -- Project_Node_Kind, look at package Tree_Private_Part.
88 procedure Initialize;
89 -- Initialize the Project File tree: empty the Project_Nodes table
90 -- and reset the Projects_Htable.
92 function Default_Project_Node
93 (Of_Kind : Project_Node_Kind;
94 And_Expr_Kind : Variable_Kind := Undefined) return Project_Node_Id;
95 -- Returns a Project_Node_Record with the specified Kind and
96 -- Expr_Kind; all the other components have default nil values.
98 function Hash (N : Project_Node_Id) return Header_Num;
99 -- Used for hash tables where the key is a Project_Node_Id
101 function Imported_Or_Extended_Project_Of
102 (Project : Project_Node_Id;
103 With_Name : Name_Id) return Project_Node_Id;
104 -- Return the node of a project imported or extended by project Project and
105 -- whose name is With_Name. Return Empty_Node if there is no such project.
107 --------------
108 -- Comments --
109 --------------
111 type Comment_State is private;
112 -- A type to store the values of several global variables related to
113 -- comments.
115 procedure Save (S : out Comment_State);
116 -- Save in variable S the comment state. Called before scanning a new
117 -- project file.
119 procedure Restore (S : in Comment_State);
120 -- Restore the comment state to a previously saved value. Called after
121 -- scanning a project file.
123 procedure Reset_State;
124 -- Set the comment state to its initial value. Called before scanning a
125 -- new project file.
127 function There_Are_Unkept_Comments return Boolean;
128 -- Indicates that some of the comments in a project file could not be
129 -- stored in the parse tree.
131 procedure Set_Previous_Line_Node (To : Project_Node_Id);
132 -- Indicate the node on the previous line. If there are comments
133 -- immediately following this line, then they should be associated with
134 -- this node.
136 procedure Set_Previous_End_Node (To : Project_Node_Id);
137 -- Indicate that on the previous line the "end" belongs to node To.
138 -- If there are comments immediately following this "end" line, they
139 -- should be associated with this node.
141 procedure Set_End_Of_Line (To : Project_Node_Id);
142 -- Indicate the node on the current line. If there is an end of line
143 -- comment, then it should be associated with this node.
145 procedure Set_Next_End_Node (To : Project_Node_Id);
146 -- Put node To on the top of the end node stack. When an "end" line
147 -- is found with this node on the top of the end node stack, the comments,
148 -- if any, immediately preceding this "end" line will be associated with
149 -- this node.
151 procedure Remove_Next_End_Node;
152 -- Remove the top of the end node stack
154 ------------------------
155 -- Comment Processing --
156 ------------------------
158 type Comment_Data is record
159 Value : Name_Id := No_Name;
160 Follows_Empty_Line : Boolean := False;
161 Is_Followed_By_Empty_Line : Boolean := False;
162 end record;
164 package Comments is new Table.Table
165 (Table_Component_Type => Comment_Data,
166 Table_Index_Type => Natural,
167 Table_Low_Bound => 1,
168 Table_Initial => 10,
169 Table_Increment => 100,
170 Table_Name => "Prj.Tree.Comments");
171 -- A table to store the comments that may be stored is the tree
173 procedure Scan;
174 -- Scan the tokens and accumulate comments
176 type Comment_Location is
177 (Before, After, Before_End, After_End, End_Of_Line);
179 procedure Add_Comments (To : Project_Node_Id; Where : Comment_Location);
180 -- Add comments to this node
182 ----------------------
183 -- Access Functions --
184 ----------------------
186 -- The following query functions are part of the abstract interface
187 -- of the Project File tree
189 function Name_Of (Node : Project_Node_Id) return Name_Id;
190 pragma Inline (Name_Of);
191 -- Valid for all non empty nodes. May return No_Name for nodes that have
192 -- no names.
194 function Kind_Of (Node : Project_Node_Id) return Project_Node_Kind;
195 pragma Inline (Kind_Of);
196 -- Valid for all non empty nodes
198 function Location_Of (Node : Project_Node_Id) return Source_Ptr;
199 pragma Inline (Location_Of);
200 -- Valid for all non empty nodes
202 function First_Comment_After
203 (Node : Project_Node_Id) return Project_Node_Id;
204 -- Valid only for N_Comment_Zones nodes
206 function First_Comment_After_End
207 (Node : Project_Node_Id) return Project_Node_Id;
208 -- Valid only for N_Comment_Zones nodes
210 function First_Comment_Before
211 (Node : Project_Node_Id) return Project_Node_Id;
212 -- Valid only for N_Comment_Zones nodes
214 function First_Comment_Before_End
215 (Node : Project_Node_Id) return Project_Node_Id;
216 -- Valid only for N_Comment_Zones nodes
218 function Next_Comment (Node : Project_Node_Id) return Project_Node_Id;
219 -- Valid only for N_Comment nodes
221 function End_Of_Line_Comment (Node : Project_Node_Id) return Name_Id;
222 -- Valid only for non empty nodes
224 function Follows_Empty_Line (Node : Project_Node_Id) return Boolean;
225 -- Valid only for N_Comment nodes
227 function Is_Followed_By_Empty_Line (Node : Project_Node_Id) return Boolean;
228 -- Valid only for N_Comment nodes
230 function Project_File_Includes_Unkept_Comments
231 (Node : Project_Node_Id)
232 return Boolean;
233 -- Valid only for N_Project nodes
235 function Directory_Of (Node : Project_Node_Id) return Name_Id;
236 pragma Inline (Directory_Of);
237 -- Only valid for N_Project nodes
239 function Expression_Kind_Of (Node : Project_Node_Id) return Variable_Kind;
240 pragma Inline (Expression_Kind_Of);
241 -- Only valid for N_Literal_String, N_Attribute_Declaration,
242 -- N_Variable_Declaration, N_Typed_Variable_Declaration, N_Expression,
243 -- N_Term, N_Variable_Reference or N_Attribute_Reference nodes.
245 function Is_Extending_All (Node : Project_Node_Id) return Boolean;
246 pragma Inline (Is_Extending_All);
247 -- Only valid for N_Project and N_With_Clause
249 function First_Variable_Of
250 (Node : Project_Node_Id) return Variable_Node_Id;
251 pragma Inline (First_Variable_Of);
252 -- Only valid for N_Project or N_Package_Declaration nodes
254 function First_Package_Of
255 (Node : Project_Node_Id) return Package_Declaration_Id;
256 pragma Inline (First_Package_Of);
257 -- Only valid for N_Project nodes
259 function Package_Id_Of (Node : Project_Node_Id) return Package_Node_Id;
260 pragma Inline (Package_Id_Of);
261 -- Only valid for N_Package_Declaration nodes
263 function Path_Name_Of (Node : Project_Node_Id) return Name_Id;
264 pragma Inline (Path_Name_Of);
265 -- Only valid for N_Project and N_With_Clause nodes
267 function String_Value_Of (Node : Project_Node_Id) return Name_Id;
268 pragma Inline (String_Value_Of);
269 -- Only valid for N_With_Clause, N_Literal_String nodes or N_Comment
271 function Source_Index_Of (Node : Project_Node_Id) return Int;
272 pragma Inline (Source_Index_Of);
273 -- Only valid for N_Literal_String and N_Attribute_Declaration nodes
275 function First_With_Clause_Of
276 (Node : Project_Node_Id) return Project_Node_Id;
277 pragma Inline (First_With_Clause_Of);
278 -- Only valid for N_Project nodes
280 function Project_Declaration_Of
281 (Node : Project_Node_Id) return Project_Node_Id;
282 pragma Inline (Project_Declaration_Of);
283 -- Only valid for N_Project nodes
285 function Extending_Project_Of
286 (Node : Project_Node_Id) return Project_Node_Id;
287 pragma Inline (Extending_Project_Of);
288 -- Only valid for N_Project_Declaration nodes
290 function First_String_Type_Of
291 (Node : Project_Node_Id) return Project_Node_Id;
292 pragma Inline (First_String_Type_Of);
293 -- Only valid for N_Project nodes
295 function Extended_Project_Path_Of
296 (Node : Project_Node_Id) return Name_Id;
297 pragma Inline (Extended_Project_Path_Of);
298 -- Only valid for N_With_Clause nodes
300 function Project_Node_Of
301 (Node : Project_Node_Id) return Project_Node_Id;
302 pragma Inline (Project_Node_Of);
303 -- Only valid for N_With_Clause, N_Variable_Reference and
304 -- N_Attribute_Reference nodes.
306 function Non_Limited_Project_Node_Of
307 (Node : Project_Node_Id) return Project_Node_Id;
308 pragma Inline (Non_Limited_Project_Node_Of);
309 -- Only valid for N_With_Clause nodes. Returns Empty_Node for limited
310 -- imported project files, otherwise returns the same result as
311 -- Project_Node_Of.
313 function Next_With_Clause_Of
314 (Node : Project_Node_Id) return Project_Node_Id;
315 pragma Inline (Next_With_Clause_Of);
316 -- Only valid for N_With_Clause nodes
318 function First_Declarative_Item_Of
319 (Node : Project_Node_Id) return Project_Node_Id;
320 pragma Inline (First_Declarative_Item_Of);
321 -- Only valid for N_With_Clause nodes
323 function Extended_Project_Of
324 (Node : Project_Node_Id) return Project_Node_Id;
325 pragma Inline (Extended_Project_Of);
326 -- Only valid for N_Project_Declaration nodes
328 function Current_Item_Node
329 (Node : Project_Node_Id) return Project_Node_Id;
330 pragma Inline (Current_Item_Node);
331 -- Only valid for N_Declarative_Item nodes
333 function Next_Declarative_Item
334 (Node : Project_Node_Id) return Project_Node_Id;
335 pragma Inline (Next_Declarative_Item);
336 -- Only valid for N_Declarative_Item node
338 function Project_Of_Renamed_Package_Of
339 (Node : Project_Node_Id) return Project_Node_Id;
340 pragma Inline (Project_Of_Renamed_Package_Of);
341 -- Only valid for N_Package_Declaration nodes.
342 -- May return Empty_Node.
344 function Next_Package_In_Project
345 (Node : Project_Node_Id) return Project_Node_Id;
346 pragma Inline (Next_Package_In_Project);
347 -- Only valid for N_Package_Declaration nodes
349 function First_Literal_String
350 (Node : Project_Node_Id) return Project_Node_Id;
351 pragma Inline (First_Literal_String);
352 -- Only valid for N_String_Type_Declaration nodes
354 function Next_String_Type
355 (Node : Project_Node_Id) return Project_Node_Id;
356 pragma Inline (Next_String_Type);
357 -- Only valid for N_String_Type_Declaration nodes
359 function Next_Literal_String
360 (Node : Project_Node_Id) return Project_Node_Id;
361 pragma Inline (Next_Literal_String);
362 -- Only valid for N_Literal_String nodes
364 function Expression_Of
365 (Node : Project_Node_Id) return Project_Node_Id;
366 pragma Inline (Expression_Of);
367 -- Only valid for N_Attribute_Declaration, N_Typed_Variable_Declaration
368 -- or N_Variable_Declaration nodes
370 function Associative_Project_Of
371 (Node : Project_Node_Id)
372 return Project_Node_Id;
373 pragma Inline (Associative_Project_Of);
374 -- Only valid for N_Attribute_Declaration nodes
376 function Associative_Package_Of
377 (Node : Project_Node_Id)
378 return Project_Node_Id;
379 pragma Inline (Associative_Package_Of);
380 -- Only valid for N_Attribute_Declaration nodes
382 function Value_Is_Valid
383 (For_Typed_Variable : Project_Node_Id;
384 Value : Name_Id) return Boolean;
385 pragma Inline (Value_Is_Valid);
386 -- Only valid for N_Typed_Variable_Declaration. Returns True if Value is
387 -- in the list of allowed strings for For_Typed_Variable. False otherwise.
389 function Associative_Array_Index_Of
390 (Node : Project_Node_Id) return Name_Id;
391 pragma Inline (Associative_Array_Index_Of);
392 -- Only valid for N_Attribute_Declaration and N_Attribute_Reference.
393 -- Returns No_String for non associative array attributes.
395 function Next_Variable
396 (Node : Project_Node_Id) return Project_Node_Id;
397 pragma Inline (Next_Variable);
398 -- Only valid for N_Typed_Variable_Declaration or N_Variable_Declaration
399 -- nodes.
401 function First_Term
402 (Node : Project_Node_Id) return Project_Node_Id;
403 pragma Inline (First_Term);
404 -- Only valid for N_Expression nodes
406 function Next_Expression_In_List
407 (Node : Project_Node_Id) return Project_Node_Id;
408 pragma Inline (Next_Expression_In_List);
409 -- Only valid for N_Expression nodes
411 function Current_Term
412 (Node : Project_Node_Id) return Project_Node_Id;
413 pragma Inline (Current_Term);
414 -- Only valid for N_Term nodes
416 function Next_Term
417 (Node : Project_Node_Id) return Project_Node_Id;
418 pragma Inline (Next_Term);
419 -- Only valid for N_Term nodes
421 function First_Expression_In_List
422 (Node : Project_Node_Id) return Project_Node_Id;
423 pragma Inline (First_Expression_In_List);
424 -- Only valid for N_Literal_String_List nodes
426 function Package_Node_Of
427 (Node : Project_Node_Id) return Project_Node_Id;
428 pragma Inline (Package_Node_Of);
429 -- Only valid for N_Variable_Reference or N_Attribute_Reference nodes.
430 -- May return Empty_Node.
432 function String_Type_Of
433 (Node : Project_Node_Id) return Project_Node_Id;
434 pragma Inline (String_Type_Of);
435 -- Only valid for N_Variable_Reference or N_Typed_Variable_Declaration
436 -- nodes.
438 function External_Reference_Of
439 (Node : Project_Node_Id) return Project_Node_Id;
440 pragma Inline (External_Reference_Of);
441 -- Only valid for N_External_Value nodes
443 function External_Default_Of
444 (Node : Project_Node_Id) return Project_Node_Id;
445 pragma Inline (External_Default_Of);
446 -- Only valid for N_External_Value nodes
448 function Case_Variable_Reference_Of
449 (Node : Project_Node_Id) return Project_Node_Id;
450 pragma Inline (Case_Variable_Reference_Of);
451 -- Only valid for N_Case_Construction nodes
453 function First_Case_Item_Of
454 (Node : Project_Node_Id) return Project_Node_Id;
455 pragma Inline (First_Case_Item_Of);
456 -- Only valid for N_Case_Construction nodes
458 function First_Choice_Of
459 (Node : Project_Node_Id) return Project_Node_Id;
460 pragma Inline (First_Choice_Of);
461 -- Return the first choice in a N_Case_Item, or Empty_Node if
462 -- this is when others.
464 function Next_Case_Item
465 (Node : Project_Node_Id) return Project_Node_Id;
466 pragma Inline (Next_Case_Item);
467 -- Only valid for N_Case_Item nodes
469 function Case_Insensitive (Node : Project_Node_Id) return Boolean;
470 -- Only valid for N_Attribute_Declaration and N_Attribute_Reference nodes
472 --------------------
473 -- Set Procedures --
474 --------------------
476 -- The following procedures are part of the abstract interface of
477 -- the Project File tree.
479 -- Each Set_* procedure is valid only for the same Project_Node_Kind
480 -- nodes as the corresponding query function above.
482 procedure Set_Name_Of
483 (Node : Project_Node_Id;
484 To : Name_Id);
485 pragma Inline (Set_Name_Of);
487 procedure Set_Kind_Of
488 (Node : Project_Node_Id;
489 To : Project_Node_Kind);
490 pragma Inline (Set_Kind_Of);
492 procedure Set_Location_Of
493 (Node : Project_Node_Id;
494 To : Source_Ptr);
495 pragma Inline (Set_Location_Of);
497 procedure Set_First_Comment_After
498 (Node : Project_Node_Id;
499 To : Project_Node_Id);
500 pragma Inline (Set_First_Comment_After);
502 procedure Set_First_Comment_After_End
503 (Node : Project_Node_Id;
504 To : Project_Node_Id);
505 pragma Inline (Set_First_Comment_After_End);
507 procedure Set_First_Comment_Before
508 (Node : Project_Node_Id;
509 To : Project_Node_Id);
510 pragma Inline (Set_First_Comment_Before);
512 procedure Set_First_Comment_Before_End
513 (Node : Project_Node_Id;
514 To : Project_Node_Id);
515 pragma Inline (Set_First_Comment_Before_End);
517 procedure Set_Next_Comment
518 (Node : Project_Node_Id;
519 To : Project_Node_Id);
520 pragma Inline (Set_Next_Comment);
522 procedure Set_Project_File_Includes_Unkept_Comments
523 (Node : Project_Node_Id;
524 To : Boolean);
526 procedure Set_Directory_Of
527 (Node : Project_Node_Id;
528 To : Name_Id);
529 pragma Inline (Set_Directory_Of);
531 procedure Set_Expression_Kind_Of
532 (Node : Project_Node_Id;
533 To : Variable_Kind);
534 pragma Inline (Set_Expression_Kind_Of);
536 procedure Set_Is_Extending_All (Node : Project_Node_Id);
537 pragma Inline (Set_Is_Extending_All);
539 procedure Set_First_Variable_Of
540 (Node : Project_Node_Id;
541 To : Variable_Node_Id);
542 pragma Inline (Set_First_Variable_Of);
544 procedure Set_First_Package_Of
545 (Node : Project_Node_Id;
546 To : Package_Declaration_Id);
547 pragma Inline (Set_First_Package_Of);
549 procedure Set_Package_Id_Of
550 (Node : Project_Node_Id;
551 To : Package_Node_Id);
552 pragma Inline (Set_Package_Id_Of);
554 procedure Set_Path_Name_Of
555 (Node : Project_Node_Id;
556 To : Name_Id);
557 pragma Inline (Set_Path_Name_Of);
559 procedure Set_String_Value_Of
560 (Node : Project_Node_Id;
561 To : Name_Id);
562 pragma Inline (Set_String_Value_Of);
564 procedure Set_First_With_Clause_Of
565 (Node : Project_Node_Id;
566 To : Project_Node_Id);
567 pragma Inline (Set_First_With_Clause_Of);
569 procedure Set_Project_Declaration_Of
570 (Node : Project_Node_Id;
571 To : Project_Node_Id);
572 pragma Inline (Set_Project_Declaration_Of);
574 procedure Set_Extending_Project_Of
575 (Node : Project_Node_Id;
576 To : Project_Node_Id);
577 pragma Inline (Set_Extending_Project_Of);
579 procedure Set_First_String_Type_Of
580 (Node : Project_Node_Id;
581 To : Project_Node_Id);
582 pragma Inline (Set_First_String_Type_Of);
584 procedure Set_Extended_Project_Path_Of
585 (Node : Project_Node_Id;
586 To : Name_Id);
587 pragma Inline (Set_Extended_Project_Path_Of);
589 procedure Set_Project_Node_Of
590 (Node : Project_Node_Id;
591 To : Project_Node_Id;
592 Limited_With : Boolean := False);
593 pragma Inline (Set_Project_Node_Of);
595 procedure Set_Next_With_Clause_Of
596 (Node : Project_Node_Id;
597 To : Project_Node_Id);
598 pragma Inline (Set_Next_With_Clause_Of);
600 procedure Set_First_Declarative_Item_Of
601 (Node : Project_Node_Id;
602 To : Project_Node_Id);
603 pragma Inline (Set_First_Declarative_Item_Of);
605 procedure Set_Extended_Project_Of
606 (Node : Project_Node_Id;
607 To : Project_Node_Id);
608 pragma Inline (Set_Extended_Project_Of);
610 procedure Set_Current_Item_Node
611 (Node : Project_Node_Id;
612 To : Project_Node_Id);
613 pragma Inline (Set_Current_Item_Node);
615 procedure Set_Next_Declarative_Item
616 (Node : Project_Node_Id;
617 To : Project_Node_Id);
618 pragma Inline (Set_Next_Declarative_Item);
620 procedure Set_Project_Of_Renamed_Package_Of
621 (Node : Project_Node_Id;
622 To : Project_Node_Id);
623 pragma Inline (Set_Project_Of_Renamed_Package_Of);
625 procedure Set_Next_Package_In_Project
626 (Node : Project_Node_Id;
627 To : Project_Node_Id);
628 pragma Inline (Set_Next_Package_In_Project);
630 procedure Set_First_Literal_String
631 (Node : Project_Node_Id;
632 To : Project_Node_Id);
633 pragma Inline (Set_First_Literal_String);
635 procedure Set_Next_String_Type
636 (Node : Project_Node_Id;
637 To : Project_Node_Id);
638 pragma Inline (Set_Next_String_Type);
640 procedure Set_Next_Literal_String
641 (Node : Project_Node_Id;
642 To : Project_Node_Id);
643 pragma Inline (Set_Next_Literal_String);
645 procedure Set_Expression_Of
646 (Node : Project_Node_Id;
647 To : Project_Node_Id);
648 pragma Inline (Set_Expression_Of);
650 procedure Set_Associative_Project_Of
651 (Node : Project_Node_Id;
652 To : Project_Node_Id);
653 pragma Inline (Set_Associative_Project_Of);
655 procedure Set_Associative_Package_Of
656 (Node : Project_Node_Id;
657 To : Project_Node_Id);
658 pragma Inline (Set_Associative_Package_Of);
660 procedure Set_Associative_Array_Index_Of
661 (Node : Project_Node_Id;
662 To : Name_Id);
663 pragma Inline (Set_Associative_Array_Index_Of);
665 procedure Set_Next_Variable
666 (Node : Project_Node_Id;
667 To : Project_Node_Id);
668 pragma Inline (Set_Next_Variable);
670 procedure Set_First_Term
671 (Node : Project_Node_Id;
672 To : Project_Node_Id);
673 pragma Inline (Set_First_Term);
675 procedure Set_Next_Expression_In_List
676 (Node : Project_Node_Id;
677 To : Project_Node_Id);
678 pragma Inline (Set_Next_Expression_In_List);
680 procedure Set_Current_Term
681 (Node : Project_Node_Id;
682 To : Project_Node_Id);
683 pragma Inline (Set_Current_Term);
685 procedure Set_Next_Term
686 (Node : Project_Node_Id;
687 To : Project_Node_Id);
688 pragma Inline (Set_Next_Term);
690 procedure Set_First_Expression_In_List
691 (Node : Project_Node_Id;
692 To : Project_Node_Id);
693 pragma Inline (Set_First_Expression_In_List);
695 procedure Set_Package_Node_Of
696 (Node : Project_Node_Id;
697 To : Project_Node_Id);
698 pragma Inline (Set_Package_Node_Of);
700 procedure Set_Source_Index_Of
701 (Node : Project_Node_Id;
702 To : Int);
703 pragma Inline (Set_Source_Index_Of);
705 procedure Set_String_Type_Of
706 (Node : Project_Node_Id;
707 To : Project_Node_Id);
708 pragma Inline (Set_String_Type_Of);
710 procedure Set_External_Reference_Of
711 (Node : Project_Node_Id;
712 To : Project_Node_Id);
713 pragma Inline (Set_External_Reference_Of);
715 procedure Set_External_Default_Of
716 (Node : Project_Node_Id;
717 To : Project_Node_Id);
718 pragma Inline (Set_External_Default_Of);
720 procedure Set_Case_Variable_Reference_Of
721 (Node : Project_Node_Id;
722 To : Project_Node_Id);
723 pragma Inline (Set_Case_Variable_Reference_Of);
725 procedure Set_First_Case_Item_Of
726 (Node : Project_Node_Id;
727 To : Project_Node_Id);
728 pragma Inline (Set_First_Case_Item_Of);
730 procedure Set_First_Choice_Of
731 (Node : Project_Node_Id;
732 To : Project_Node_Id);
733 pragma Inline (Set_First_Choice_Of);
735 procedure Set_Next_Case_Item
736 (Node : Project_Node_Id;
737 To : Project_Node_Id);
738 pragma Inline (Set_Next_Case_Item);
740 procedure Set_Case_Insensitive
741 (Node : Project_Node_Id;
742 To : Boolean);
744 -------------------------------
745 -- Restricted Access Section --
746 -------------------------------
748 package Tree_Private_Part is
750 -- This is conceptually in the private part.
751 -- However, for efficiency, some packages are accessing it directly.
753 type Project_Node_Record is record
755 Kind : Project_Node_Kind;
757 Location : Source_Ptr := No_Location;
759 Directory : Name_Id := No_Name;
760 -- Only for N_Project
762 Expr_Kind : Variable_Kind := Undefined;
763 -- See below for what Project_Node_Kind it is used
765 Variables : Variable_Node_Id := Empty_Node;
766 -- First variable in a project or a package
768 Packages : Package_Declaration_Id := Empty_Node;
769 -- First package declaration in a project
771 Pkg_Id : Package_Node_Id := Empty_Package;
772 -- Only used for N_Package_Declaration
773 -- The component Pkg_Id is an entry into the table Package_Attributes
774 -- (in Prj.Attr). It is used to indicate all the attributes of the
775 -- package with their characteristics.
777 -- The tables Prj.Attr.Attributes and Prj.Attr.Package_Attributes
778 -- are built once and for all through a call (from Prj.Initialize)
779 -- to procedure Prj.Attr.Initialize. It is never modified after that.
781 Name : Name_Id := No_Name;
782 -- See below for what Project_Node_Kind it is used
784 Src_Index : Int := 0;
785 -- Index of a unit in a multi-unit source.
786 -- Onli for some N_Attribute_Declaration and N_Literal_String.
788 Path_Name : Name_Id := No_Name;
789 -- See below for what Project_Node_Kind it is used
791 Value : Name_Id := No_Name;
792 -- See below for what Project_Node_Kind it is used
794 Field1 : Project_Node_Id := Empty_Node;
795 -- See below the meaning for each Project_Node_Kind
797 Field2 : Project_Node_Id := Empty_Node;
798 -- See below the meaning for each Project_Node_Kind
800 Field3 : Project_Node_Id := Empty_Node;
801 -- See below the meaning for each Project_Node_Kind
803 Flag1 : Boolean := False;
804 -- This flag is significant only for:
805 -- N_Attribute_Declaration and N_Atribute_Reference
806 -- It indicates for an associative array attribute, that the
807 -- index is case insensitive.
808 -- N_Comment - it indicates that the comment is preceded by an
809 -- empty line.
810 -- N_Project - it indicates that there are comments in the project
811 -- source that cannot be kept in the tree.
812 -- N_Project_Declaration
813 -- - it indicates that there are unkept comments in the
814 -- project.
816 Flag2 : Boolean := False;
817 -- This flag is significant only for:
818 -- N_Project - it indicates that the project "extends all" another
819 -- project.
820 -- N_Comment - it indicates that the comment is followed by an
821 -- empty line.
822 -- N_With_Clause
823 -- - it indicates that the originally imported project
824 -- is an extending all project.
826 Comments : Project_Node_Id := Empty_Node;
827 -- For nodes other that N_Comment_Zones or N_Comment, designates the
828 -- comment zones associated with the node.
829 -- for N_Comment_Zones, designates the comment after the "end" of
830 -- the construct.
831 -- For N_Comment, designates the next comment, if any.
833 end record;
835 -- type Project_Node_Kind is
837 -- (N_Project,
838 -- -- Name: project name
839 -- -- Path_Name: project path name
840 -- -- Expr_Kind: Undefined
841 -- -- Field1: first with clause
842 -- -- Field2: project declaration
843 -- -- Field3: first string type
844 -- -- Value: extended project path name (if any)
846 -- N_With_Clause,
847 -- -- Name: imported project name
848 -- -- Path_Name: imported project path name
849 -- -- Expr_Kind: Undefined
850 -- -- Field1: project node
851 -- -- Field2: next with clause
852 -- -- Field3: project node or empty if "limited with"
853 -- -- Value: literal string withed
855 -- N_Project_Declaration,
856 -- -- Name: not used
857 -- -- Path_Name: not used
858 -- -- Expr_Kind: Undefined
859 -- -- Field1: first declarative item
860 -- -- Field2: extended project
861 -- -- Field3: extending project
862 -- -- Value: not used
864 -- N_Declarative_Item,
865 -- -- Name: not used
866 -- -- Path_Name: not used
867 -- -- Expr_Kind: Undefined
868 -- -- Field1: current item node
869 -- -- Field2: next declarative item
870 -- -- Field3: not used
871 -- -- Value: not used
873 -- N_Package_Declaration,
874 -- -- Name: package name
875 -- -- Path_Name: not used
876 -- -- Expr_Kind: Undefined
877 -- -- Field1: project of renamed package (if any)
878 -- -- Field2: first declarative item
879 -- -- Field3: next package in project
880 -- -- Value: not used
882 -- N_String_Type_Declaration,
883 -- -- Name: type name
884 -- -- Path_Name: not used
885 -- -- Expr_Kind: Undefined
886 -- -- Field1: first literal string
887 -- -- Field2: next string type
888 -- -- Field3: not used
889 -- -- Value: not used
891 -- N_Literal_String,
892 -- -- Name: not used
893 -- -- Path_Name: not used
894 -- -- Expr_Kind: Single
895 -- -- Field1: next literal string
896 -- -- Field2: not used
897 -- -- Field3: not used
898 -- -- Value: string value
900 -- N_Attribute_Declaration,
901 -- -- Name: attribute name
902 -- -- Path_Name: not used
903 -- -- Expr_Kind: attribute kind
904 -- -- Field1: expression
905 -- -- Field2: project of full associative array
906 -- -- Field3: package of full associative array
907 -- -- Value: associative array index
908 -- -- (if an associative array element)
910 -- N_Typed_Variable_Declaration,
911 -- -- Name: variable name
912 -- -- Path_Name: not used
913 -- -- Expr_Kind: Single
914 -- -- Field1: expression
915 -- -- Field2: type of variable (N_String_Type_Declaration)
916 -- -- Field3: next variable
917 -- -- Value: not used
919 -- N_Variable_Declaration,
920 -- -- Name: variable name
921 -- -- Path_Name: not used
922 -- -- Expr_Kind: variable kind
923 -- -- Field1: expression
924 -- -- Field2: not used
925 -- -- Field3 is used for next variable, instead of Field2,
926 -- -- so that it is the same field for
927 -- -- N_Variable_Declaration and
928 -- -- N_Typed_Variable_Declaration
929 -- -- Field3: next variable
930 -- -- Value: not used
932 -- N_Expression,
933 -- -- Name: not used
934 -- -- Path_Name: not used
935 -- -- Expr_Kind: expression kind
936 -- -- Field1: first term
937 -- -- Field2: next expression in list
938 -- -- Field3: not used
939 -- -- Value: not used
941 -- N_Term,
942 -- -- Name: not used
943 -- -- Path_Name: not used
944 -- -- Expr_Kind: term kind
945 -- -- Field1: current term
946 -- -- Field2: next term in the expression
947 -- -- Field3: not used
948 -- -- Value: not used
950 -- N_Literal_String_List,
951 -- -- Designates a list of string expressions between brackets
952 -- -- separated by commas. The string expressions are not necessarily
953 -- -- literal strings.
954 -- -- Name: not used
955 -- -- Path_Name: not used
956 -- -- Expr_Kind: List
957 -- -- Field1: first expression
958 -- -- Field2: not used
959 -- -- Field3: not used
960 -- -- Value: not used
962 -- N_Variable_Reference,
963 -- -- Name: variable name
964 -- -- Path_Name: not used
965 -- -- Expr_Kind: variable kind
966 -- -- Field1: project (if specified)
967 -- -- Field2: package (if specified)
968 -- -- Field3: type of variable (N_String_Type_Declaration), if any
969 -- -- Value: not used
971 -- N_External_Value,
972 -- -- Name: not used
973 -- -- Path_Name: not used
974 -- -- Expr_Kind: Single
975 -- -- Field1: Name of the external reference (literal string)
976 -- -- Field2: Default (literal string)
977 -- -- Field3: not used
978 -- -- Value: not used
980 -- N_Attribute_Reference,
981 -- -- Name: attribute name
982 -- -- Path_Name: not used
983 -- -- Expr_Kind: attribute kind
984 -- -- Field1: project
985 -- -- Field2: package (if attribute of a package)
986 -- -- Field3: not used
987 -- -- Value: associative array index
988 -- -- (if an associative array element)
990 -- N_Case_Construction,
991 -- -- Name: not used
992 -- -- Path_Name: not used
993 -- -- Expr_Kind: Undefined
994 -- -- Field1: case variable reference
995 -- -- Field2: first case item
996 -- -- Field3: not used
997 -- -- Value: not used
999 -- N_Case_Item
1000 -- -- Name: not used
1001 -- -- Path_Name: not used
1002 -- -- Expr_Kind: not used
1003 -- -- Field1: first choice (literal string), or Empty_Node
1004 -- -- for when others
1005 -- -- Field2: first declarative item
1006 -- -- Field3: next case item
1007 -- -- Value: not used
1009 -- N_Comment_zones
1010 -- -- Name: not used
1011 -- -- Path_Name: not used
1012 -- -- Expr_Kind: not used
1013 -- -- Field1: comment before the construct
1014 -- -- Field2: comment after the construct
1015 -- -- Field3: comment before the "end" of the construct
1016 -- -- Value: end of line comment
1017 -- -- Comments: comment after the "end" of the construct
1019 -- N_Comment
1020 -- -- Name: not used
1021 -- -- Path_Name: not used
1022 -- -- Expr_Kind: not used
1023 -- -- Field1: not used
1024 -- -- Field2: not used
1025 -- -- Field3: not used
1026 -- -- Value: comment
1027 -- -- Flag1: comment is preceded by an empty line
1028 -- -- Flag2: comment is followed by an empty line
1029 -- -- Comments: next comment
1031 package Project_Nodes is
1032 new Table.Table (Table_Component_Type => Project_Node_Record,
1033 Table_Index_Type => Project_Node_Id,
1034 Table_Low_Bound => First_Node_Id,
1035 Table_Initial => Project_Nodes_Initial,
1036 Table_Increment => Project_Nodes_Increment,
1037 Table_Name => "Project_Nodes");
1038 -- This table contains the syntactic tree of project data
1039 -- from project files.
1041 type Project_Name_And_Node is record
1042 Name : Name_Id;
1043 -- Name of the project
1045 Node : Project_Node_Id;
1046 -- Node of the project in table Project_Nodes
1048 Canonical_Path : Name_Id;
1049 -- Resolved and canonical path of the project file
1051 Extended : Boolean;
1052 -- True when the project is being extended by another project
1053 end record;
1055 No_Project_Name_And_Node : constant Project_Name_And_Node :=
1056 (Name => No_Name,
1057 Node => Empty_Node,
1058 Canonical_Path => No_Name,
1059 Extended => True);
1061 package Projects_Htable is new GNAT.HTable.Simple_HTable
1062 (Header_Num => Header_Num,
1063 Element => Project_Name_And_Node,
1064 No_Element => No_Project_Name_And_Node,
1065 Key => Name_Id,
1066 Hash => Hash,
1067 Equal => "=");
1068 -- This hash table contains a mapping of project names to project nodes.
1069 -- Note that this hash table contains only the nodes whose Kind is
1070 -- N_Project. It is used to find the node of a project from its
1071 -- name, and to verify if a project has already been parsed, knowing
1072 -- its name.
1074 end Tree_Private_Part;
1076 private
1077 type Comment_Array is array (Positive range <>) of Comment_Data;
1078 type Comments_Ptr is access Comment_Array;
1080 type Comment_State is record
1081 End_Of_Line_Node : Project_Node_Id := Empty_Node;
1083 Previous_Line_Node : Project_Node_Id := Empty_Node;
1085 Previous_End_Node : Project_Node_Id := Empty_Node;
1087 Unkept_Comments : Boolean := False;
1089 Comments : Comments_Ptr := null;
1090 end record;
1092 end Prj.Tree;