OSDN Git Service

* 1aexcept.adb, 1aexcept.ads, 1ic.ads, 1ssecsta.adb,
[pf3gnuchains/gcc-fork.git] / gcc / ada / par-ch8.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                              P A R . C H 8                               --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2001 Free Software Foundation, Inc.          --
10 --                                                                          --
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.                                                      --
21 --                                                                          --
22 -- GNAT was originally developed  by the GNAT team at  New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
24 --                                                                          --
25 ------------------------------------------------------------------------------
26
27 pragma Style_Checks (All_Checks);
28 --  Turn off subprogram body ordering check. Subprograms are in order
29 --  by RM section rather than alphabetical
30
31 separate (Par)
32 package body Ch8 is
33
34    -----------------------
35    -- Local Subprograms --
36    -----------------------
37
38    function P_Use_Package_Clause                           return Node_Id;
39    function P_Use_Type_Clause                              return Node_Id;
40
41    ---------------------
42    -- 8.4  Use Clause --
43    ---------------------
44
45    --  USE_CLAUSE ::= USE_PACKAGE_CLAUSE | USE_TYPE_CLAUSE
46
47    --  The caller has checked that the initial token is USE
48
49    --  Error recovery: cannot raise Error_Resync
50
51    function P_Use_Clause return Node_Id is
52    begin
53       Scan; -- past USE
54
55       if Token = Tok_Type then
56          return P_Use_Type_Clause;
57
58       else
59          return P_Use_Package_Clause;
60       end if;
61    end P_Use_Clause;
62
63    -----------------------------
64    -- 8.4  Use Package Clause --
65    -----------------------------
66
67    --  USE_PACKAGE_CLAUSE ::= use package_NAME {, package_NAME};
68
69    --  The caller has scanned out the USE keyword
70
71    --  Error recovery: cannot raise Error_Resync
72
73    function P_Use_Package_Clause return Node_Id is
74       Use_Node : Node_Id;
75
76    begin
77       Use_Node := New_Node (N_Use_Package_Clause, Prev_Token_Ptr);
78       Set_Names (Use_Node, New_List);
79
80       if Token = Tok_Package then
81          Error_Msg_SC ("PACKAGE should not appear here");
82          Scan; -- past PACKAGE
83       end if;
84
85       loop
86          Append (P_Qualified_Simple_Name, Names (Use_Node));
87          exit when Token /= Tok_Comma;
88          Scan; -- past comma
89       end loop;
90
91       TF_Semicolon;
92       return Use_Node;
93    end P_Use_Package_Clause;
94
95    --------------------------
96    -- 8.4  Use Type Clause --
97    --------------------------
98
99    --  USE_TYPE_CLAUSE ::= use type SUBTYPE_MARK {, SUBTYPE_MARK};
100
101    --  The caller has checked that the initial token is USE, scanned it out
102    --  and that the current token is TYPE.
103
104    --  Error recovery: cannot raise Error_Resync
105
106    function P_Use_Type_Clause return Node_Id is
107       Use_Node : Node_Id;
108
109    begin
110       Use_Node := New_Node (N_Use_Type_Clause, Prev_Token_Ptr);
111       Set_Subtype_Marks (Use_Node, New_List);
112
113       if Ada_83 then
114          Error_Msg_SC ("(Ada 83) use type not allowed!");
115       end if;
116
117       Scan; -- past TYPE
118
119       loop
120          Append (P_Subtype_Mark, Subtype_Marks (Use_Node));
121          No_Constraint;
122          exit when Token /= Tok_Comma;
123          Scan; -- past comma
124       end loop;
125
126       TF_Semicolon;
127       return Use_Node;
128    end P_Use_Type_Clause;
129
130    -------------------------------
131    -- 8.5  Renaming Declaration --
132    -------------------------------
133
134    --  Object renaming declarations and exception renaming declarations
135    --  are parsed by P_Identifier_Declaration (3.3.1)
136
137    --  Subprogram renaming declarations are parsed by P_Subprogram (6.1)
138
139    --  Package renaming declarations are parsed by P_Package (7.1)
140
141    --  Generic renaming declarations are parsed by P_Generic (12.1)
142
143    ----------------------------------------
144    -- 8.5.1  Object Renaming Declaration --
145    ----------------------------------------
146
147    --  Parsed by P_Identifier_Declarations (3.3.1)
148
149    ----------------------------------------
150    -- 8.5.2  Exception Renaming Declaration --
151    ----------------------------------------
152
153    --  Parsed by P_Identifier_Declarations (3.3.1)
154
155    -----------------------------------------
156    -- 8.5.3  Package Renaming Declaration --
157    -----------------------------------------
158
159    --  Parsed by P_Package (7.1)
160
161    --------------------------------------------
162    -- 8.5.4  Subprogram Renaming Declaration --
163    --------------------------------------------
164
165    --  Parsed by P_Subprogram (6.1)
166
167    -----------------------------------------
168    -- 8.5.2  Generic Renaming Declaration --
169    -----------------------------------------
170
171    --  Parsed by P_Generic (12.1)
172
173 end Ch8;