1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
27 ------------------------------------------------------------------------------
29 pragma Style_Checks (All_Checks);
30 -- Turn off subprogram body ordering check. Subprograms are in order
31 -- by RM section rather than alphabetical
36 -- Local functions, used only in this chapter
38 function P_Formal_Derived_Type_Definition return Node_Id;
39 function P_Formal_Discrete_Type_Definition return Node_Id;
40 function P_Formal_Fixed_Point_Definition return Node_Id;
41 function P_Formal_Floating_Point_Definition return Node_Id;
42 function P_Formal_Modular_Type_Definition return Node_Id;
43 function P_Formal_Package_Declaration return Node_Id;
44 function P_Formal_Private_Type_Definition return Node_Id;
45 function P_Formal_Signed_Integer_Type_Definition return Node_Id;
46 function P_Formal_Subprogram_Declaration return Node_Id;
47 function P_Formal_Type_Declaration return Node_Id;
48 function P_Formal_Type_Definition return Node_Id;
49 function P_Generic_Association return Node_Id;
51 procedure P_Formal_Object_Declarations (Decls : List_Id);
52 -- Scans one or more formal object declarations and appends them to
53 -- Decls. Scans more than one declaration only in the case where the
54 -- source has a declaration with multiple defining identifiers.
56 --------------------------------
57 -- 12.1 Generic (also 8.5.5) --
58 --------------------------------
60 -- This routine parses either one of the forms of a generic declaration
61 -- or a generic renaming declaration.
63 -- GENERIC_DECLARATION ::=
64 -- GENERIC_SUBPROGRAM_DECLARATION | GENERIC_PACKAGE_DECLARATION
66 -- GENERIC_SUBPROGRAM_DECLARATION ::=
67 -- GENERIC_FORMAL_PART SUBPROGRAM_SPECIFICATION;
69 -- GENERIC_PACKAGE_DECLARATION ::=
70 -- GENERIC_FORMAL_PART PACKAGE_SPECIFICATION;
72 -- GENERIC_FORMAL_PART ::=
73 -- generic {GENERIC_FORMAL_PARAMETER_DECLARATION | USE_CLAUSE}
75 -- GENERIC_RENAMING_DECLARATION ::=
76 -- generic package DEFINING_PROGRAM_UNIT_NAME
77 -- renames generic_package_NAME
78 -- | generic procedure DEFINING_PROGRAM_UNIT_NAME
79 -- renames generic_procedure_NAME
80 -- | generic function DEFINING_PROGRAM_UNIT_NAME
81 -- renames generic_function_NAME
83 -- GENERIC_FORMAL_PARAMETER_DECLARATION ::=
84 -- FORMAL_OBJECT_DECLARATION
85 -- | FORMAL_TYPE_DECLARATION
86 -- | FORMAL_SUBPROGRAM_DECLARATION
87 -- | FORMAL_PACKAGE_DECLARATION
89 -- The caller has checked that the initial token is GENERIC
91 -- Error recovery: can raise Error_Resync
93 function P_Generic return Node_Id is
94 Gen_Sloc : constant Source_Ptr := Token_Ptr;
99 Ren_Token : Token_Type;
100 Scan_State : Saved_Scan_State;
103 Scan; -- past GENERIC
105 if Token = Tok_Private then
106 Error_Msg_SC ("PRIVATE goes before GENERIC, not after");
107 Scan; -- past junk PRIVATE token
110 Save_Scan_State (Scan_State); -- at token past GENERIC
112 -- Check for generic renaming declaration case
114 if Token = Tok_Package
115 or else Token = Tok_Function
116 or else Token = Tok_Procedure
119 Scan; -- scan past PACKAGE, FUNCTION or PROCEDURE
121 if Token = Tok_Identifier then
122 Def_Unit := P_Defining_Program_Unit_Name;
124 Check_Misspelling_Of (Tok_Renames);
126 if Token = Tok_Renames then
127 if Ren_Token = Tok_Package then
128 Decl_Node := New_Node
129 (N_Generic_Package_Renaming_Declaration, Gen_Sloc);
131 elsif Ren_Token = Tok_Procedure then
132 Decl_Node := New_Node
133 (N_Generic_Procedure_Renaming_Declaration, Gen_Sloc);
135 else -- Ren_Token = Tok_Function then
136 Decl_Node := New_Node
137 (N_Generic_Function_Renaming_Declaration, Gen_Sloc);
140 Scan; -- past RENAMES
141 Set_Defining_Unit_Name (Decl_Node, Def_Unit);
142 Set_Name (Decl_Node, P_Name);
149 -- Fall through if this is *not* a generic renaming declaration
151 Restore_Scan_State (Scan_State);
154 -- Loop through generic parameter declarations and use clauses
157 P_Pragmas_Opt (Decls);
158 Ignore (Tok_Private);
160 if Token = Tok_Use then
161 Append (P_Use_Clause, Decls);
163 -- Parse a generic parameter declaration
165 if Token = Tok_Identifier then
166 P_Formal_Object_Declarations (Decls);
168 elsif Token = Tok_Type then
169 Append (P_Formal_Type_Declaration, Decls);
171 elsif Token = Tok_With then
174 if Token = Tok_Package then
175 Append (P_Formal_Package_Declaration, Decls);
177 elsif Token = Tok_Procedure or Token = Tok_Function then
178 Append (P_Formal_Subprogram_Declaration, Decls);
182 ("FUNCTION, PROCEDURE or PACKAGE expected here");
183 Resync_Past_Semicolon;
186 elsif Token = Tok_Subtype then
187 Error_Msg_SC ("subtype declaration not allowed " &
188 "as generic parameter declaration!");
189 Resync_Past_Semicolon;
198 -- Generic formal part is scanned, scan out subprogram or package spec
200 if Token = Tok_Package then
201 Gen_Decl := New_Node (N_Generic_Package_Declaration, Gen_Sloc);
202 Set_Specification (Gen_Decl, P_Package (Pf_Spcn));
204 Gen_Decl := New_Node (N_Generic_Subprogram_Declaration, Gen_Sloc);
205 Set_Specification (Gen_Decl, P_Subprogram_Specification);
209 Set_Generic_Formal_Declarations (Gen_Decl, Decls);
213 -------------------------------
214 -- 12.1 Generic Declaration --
215 -------------------------------
217 -- Parsed by P_Generic (12.1)
219 ------------------------------------------
220 -- 12.1 Generic Subprogram Declaration --
221 ------------------------------------------
223 -- Parsed by P_Generic (12.1)
225 ---------------------------------------
226 -- 12.1 Generic Package Declaration --
227 ---------------------------------------
229 -- Parsed by P_Generic (12.1)
231 -------------------------------
232 -- 12.1 Generic Formal Part --
233 -------------------------------
235 -- Parsed by P_Generic (12.1)
237 -------------------------------------------------
238 -- 12.1 Generic Formal Parameter Declaration --
239 -------------------------------------------------
241 -- Parsed by P_Generic (12.1)
243 ---------------------------------
244 -- 12.3 Generic Instantiation --
245 ---------------------------------
247 -- Generic package instantiation parsed by P_Package (7.1)
248 -- Generic procedure instantiation parsed by P_Subprogram (6.1)
249 -- Generic function instantiation parsed by P_Subprogram (6.1)
251 -------------------------------
252 -- 12.3 Generic Actual Part --
253 -------------------------------
255 -- GENERIC_ACTUAL_PART ::=
256 -- (GENERIC_ASSOCIATION {, GENERIC_ASSOCIATION})
258 -- Returns a list of generic associations, or Empty if none are present
260 -- Error recovery: cannot raise Error_Resync
262 function P_Generic_Actual_Part_Opt return List_Id is
263 Association_List : List_Id;
266 -- Figure out if a generic actual part operation is present. Clearly
267 -- there is no generic actual part if the current token is semicolon
269 if Token = Tok_Semicolon then
272 -- If we don't have a left paren, then we have an error, and the job
273 -- is to figure out whether a left paren or semicolon was intended.
274 -- We assume a missing left paren (and hence a generic actual part
275 -- present) if the current token is not on a new line, or if it is
276 -- indented from the subprogram token. Otherwise assume missing
277 -- semicolon (which will be diagnosed by caller) and no generic part
279 elsif Token /= Tok_Left_Paren
280 and then Token_Is_At_Start_Of_Line
281 and then Start_Column <= Scope.Table (Scope.Last).Ecol
285 -- Otherwise we have a generic actual part (either a left paren is
286 -- present, or we have decided that there must be a missing left paren)
289 Association_List := New_List;
293 Append (P_Generic_Association, Association_List);
294 exit when not Comma_Present;
298 return Association_List;
301 end P_Generic_Actual_Part_Opt;
303 -------------------------------
304 -- 12.3 Generic Association --
305 -------------------------------
307 -- GENERIC_ASSOCIATION ::=
308 -- [generic_formal_parameter_SELECTOR_NAME =>]
309 -- EXPLICIT_GENERIC_ACTUAL_PARAMETER
311 -- EXPLICIT_GENERIC_ACTUAL_PARAMETER ::=
312 -- EXPRESSION | variable_NAME | subprogram_NAME
313 -- | entry_NAME | SUBTYPE_MARK | package_instance_NAME
315 -- Error recovery: cannot raise Error_Resync
317 function P_Generic_Association return Node_Id is
318 Scan_State : Saved_Scan_State;
319 Param_Name_Node : Node_Id;
320 Generic_Assoc_Node : Node_Id;
323 Generic_Assoc_Node := New_Node (N_Generic_Association, Token_Ptr);
325 if Token in Token_Class_Desig then
326 Param_Name_Node := Token_Node;
327 Save_Scan_State (Scan_State); -- at designator
328 Scan; -- past simple name or operator symbol
330 if Token = Tok_Arrow then
332 Set_Selector_Name (Generic_Assoc_Node, Param_Name_Node);
334 Restore_Scan_State (Scan_State); -- to designator
338 Set_Explicit_Generic_Actual_Parameter (Generic_Assoc_Node, P_Expression);
339 return Generic_Assoc_Node;
340 end P_Generic_Association;
342 ---------------------------------------------
343 -- 12.3 Explicit Generic Actual Parameter --
344 ---------------------------------------------
346 -- Parsed by P_Generic_Association (12.3)
348 --------------------------------------
349 -- 12.4 Formal Object Declarations --
350 --------------------------------------
352 -- FORMAL_OBJECT_DECLARATION ::=
353 -- DEFINING_IDENTIFIER_LIST :
354 -- MODE SUBTYPE_MARK [:= DEFAULT_EXPRESSION];
356 -- The caller has checked that the initial token is an identifier
358 -- Error recovery: cannot raise Error_Resync
360 procedure P_Formal_Object_Declarations (Decls : List_Id) is
362 Scan_State : Saved_Scan_State;
366 Idents : array (Int range 1 .. 4096) of Entity_Id;
367 -- This array holds the list of defining identifiers. The upper bound
368 -- of 4096 is intended to be essentially infinite, and we do not even
369 -- bother to check for it being exceeded.
372 Idents (1) := P_Defining_Identifier;
375 while Comma_Present loop
376 Num_Idents := Num_Idents + 1;
377 Idents (Num_Idents) := P_Defining_Identifier;
382 -- If there are multiple identifiers, we repeatedly scan the
383 -- type and initialization expression information by resetting
384 -- the scan pointer (so that we get completely separate trees
385 -- for each occurrence).
387 if Num_Idents > 1 then
388 Save_Scan_State (Scan_State);
391 -- Loop through defining identifiers in list
395 Decl_Node := New_Node (N_Formal_Object_Declaration, Token_Ptr);
396 Set_Defining_Identifier (Decl_Node, Idents (Ident));
398 Set_Subtype_Mark (Decl_Node, P_Subtype_Mark_Resync);
400 Set_Expression (Decl_Node, Init_Expr_Opt);
403 Set_Prev_Ids (Decl_Node, True);
406 if Ident < Num_Idents then
407 Set_More_Ids (Decl_Node, True);
410 Append (Decl_Node, Decls);
412 exit Ident_Loop when Ident = Num_Idents;
414 Restore_Scan_State (Scan_State);
418 end P_Formal_Object_Declarations;
420 -----------------------------------
421 -- 12.5 Formal Type Declaration --
422 -----------------------------------
424 -- FORMAL_TYPE_DECLARATION ::=
425 -- type DEFINING_IDENTIFIER [DISCRIMINANT_PART]
426 -- is FORMAL_TYPE_DEFINITION;
428 -- The caller has checked that the initial token is TYPE
430 -- Error recovery: cannot raise Error_Resync
432 function P_Formal_Type_Declaration return Node_Id is
437 Decl_Node := New_Node (N_Formal_Type_Declaration, Token_Ptr);
439 Set_Defining_Identifier (Decl_Node, P_Defining_Identifier);
441 if P_Unknown_Discriminant_Part_Opt then
442 Set_Unknown_Discriminants_Present (Decl_Node, True);
444 Set_Discriminant_Specifications
445 (Decl_Node, P_Known_Discriminant_Part_Opt);
450 Def_Node := P_Formal_Type_Definition;
452 if Def_Node /= Error then
453 Set_Formal_Type_Definition (Decl_Node, Def_Node);
460 end P_Formal_Type_Declaration;
462 ----------------------------------
463 -- 12.5 Formal Type Definition --
464 ----------------------------------
466 -- FORMAL_TYPE_DEFINITION ::=
467 -- FORMAL_PRIVATE_TYPE_DEFINITION
468 -- | FORMAL_DERIVED_TYPE_DEFINITION
469 -- | FORMAL_DISCRETE_TYPE_DEFINITION
470 -- | FORMAL_SIGNED_INTEGER_TYPE_DEFINITION
471 -- | FORMAL_MODULAR_TYPE_DEFINITION
472 -- | FORMAL_FLOATING_POINT_DEFINITION
473 -- | FORMAL_ORDINARY_FIXED_POINT_DEFINITION
474 -- | FORMAL_DECIMAL_FIXED_POINT_DEFINITION
475 -- | FORMAL_ARRAY_TYPE_DEFINITION
476 -- | FORMAL_ACCESS_TYPE_DEFINITION
478 -- FORMAL_ARRAY_TYPE_DEFINITION ::= ARRAY_TYPE_DEFINITION
480 -- FORMAL_ACCESS_TYPE_DEFINITION ::= ACCESS_TYPE_DEFINITION
482 function P_Formal_Type_Definition return Node_Id is
483 Scan_State : Saved_Scan_State;
486 if Token_Name = Name_Abstract then
487 Check_95_Keyword (Tok_Abstract, Tok_Tagged);
490 if Token_Name = Name_Tagged then
491 Check_95_Keyword (Tok_Tagged, Tok_Private);
492 Check_95_Keyword (Tok_Tagged, Tok_Limited);
497 -- Mostly we can tell what we have from the initial token. The one
498 -- exception is ABSTRACT, where we have to scan ahead to see if we
499 -- have a formal derived type or a formal private type definition.
502 Save_Scan_State (Scan_State);
503 Scan; -- past ABSTRACT
505 if Token = Tok_New then
506 Restore_Scan_State (Scan_State); -- to ABSTRACT
507 return P_Formal_Derived_Type_Definition;
510 Restore_Scan_State (Scan_State); -- to ABSTRACT
511 return P_Formal_Private_Type_Definition;
514 when Tok_Private | Tok_Limited | Tok_Tagged =>
515 return P_Formal_Private_Type_Definition;
518 return P_Formal_Derived_Type_Definition;
520 when Tok_Left_Paren =>
521 return P_Formal_Discrete_Type_Definition;
524 return P_Formal_Signed_Integer_Type_Definition;
527 return P_Formal_Modular_Type_Definition;
530 return P_Formal_Floating_Point_Definition;
533 return P_Formal_Fixed_Point_Definition;
536 return P_Array_Type_Definition;
539 return P_Access_Type_Definition;
542 Error_Msg_SC ("record not allowed in generic type definition!");
543 Discard_Junk_Node (P_Record_Definition);
547 Error_Msg_BC ("expecting generic type definition here");
548 Resync_Past_Semicolon;
552 end P_Formal_Type_Definition;
554 --------------------------------------------
555 -- 12.5.1 Formal Private Type Definition --
556 --------------------------------------------
558 -- FORMAL_PRIVATE_TYPE_DEFINITION ::=
559 -- [[abstract] tagged] [limited] private
561 -- The caller has checked the initial token is PRIVATE, ABSTRACT,
564 -- Error recovery: cannot raise Error_Resync
566 function P_Formal_Private_Type_Definition return Node_Id is
570 Def_Node := New_Node (N_Formal_Private_Type_Definition, Token_Ptr);
572 if Token = Tok_Abstract then
573 Scan; -- past ABSTRACT
575 if Token_Name = Name_Tagged then
576 Check_95_Keyword (Tok_Tagged, Tok_Private);
577 Check_95_Keyword (Tok_Tagged, Tok_Limited);
580 if Token /= Tok_Tagged then
581 Error_Msg_SP ("ABSTRACT must be followed by TAGGED");
583 Set_Abstract_Present (Def_Node, True);
587 if Token = Tok_Tagged then
588 Set_Tagged_Present (Def_Node, True);
592 if Token = Tok_Limited then
593 Set_Limited_Present (Def_Node, True);
594 Scan; -- past LIMITED
597 Set_Sloc (Def_Node, Token_Ptr);
600 end P_Formal_Private_Type_Definition;
602 --------------------------------------------
603 -- 12.5.1 Formal Derived Type Definition --
604 --------------------------------------------
606 -- FORMAL_DERIVED_TYPE_DEFINITION ::=
607 -- [abstract] new SUBTYPE_MARK [with private]
609 -- The caller has checked the initial token(s) is/are NEW or ASTRACT NEW
611 -- Error recovery: cannot raise Error_Resync
613 function P_Formal_Derived_Type_Definition return Node_Id is
617 Def_Node := New_Node (N_Formal_Derived_Type_Definition, Token_Ptr);
619 if Token = Tok_Abstract then
620 Set_Abstract_Present (Def_Node);
621 Scan; -- past ABSTRACT
625 Set_Subtype_Mark (Def_Node, P_Subtype_Mark);
628 if Token = Tok_With then
630 Set_Private_Present (Def_Node, True);
633 elsif Token = Tok_Tagged then
636 if Token = Tok_Private then
637 Error_Msg_SC ("TAGGED should be WITH");
638 Set_Private_Present (Def_Node, True);
646 end P_Formal_Derived_Type_Definition;
648 ---------------------------------------------
649 -- 12.5.2 Formal Discrete Type Definition --
650 ---------------------------------------------
652 -- FORMAL_DISCRETE_TYPE_DEFINITION ::= (<>)
654 -- The caller has checked the initial token is left paren
656 -- Error recovery: cannot raise Error_Resync
658 function P_Formal_Discrete_Type_Definition return Node_Id is
662 Def_Node := New_Node (N_Formal_Discrete_Type_Definition, Token_Ptr);
663 Scan; -- past left paren
667 end P_Formal_Discrete_Type_Definition;
669 ---------------------------------------------------
670 -- 12.5.2 Formal Signed Integer Type Definition --
671 ---------------------------------------------------
673 -- FORMAL_SIGNED_INTEGER_TYPE_DEFINITION ::= range <>
675 -- The caller has checked the initial token is RANGE
677 -- Error recovery: cannot raise Error_Resync
679 function P_Formal_Signed_Integer_Type_Definition return Node_Id is
684 New_Node (N_Formal_Signed_Integer_Type_Definition, Token_Ptr);
688 end P_Formal_Signed_Integer_Type_Definition;
690 --------------------------------------------
691 -- 12.5.2 Formal Modular Type Definition --
692 --------------------------------------------
694 -- FORMAL_MODULAR_TYPE_DEFINITION ::= mod <>
696 -- The caller has checked the initial token is MOD
698 -- Error recovery: cannot raise Error_Resync
700 function P_Formal_Modular_Type_Definition return Node_Id is
705 New_Node (N_Formal_Modular_Type_Definition, Token_Ptr);
709 end P_Formal_Modular_Type_Definition;
711 ----------------------------------------------
712 -- 12.5.2 Formal Floating Point Definition --
713 ----------------------------------------------
715 -- FORMAL_FLOATING_POINT_DEFINITION ::= digits <>
717 -- The caller has checked the initial token is DIGITS
719 -- Error recovery: cannot raise Error_Resync
721 function P_Formal_Floating_Point_Definition return Node_Id is
726 New_Node (N_Formal_Floating_Point_Definition, Token_Ptr);
730 end P_Formal_Floating_Point_Definition;
732 -------------------------------------------
733 -- 12.5.2 Formal Fixed Point Definition --
734 -------------------------------------------
736 -- This routine parses either a formal ordinary fixed point definition
737 -- or a formal decimal fixed point definition:
739 -- FORMAL_ORDINARY_FIXED_POINT_DEFINITION ::= delta <>
741 -- FORMAL_DECIMAL_FIXED_POINT_DEFINITION ::= delta <> digits <>
743 -- The caller has checked the initial token is DELTA
745 -- Error recovery: cannot raise Error_Resync
747 function P_Formal_Fixed_Point_Definition return Node_Id is
749 Delta_Sloc : Source_Ptr;
752 Delta_Sloc := Token_Ptr;
756 if Token = Tok_Digits then
758 New_Node (N_Formal_Decimal_Fixed_Point_Definition, Delta_Sloc);
763 New_Node (N_Formal_Ordinary_Fixed_Point_Definition, Delta_Sloc);
767 end P_Formal_Fixed_Point_Definition;
769 ----------------------------------------------------
770 -- 12.5.2 Formal Ordinary Fixed Point Definition --
771 ----------------------------------------------------
773 -- Parsed by P_Formal_Fixed_Point_Definition (12.5.2)
775 ---------------------------------------------------
776 -- 12.5.2 Formal Decimal Fixed Point Definition --
777 ---------------------------------------------------
779 -- Parsed by P_Formal_Fixed_Point_Definition (12.5.2)
781 ------------------------------------------
782 -- 12.5.3 Formal Array Type Definition --
783 ------------------------------------------
785 -- Parsed by P_Formal_Type_Definition (12.5)
787 -------------------------------------------
788 -- 12.5.4 Formal Access Type Definition --
789 -------------------------------------------
791 -- Parsed by P_Formal_Type_Definition (12.5)
793 -----------------------------------------
794 -- 12.6 Formal Subprogram Declaration --
795 -----------------------------------------
797 -- FORMAL_SUBPROGRAM_DECLARATION ::=
798 -- with SUBPROGRAM_SPECIFICATION [is SUBPROGRAM_DEFAULT];
800 -- SUBPROGRAM_DEFAULT ::= DEFAULT_NAME | <>
802 -- DEFAULT_NAME ::= NAME
804 -- The caller has checked that the initial tokens are WITH FUNCTION or
805 -- WITH PROCEDURE, and the initial WITH has been scanned out.
807 -- Note: we separate this into two procedures because the name is allowed
808 -- to be an operator symbol for a function, but not for a procedure.
810 -- Error recovery: cannot raise Error_Resync
812 function P_Formal_Subprogram_Declaration return Node_Id is
816 Def_Node := New_Node (N_Formal_Subprogram_Declaration, Prev_Token_Ptr);
817 Set_Specification (Def_Node, P_Subprogram_Specification);
819 if Token = Tok_Is then
820 T_Is; -- past IS, skip extra IS or ";"
822 if Token = Tok_Box then
823 Set_Box_Present (Def_Node, True);
827 Set_Default_Name (Def_Node, P_Name);
834 end P_Formal_Subprogram_Declaration;
836 ------------------------------
837 -- 12.6 Subprogram Default --
838 ------------------------------
840 -- Parsed by P_Formal_Procedure_Declaration (12.6)
842 ------------------------
843 -- 12.6 Default Name --
844 ------------------------
846 -- Parsed by P_Formal_Procedure_Declaration (12.6)
848 --------------------------------------
849 -- 12.7 Formal Package Declaration --
850 --------------------------------------
852 -- FORMAL_PACKAGE_DECLARATION ::=
853 -- with package DEFINING_IDENTIFIER
854 -- is new generic_package_NAME FORMAL_PACKAGE_ACTUAL_PART;
856 -- FORMAL_PACKAGE_ACTUAL_PART ::=
857 -- (<>) | [GENERIC_ACTUAL_PART]
859 -- The caller has checked that the initial tokens are WITH PACKAGE,
860 -- and the initial WITH has been scanned out (so Token = Tok_Package).
862 -- Error recovery: cannot raise Error_Resync
864 function P_Formal_Package_Declaration return Node_Id is
866 Scan_State : Saved_Scan_State;
869 Def_Node := New_Node (N_Formal_Package_Declaration, Prev_Token_Ptr);
870 Scan; -- past PACKAGE
871 Set_Defining_Identifier (Def_Node, P_Defining_Identifier);
874 Set_Name (Def_Node, P_Qualified_Simple_Name);
876 if Token = Tok_Left_Paren then
877 Save_Scan_State (Scan_State); -- at the left paren
878 Scan; -- past the left paren
880 if Token = Tok_Box then
881 Set_Box_Present (Def_Node, True);
886 Restore_Scan_State (Scan_State); -- to the left paren
887 Set_Generic_Associations (Def_Node, P_Generic_Actual_Part_Opt);
893 end P_Formal_Package_Declaration;
895 --------------------------------------
896 -- 12.7 Formal Package Actual Part --
897 --------------------------------------
899 -- Parsed by P_Formal_Package_Declaration (12.7)