1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2009, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- This package defines the structure of the Project File tree
28 with GNAT
.Dynamic_HTables
;
29 with GNAT
.Dynamic_Tables
;
33 with Prj
.Attr
; use Prj
.Attr
;
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
71 N_Project_Declaration
,
73 N_Package_Declaration
,
74 N_String_Type_Declaration
,
76 N_Attribute_Declaration
,
77 N_Typed_Variable_Declaration
,
78 N_Variable_Declaration
,
81 N_Literal_String_List
,
84 N_Attribute_Reference
,
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
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;
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.
127 type Comment_State
is private;
128 -- A type to store the values of several global variables related to
131 procedure Save
(S
: out Comment_State
);
132 -- Save in variable S the comment state. Called before scanning a new
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
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
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;
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,
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.
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
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
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
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_Project_Declaration, N_Case_Item and
412 -- N_Package_Declaration.
414 function Extended_Project_Of
415 (Node
: Project_Node_Id
;
416 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
417 pragma Inline
(Extended_Project_Of
);
418 -- Only valid for N_Project_Declaration nodes
420 function Current_Item_Node
421 (Node
: Project_Node_Id
;
422 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
423 pragma Inline
(Current_Item_Node
);
424 -- Only valid for N_Declarative_Item nodes
426 function Next_Declarative_Item
427 (Node
: Project_Node_Id
;
428 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
429 pragma Inline
(Next_Declarative_Item
);
430 -- Only valid for N_Declarative_Item node
432 function Project_Of_Renamed_Package_Of
433 (Node
: Project_Node_Id
;
434 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
435 pragma Inline
(Project_Of_Renamed_Package_Of
);
436 -- Only valid for N_Package_Declaration nodes. May return Empty_Node.
438 function Next_Package_In_Project
439 (Node
: Project_Node_Id
;
440 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
441 pragma Inline
(Next_Package_In_Project
);
442 -- Only valid for N_Package_Declaration nodes
444 function First_Literal_String
445 (Node
: Project_Node_Id
;
446 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
447 pragma Inline
(First_Literal_String
);
448 -- Only valid for N_String_Type_Declaration nodes
450 function Next_String_Type
451 (Node
: Project_Node_Id
;
452 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
453 pragma Inline
(Next_String_Type
);
454 -- Only valid for N_String_Type_Declaration nodes
456 function Next_Literal_String
457 (Node
: Project_Node_Id
;
458 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
459 pragma Inline
(Next_Literal_String
);
460 -- Only valid for N_Literal_String nodes
462 function Expression_Of
463 (Node
: Project_Node_Id
;
464 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
465 pragma Inline
(Expression_Of
);
466 -- Only valid for N_Attribute_Declaration, N_Typed_Variable_Declaration
467 -- or N_Variable_Declaration nodes
469 function Associative_Project_Of
470 (Node
: Project_Node_Id
;
471 In_Tree
: Project_Node_Tree_Ref
)
472 return Project_Node_Id
;
473 pragma Inline
(Associative_Project_Of
);
474 -- Only valid for N_Attribute_Declaration nodes
476 function Associative_Package_Of
477 (Node
: Project_Node_Id
;
478 In_Tree
: Project_Node_Tree_Ref
)
479 return Project_Node_Id
;
480 pragma Inline
(Associative_Package_Of
);
481 -- Only valid for N_Attribute_Declaration nodes
483 function Value_Is_Valid
484 (For_Typed_Variable
: Project_Node_Id
;
485 In_Tree
: Project_Node_Tree_Ref
;
486 Value
: Name_Id
) return Boolean;
487 pragma Inline
(Value_Is_Valid
);
488 -- Only valid for N_Typed_Variable_Declaration. Returns True if Value is
489 -- in the list of allowed strings for For_Typed_Variable. False otherwise.
491 function Associative_Array_Index_Of
492 (Node
: Project_Node_Id
;
493 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
;
494 pragma Inline
(Associative_Array_Index_Of
);
495 -- Only valid for N_Attribute_Declaration and N_Attribute_Reference.
496 -- Returns No_Name for non associative array attributes.
498 function Next_Variable
499 (Node
: Project_Node_Id
;
500 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
501 pragma Inline
(Next_Variable
);
502 -- Only valid for N_Typed_Variable_Declaration or N_Variable_Declaration
506 (Node
: Project_Node_Id
;
507 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
508 pragma Inline
(First_Term
);
509 -- Only valid for N_Expression nodes
511 function Next_Expression_In_List
512 (Node
: Project_Node_Id
;
513 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
514 pragma Inline
(Next_Expression_In_List
);
515 -- Only valid for N_Expression nodes
517 function Current_Term
518 (Node
: Project_Node_Id
;
519 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
520 pragma Inline
(Current_Term
);
521 -- Only valid for N_Term nodes
524 (Node
: Project_Node_Id
;
525 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
526 pragma Inline
(Next_Term
);
527 -- Only valid for N_Term nodes
529 function First_Expression_In_List
530 (Node
: Project_Node_Id
;
531 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
532 pragma Inline
(First_Expression_In_List
);
533 -- Only valid for N_Literal_String_List nodes
535 function Package_Node_Of
536 (Node
: Project_Node_Id
;
537 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
538 pragma Inline
(Package_Node_Of
);
539 -- Only valid for N_Variable_Reference or N_Attribute_Reference nodes.
540 -- May return Empty_Node.
542 function String_Type_Of
543 (Node
: Project_Node_Id
;
544 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
545 pragma Inline
(String_Type_Of
);
546 -- Only valid for N_Variable_Reference or N_Typed_Variable_Declaration
549 function External_Reference_Of
550 (Node
: Project_Node_Id
;
551 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
552 pragma Inline
(External_Reference_Of
);
553 -- Only valid for N_External_Value nodes
555 function External_Default_Of
556 (Node
: Project_Node_Id
;
557 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
558 pragma Inline
(External_Default_Of
);
559 -- Only valid for N_External_Value nodes
561 function Case_Variable_Reference_Of
562 (Node
: Project_Node_Id
;
563 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
564 pragma Inline
(Case_Variable_Reference_Of
);
565 -- Only valid for N_Case_Construction nodes
567 function First_Case_Item_Of
568 (Node
: Project_Node_Id
;
569 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
570 pragma Inline
(First_Case_Item_Of
);
571 -- Only valid for N_Case_Construction nodes
573 function First_Choice_Of
574 (Node
: Project_Node_Id
;
575 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
576 pragma Inline
(First_Choice_Of
);
577 -- Only valid for N_Case_Item nodes. Return the first choice in a
578 -- N_Case_Item, or Empty_Node if this is when others.
580 function Next_Case_Item
581 (Node
: Project_Node_Id
;
582 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
583 pragma Inline
(Next_Case_Item
);
584 -- Only valid for N_Case_Item nodes
586 function Case_Insensitive
587 (Node
: Project_Node_Id
;
588 In_Tree
: Project_Node_Tree_Ref
) return Boolean;
589 -- Only valid for N_Attribute_Declaration and N_Attribute_Reference nodes
591 -----------------------
592 -- Create procedures --
593 -----------------------
594 -- The following procedures are used to edit a project file tree. They are
595 -- slightly higher-level than the Set_* procedures below
597 function Create_Project
598 (In_Tree
: Project_Node_Tree_Ref
;
600 Full_Path
: Path_Name_Type
;
601 Is_Config_File
: Boolean := False) return Project_Node_Id
;
602 -- Create a new node for a project and register it in the tree so that it
603 -- can be retrieved later on.
605 function Create_Package
606 (Tree
: Project_Node_Tree_Ref
;
607 Project
: Project_Node_Id
;
608 Pkg
: String) return Project_Node_Id
;
609 -- Create a new package in Project. If the package already exists, it is
610 -- returned. The name of the package *must* be lower-cases, or none of its
611 -- attributes will be recognized.
613 function Create_Attribute
614 (Tree
: Project_Node_Tree_Ref
;
615 Prj_Or_Pkg
: Project_Node_Id
;
617 Index_Name
: Name_Id
:= No_Name
;
618 Kind
: Variable_Kind
:= List
;
619 At_Index
: Integer := 0;
620 Value
: Project_Node_Id
:= Empty_Node
) return Project_Node_Id
;
621 -- Create a new attribute. The new declaration is added at the end of the
622 -- declarative item list for Prj_Or_Pkg (a project or a package), but
623 -- before any package declaration). No addition is done if Prj_Or_Pkg is
624 -- Empty_Node. If Index_Name is not "", then if creates an attribute value
625 -- for a specific index. At_Index is used for the " at <idx>" in the naming
628 -- To set the value of the attribute, either provide a value for Value, or
629 -- use Set_Expression_Of to set the value of the attribute (in which case
630 -- Enclose_In_Expression might be useful). The former is recommended since
631 -- it will more correctly handle cases where the index needs to be set on
632 -- the expression rather than on the index of the attribute (i.e. 'for
633 -- Specification ("unit") use "file" at 3', versus 'for Executable ("file"
634 -- at 3) use "name"'). Value must be a N_String_Literal if an index will be
637 function Create_Literal_String
638 (Str
: Namet
.Name_Id
;
639 Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
640 -- Create a literal string whose value is Str
643 (Tree
: Project_Node_Tree_Ref
;
644 Parent
: Project_Node_Id
;
645 Expr
: Project_Node_Id
;
646 Add_Before_First_Pkg
: Boolean := False;
647 Add_Before_First_Case
: Boolean := False);
648 -- Add a new declarative item in the list in Parent. This new declarative
649 -- item will contain Expr (unless Expr is already a declarative item, in
650 -- which case it is added directly to the list). The new item is inserted
651 -- at the end of the list, unless Add_Before_First_Pkg is True. In the
652 -- latter case, it is added just before the first case construction is
653 -- seen, or before the first package (this assumes that all packages are
654 -- found at the end of the project, which isn't true in the general case
655 -- unless you have normalized the project to match this description).
657 function Enclose_In_Expression
658 (Node
: Project_Node_Id
;
659 Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
660 -- Enclose the Node inside a N_Expression node, and return this expression.
661 -- This does nothing if Node is already a N_Expression.
667 -- The following procedures are part of the abstract interface of the
668 -- Project File tree.
670 -- Foe each Set_* procedure the condition of validity is specified. If an
671 -- access function is called with invalid arguments, then exception
672 -- Assertion_Error is raised if assertions are enabled, otherwise the
673 -- behaviour is not defined and may result in a crash.
675 -- These are very low-level, and manipulate the tree itself directly. You
676 -- should look at the Create_* procedure instead if you want to use higher
679 procedure Set_Name_Of
680 (Node
: Project_Node_Id
;
681 In_Tree
: Project_Node_Tree_Ref
;
683 pragma Inline
(Set_Name_Of
);
684 -- Valid for all non empty nodes.
686 procedure Set_Kind_Of
687 (Node
: Project_Node_Id
;
688 In_Tree
: Project_Node_Tree_Ref
;
689 To
: Project_Node_Kind
);
690 pragma Inline
(Set_Kind_Of
);
691 -- Valid for all non empty nodes
693 procedure Set_Location_Of
694 (Node
: Project_Node_Id
;
695 In_Tree
: Project_Node_Tree_Ref
;
697 pragma Inline
(Set_Location_Of
);
698 -- Valid for all non empty nodes
700 procedure Set_First_Comment_After
701 (Node
: Project_Node_Id
;
702 In_Tree
: Project_Node_Tree_Ref
;
703 To
: Project_Node_Id
);
704 pragma Inline
(Set_First_Comment_After
);
705 -- Valid only for N_Comment_Zones nodes
707 procedure Set_First_Comment_After_End
708 (Node
: Project_Node_Id
;
709 In_Tree
: Project_Node_Tree_Ref
;
710 To
: Project_Node_Id
);
711 pragma Inline
(Set_First_Comment_After_End
);
712 -- Valid only for N_Comment_Zones nodes
714 procedure Set_First_Comment_Before
715 (Node
: Project_Node_Id
;
716 In_Tree
: Project_Node_Tree_Ref
;
717 To
: Project_Node_Id
);
718 pragma Inline
(Set_First_Comment_Before
);
719 -- Valid only for N_Comment_Zones nodes
721 procedure Set_First_Comment_Before_End
722 (Node
: Project_Node_Id
;
723 In_Tree
: Project_Node_Tree_Ref
;
724 To
: Project_Node_Id
);
725 pragma Inline
(Set_First_Comment_Before_End
);
726 -- Valid only for N_Comment_Zones nodes
728 procedure Set_Next_Comment
729 (Node
: Project_Node_Id
;
730 In_Tree
: Project_Node_Tree_Ref
;
731 To
: Project_Node_Id
);
732 pragma Inline
(Set_Next_Comment
);
733 -- Valid only for N_Comment nodes
735 procedure Set_Parent_Project_Of
736 (Node
: Project_Node_Id
;
737 In_Tree
: Project_Node_Tree_Ref
;
738 To
: Project_Node_Id
);
739 -- Valid only for N_Project nodes
741 procedure Set_Project_File_Includes_Unkept_Comments
742 (Node
: Project_Node_Id
;
743 In_Tree
: Project_Node_Tree_Ref
;
745 -- Valid only for N_Project nodes
747 procedure Set_Directory_Of
748 (Node
: Project_Node_Id
;
749 In_Tree
: Project_Node_Tree_Ref
;
750 To
: Path_Name_Type
);
751 pragma Inline
(Set_Directory_Of
);
752 -- Valid only for N_Project nodes
754 procedure Set_Expression_Kind_Of
755 (Node
: Project_Node_Id
;
756 In_Tree
: Project_Node_Tree_Ref
;
758 pragma Inline
(Set_Expression_Kind_Of
);
759 -- Only valid for N_Literal_String, N_Attribute_Declaration,
760 -- N_Variable_Declaration, N_Typed_Variable_Declaration, N_Expression,
761 -- N_Term, N_Variable_Reference or N_Attribute_Reference nodes.
763 procedure Set_Is_Extending_All
764 (Node
: Project_Node_Id
;
765 In_Tree
: Project_Node_Tree_Ref
);
766 pragma Inline
(Set_Is_Extending_All
);
767 -- Only valid for N_Project and N_With_Clause
769 procedure Set_Is_Not_Last_In_List
770 (Node
: Project_Node_Id
;
771 In_Tree
: Project_Node_Tree_Ref
);
772 pragma Inline
(Set_Is_Not_Last_In_List
);
773 -- Only valid for N_With_Clause
775 procedure Set_First_Variable_Of
776 (Node
: Project_Node_Id
;
777 In_Tree
: Project_Node_Tree_Ref
;
778 To
: Variable_Node_Id
);
779 pragma Inline
(Set_First_Variable_Of
);
780 -- Only valid for N_Project or N_Package_Declaration nodes
782 procedure Set_First_Package_Of
783 (Node
: Project_Node_Id
;
784 In_Tree
: Project_Node_Tree_Ref
;
785 To
: Package_Declaration_Id
);
786 pragma Inline
(Set_First_Package_Of
);
787 -- Only valid for N_Project nodes
789 procedure Set_Package_Id_Of
790 (Node
: Project_Node_Id
;
791 In_Tree
: Project_Node_Tree_Ref
;
792 To
: Package_Node_Id
);
793 pragma Inline
(Set_Package_Id_Of
);
794 -- Only valid for N_Package_Declaration nodes
796 procedure Set_Path_Name_Of
797 (Node
: Project_Node_Id
;
798 In_Tree
: Project_Node_Tree_Ref
;
799 To
: Path_Name_Type
);
800 pragma Inline
(Set_Path_Name_Of
);
801 -- Only valid for N_Project and N_With_Clause nodes
803 procedure Set_String_Value_Of
804 (Node
: Project_Node_Id
;
805 In_Tree
: Project_Node_Tree_Ref
;
807 pragma Inline
(Set_String_Value_Of
);
808 -- Only valid for N_With_Clause, N_Literal_String nodes or N_Comment.
810 procedure Set_Source_Index_Of
811 (Node
: Project_Node_Id
;
812 In_Tree
: Project_Node_Tree_Ref
;
814 pragma Inline
(Set_Source_Index_Of
);
815 -- Only valid for N_Literal_String and N_Attribute_Declaration nodes. For
816 -- N_Literal_String, set the source index of the litteral string. For
817 -- N_Attribute_Declaration, set the source index of the index of the
818 -- associative array element.
820 procedure Set_First_With_Clause_Of
821 (Node
: Project_Node_Id
;
822 In_Tree
: Project_Node_Tree_Ref
;
823 To
: Project_Node_Id
);
824 pragma Inline
(Set_First_With_Clause_Of
);
825 -- Only valid for N_Project nodes
827 procedure Set_Project_Declaration_Of
828 (Node
: Project_Node_Id
;
829 In_Tree
: Project_Node_Tree_Ref
;
830 To
: Project_Node_Id
);
831 pragma Inline
(Set_Project_Declaration_Of
);
832 -- Only valid for N_Project nodes
834 procedure Set_Project_Qualifier_Of
835 (Node
: Project_Node_Id
;
836 In_Tree
: Project_Node_Tree_Ref
;
837 To
: Project_Qualifier
);
838 pragma Inline
(Set_Project_Qualifier_Of
);
839 -- Only valid for N_Project nodes
841 procedure Set_Extending_Project_Of
842 (Node
: Project_Node_Id
;
843 In_Tree
: Project_Node_Tree_Ref
;
844 To
: Project_Node_Id
);
845 pragma Inline
(Set_Extending_Project_Of
);
846 -- Only valid for N_Project_Declaration nodes
848 procedure Set_First_String_Type_Of
849 (Node
: Project_Node_Id
;
850 In_Tree
: Project_Node_Tree_Ref
;
851 To
: Project_Node_Id
);
852 pragma Inline
(Set_First_String_Type_Of
);
853 -- Only valid for N_Project nodes
855 procedure Set_Extended_Project_Path_Of
856 (Node
: Project_Node_Id
;
857 In_Tree
: Project_Node_Tree_Ref
;
858 To
: Path_Name_Type
);
859 pragma Inline
(Set_Extended_Project_Path_Of
);
860 -- Only valid for N_With_Clause nodes
862 procedure Set_Project_Node_Of
863 (Node
: Project_Node_Id
;
864 In_Tree
: Project_Node_Tree_Ref
;
865 To
: Project_Node_Id
;
866 Limited_With
: Boolean := False);
867 pragma Inline
(Set_Project_Node_Of
);
868 -- Only valid for N_With_Clause, N_Variable_Reference and
869 -- N_Attribute_Reference nodes.
871 procedure Set_Next_With_Clause_Of
872 (Node
: Project_Node_Id
;
873 In_Tree
: Project_Node_Tree_Ref
;
874 To
: Project_Node_Id
);
875 pragma Inline
(Set_Next_With_Clause_Of
);
876 -- Only valid for N_With_Clause nodes
878 procedure Set_First_Declarative_Item_Of
879 (Node
: Project_Node_Id
;
880 In_Tree
: Project_Node_Tree_Ref
;
881 To
: Project_Node_Id
);
882 pragma Inline
(Set_First_Declarative_Item_Of
);
883 -- Only valid for N_Project_Declaration, N_Case_Item and
884 -- N_Package_Declaration.
886 procedure Set_Extended_Project_Of
887 (Node
: Project_Node_Id
;
888 In_Tree
: Project_Node_Tree_Ref
;
889 To
: Project_Node_Id
);
890 pragma Inline
(Set_Extended_Project_Of
);
891 -- Only valid for N_Project_Declaration nodes
893 procedure Set_Current_Item_Node
894 (Node
: Project_Node_Id
;
895 In_Tree
: Project_Node_Tree_Ref
;
896 To
: Project_Node_Id
);
897 pragma Inline
(Set_Current_Item_Node
);
898 -- Only valid for N_Declarative_Item nodes
900 procedure Set_Next_Declarative_Item
901 (Node
: Project_Node_Id
;
902 In_Tree
: Project_Node_Tree_Ref
;
903 To
: Project_Node_Id
);
904 pragma Inline
(Set_Next_Declarative_Item
);
905 -- Only valid for N_Declarative_Item node
907 procedure Set_Project_Of_Renamed_Package_Of
908 (Node
: Project_Node_Id
;
909 In_Tree
: Project_Node_Tree_Ref
;
910 To
: Project_Node_Id
);
911 pragma Inline
(Set_Project_Of_Renamed_Package_Of
);
912 -- Only valid for N_Package_Declaration nodes.
914 procedure Set_Next_Package_In_Project
915 (Node
: Project_Node_Id
;
916 In_Tree
: Project_Node_Tree_Ref
;
917 To
: Project_Node_Id
);
918 pragma Inline
(Set_Next_Package_In_Project
);
919 -- Only valid for N_Package_Declaration nodes
921 procedure Set_First_Literal_String
922 (Node
: Project_Node_Id
;
923 In_Tree
: Project_Node_Tree_Ref
;
924 To
: Project_Node_Id
);
925 pragma Inline
(Set_First_Literal_String
);
926 -- Only valid for N_String_Type_Declaration nodes
928 procedure Set_Next_String_Type
929 (Node
: Project_Node_Id
;
930 In_Tree
: Project_Node_Tree_Ref
;
931 To
: Project_Node_Id
);
932 pragma Inline
(Set_Next_String_Type
);
933 -- Only valid for N_String_Type_Declaration nodes
935 procedure Set_Next_Literal_String
936 (Node
: Project_Node_Id
;
937 In_Tree
: Project_Node_Tree_Ref
;
938 To
: Project_Node_Id
);
939 pragma Inline
(Set_Next_Literal_String
);
940 -- Only valid for N_Literal_String nodes
942 procedure Set_Expression_Of
943 (Node
: Project_Node_Id
;
944 In_Tree
: Project_Node_Tree_Ref
;
945 To
: Project_Node_Id
);
946 pragma Inline
(Set_Expression_Of
);
947 -- Only valid for N_Attribute_Declaration, N_Typed_Variable_Declaration
948 -- or N_Variable_Declaration nodes
950 procedure Set_Associative_Project_Of
951 (Node
: Project_Node_Id
;
952 In_Tree
: Project_Node_Tree_Ref
;
953 To
: Project_Node_Id
);
954 pragma Inline
(Set_Associative_Project_Of
);
955 -- Only valid for N_Attribute_Declaration nodes
957 procedure Set_Associative_Package_Of
958 (Node
: Project_Node_Id
;
959 In_Tree
: Project_Node_Tree_Ref
;
960 To
: Project_Node_Id
);
961 pragma Inline
(Set_Associative_Package_Of
);
962 -- Only valid for N_Attribute_Declaration nodes
964 procedure Set_Associative_Array_Index_Of
965 (Node
: Project_Node_Id
;
966 In_Tree
: Project_Node_Tree_Ref
;
968 pragma Inline
(Set_Associative_Array_Index_Of
);
969 -- Only valid for N_Attribute_Declaration and N_Attribute_Reference.
971 procedure Set_Next_Variable
972 (Node
: Project_Node_Id
;
973 In_Tree
: Project_Node_Tree_Ref
;
974 To
: Project_Node_Id
);
975 pragma Inline
(Set_Next_Variable
);
976 -- Only valid for N_Typed_Variable_Declaration or N_Variable_Declaration
979 procedure Set_First_Term
980 (Node
: Project_Node_Id
;
981 In_Tree
: Project_Node_Tree_Ref
;
982 To
: Project_Node_Id
);
983 pragma Inline
(Set_First_Term
);
984 -- Only valid for N_Expression nodes
986 procedure Set_Next_Expression_In_List
987 (Node
: Project_Node_Id
;
988 In_Tree
: Project_Node_Tree_Ref
;
989 To
: Project_Node_Id
);
990 pragma Inline
(Set_Next_Expression_In_List
);
991 -- Only valid for N_Expression nodes
993 procedure Set_Current_Term
994 (Node
: Project_Node_Id
;
995 In_Tree
: Project_Node_Tree_Ref
;
996 To
: Project_Node_Id
);
997 pragma Inline
(Set_Current_Term
);
998 -- Only valid for N_Term nodes
1000 procedure Set_Next_Term
1001 (Node
: Project_Node_Id
;
1002 In_Tree
: Project_Node_Tree_Ref
;
1003 To
: Project_Node_Id
);
1004 pragma Inline
(Set_Next_Term
);
1005 -- Only valid for N_Term nodes
1007 procedure Set_First_Expression_In_List
1008 (Node
: Project_Node_Id
;
1009 In_Tree
: Project_Node_Tree_Ref
;
1010 To
: Project_Node_Id
);
1011 pragma Inline
(Set_First_Expression_In_List
);
1012 -- Only valid for N_Literal_String_List nodes
1014 procedure Set_Package_Node_Of
1015 (Node
: Project_Node_Id
;
1016 In_Tree
: Project_Node_Tree_Ref
;
1017 To
: Project_Node_Id
);
1018 pragma Inline
(Set_Package_Node_Of
);
1019 -- Only valid for N_Variable_Reference or N_Attribute_Reference nodes.
1021 procedure Set_String_Type_Of
1022 (Node
: Project_Node_Id
;
1023 In_Tree
: Project_Node_Tree_Ref
;
1024 To
: Project_Node_Id
);
1025 pragma Inline
(Set_String_Type_Of
);
1026 -- Only valid for N_Variable_Reference or N_Typed_Variable_Declaration
1029 procedure Set_External_Reference_Of
1030 (Node
: Project_Node_Id
;
1031 In_Tree
: Project_Node_Tree_Ref
;
1032 To
: Project_Node_Id
);
1033 pragma Inline
(Set_External_Reference_Of
);
1034 -- Only valid for N_External_Value nodes
1036 procedure Set_External_Default_Of
1037 (Node
: Project_Node_Id
;
1038 In_Tree
: Project_Node_Tree_Ref
;
1039 To
: Project_Node_Id
);
1040 pragma Inline
(Set_External_Default_Of
);
1041 -- Only valid for N_External_Value nodes
1043 procedure Set_Case_Variable_Reference_Of
1044 (Node
: Project_Node_Id
;
1045 In_Tree
: Project_Node_Tree_Ref
;
1046 To
: Project_Node_Id
);
1047 pragma Inline
(Set_Case_Variable_Reference_Of
);
1048 -- Only valid for N_Case_Construction nodes
1050 procedure Set_First_Case_Item_Of
1051 (Node
: Project_Node_Id
;
1052 In_Tree
: Project_Node_Tree_Ref
;
1053 To
: Project_Node_Id
);
1054 pragma Inline
(Set_First_Case_Item_Of
);
1055 -- Only valid for N_Case_Construction nodes
1057 procedure Set_First_Choice_Of
1058 (Node
: Project_Node_Id
;
1059 In_Tree
: Project_Node_Tree_Ref
;
1060 To
: Project_Node_Id
);
1061 pragma Inline
(Set_First_Choice_Of
);
1062 -- Only valid for N_Case_Item nodes.
1064 procedure Set_Next_Case_Item
1065 (Node
: Project_Node_Id
;
1066 In_Tree
: Project_Node_Tree_Ref
;
1067 To
: Project_Node_Id
);
1068 pragma Inline
(Set_Next_Case_Item
);
1069 -- Only valid for N_Case_Item nodes.
1071 procedure Set_Case_Insensitive
1072 (Node
: Project_Node_Id
;
1073 In_Tree
: Project_Node_Tree_Ref
;
1075 -- Only valid for N_Attribute_Declaration and N_Attribute_Reference nodes
1077 -------------------------------
1078 -- Restricted Access Section --
1079 -------------------------------
1081 package Tree_Private_Part
is
1083 -- This is conceptually in the private part. However, for efficiency,
1084 -- some packages are accessing it directly.
1086 type Project_Node_Record
is record
1088 Kind
: Project_Node_Kind
;
1090 Qualifier
: Project_Qualifier
:= Unspecified
;
1092 Location
: Source_Ptr
:= No_Location
;
1094 Directory
: Path_Name_Type
:= No_Path
;
1095 -- Only for N_Project
1097 Expr_Kind
: Variable_Kind
:= Undefined
;
1098 -- See below for what Project_Node_Kind it is used
1100 Variables
: Variable_Node_Id
:= Empty_Node
;
1101 -- First variable in a project or a package
1103 Packages
: Package_Declaration_Id
:= Empty_Node
;
1104 -- First package declaration in a project
1106 Pkg_Id
: Package_Node_Id
:= Empty_Package
;
1107 -- Only used for N_Package_Declaration
1109 -- The component Pkg_Id is an entry into the table Package_Attributes
1110 -- (in Prj.Attr). It is used to indicate all the attributes of the
1111 -- package with their characteristics.
1113 -- The tables Prj.Attr.Attributes and Prj.Attr.Package_Attributes
1114 -- are built once and for all through a call (from Prj.Initialize)
1115 -- to procedure Prj.Attr.Initialize. It is never modified after that.
1117 Name
: Name_Id
:= No_Name
;
1118 -- See below for what Project_Node_Kind it is used
1120 Src_Index
: Int
:= 0;
1121 -- Index of a unit in a multi-unit source.
1122 -- Only for some N_Attribute_Declaration and N_Literal_String.
1124 Path_Name
: Path_Name_Type
:= No_Path
;
1125 -- See below for what Project_Node_Kind it is used
1127 Value
: Name_Id
:= No_Name
;
1128 -- See below for what Project_Node_Kind it is used
1130 Field1
: Project_Node_Id
:= Empty_Node
;
1131 -- See below the meaning for each Project_Node_Kind
1133 Field2
: Project_Node_Id
:= Empty_Node
;
1134 -- See below the meaning for each Project_Node_Kind
1136 Field3
: Project_Node_Id
:= Empty_Node
;
1137 -- See below the meaning for each Project_Node_Kind
1139 Field4
: Project_Node_Id
:= Empty_Node
;
1140 -- See below the meaning for each Project_Node_Kind
1142 Flag1
: Boolean := False;
1143 -- This flag is significant only for:
1145 -- N_Attribute_Declaration and N_Attribute_Reference
1146 -- Indicates for an associative array attribute, that the
1147 -- index is case insensitive.
1150 -- Indicates that the comment is preceded by an empty line.
1153 -- Indicates that there are comments in the project source that
1154 -- cannot be kept in the tree.
1156 -- N_Project_Declaration
1157 -- Indicates that there are unkept comments in the project.
1160 -- Indicates that this is not the last with in a with clause.
1161 -- Set for "A", but not for "B" in with "B"; and with "A", "B";
1163 Flag2
: Boolean := False;
1164 -- This flag is significant only for:
1167 -- Indicates that the project "extends all" another project.
1170 -- Indicates that the comment is followed by an empty line.
1173 -- Indicates that the originally imported project is an extending
1176 Comments
: Project_Node_Id
:= Empty_Node
;
1177 -- For nodes other that N_Comment_Zones or N_Comment, designates the
1178 -- comment zones associated with the node.
1180 -- For N_Comment_Zones, designates the comment after the "end" of
1183 -- For N_Comment, designates the next comment, if any.
1187 -- type Project_Node_Kind is
1190 -- -- Name: project name
1191 -- -- Path_Name: project path name
1192 -- -- Expr_Kind: Undefined
1193 -- -- Field1: first with clause
1194 -- -- Field2: project declaration
1195 -- -- Field3: first string type
1196 -- -- Field4: parent project, if any
1197 -- -- Value: extended project path name (if any)
1200 -- -- Name: imported project name
1201 -- -- Path_Name: imported project path name
1202 -- -- Expr_Kind: Undefined
1203 -- -- Field1: project node
1204 -- -- Field2: next with clause
1205 -- -- Field3: project node or empty if "limited with"
1206 -- -- Field4: not used
1207 -- -- Value: literal string withed
1209 -- N_Project_Declaration,
1210 -- -- Name: not used
1211 -- -- Path_Name: not used
1212 -- -- Expr_Kind: Undefined
1213 -- -- Field1: first declarative item
1214 -- -- Field2: extended project
1215 -- -- Field3: extending project
1216 -- -- Field4: not used
1217 -- -- Value: not used
1219 -- N_Declarative_Item,
1220 -- -- Name: not used
1221 -- -- Path_Name: not used
1222 -- -- Expr_Kind: Undefined
1223 -- -- Field1: current item node
1224 -- -- Field2: next declarative item
1225 -- -- Field3: not used
1226 -- -- Field4: not used
1227 -- -- Value: not used
1229 -- N_Package_Declaration,
1230 -- -- Name: package name
1231 -- -- Path_Name: not used
1232 -- -- Expr_Kind: Undefined
1233 -- -- Field1: project of renamed package (if any)
1234 -- -- Field2: first declarative item
1235 -- -- Field3: next package in project
1236 -- -- Field4: not used
1237 -- -- Value: not used
1239 -- N_String_Type_Declaration,
1240 -- -- Name: type name
1241 -- -- Path_Name: not used
1242 -- -- Expr_Kind: Undefined
1243 -- -- Field1: first literal string
1244 -- -- Field2: next string type
1245 -- -- Field3: not used
1246 -- -- Field4: not used
1247 -- -- Value: not used
1249 -- N_Literal_String,
1250 -- -- Name: not used
1251 -- -- Path_Name: not used
1252 -- -- Expr_Kind: Single
1253 -- -- Field1: next literal string
1254 -- -- Field2: not used
1255 -- -- Field3: not used
1256 -- -- Field4: not used
1257 -- -- Value: string value
1259 -- N_Attribute_Declaration,
1260 -- -- Name: attribute name
1261 -- -- Path_Name: not used
1262 -- -- Expr_Kind: attribute kind
1263 -- -- Field1: expression
1264 -- -- Field2: project of full associative array
1265 -- -- Field3: package of full associative array
1266 -- -- Field4: not used
1267 -- -- Value: associative array index
1268 -- -- (if an associative array element)
1270 -- N_Typed_Variable_Declaration,
1271 -- -- Name: variable name
1272 -- -- Path_Name: not used
1273 -- -- Expr_Kind: Single
1274 -- -- Field1: expression
1275 -- -- Field2: type of variable (N_String_Type_Declaration)
1276 -- -- Field3: next variable
1277 -- -- Field4: not used
1278 -- -- Value: not used
1280 -- N_Variable_Declaration,
1281 -- -- Name: variable name
1282 -- -- Path_Name: not used
1283 -- -- Expr_Kind: variable kind
1284 -- -- Field1: expression
1285 -- -- Field2: not used
1286 -- -- Field3 is used for next variable, instead of Field2,
1287 -- -- so that it is the same field for
1288 -- -- N_Variable_Declaration and
1289 -- -- N_Typed_Variable_Declaration
1290 -- -- Field3: next variable
1291 -- -- Field4: not used
1292 -- -- Value: not used
1295 -- -- Name: not used
1296 -- -- Path_Name: not used
1297 -- -- Expr_Kind: expression kind
1298 -- -- Field1: first term
1299 -- -- Field2: next expression in list
1300 -- -- Field3: not used
1301 -- -- Value: not used
1304 -- -- Name: not used
1305 -- -- Path_Name: not used
1306 -- -- Expr_Kind: term kind
1307 -- -- Field1: current term
1308 -- -- Field2: next term in the expression
1309 -- -- Field3: not used
1310 -- -- Field4: not used
1311 -- -- Value: not used
1313 -- N_Literal_String_List,
1314 -- -- Designates a list of string expressions between brackets
1315 -- -- separated by commas. The string expressions are not necessarily
1316 -- -- literal strings.
1317 -- -- Name: not used
1318 -- -- Path_Name: not used
1319 -- -- Expr_Kind: List
1320 -- -- Field1: first expression
1321 -- -- Field2: not used
1322 -- -- Field3: not used
1323 -- -- Field4: not used
1324 -- -- Value: not used
1326 -- N_Variable_Reference,
1327 -- -- Name: variable name
1328 -- -- Path_Name: not used
1329 -- -- Expr_Kind: variable kind
1330 -- -- Field1: project (if specified)
1331 -- -- Field2: package (if specified)
1332 -- -- Field3: type of variable (N_String_Type_Declaration), if any
1333 -- -- Field4: not used
1334 -- -- Value: not used
1336 -- N_External_Value,
1337 -- -- Name: not used
1338 -- -- Path_Name: not used
1339 -- -- Expr_Kind: Single
1340 -- -- Field1: Name of the external reference (literal string)
1341 -- -- Field2: Default (literal string)
1342 -- -- Field3: not used
1343 -- -- Value: not used
1345 -- N_Attribute_Reference,
1346 -- -- Name: attribute name
1347 -- -- Path_Name: not used
1348 -- -- Expr_Kind: attribute kind
1349 -- -- Field1: project
1350 -- -- Field2: package (if attribute of a package)
1351 -- -- Field3: not used
1352 -- -- Field4: not used
1353 -- -- Value: associative array index
1354 -- -- (if an associative array element)
1356 -- N_Case_Construction,
1357 -- -- Name: not used
1358 -- -- Path_Name: not used
1359 -- -- Expr_Kind: Undefined
1360 -- -- Field1: case variable reference
1361 -- -- Field2: first case item
1362 -- -- Field3: not used
1363 -- -- Field4: not used
1364 -- -- Value: not used
1367 -- -- Name: not used
1368 -- -- Path_Name: not used
1369 -- -- Expr_Kind: not used
1370 -- -- Field1: first choice (literal string), or Empty_Node
1371 -- -- for when others
1372 -- -- Field2: first declarative item
1373 -- -- Field3: next case item
1374 -- -- Field4: not used
1375 -- -- Value: not used
1378 -- -- Name: not used
1379 -- -- Path_Name: not used
1380 -- -- Expr_Kind: not used
1381 -- -- Field1: comment before the construct
1382 -- -- Field2: comment after the construct
1383 -- -- Field3: comment before the "end" of the construct
1384 -- -- Value: end of line comment
1385 -- -- Field4: not used
1386 -- -- Comments: comment after the "end" of the construct
1389 -- -- Name: not used
1390 -- -- Path_Name: not used
1391 -- -- Expr_Kind: not used
1392 -- -- Field1: not used
1393 -- -- Field2: not used
1394 -- -- Field3: not used
1395 -- -- Field4: not used
1396 -- -- Value: comment
1397 -- -- Flag1: comment is preceded by an empty line
1398 -- -- Flag2: comment is followed by an empty line
1399 -- -- Comments: next comment
1401 package Project_Node_Table
is new
1403 (Table_Component_Type
=> Project_Node_Record
,
1404 Table_Index_Type
=> Project_Node_Id
,
1405 Table_Low_Bound
=> First_Node_Id
,
1406 Table_Initial
=> Project_Nodes_Initial
,
1407 Table_Increment
=> Project_Nodes_Increment
);
1408 -- Table contains the syntactic tree of project data from project files
1410 type Project_Name_And_Node
is record
1412 -- Name of the project
1414 Display_Name
: Name_Id
;
1415 -- The name of the project as it appears in the .gpr file
1417 Node
: Project_Node_Id
;
1418 -- Node of the project in table Project_Nodes
1420 Canonical_Path
: Path_Name_Type
;
1421 -- Resolved and canonical path of a real project file.
1422 -- No_Name in case of virtual projects.
1425 -- True when the project is being extended by another project
1427 Proj_Qualifier
: Project_Qualifier
;
1428 -- The project qualifier of the project, if any
1431 No_Project_Name_And_Node
: constant Project_Name_And_Node
:=
1433 Display_Name
=> No_Name
,
1435 Canonical_Path
=> No_Path
,
1437 Proj_Qualifier
=> Unspecified
);
1439 package Projects_Htable
is new GNAT
.Dynamic_HTables
.Simple_HTable
1440 (Header_Num
=> Header_Num
,
1441 Element
=> Project_Name_And_Node
,
1442 No_Element
=> No_Project_Name_And_Node
,
1446 -- This hash table contains a mapping of project names to project nodes.
1447 -- Note that this hash table contains only the nodes whose Kind is
1448 -- N_Project. It is used to find the node of a project from its name,
1449 -- and to verify if a project has already been parsed, knowing its name.
1451 end Tree_Private_Part
;
1453 package Name_To_Name_HTable
is new GNAT
.Dynamic_HTables
.Simple_HTable
1454 (Header_Num
=> Header_Num
,
1456 No_Element
=> No_Name
,
1460 -- General type for htables associating name_id to name_id. This is in
1461 -- particular used to store the values of external references.
1463 type Project_Node_Tree_Data
is record
1464 Project_Nodes
: Tree_Private_Part
.Project_Node_Table
.Instance
;
1465 Projects_HT
: Tree_Private_Part
.Projects_Htable
.Instance
;
1467 External_References
: Name_To_Name_HTable
.Instance
;
1468 -- External references are stored in this hash table (and manipulated
1469 -- through subprogrames in prj-ext.ads). External references are
1470 -- project-tree specific so that one can load the same tree twice but
1471 -- have two views of it, for instance.
1473 Project_Path
: String_Access
;
1474 -- The project path, manipulated through subprograms in prj-ext.ads.
1475 -- As a special case, if the first character is '#:" or this variable is
1476 -- unset, this means that the PATH has not been fully initialized yet
1477 -- (although subprograms prj-ext.ads will properly take care of that).
1479 -- The project path is tree specific, since we might want to load
1480 -- simultaneously multiple projects, each with its own search path, in
1481 -- particular when using different compilers with different default
1482 -- search directories.
1485 procedure Free
(Proj
: in out Project_Node_Tree_Ref
);
1486 -- Free memory used by Prj
1489 type Comment_Array
is array (Positive range <>) of Comment_Data
;
1490 type Comments_Ptr
is access Comment_Array
;
1492 type Comment_State
is record
1493 End_Of_Line_Node
: Project_Node_Id
:= Empty_Node
;
1494 Previous_Line_Node
: Project_Node_Id
:= Empty_Node
;
1495 Previous_End_Node
: Project_Node_Id
:= Empty_Node
;
1496 Unkept_Comments
: Boolean := False;
1497 Comments
: Comments_Ptr
:= null;