1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2018, 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 pragma Style_Checks
(All_Checks
);
27 -- Turn off subprogram body ordering check. Subprograms are in order
28 -- by RM section rather than alphabetical
33 -----------------------
34 -- Local Subprograms --
35 -----------------------
37 procedure Append_Use_Clause
40 Is_First
: in out Boolean;
41 Is_Last
: in out Boolean);
42 -- Append a use_clause to the Item_List, appropriately setting the Prev_Ids
43 -- and More_Ids flags for each split use node. The flags Is_First and
44 -- Is_Last track position of subtype_marks or names within the original
47 procedure P_Use_Package_Clause
(Item_List
: List_Id
);
48 procedure P_Use_Type_Clause
(Item_List
: List_Id
);
50 -----------------------
51 -- Append_Use_Clause --
52 -----------------------
54 procedure Append_Use_Clause
57 Is_First
: in out Boolean;
58 Is_Last
: in out Boolean)
61 if Token
/= Tok_Comma
then
63 Set_Prev_Ids
(Use_Node
);
66 Append
(Use_Node
, Item_List
);
70 Set_More_Ids
(Use_Node
);
73 Set_Prev_Ids
(Use_Node
);
78 Append
(Use_Node
, Item_List
);
81 end Append_Use_Clause
;
87 -- USE_CLAUSE ::= USE_PACKAGE_CLAUSE | USE_TYPE_CLAUSE
89 -- The caller has checked that the initial token is USE
91 -- Error recovery: cannot raise Error_Resync
93 procedure P_Use_Clause
(Item_List
: List_Id
) is
97 if Token
= Tok_Type
or else Token
= Tok_All
then
98 P_Use_Type_Clause
(Item_List
);
100 P_Use_Package_Clause
(Item_List
);
104 -----------------------------
105 -- 8.4 Use Package Clause --
106 -----------------------------
108 -- USE_PACKAGE_CLAUSE ::= use package_NAME {, package_NAME};
110 -- The caller has scanned out the USE keyword
112 -- Error recovery: cannot raise Error_Resync
114 procedure P_Use_Package_Clause
(Item_List
: List_Id
) is
115 Is_First
: Boolean := True;
116 Is_Last
: Boolean := False;
118 Use_Sloc
: constant Source_Ptr
:= Prev_Token_Ptr
;
121 if Token
= Tok_Package
then
122 Error_Msg_SC
("PACKAGE should not appear here");
123 Scan
; -- Past PACKAGE
126 -- Loop through names in a single use_package_clause, generating an
127 -- N_Use_Package_Clause node for each name encountered.
130 Use_Node
:= New_Node
(N_Use_Package_Clause
, Use_Sloc
);
131 Set_Name
(Use_Node
, P_Qualified_Simple_Name
);
133 -- Locally chain each name's use-package node
135 Append_Use_Clause
(Item_List
, Use_Node
, Is_First
, Is_Last
);
140 end P_Use_Package_Clause
;
142 --------------------------
143 -- 8.4 Use Type Clause --
144 --------------------------
146 -- USE_TYPE_CLAUSE ::= use [ALL] type SUBTYPE_MARK {, SUBTYPE_MARK};
148 -- The caller has checked that the initial token is USE, scanned it out
149 -- and that the current token is either ALL or TYPE.
151 -- Note: Use of ALL is an Ada 2012 feature
153 -- Error recovery: cannot raise Error_Resync
155 procedure P_Use_Type_Clause
(Item_List
: List_Id
) is
156 Use_Sloc
: constant Source_Ptr
:= Prev_Token_Ptr
;
158 All_Present
: Boolean;
159 Is_First
: Boolean := True;
160 Is_Last
: Boolean := False;
164 if Token
= Tok_All
then
165 Error_Msg_Ada_2012_Feature
("|`USE ALL TYPE`", Token_Ptr
);
169 if Token
/= Tok_Type
then
170 Error_Msg_SC
("TYPE expected");
174 pragma Assert
(Token
= Tok_Type
);
175 All_Present
:= False;
178 if Ada_Version
= Ada_83
then
179 Error_Msg_SC
("(Ada 83) use type not allowed!");
184 -- Loop through subtype_marks in one use_type_clause, generating a
185 -- separate N_Use_Type_Clause node for each subtype_mark encountered.
188 Use_Node
:= New_Node
(N_Use_Type_Clause
, Use_Sloc
);
189 Set_All_Present
(Use_Node
, All_Present
);
190 Set_Used_Operations
(Use_Node
, No_Elist
);
192 Set_Subtype_Mark
(Use_Node
, P_Subtype_Mark
);
196 -- Locally chain each subtype_mark's use-type node
198 Append_Use_Clause
(Item_List
, Use_Node
, Is_First
, Is_Last
);
203 end P_Use_Type_Clause
;
205 -------------------------------
206 -- 8.5 Renaming Declaration --
207 -------------------------------
209 -- Object renaming declarations and exception renaming declarations
210 -- are parsed by P_Identifier_Declaration (3.3.1)
212 -- Subprogram renaming declarations are parsed by P_Subprogram (6.1)
214 -- Package renaming declarations are parsed by P_Package (7.1)
216 -- Generic renaming declarations are parsed by P_Generic (12.1)
218 ----------------------------------------
219 -- 8.5.1 Object Renaming Declaration --
220 ----------------------------------------
222 -- Parsed by P_Identifier_Declarations (3.3.1)
224 -------------------------------------------
225 -- 8.5.2 Exception Renaming Declaration --
226 -------------------------------------------
228 -- Parsed by P_Identifier_Declarations (3.3.1)
230 -----------------------------------------
231 -- 8.5.3 Package Renaming Declaration --
232 -----------------------------------------
234 -- Parsed by P_Package (7.1)
236 --------------------------------------------
237 -- 8.5.4 Subprogram Renaming Declaration --
238 --------------------------------------------
240 -- Parsed by P_Subprogram (6.1)
242 -----------------------------------------
243 -- 8.5.2 Generic Renaming Declaration --
244 -----------------------------------------
246 -- Parsed by P_Generic (12.1)