1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004 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 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. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 pragma Style_Checks
(All_Checks
);
28 -- Turn off subprogram body ordering check. Subprograms are in order
29 -- by RM section rather than alphabetical
34 -- Local functions, used only in this chapter
36 function P_Formal_Derived_Type_Definition
return Node_Id
;
37 function P_Formal_Discrete_Type_Definition
return Node_Id
;
38 function P_Formal_Fixed_Point_Definition
return Node_Id
;
39 function P_Formal_Floating_Point_Definition
return Node_Id
;
40 function P_Formal_Modular_Type_Definition
return Node_Id
;
41 function P_Formal_Package_Declaration
return Node_Id
;
42 function P_Formal_Private_Type_Definition
return Node_Id
;
43 function P_Formal_Signed_Integer_Type_Definition
return Node_Id
;
44 function P_Formal_Subprogram_Declaration
return Node_Id
;
45 function P_Formal_Type_Declaration
return Node_Id
;
46 function P_Formal_Type_Definition
return Node_Id
;
47 function P_Generic_Association
return Node_Id
;
49 procedure P_Formal_Object_Declarations
(Decls
: List_Id
);
50 -- Scans one or more formal object declarations and appends them to
51 -- Decls. Scans more than one declaration only in the case where the
52 -- source has a declaration with multiple defining identifiers.
54 --------------------------------
55 -- 12.1 Generic (also 8.5.5) --
56 --------------------------------
58 -- This routine parses either one of the forms of a generic declaration
59 -- or a generic renaming declaration.
61 -- GENERIC_DECLARATION ::=
62 -- GENERIC_SUBPROGRAM_DECLARATION | GENERIC_PACKAGE_DECLARATION
64 -- GENERIC_SUBPROGRAM_DECLARATION ::=
65 -- GENERIC_FORMAL_PART SUBPROGRAM_SPECIFICATION;
67 -- GENERIC_PACKAGE_DECLARATION ::=
68 -- GENERIC_FORMAL_PART PACKAGE_SPECIFICATION;
70 -- GENERIC_FORMAL_PART ::=
71 -- generic {GENERIC_FORMAL_PARAMETER_DECLARATION | USE_CLAUSE}
73 -- GENERIC_RENAMING_DECLARATION ::=
74 -- generic package DEFINING_PROGRAM_UNIT_NAME
75 -- renames generic_package_NAME
76 -- | generic procedure DEFINING_PROGRAM_UNIT_NAME
77 -- renames generic_procedure_NAME
78 -- | generic function DEFINING_PROGRAM_UNIT_NAME
79 -- renames generic_function_NAME
81 -- GENERIC_FORMAL_PARAMETER_DECLARATION ::=
82 -- FORMAL_OBJECT_DECLARATION
83 -- | FORMAL_TYPE_DECLARATION
84 -- | FORMAL_SUBPROGRAM_DECLARATION
85 -- | FORMAL_PACKAGE_DECLARATION
87 -- The caller has checked that the initial token is GENERIC
89 -- Error recovery: can raise Error_Resync
91 function P_Generic
return Node_Id
is
92 Gen_Sloc
: constant Source_Ptr
:= Token_Ptr
;
97 Ren_Token
: Token_Type
;
98 Scan_State
: Saved_Scan_State
;
101 Scan
; -- past GENERIC
103 if Token
= Tok_Private
then
104 Error_Msg_SC
("PRIVATE goes before GENERIC, not after");
105 Scan
; -- past junk PRIVATE token
108 Save_Scan_State
(Scan_State
); -- at token past GENERIC
110 -- Check for generic renaming declaration case
112 if Token
= Tok_Package
113 or else Token
= Tok_Function
114 or else Token
= Tok_Procedure
117 Scan
; -- scan past PACKAGE, FUNCTION or PROCEDURE
119 if Token
= Tok_Identifier
then
120 Def_Unit
:= P_Defining_Program_Unit_Name
;
122 Check_Misspelling_Of
(Tok_Renames
);
124 if Token
= Tok_Renames
then
125 if Ren_Token
= Tok_Package
then
126 Decl_Node
:= New_Node
127 (N_Generic_Package_Renaming_Declaration
, Gen_Sloc
);
129 elsif Ren_Token
= Tok_Procedure
then
130 Decl_Node
:= New_Node
131 (N_Generic_Procedure_Renaming_Declaration
, Gen_Sloc
);
133 else -- Ren_Token = Tok_Function then
134 Decl_Node
:= New_Node
135 (N_Generic_Function_Renaming_Declaration
, Gen_Sloc
);
138 Scan
; -- past RENAMES
139 Set_Defining_Unit_Name
(Decl_Node
, Def_Unit
);
140 Set_Name
(Decl_Node
, P_Name
);
147 -- Fall through if this is *not* a generic renaming declaration
149 Restore_Scan_State
(Scan_State
);
152 -- Loop through generic parameter declarations and use clauses
155 P_Pragmas_Opt
(Decls
);
156 Ignore
(Tok_Private
);
158 if Token
= Tok_Use
then
159 Append
(P_Use_Clause
, Decls
);
161 -- Parse a generic parameter declaration
163 if Token
= Tok_Identifier
then
164 P_Formal_Object_Declarations
(Decls
);
166 elsif Token
= Tok_Type
then
167 Append
(P_Formal_Type_Declaration
, Decls
);
169 elsif Token
= Tok_With
then
172 if Token
= Tok_Package
then
173 Append
(P_Formal_Package_Declaration
, Decls
);
175 elsif Token
= Tok_Procedure
or Token
= Tok_Function
then
176 Append
(P_Formal_Subprogram_Declaration
, Decls
);
180 ("FUNCTION, PROCEDURE or PACKAGE expected here");
181 Resync_Past_Semicolon
;
184 elsif Token
= Tok_Subtype
then
185 Error_Msg_SC
("subtype declaration not allowed " &
186 "as generic parameter declaration!");
187 Resync_Past_Semicolon
;
196 -- Generic formal part is scanned, scan out subprogram or package spec
198 if Token
= Tok_Package
then
199 Gen_Decl
:= New_Node
(N_Generic_Package_Declaration
, Gen_Sloc
);
200 Set_Specification
(Gen_Decl
, P_Package
(Pf_Spcn
));
202 Gen_Decl
:= New_Node
(N_Generic_Subprogram_Declaration
, Gen_Sloc
);
204 Set_Specification
(Gen_Decl
, P_Subprogram_Specification
);
206 if Nkind
(Defining_Unit_Name
(Specification
(Gen_Decl
))) =
207 N_Defining_Program_Unit_Name
208 and then Scope
.Last
> 0
210 Error_Msg_SP
("child unit allowed only at library level");
215 Set_Generic_Formal_Declarations
(Gen_Decl
, Decls
);
219 -------------------------------
220 -- 12.1 Generic Declaration --
221 -------------------------------
223 -- Parsed by P_Generic (12.1)
225 ------------------------------------------
226 -- 12.1 Generic Subprogram Declaration --
227 ------------------------------------------
229 -- Parsed by P_Generic (12.1)
231 ---------------------------------------
232 -- 12.1 Generic Package Declaration --
233 ---------------------------------------
235 -- Parsed by P_Generic (12.1)
237 -------------------------------
238 -- 12.1 Generic Formal Part --
239 -------------------------------
241 -- Parsed by P_Generic (12.1)
243 -------------------------------------------------
244 -- 12.1 Generic Formal Parameter Declaration --
245 -------------------------------------------------
247 -- Parsed by P_Generic (12.1)
249 ---------------------------------
250 -- 12.3 Generic Instantiation --
251 ---------------------------------
253 -- Generic package instantiation parsed by P_Package (7.1)
254 -- Generic procedure instantiation parsed by P_Subprogram (6.1)
255 -- Generic function instantiation parsed by P_Subprogram (6.1)
257 -------------------------------
258 -- 12.3 Generic Actual Part --
259 -------------------------------
261 -- GENERIC_ACTUAL_PART ::=
262 -- (GENERIC_ASSOCIATION {, GENERIC_ASSOCIATION})
264 -- Returns a list of generic associations, or Empty if none are present
266 -- Error recovery: cannot raise Error_Resync
268 function P_Generic_Actual_Part_Opt
return List_Id
is
269 Association_List
: List_Id
;
272 -- Figure out if a generic actual part operation is present. Clearly
273 -- there is no generic actual part if the current token is semicolon
275 if Token
= Tok_Semicolon
then
278 -- If we don't have a left paren, then we have an error, and the job
279 -- is to figure out whether a left paren or semicolon was intended.
280 -- We assume a missing left paren (and hence a generic actual part
281 -- present) if the current token is not on a new line, or if it is
282 -- indented from the subprogram token. Otherwise assume missing
283 -- semicolon (which will be diagnosed by caller) and no generic part
285 elsif Token
/= Tok_Left_Paren
286 and then Token_Is_At_Start_Of_Line
287 and then Start_Column
<= Scope
.Table
(Scope
.Last
).Ecol
291 -- Otherwise we have a generic actual part (either a left paren is
292 -- present, or we have decided that there must be a missing left paren)
295 Association_List
:= New_List
;
299 Append
(P_Generic_Association
, Association_List
);
300 exit when not Comma_Present
;
304 return Association_List
;
307 end P_Generic_Actual_Part_Opt
;
309 -------------------------------
310 -- 12.3 Generic Association --
311 -------------------------------
313 -- GENERIC_ASSOCIATION ::=
314 -- [generic_formal_parameter_SELECTOR_NAME =>]
315 -- EXPLICIT_GENERIC_ACTUAL_PARAMETER
317 -- EXPLICIT_GENERIC_ACTUAL_PARAMETER ::=
318 -- EXPRESSION | variable_NAME | subprogram_NAME
319 -- | entry_NAME | SUBTYPE_MARK | package_instance_NAME
321 -- Error recovery: cannot raise Error_Resync
323 function P_Generic_Association
return Node_Id
is
324 Scan_State
: Saved_Scan_State
;
325 Param_Name_Node
: Node_Id
;
326 Generic_Assoc_Node
: Node_Id
;
329 Generic_Assoc_Node
:= New_Node
(N_Generic_Association
, Token_Ptr
);
331 if Token
in Token_Class_Desig
then
332 Param_Name_Node
:= Token_Node
;
333 Save_Scan_State
(Scan_State
); -- at designator
334 Scan
; -- past simple name or operator symbol
336 if Token
= Tok_Arrow
then
338 Set_Selector_Name
(Generic_Assoc_Node
, Param_Name_Node
);
340 Restore_Scan_State
(Scan_State
); -- to designator
344 Set_Explicit_Generic_Actual_Parameter
(Generic_Assoc_Node
, P_Expression
);
345 return Generic_Assoc_Node
;
346 end P_Generic_Association
;
348 ---------------------------------------------
349 -- 12.3 Explicit Generic Actual Parameter --
350 ---------------------------------------------
352 -- Parsed by P_Generic_Association (12.3)
354 --------------------------------------
355 -- 12.4 Formal Object Declarations --
356 --------------------------------------
358 -- FORMAL_OBJECT_DECLARATION ::=
359 -- DEFINING_IDENTIFIER_LIST :
360 -- MODE SUBTYPE_MARK [:= DEFAULT_EXPRESSION];
362 -- The caller has checked that the initial token is an identifier
364 -- Error recovery: cannot raise Error_Resync
366 procedure P_Formal_Object_Declarations
(Decls
: List_Id
) is
368 Scan_State
: Saved_Scan_State
;
372 Idents
: array (Int
range 1 .. 4096) of Entity_Id
;
373 -- This array holds the list of defining identifiers. The upper bound
374 -- of 4096 is intended to be essentially infinite, and we do not even
375 -- bother to check for it being exceeded.
378 Idents
(1) := P_Defining_Identifier
(C_Comma_Colon
);
381 while Comma_Present
loop
382 Num_Idents
:= Num_Idents
+ 1;
383 Idents
(Num_Idents
) := P_Defining_Identifier
(C_Comma_Colon
);
388 -- If there are multiple identifiers, we repeatedly scan the
389 -- type and initialization expression information by resetting
390 -- the scan pointer (so that we get completely separate trees
391 -- for each occurrence).
393 if Num_Idents
> 1 then
394 Save_Scan_State
(Scan_State
);
397 -- Loop through defining identifiers in list
401 Decl_Node
:= New_Node
(N_Formal_Object_Declaration
, Token_Ptr
);
402 Set_Defining_Identifier
(Decl_Node
, Idents
(Ident
));
404 Set_Subtype_Mark
(Decl_Node
, P_Subtype_Mark_Resync
);
406 Set_Expression
(Decl_Node
, Init_Expr_Opt
);
409 Set_Prev_Ids
(Decl_Node
, True);
412 if Ident
< Num_Idents
then
413 Set_More_Ids
(Decl_Node
, True);
416 Append
(Decl_Node
, Decls
);
418 exit Ident_Loop
when Ident
= Num_Idents
;
420 Restore_Scan_State
(Scan_State
);
424 end P_Formal_Object_Declarations
;
426 -----------------------------------
427 -- 12.5 Formal Type Declaration --
428 -----------------------------------
430 -- FORMAL_TYPE_DECLARATION ::=
431 -- type DEFINING_IDENTIFIER [DISCRIMINANT_PART]
432 -- is FORMAL_TYPE_DEFINITION;
434 -- The caller has checked that the initial token is TYPE
436 -- Error recovery: cannot raise Error_Resync
438 function P_Formal_Type_Declaration
return Node_Id
is
443 Decl_Node
:= New_Node
(N_Formal_Type_Declaration
, Token_Ptr
);
445 Set_Defining_Identifier
(Decl_Node
, P_Defining_Identifier
);
447 if P_Unknown_Discriminant_Part_Opt
then
448 Set_Unknown_Discriminants_Present
(Decl_Node
, True);
450 Set_Discriminant_Specifications
451 (Decl_Node
, P_Known_Discriminant_Part_Opt
);
456 Def_Node
:= P_Formal_Type_Definition
;
458 if Def_Node
/= Error
then
459 Set_Formal_Type_Definition
(Decl_Node
, Def_Node
);
465 -- If we have semicolon, skip it to avoid cascaded errors
467 if Token
= Tok_Semicolon
then
473 end P_Formal_Type_Declaration
;
475 ----------------------------------
476 -- 12.5 Formal Type Definition --
477 ----------------------------------
479 -- FORMAL_TYPE_DEFINITION ::=
480 -- FORMAL_PRIVATE_TYPE_DEFINITION
481 -- | FORMAL_DERIVED_TYPE_DEFINITION
482 -- | FORMAL_DISCRETE_TYPE_DEFINITION
483 -- | FORMAL_SIGNED_INTEGER_TYPE_DEFINITION
484 -- | FORMAL_MODULAR_TYPE_DEFINITION
485 -- | FORMAL_FLOATING_POINT_DEFINITION
486 -- | FORMAL_ORDINARY_FIXED_POINT_DEFINITION
487 -- | FORMAL_DECIMAL_FIXED_POINT_DEFINITION
488 -- | FORMAL_ARRAY_TYPE_DEFINITION
489 -- | FORMAL_ACCESS_TYPE_DEFINITION
491 -- FORMAL_ARRAY_TYPE_DEFINITION ::= ARRAY_TYPE_DEFINITION
493 -- FORMAL_ACCESS_TYPE_DEFINITION ::= ACCESS_TYPE_DEFINITION
495 function P_Formal_Type_Definition
return Node_Id
is
496 Scan_State
: Saved_Scan_State
;
499 if Token_Name
= Name_Abstract
then
500 Check_95_Keyword
(Tok_Abstract
, Tok_Tagged
);
503 if Token_Name
= Name_Tagged
then
504 Check_95_Keyword
(Tok_Tagged
, Tok_Private
);
505 Check_95_Keyword
(Tok_Tagged
, Tok_Limited
);
510 -- Mostly we can tell what we have from the initial token. The one
511 -- exception is ABSTRACT, where we have to scan ahead to see if we
512 -- have a formal derived type or a formal private type definition.
515 Save_Scan_State
(Scan_State
);
516 Scan
; -- past ABSTRACT
518 if Token
= Tok_New
then
519 Restore_Scan_State
(Scan_State
); -- to ABSTRACT
520 return P_Formal_Derived_Type_Definition
;
523 Restore_Scan_State
(Scan_State
); -- to ABSTRACT
524 return P_Formal_Private_Type_Definition
;
527 when Tok_Private | Tok_Limited | Tok_Tagged
=>
528 return P_Formal_Private_Type_Definition
;
531 return P_Formal_Derived_Type_Definition
;
533 when Tok_Left_Paren
=>
534 return P_Formal_Discrete_Type_Definition
;
537 return P_Formal_Signed_Integer_Type_Definition
;
540 return P_Formal_Modular_Type_Definition
;
543 return P_Formal_Floating_Point_Definition
;
546 return P_Formal_Fixed_Point_Definition
;
549 return P_Array_Type_Definition
;
552 return P_Access_Type_Definition
;
555 Error_Msg_SC
("record not allowed in generic type definition!");
556 Discard_Junk_Node
(P_Record_Definition
);
560 Error_Msg_BC
("expecting generic type definition here");
561 Resync_Past_Semicolon
;
565 end P_Formal_Type_Definition
;
567 --------------------------------------------
568 -- 12.5.1 Formal Private Type Definition --
569 --------------------------------------------
571 -- FORMAL_PRIVATE_TYPE_DEFINITION ::=
572 -- [[abstract] tagged] [limited] private
574 -- The caller has checked the initial token is PRIVATE, ABSTRACT,
577 -- Error recovery: cannot raise Error_Resync
579 function P_Formal_Private_Type_Definition
return Node_Id
is
583 Def_Node
:= New_Node
(N_Formal_Private_Type_Definition
, Token_Ptr
);
585 if Token
= Tok_Abstract
then
586 Scan
; -- past ABSTRACT
588 if Token_Name
= Name_Tagged
then
589 Check_95_Keyword
(Tok_Tagged
, Tok_Private
);
590 Check_95_Keyword
(Tok_Tagged
, Tok_Limited
);
593 if Token
/= Tok_Tagged
then
594 Error_Msg_SP
("ABSTRACT must be followed by TAGGED");
596 Set_Abstract_Present
(Def_Node
, True);
600 if Token
= Tok_Tagged
then
601 Set_Tagged_Present
(Def_Node
, True);
605 if Token
= Tok_Limited
then
606 Set_Limited_Present
(Def_Node
, True);
607 Scan
; -- past LIMITED
610 Set_Sloc
(Def_Node
, Token_Ptr
);
613 end P_Formal_Private_Type_Definition
;
615 --------------------------------------------
616 -- 12.5.1 Formal Derived Type Definition --
617 --------------------------------------------
619 -- FORMAL_DERIVED_TYPE_DEFINITION ::=
620 -- [abstract] new SUBTYPE_MARK [with private]
622 -- The caller has checked the initial token(s) is/are NEW or ASTRACT NEW
624 -- Error recovery: cannot raise Error_Resync
626 function P_Formal_Derived_Type_Definition
return Node_Id
is
630 Def_Node
:= New_Node
(N_Formal_Derived_Type_Definition
, Token_Ptr
);
632 if Token
= Tok_Abstract
then
633 Set_Abstract_Present
(Def_Node
);
634 Scan
; -- past ABSTRACT
638 Set_Subtype_Mark
(Def_Node
, P_Subtype_Mark
);
641 if Token
= Tok_With
then
643 Set_Private_Present
(Def_Node
, True);
646 elsif Token
= Tok_Tagged
then
649 if Token
= Tok_Private
then
650 Error_Msg_SC
("TAGGED should be WITH");
651 Set_Private_Present
(Def_Node
, True);
659 end P_Formal_Derived_Type_Definition
;
661 ---------------------------------------------
662 -- 12.5.2 Formal Discrete Type Definition --
663 ---------------------------------------------
665 -- FORMAL_DISCRETE_TYPE_DEFINITION ::= (<>)
667 -- The caller has checked the initial token is left paren
669 -- Error recovery: cannot raise Error_Resync
671 function P_Formal_Discrete_Type_Definition
return Node_Id
is
675 Def_Node
:= New_Node
(N_Formal_Discrete_Type_Definition
, Token_Ptr
);
676 Scan
; -- past left paren
680 end P_Formal_Discrete_Type_Definition
;
682 ---------------------------------------------------
683 -- 12.5.2 Formal Signed Integer Type Definition --
684 ---------------------------------------------------
686 -- FORMAL_SIGNED_INTEGER_TYPE_DEFINITION ::= range <>
688 -- The caller has checked the initial token is RANGE
690 -- Error recovery: cannot raise Error_Resync
692 function P_Formal_Signed_Integer_Type_Definition
return Node_Id
is
697 New_Node
(N_Formal_Signed_Integer_Type_Definition
, Token_Ptr
);
701 end P_Formal_Signed_Integer_Type_Definition
;
703 --------------------------------------------
704 -- 12.5.2 Formal Modular Type Definition --
705 --------------------------------------------
707 -- FORMAL_MODULAR_TYPE_DEFINITION ::= mod <>
709 -- The caller has checked the initial token is MOD
711 -- Error recovery: cannot raise Error_Resync
713 function P_Formal_Modular_Type_Definition
return Node_Id
is
718 New_Node
(N_Formal_Modular_Type_Definition
, Token_Ptr
);
722 end P_Formal_Modular_Type_Definition
;
724 ----------------------------------------------
725 -- 12.5.2 Formal Floating Point Definition --
726 ----------------------------------------------
728 -- FORMAL_FLOATING_POINT_DEFINITION ::= digits <>
730 -- The caller has checked the initial token is DIGITS
732 -- Error recovery: cannot raise Error_Resync
734 function P_Formal_Floating_Point_Definition
return Node_Id
is
739 New_Node
(N_Formal_Floating_Point_Definition
, Token_Ptr
);
743 end P_Formal_Floating_Point_Definition
;
745 -------------------------------------------
746 -- 12.5.2 Formal Fixed Point Definition --
747 -------------------------------------------
749 -- This routine parses either a formal ordinary fixed point definition
750 -- or a formal decimal fixed point definition:
752 -- FORMAL_ORDINARY_FIXED_POINT_DEFINITION ::= delta <>
754 -- FORMAL_DECIMAL_FIXED_POINT_DEFINITION ::= delta <> digits <>
756 -- The caller has checked the initial token is DELTA
758 -- Error recovery: cannot raise Error_Resync
760 function P_Formal_Fixed_Point_Definition
return Node_Id
is
762 Delta_Sloc
: Source_Ptr
;
765 Delta_Sloc
:= Token_Ptr
;
769 if Token
= Tok_Digits
then
771 New_Node
(N_Formal_Decimal_Fixed_Point_Definition
, Delta_Sloc
);
776 New_Node
(N_Formal_Ordinary_Fixed_Point_Definition
, Delta_Sloc
);
780 end P_Formal_Fixed_Point_Definition
;
782 ----------------------------------------------------
783 -- 12.5.2 Formal Ordinary Fixed Point Definition --
784 ----------------------------------------------------
786 -- Parsed by P_Formal_Fixed_Point_Definition (12.5.2)
788 ---------------------------------------------------
789 -- 12.5.2 Formal Decimal Fixed Point Definition --
790 ---------------------------------------------------
792 -- Parsed by P_Formal_Fixed_Point_Definition (12.5.2)
794 ------------------------------------------
795 -- 12.5.3 Formal Array Type Definition --
796 ------------------------------------------
798 -- Parsed by P_Formal_Type_Definition (12.5)
800 -------------------------------------------
801 -- 12.5.4 Formal Access Type Definition --
802 -------------------------------------------
804 -- Parsed by P_Formal_Type_Definition (12.5)
806 -----------------------------------------
807 -- 12.6 Formal Subprogram Declaration --
808 -----------------------------------------
810 -- FORMAL_SUBPROGRAM_DECLARATION ::=
811 -- with SUBPROGRAM_SPECIFICATION [is SUBPROGRAM_DEFAULT];
813 -- SUBPROGRAM_DEFAULT ::= DEFAULT_NAME | <>
815 -- DEFAULT_NAME ::= NAME
817 -- The caller has checked that the initial tokens are WITH FUNCTION or
818 -- WITH PROCEDURE, and the initial WITH has been scanned out.
820 -- Note: we separate this into two procedures because the name is allowed
821 -- to be an operator symbol for a function, but not for a procedure.
823 -- Error recovery: cannot raise Error_Resync
825 function P_Formal_Subprogram_Declaration
return Node_Id
is
829 Def_Node
:= New_Node
(N_Formal_Subprogram_Declaration
, Prev_Token_Ptr
);
830 Set_Specification
(Def_Node
, P_Subprogram_Specification
);
832 if Token
= Tok_Is
then
833 T_Is
; -- past IS, skip extra IS or ";"
835 if Token
= Tok_Box
then
836 Set_Box_Present
(Def_Node
, True);
840 Set_Default_Name
(Def_Node
, P_Name
);
847 end P_Formal_Subprogram_Declaration
;
849 ------------------------------
850 -- 12.6 Subprogram Default --
851 ------------------------------
853 -- Parsed by P_Formal_Procedure_Declaration (12.6)
855 ------------------------
856 -- 12.6 Default Name --
857 ------------------------
859 -- Parsed by P_Formal_Procedure_Declaration (12.6)
861 --------------------------------------
862 -- 12.7 Formal Package Declaration --
863 --------------------------------------
865 -- FORMAL_PACKAGE_DECLARATION ::=
866 -- with package DEFINING_IDENTIFIER
867 -- is new generic_package_NAME FORMAL_PACKAGE_ACTUAL_PART;
869 -- FORMAL_PACKAGE_ACTUAL_PART ::=
870 -- (<>) | [GENERIC_ACTUAL_PART]
872 -- The caller has checked that the initial tokens are WITH PACKAGE,
873 -- and the initial WITH has been scanned out (so Token = Tok_Package).
875 -- Error recovery: cannot raise Error_Resync
877 function P_Formal_Package_Declaration
return Node_Id
is
879 Scan_State
: Saved_Scan_State
;
882 Def_Node
:= New_Node
(N_Formal_Package_Declaration
, Prev_Token_Ptr
);
883 Scan
; -- past PACKAGE
884 Set_Defining_Identifier
(Def_Node
, P_Defining_Identifier
(C_Is
));
887 Set_Name
(Def_Node
, P_Qualified_Simple_Name
);
889 if Token
= Tok_Left_Paren
then
890 Save_Scan_State
(Scan_State
); -- at the left paren
891 Scan
; -- past the left paren
893 if Token
= Tok_Box
then
894 Set_Box_Present
(Def_Node
, True);
899 Restore_Scan_State
(Scan_State
); -- to the left paren
900 Set_Generic_Associations
(Def_Node
, P_Generic_Actual_Part_Opt
);
906 end P_Formal_Package_Declaration
;
908 --------------------------------------
909 -- 12.7 Formal Package Actual Part --
910 --------------------------------------
912 -- Parsed by P_Formal_Package_Declaration (12.7)