1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005 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
490 -- | FORMAL_INTERFACE_TYPE_DEFINITION
492 -- FORMAL_ARRAY_TYPE_DEFINITION ::= ARRAY_TYPE_DEFINITION
494 -- FORMAL_ACCESS_TYPE_DEFINITION ::= ACCESS_TYPE_DEFINITION
496 -- FORMAL_INTERFACE_TYPE_DEFINITION ::= INTERFACE_TYPE_DEFINITION
498 function P_Formal_Type_Definition
return Node_Id
is
499 Scan_State
: Saved_Scan_State
;
500 Typedef_Node
: Node_Id
;
503 if Token_Name
= Name_Abstract
then
504 Check_95_Keyword
(Tok_Abstract
, Tok_Tagged
);
507 if Token_Name
= Name_Tagged
then
508 Check_95_Keyword
(Tok_Tagged
, Tok_Private
);
509 Check_95_Keyword
(Tok_Tagged
, Tok_Limited
);
514 -- Mostly we can tell what we have from the initial token. The one
515 -- exception is ABSTRACT, where we have to scan ahead to see if we
516 -- have a formal derived type or a formal private type definition.
519 Save_Scan_State
(Scan_State
);
520 Scan
; -- past ABSTRACT
522 if Token
= Tok_New
then
523 Restore_Scan_State
(Scan_State
); -- to ABSTRACT
524 return P_Formal_Derived_Type_Definition
;
527 Restore_Scan_State
(Scan_State
); -- to ABSTRACT
528 return P_Formal_Private_Type_Definition
;
532 return P_Access_Type_Definition
;
535 return P_Array_Type_Definition
;
538 return P_Formal_Fixed_Point_Definition
;
541 return P_Formal_Floating_Point_Definition
;
543 when Tok_Interface
=> -- Ada 2005 (AI-251)
544 return P_Interface_Type_Definition
(Is_Synchronized
=> False);
546 when Tok_Left_Paren
=>
547 return P_Formal_Discrete_Type_Definition
;
550 Save_Scan_State
(Scan_State
);
551 Scan
; -- past LIMITED
553 if Token
= Tok_Interface
then
554 Typedef_Node
:= P_Interface_Type_Definition
555 (Is_Synchronized
=> False);
556 Set_Limited_Present
(Typedef_Node
);
560 Restore_Scan_State
(Scan_State
);
561 return P_Formal_Private_Type_Definition
;
565 return P_Formal_Modular_Type_Definition
;
568 return P_Formal_Derived_Type_Definition
;
572 return P_Formal_Private_Type_Definition
;
575 return P_Formal_Signed_Integer_Type_Definition
;
578 Error_Msg_SC
("record not allowed in generic type definition!");
579 Discard_Junk_Node
(P_Record_Definition
);
588 Scan
; -- past TASK, PROTECTED or SYNCHRONIZED
591 Saved_Token
: constant Token_Type
:= Token
;
594 Typedef_Node
:= P_Interface_Type_Definition
595 (Is_Synchronized
=> True);
599 Set_Task_Present
(Typedef_Node
);
601 when Tok_Protected
=>
602 Set_Protected_Present
(Typedef_Node
);
604 when Tok_Synchronized
=>
605 Set_Synchronized_Present
(Typedef_Node
);
615 Error_Msg_BC
("expecting generic type definition here");
616 Resync_Past_Semicolon
;
620 end P_Formal_Type_Definition
;
622 --------------------------------------------
623 -- 12.5.1 Formal Private Type Definition --
624 --------------------------------------------
626 -- FORMAL_PRIVATE_TYPE_DEFINITION ::=
627 -- [[abstract] tagged] [limited] private
629 -- The caller has checked the initial token is PRIVATE, ABSTRACT,
632 -- Error recovery: cannot raise Error_Resync
634 function P_Formal_Private_Type_Definition
return Node_Id
is
638 Def_Node
:= New_Node
(N_Formal_Private_Type_Definition
, Token_Ptr
);
640 if Token
= Tok_Abstract
then
641 Scan
; -- past ABSTRACT
643 if Token_Name
= Name_Tagged
then
644 Check_95_Keyword
(Tok_Tagged
, Tok_Private
);
645 Check_95_Keyword
(Tok_Tagged
, Tok_Limited
);
648 if Token
/= Tok_Tagged
then
649 Error_Msg_SP
("ABSTRACT must be followed by TAGGED");
651 Set_Abstract_Present
(Def_Node
, True);
655 if Token
= Tok_Tagged
then
656 Set_Tagged_Present
(Def_Node
, True);
660 if Token
= Tok_Limited
then
661 Set_Limited_Present
(Def_Node
, True);
662 Scan
; -- past LIMITED
665 Set_Sloc
(Def_Node
, Token_Ptr
);
668 end P_Formal_Private_Type_Definition
;
670 --------------------------------------------
671 -- 12.5.1 Formal Derived Type Definition --
672 --------------------------------------------
674 -- FORMAL_DERIVED_TYPE_DEFINITION ::=
675 -- [abstract] new SUBTYPE_MARK [[AND interface_list] with private]
677 -- The caller has checked the initial token(s) is/are NEW or ASTRACT NEW
679 -- Error recovery: cannot raise Error_Resync
681 function P_Formal_Derived_Type_Definition
return Node_Id
is
685 Def_Node
:= New_Node
(N_Formal_Derived_Type_Definition
, Token_Ptr
);
687 if Token
= Tok_Abstract
then
688 Set_Abstract_Present
(Def_Node
);
689 Scan
; -- past ABSTRACT
693 Set_Subtype_Mark
(Def_Node
, P_Subtype_Mark
);
696 -- Ada 2005 (AI-251): Deal with interfaces
698 if Token
= Tok_And
then
701 if Ada_Version
< Ada_05
then
703 ("abstract interface is an Ada 2005 extension");
704 Error_Msg_SP
("\unit must be compiled with -gnat05 switch");
707 Set_Interface_List
(Def_Node
, New_List
);
710 Append
(P_Qualified_Simple_Name
, Interface_List
(Def_Node
));
711 exit when Token
/= Tok_And
;
716 if Token
= Tok_With
then
718 Set_Private_Present
(Def_Node
, True);
721 elsif Token
= Tok_Tagged
then
724 if Token
= Tok_Private
then
725 Error_Msg_SC
("TAGGED should be WITH");
726 Set_Private_Present
(Def_Node
, True);
734 end P_Formal_Derived_Type_Definition
;
736 ---------------------------------------------
737 -- 12.5.2 Formal Discrete Type Definition --
738 ---------------------------------------------
740 -- FORMAL_DISCRETE_TYPE_DEFINITION ::= (<>)
742 -- The caller has checked the initial token is left paren
744 -- Error recovery: cannot raise Error_Resync
746 function P_Formal_Discrete_Type_Definition
return Node_Id
is
750 Def_Node
:= New_Node
(N_Formal_Discrete_Type_Definition
, Token_Ptr
);
751 Scan
; -- past left paren
755 end P_Formal_Discrete_Type_Definition
;
757 ---------------------------------------------------
758 -- 12.5.2 Formal Signed Integer Type Definition --
759 ---------------------------------------------------
761 -- FORMAL_SIGNED_INTEGER_TYPE_DEFINITION ::= range <>
763 -- The caller has checked the initial token is RANGE
765 -- Error recovery: cannot raise Error_Resync
767 function P_Formal_Signed_Integer_Type_Definition
return Node_Id
is
772 New_Node
(N_Formal_Signed_Integer_Type_Definition
, Token_Ptr
);
776 end P_Formal_Signed_Integer_Type_Definition
;
778 --------------------------------------------
779 -- 12.5.2 Formal Modular Type Definition --
780 --------------------------------------------
782 -- FORMAL_MODULAR_TYPE_DEFINITION ::= mod <>
784 -- The caller has checked the initial token is MOD
786 -- Error recovery: cannot raise Error_Resync
788 function P_Formal_Modular_Type_Definition
return Node_Id
is
793 New_Node
(N_Formal_Modular_Type_Definition
, Token_Ptr
);
797 end P_Formal_Modular_Type_Definition
;
799 ----------------------------------------------
800 -- 12.5.2 Formal Floating Point Definition --
801 ----------------------------------------------
803 -- FORMAL_FLOATING_POINT_DEFINITION ::= digits <>
805 -- The caller has checked the initial token is DIGITS
807 -- Error recovery: cannot raise Error_Resync
809 function P_Formal_Floating_Point_Definition
return Node_Id
is
814 New_Node
(N_Formal_Floating_Point_Definition
, Token_Ptr
);
818 end P_Formal_Floating_Point_Definition
;
820 -------------------------------------------
821 -- 12.5.2 Formal Fixed Point Definition --
822 -------------------------------------------
824 -- This routine parses either a formal ordinary fixed point definition
825 -- or a formal decimal fixed point definition:
827 -- FORMAL_ORDINARY_FIXED_POINT_DEFINITION ::= delta <>
829 -- FORMAL_DECIMAL_FIXED_POINT_DEFINITION ::= delta <> digits <>
831 -- The caller has checked the initial token is DELTA
833 -- Error recovery: cannot raise Error_Resync
835 function P_Formal_Fixed_Point_Definition
return Node_Id
is
837 Delta_Sloc
: Source_Ptr
;
840 Delta_Sloc
:= Token_Ptr
;
844 if Token
= Tok_Digits
then
846 New_Node
(N_Formal_Decimal_Fixed_Point_Definition
, Delta_Sloc
);
851 New_Node
(N_Formal_Ordinary_Fixed_Point_Definition
, Delta_Sloc
);
855 end P_Formal_Fixed_Point_Definition
;
857 ----------------------------------------------------
858 -- 12.5.2 Formal Ordinary Fixed Point Definition --
859 ----------------------------------------------------
861 -- Parsed by P_Formal_Fixed_Point_Definition (12.5.2)
863 ---------------------------------------------------
864 -- 12.5.2 Formal Decimal Fixed Point Definition --
865 ---------------------------------------------------
867 -- Parsed by P_Formal_Fixed_Point_Definition (12.5.2)
869 ------------------------------------------
870 -- 12.5.3 Formal Array Type Definition --
871 ------------------------------------------
873 -- Parsed by P_Formal_Type_Definition (12.5)
875 -------------------------------------------
876 -- 12.5.4 Formal Access Type Definition --
877 -------------------------------------------
879 -- Parsed by P_Formal_Type_Definition (12.5)
881 -----------------------------------------
882 -- 12.6 Formal Subprogram Declaration --
883 -----------------------------------------
885 -- FORMAL_SUBPROGRAM_DECLARATION ::=
886 -- FORMAL_CONCRETE_SUBPROGRAM_DECLARATION
887 -- | FORMAL_ABSTRACT_SUBPROGRAM_DECLARATION
889 -- FORMAL_CONCRETE_SUBPROGRAM_DECLARATION ::=
890 -- with SUBPROGRAM_SPECIFICATION [is SUBPROGRAM_DEFAULT];
892 -- FORMAL_ABSTRACT_SUBPROGRAM_DECLARATION ::=
893 -- with SUBPROGRAM_SPECIFICATION is abstract [SUBPROGRAM_DEFAULT];
895 -- SUBPROGRAM_DEFAULT ::= DEFAULT_NAME | <>
897 -- DEFAULT_NAME ::= NAME
899 -- The caller has checked that the initial tokens are WITH FUNCTION or
900 -- WITH PROCEDURE, and the initial WITH has been scanned out.
902 -- Error recovery: cannot raise Error_Resync
904 function P_Formal_Subprogram_Declaration
return Node_Id
is
905 Prev_Sloc
: constant Source_Ptr
:= Prev_Token_Ptr
;
906 Spec_Node
: constant Node_Id
:= P_Subprogram_Specification
;
910 if Token
= Tok_Is
then
911 T_Is
; -- past IS, skip extra IS or ";"
913 if Token
= Tok_Abstract
then
915 New_Node
(N_Formal_Abstract_Subprogram_Declaration
, Prev_Sloc
);
916 Scan
; -- past ABSTRACT
918 if Ada_Version
< Ada_05
then
920 ("formal abstract subprograms are an Ada 2005 extension");
921 Error_Msg_SP
("\unit must be compiled with -gnat05 switch");
926 New_Node
(N_Formal_Concrete_Subprogram_Declaration
, Prev_Sloc
);
929 Set_Specification
(Def_Node
, Spec_Node
);
931 if Token
= Tok_Semicolon
then
934 elsif Token
= Tok_Box
then
935 Set_Box_Present
(Def_Node
, True);
940 Set_Default_Name
(Def_Node
, P_Name
);
946 New_Node
(N_Formal_Concrete_Subprogram_Declaration
, Prev_Sloc
);
947 Set_Specification
(Def_Node
, Spec_Node
);
952 end P_Formal_Subprogram_Declaration
;
954 ------------------------------
955 -- 12.6 Subprogram Default --
956 ------------------------------
958 -- Parsed by P_Formal_Procedure_Declaration (12.6)
960 ------------------------
961 -- 12.6 Default Name --
962 ------------------------
964 -- Parsed by P_Formal_Procedure_Declaration (12.6)
966 --------------------------------------
967 -- 12.7 Formal Package Declaration --
968 --------------------------------------
970 -- FORMAL_PACKAGE_DECLARATION ::=
971 -- with package DEFINING_IDENTIFIER
972 -- is new generic_package_NAME FORMAL_PACKAGE_ACTUAL_PART;
974 -- FORMAL_PACKAGE_ACTUAL_PART ::=
975 -- (<>) | [GENERIC_ACTUAL_PART]
977 -- The caller has checked that the initial tokens are WITH PACKAGE,
978 -- and the initial WITH has been scanned out (so Token = Tok_Package).
980 -- Error recovery: cannot raise Error_Resync
982 function P_Formal_Package_Declaration
return Node_Id
is
984 Scan_State
: Saved_Scan_State
;
987 Def_Node
:= New_Node
(N_Formal_Package_Declaration
, Prev_Token_Ptr
);
988 Scan
; -- past PACKAGE
989 Set_Defining_Identifier
(Def_Node
, P_Defining_Identifier
(C_Is
));
992 Set_Name
(Def_Node
, P_Qualified_Simple_Name
);
994 if Token
= Tok_Left_Paren
then
995 Save_Scan_State
(Scan_State
); -- at the left paren
996 Scan
; -- past the left paren
998 if Token
= Tok_Box
then
999 Set_Box_Present
(Def_Node
, True);
1004 Restore_Scan_State
(Scan_State
); -- to the left paren
1005 Set_Generic_Associations
(Def_Node
, P_Generic_Actual_Part_Opt
);
1011 end P_Formal_Package_Declaration
;
1013 --------------------------------------
1014 -- 12.7 Formal Package Actual Part --
1015 --------------------------------------
1017 -- Parsed by P_Formal_Package_Declaration (12.7)