annotate gcc/ada/par.adb @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- P A R --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 with Aspects; use Aspects;
kono
parents:
diff changeset
27 with Atree; use Atree;
kono
parents:
diff changeset
28 with Casing; use Casing;
kono
parents:
diff changeset
29 with Debug; use Debug;
kono
parents:
diff changeset
30 with Elists; use Elists;
kono
parents:
diff changeset
31 with Errout; use Errout;
kono
parents:
diff changeset
32 with Fname; use Fname;
kono
parents:
diff changeset
33 with Lib; use Lib;
kono
parents:
diff changeset
34 with Namet; use Namet;
kono
parents:
diff changeset
35 with Namet.Sp; use Namet.Sp;
kono
parents:
diff changeset
36 with Nlists; use Nlists;
kono
parents:
diff changeset
37 with Nmake; use Nmake;
kono
parents:
diff changeset
38 with Opt; use Opt;
kono
parents:
diff changeset
39 with Output; use Output;
kono
parents:
diff changeset
40 with Par_SCO; use Par_SCO;
kono
parents:
diff changeset
41 with Restrict; use Restrict;
kono
parents:
diff changeset
42 with Scans; use Scans;
kono
parents:
diff changeset
43 with Scn; use Scn;
kono
parents:
diff changeset
44 with Sem_Util; use Sem_Util;
kono
parents:
diff changeset
45 with Sinput; use Sinput;
kono
parents:
diff changeset
46 with Sinput.L; use Sinput.L;
kono
parents:
diff changeset
47 with Sinfo; use Sinfo;
kono
parents:
diff changeset
48 with Snames; use Snames;
kono
parents:
diff changeset
49 with Style;
kono
parents:
diff changeset
50 with Stylesw; use Stylesw;
kono
parents:
diff changeset
51 with Table;
kono
parents:
diff changeset
52 with Tbuild; use Tbuild;
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 ---------
kono
parents:
diff changeset
55 -- Par --
kono
parents:
diff changeset
56 ---------
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 function Par (Configuration_Pragmas : Boolean) return List_Id is
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 Num_Library_Units : Natural := 0;
kono
parents:
diff changeset
61 -- Count number of units parsed (relevant only in syntax check only mode,
kono
parents:
diff changeset
62 -- since in semantics check mode only a single unit is permitted anyway).
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 Save_Config_Switches : Config_Switches_Type;
kono
parents:
diff changeset
65 -- Variable used to save values of config switches while we parse the
kono
parents:
diff changeset
66 -- new unit, to be restored on exit for proper recursive behavior.
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 Loop_Block_Count : Nat := 0;
kono
parents:
diff changeset
69 -- Counter used for constructing loop/block names (see the routine
kono
parents:
diff changeset
70 -- Par.Ch5.Get_Loop_Block_Name).
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 Inside_Record_Definition : Boolean := False;
kono
parents:
diff changeset
73 -- True within a record definition. Used to control warning for
kono
parents:
diff changeset
74 -- redefinition of standard entities (not issued for field names).
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 --------------------
kono
parents:
diff changeset
77 -- Error Recovery --
kono
parents:
diff changeset
78 --------------------
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 -- When an error is encountered, a call is made to one of the Error_Msg
kono
parents:
diff changeset
81 -- routines to record the error. If the syntax scan is not derailed by the
kono
parents:
diff changeset
82 -- error (e.g. a complaint that logical operators are inconsistent in an
kono
parents:
diff changeset
83 -- EXPRESSION), then control returns from the Error_Msg call, and the
kono
parents:
diff changeset
84 -- parse continues unimpeded.
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 -- If on the other hand, the Error_Msg represents a situation from which
kono
parents:
diff changeset
87 -- the parser cannot recover locally, the exception Error_Resync is raised
kono
parents:
diff changeset
88 -- immediately after the call to Error_Msg. Handlers for Error_Resync
kono
parents:
diff changeset
89 -- are located at strategic points to resynchronize the parse. For example,
kono
parents:
diff changeset
90 -- when an error occurs in a statement, the handler skips to the next
kono
parents:
diff changeset
91 -- semicolon and continues the scan from there.
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 -- Each parsing procedure contains a note with the heading "Error recovery"
kono
parents:
diff changeset
94 -- which shows if it can propagate the Error_Resync exception. In order
kono
parents:
diff changeset
95 -- not to propagate the exception, a procedure must either contain its own
kono
parents:
diff changeset
96 -- handler for this exception, or it must not call any other routines which
kono
parents:
diff changeset
97 -- propagate the exception.
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 -- Note: the arrangement of Error_Resync handlers is such that it should
kono
parents:
diff changeset
100 -- never be possible to transfer control through a procedure which made
kono
parents:
diff changeset
101 -- an entry in the scope stack, invalidating the contents of the stack.
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 Error_Resync : exception;
kono
parents:
diff changeset
104 -- Exception raised on error that is not handled locally, see above
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 Last_Resync_Point : Source_Ptr;
kono
parents:
diff changeset
107 -- The resynchronization routines in Par.Sync run a risk of getting
kono
parents:
diff changeset
108 -- stuck in an infinite loop if they do not skip a token, and the caller
kono
parents:
diff changeset
109 -- keeps repeating the same resync call. On the other hand, if they skip
kono
parents:
diff changeset
110 -- a token unconditionally, some recovery opportunities are missed. The
kono
parents:
diff changeset
111 -- variable Last_Resync_Point records the token location previously set
kono
parents:
diff changeset
112 -- by a Resync call, and if a subsequent Resync call occurs at the same
kono
parents:
diff changeset
113 -- location, then the Resync routine does guarantee to skip a token.
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 --------------------------------------------
kono
parents:
diff changeset
116 -- Handling Semicolon Used in Place of IS --
kono
parents:
diff changeset
117 --------------------------------------------
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 -- The following global variables are used in handling the error situation
kono
parents:
diff changeset
120 -- of using a semicolon in place of IS in a subprogram declaration as in:
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 -- procedure X (Y : Integer);
kono
parents:
diff changeset
123 -- Q : Integer;
kono
parents:
diff changeset
124 -- begin
kono
parents:
diff changeset
125 -- ...
kono
parents:
diff changeset
126 -- end;
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 -- The two contexts in which this can appear are at the outer level, and
kono
parents:
diff changeset
129 -- within a declarative region. At the outer level, we know something is
kono
parents:
diff changeset
130 -- wrong as soon as we see the Q (or begin, if there are no declarations),
kono
parents:
diff changeset
131 -- and we can immediately decide that the semicolon should have been IS.
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 -- The situation in a declarative region is more complex. The declaration
kono
parents:
diff changeset
134 -- of Q could belong to the outer region, and we do not know that we have
kono
parents:
diff changeset
135 -- an error until we hit the begin. It is still not clear at this point
kono
parents:
diff changeset
136 -- from a syntactic point of view that something is wrong, because the
kono
parents:
diff changeset
137 -- begin could belong to the enclosing subprogram or package. However, we
kono
parents:
diff changeset
138 -- can incorporate a bit of semantic knowledge and note that the body of
kono
parents:
diff changeset
139 -- X is missing, so we definitely DO have an error. We diagnose this error
kono
parents:
diff changeset
140 -- as semicolon in place of IS on the subprogram line.
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 -- There are two styles for this diagnostic. If the begin immediately
kono
parents:
diff changeset
143 -- follows the semicolon, then we can place a flag (IS expected) right
kono
parents:
diff changeset
144 -- on the semicolon. Otherwise we do not detect the error until we hit
kono
parents:
diff changeset
145 -- the begin which refers back to the line with the semicolon.
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 -- To control the process in the second case, the following global
kono
parents:
diff changeset
148 -- variables are set to indicate that we have a subprogram declaration
kono
parents:
diff changeset
149 -- whose body is required and has not yet been found. The prefix SIS
kono
parents:
diff changeset
150 -- stands for "Subprogram IS" handling.
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 SIS_Entry_Active : Boolean := False;
kono
parents:
diff changeset
153 -- Set True to indicate that an entry is active (i.e. that a subprogram
kono
parents:
diff changeset
154 -- declaration has been encountered, and no body for this subprogram has
kono
parents:
diff changeset
155 -- been encountered). The remaining fields are valid only if this is True.
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 SIS_Labl : Node_Id;
kono
parents:
diff changeset
158 -- Subprogram designator
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 SIS_Sloc : Source_Ptr;
kono
parents:
diff changeset
161 -- Source location of FUNCTION/PROCEDURE keyword
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 SIS_Ecol : Column_Number;
kono
parents:
diff changeset
164 -- Column number of FUNCTION/PROCEDURE keyword
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 SIS_Semicolon_Sloc : Source_Ptr;
kono
parents:
diff changeset
167 -- Source location of semicolon at end of subprogram declaration
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 SIS_Declaration_Node : Node_Id;
kono
parents:
diff changeset
170 -- Pointer to tree node for subprogram declaration
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 SIS_Missing_Semicolon_Message : Error_Msg_Id;
kono
parents:
diff changeset
173 -- Used to save message ID of missing semicolon message (which will be
kono
parents:
diff changeset
174 -- modified to missing IS if necessary). Set to No_Error_Msg in the
kono
parents:
diff changeset
175 -- normal (non-error) case.
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 -- Five things can happen to an active SIS entry
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 -- 1. If a BEGIN is encountered with an SIS entry active, then we have
kono
parents:
diff changeset
180 -- exactly the situation in which we know the body of the subprogram is
kono
parents:
diff changeset
181 -- missing. After posting an error message, we change the spec to a body,
kono
parents:
diff changeset
182 -- rechaining the declarations that intervened between the spec and BEGIN.
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 -- 2. Another subprogram declaration or body is encountered. In this
kono
parents:
diff changeset
185 -- case the entry gets overwritten with the information for the new
kono
parents:
diff changeset
186 -- subprogram declaration. We don't catch some nested cases this way,
kono
parents:
diff changeset
187 -- but it doesn't seem worth the effort.
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 -- 3. A nested declarative region (e.g. package declaration or package
kono
parents:
diff changeset
190 -- body) is encountered. The SIS active indication is reset at the start
kono
parents:
diff changeset
191 -- of such a nested region. Again, like case 2, this causes us to miss
kono
parents:
diff changeset
192 -- some nested cases, but it doesn't seen worth the effort to stack and
kono
parents:
diff changeset
193 -- unstack the SIS information. Maybe we will reconsider this if we ever
kono
parents:
diff changeset
194 -- get a complaint about a missed case.
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 -- 4. We encounter a valid pragma INTERFACE or IMPORT that effectively
kono
parents:
diff changeset
197 -- supplies the missing body. In this case we reset the entry.
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 -- 5. We encounter the end of the declarative region without encountering
kono
parents:
diff changeset
200 -- a BEGIN first. In this situation we simply reset the entry. We know
kono
parents:
diff changeset
201 -- that there is a missing body, but it seems more reasonable to let the
kono
parents:
diff changeset
202 -- later semantic checking discover this.
kono
parents:
diff changeset
203
kono
parents:
diff changeset
204 ----------------------------------------------------
kono
parents:
diff changeset
205 -- Handling of Reserved Words Used as Identifiers --
kono
parents:
diff changeset
206 ----------------------------------------------------
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 -- Note: throughout the parser, the terms reserved word and keyword are
kono
parents:
diff changeset
209 -- used interchangeably to refer to the same set of reserved keywords
kono
parents:
diff changeset
210 -- (including until, protected, etc).
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 -- If a reserved word is used in place of an identifier, the parser where
kono
parents:
diff changeset
213 -- possible tries to recover gracefully. In particular, if the keyword is
kono
parents:
diff changeset
214 -- clearly spelled using identifier casing, e.g. Until in a source program
kono
parents:
diff changeset
215 -- using mixed case identifiers and lower case keywords, then the keyword
kono
parents:
diff changeset
216 -- is treated as an identifier if it appears in a place where an identifier
kono
parents:
diff changeset
217 -- is required.
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219 -- The situation is more complex if the keyword is spelled with normal
kono
parents:
diff changeset
220 -- keyword casing. In this case, the parser is more reluctant to consider
kono
parents:
diff changeset
221 -- it to be intended as an identifier, unless it has some further
kono
parents:
diff changeset
222 -- confirmation.
kono
parents:
diff changeset
223
kono
parents:
diff changeset
224 -- In the case of an identifier appearing in the identifier list of a
kono
parents:
diff changeset
225 -- declaration, the appearance of a comma or colon right after the keyword
kono
parents:
diff changeset
226 -- on the same line is taken as confirmation. For an enumeration literal,
kono
parents:
diff changeset
227 -- a comma or right paren right after the identifier is also treated as
kono
parents:
diff changeset
228 -- adequate confirmation.
kono
parents:
diff changeset
229
kono
parents:
diff changeset
230 -- The following type is used in calls to Is_Reserved_Identifier and
kono
parents:
diff changeset
231 -- also to P_Defining_Identifier and P_Identifier. The default for all
kono
parents:
diff changeset
232 -- these functions is that reserved words in reserved word case are not
kono
parents:
diff changeset
233 -- considered to be reserved identifiers. The Id_Check value indicates
kono
parents:
diff changeset
234 -- tokens, which if they appear immediately after the identifier, are
kono
parents:
diff changeset
235 -- taken as confirming that the use of an identifier was expected
kono
parents:
diff changeset
236
kono
parents:
diff changeset
237 type Id_Check is
kono
parents:
diff changeset
238 (None,
kono
parents:
diff changeset
239 -- Default, no special token test
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 C_Comma_Right_Paren,
kono
parents:
diff changeset
242 -- Consider as identifier if followed by comma or right paren
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 C_Comma_Colon,
kono
parents:
diff changeset
245 -- Consider as identifier if followed by comma or colon
kono
parents:
diff changeset
246
kono
parents:
diff changeset
247 C_Do,
kono
parents:
diff changeset
248 -- Consider as identifier if followed by DO
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 C_Dot,
kono
parents:
diff changeset
251 -- Consider as identifier if followed by period
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 C_Greater_Greater,
kono
parents:
diff changeset
254 -- Consider as identifier if followed by >>
kono
parents:
diff changeset
255
kono
parents:
diff changeset
256 C_In,
kono
parents:
diff changeset
257 -- Consider as identifier if followed by IN
kono
parents:
diff changeset
258
kono
parents:
diff changeset
259 C_Is,
kono
parents:
diff changeset
260 -- Consider as identifier if followed by IS
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 C_Left_Paren_Semicolon,
kono
parents:
diff changeset
263 -- Consider as identifier if followed by left paren or semicolon
kono
parents:
diff changeset
264
kono
parents:
diff changeset
265 C_Use,
kono
parents:
diff changeset
266 -- Consider as identifier if followed by USE
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 C_Vertical_Bar_Arrow);
kono
parents:
diff changeset
269 -- Consider as identifier if followed by | or =>
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 --------------------------------------------
kono
parents:
diff changeset
272 -- Handling IS Used in Place of Semicolon --
kono
parents:
diff changeset
273 --------------------------------------------
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 -- This is a somewhat trickier situation, and we can't catch it in all
kono
parents:
diff changeset
276 -- cases, but we do our best to detect common situations resulting from
kono
parents:
diff changeset
277 -- a "cut and paste" operation which forgets to change the IS to semicolon.
kono
parents:
diff changeset
278 -- Consider the following example:
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 -- package body X is
kono
parents:
diff changeset
281 -- procedure A;
kono
parents:
diff changeset
282 -- procedure B is
kono
parents:
diff changeset
283 -- procedure C;
kono
parents:
diff changeset
284 -- ...
kono
parents:
diff changeset
285 -- procedure D is
kono
parents:
diff changeset
286 -- begin
kono
parents:
diff changeset
287 -- ...
kono
parents:
diff changeset
288 -- end;
kono
parents:
diff changeset
289 -- begin
kono
parents:
diff changeset
290 -- ...
kono
parents:
diff changeset
291 -- end;
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 -- The trouble is that the section of text from PROCEDURE B through END;
kono
parents:
diff changeset
294 -- constitutes a valid procedure body, and the danger is that we find out
kono
parents:
diff changeset
295 -- far too late that something is wrong (indeed most compilers will behave
kono
parents:
diff changeset
296 -- uncomfortably on the above example).
kono
parents:
diff changeset
297
kono
parents:
diff changeset
298 -- We have two approaches to helping to control this situation. First we
kono
parents:
diff changeset
299 -- make every attempt to avoid swallowing the last END; if we can be sure
kono
parents:
diff changeset
300 -- that some error will result from doing so. In particular, we won't
kono
parents:
diff changeset
301 -- accept the END; unless it is exactly correct (in particular it must not
kono
parents:
diff changeset
302 -- have incorrect name tokens), and we won't accept it if it is immediately
kono
parents:
diff changeset
303 -- followed by end of file, WITH or SEPARATE (all tokens that unmistakeably
kono
parents:
diff changeset
304 -- signal the start of a compilation unit, and which therefore allow us to
kono
parents:
diff changeset
305 -- reserve the END; for the outer level.) For more details on this aspect
kono
parents:
diff changeset
306 -- of the handling, see package Par.Endh.
kono
parents:
diff changeset
307
kono
parents:
diff changeset
308 -- If we can avoid eating up the END; then the result in the absence of
kono
parents:
diff changeset
309 -- any additional steps would be to post a missing END referring back to
kono
parents:
diff changeset
310 -- the subprogram with the bogus IS. Similarly, if the enclosing package
kono
parents:
diff changeset
311 -- has no BEGIN, then the result is a missing BEGIN message, which again
kono
parents:
diff changeset
312 -- refers back to the subprogram header.
kono
parents:
diff changeset
313
kono
parents:
diff changeset
314 -- Such an error message is not too bad (it's already a big improvement
kono
parents:
diff changeset
315 -- over what many parsers do), but it's not ideal, because the declarations
kono
parents:
diff changeset
316 -- following the IS have been absorbed into the wrong scope. In the above
kono
parents:
diff changeset
317 -- case, this could result for example in a bogus complaint that the body
kono
parents:
diff changeset
318 -- of D was missing from the package.
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 -- To catch at least some of these cases, we take the following additional
kono
parents:
diff changeset
321 -- steps. First, a subprogram body is marked as having a suspicious IS if
kono
parents:
diff changeset
322 -- the declaration line is followed by a line which starts with a symbol
kono
parents:
diff changeset
323 -- that can start a declaration in the same column, or to the left of the
kono
parents:
diff changeset
324 -- column in which the FUNCTION or PROCEDURE starts (normal style is to
kono
parents:
diff changeset
325 -- indent any declarations which really belong a subprogram). If such a
kono
parents:
diff changeset
326 -- subprogram encounters a missing BEGIN or missing END, then we decide
kono
parents:
diff changeset
327 -- that the IS should have been a semicolon, and the subprogram body node
kono
parents:
diff changeset
328 -- is marked (by setting the Bad_Is_Detected flag true. Note that we do
kono
parents:
diff changeset
329 -- not do this for library level procedures, only for nested procedures,
kono
parents:
diff changeset
330 -- since for library level procedures, we must have a body.
kono
parents:
diff changeset
331
kono
parents:
diff changeset
332 -- The processing for a declarative part checks to see if the last
kono
parents:
diff changeset
333 -- declaration scanned is marked in this way, and if it is, the tree
kono
parents:
diff changeset
334 -- is modified to reflect the IS being interpreted as a semicolon.
kono
parents:
diff changeset
335
kono
parents:
diff changeset
336 ---------------------------------------------------
kono
parents:
diff changeset
337 -- Parser Type Definitions and Control Variables --
kono
parents:
diff changeset
338 ---------------------------------------------------
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 -- The following variable and associated type declaration are used by the
kono
parents:
diff changeset
341 -- expression parsing routines to return more detailed information about
kono
parents:
diff changeset
342 -- the categorization of a parsed expression.
kono
parents:
diff changeset
343
kono
parents:
diff changeset
344 type Expr_Form_Type is (
kono
parents:
diff changeset
345 EF_Simple_Name, -- Simple name, i.e. possibly qualified identifier
kono
parents:
diff changeset
346 EF_Name, -- Simple expression which could also be a name
kono
parents:
diff changeset
347 EF_Simple, -- Simple expression which is not call or name
kono
parents:
diff changeset
348 EF_Range_Attr, -- Range attribute reference
kono
parents:
diff changeset
349 EF_Non_Simple); -- Expression that is not a simple expression
kono
parents:
diff changeset
350
kono
parents:
diff changeset
351 Expr_Form : Expr_Form_Type;
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 -- The following type is used for calls to P_Subprogram, P_Package, P_Task,
kono
parents:
diff changeset
354 -- P_Protected to indicate which of several possibilities is acceptable.
kono
parents:
diff changeset
355
kono
parents:
diff changeset
356 type Pf_Rec is record
kono
parents:
diff changeset
357 Spcn : Boolean; -- True if specification OK
kono
parents:
diff changeset
358 Decl : Boolean; -- True if declaration OK
kono
parents:
diff changeset
359 Gins : Boolean; -- True if generic instantiation OK
kono
parents:
diff changeset
360 Pbod : Boolean; -- True if proper body OK
kono
parents:
diff changeset
361 Rnam : Boolean; -- True if renaming declaration OK
kono
parents:
diff changeset
362 Stub : Boolean; -- True if body stub OK
kono
parents:
diff changeset
363 Pexp : Boolean; -- True if parameterized expression OK
kono
parents:
diff changeset
364 Fil2 : Boolean; -- Filler to fill to 8 bits
kono
parents:
diff changeset
365 end record;
kono
parents:
diff changeset
366 pragma Pack (Pf_Rec);
kono
parents:
diff changeset
367
kono
parents:
diff changeset
368 function T return Boolean renames True;
kono
parents:
diff changeset
369 function F return Boolean renames False;
kono
parents:
diff changeset
370
kono
parents:
diff changeset
371 Pf_Decl_Gins_Pbod_Rnam_Stub_Pexp : constant Pf_Rec :=
kono
parents:
diff changeset
372 Pf_Rec'(F, T, T, T, T, T, T, F);
kono
parents:
diff changeset
373 Pf_Decl_Pexp : constant Pf_Rec :=
kono
parents:
diff changeset
374 Pf_Rec'(F, T, F, F, F, F, T, F);
kono
parents:
diff changeset
375 Pf_Decl_Gins_Pbod_Rnam_Pexp : constant Pf_Rec :=
kono
parents:
diff changeset
376 Pf_Rec'(F, T, T, T, T, F, T, F);
kono
parents:
diff changeset
377 Pf_Decl_Pbod_Pexp : constant Pf_Rec :=
kono
parents:
diff changeset
378 Pf_Rec'(F, T, F, T, F, F, T, F);
kono
parents:
diff changeset
379 Pf_Pbod_Pexp : constant Pf_Rec :=
kono
parents:
diff changeset
380 Pf_Rec'(F, F, F, T, F, F, T, F);
kono
parents:
diff changeset
381 Pf_Spcn : constant Pf_Rec :=
kono
parents:
diff changeset
382 Pf_Rec'(T, F, F, F, F, F, F, F);
kono
parents:
diff changeset
383 -- The above are the only allowed values of Pf_Rec arguments
kono
parents:
diff changeset
384
kono
parents:
diff changeset
385 type SS_Rec is record
kono
parents:
diff changeset
386 Eftm : Boolean; -- ELSIF can terminate sequence
kono
parents:
diff changeset
387 Eltm : Boolean; -- ELSE can terminate sequence
kono
parents:
diff changeset
388 Extm : Boolean; -- EXCEPTION can terminate sequence
kono
parents:
diff changeset
389 Ortm : Boolean; -- OR can terminate sequence
kono
parents:
diff changeset
390 Sreq : Boolean; -- at least one statement required
kono
parents:
diff changeset
391 Tatm : Boolean; -- THEN ABORT can terminate sequence
kono
parents:
diff changeset
392 Whtm : Boolean; -- WHEN can terminate sequence
kono
parents:
diff changeset
393 Unco : Boolean; -- Unconditional terminate after one statement
kono
parents:
diff changeset
394 end record;
kono
parents:
diff changeset
395 pragma Pack (SS_Rec);
kono
parents:
diff changeset
396
kono
parents:
diff changeset
397 SS_Eftm_Eltm_Sreq : constant SS_Rec := SS_Rec'(T, T, F, F, T, F, F, F);
kono
parents:
diff changeset
398 SS_Eltm_Ortm_Tatm : constant SS_Rec := SS_Rec'(F, T, F, T, F, T, F, F);
kono
parents:
diff changeset
399 SS_Extm_Sreq : constant SS_Rec := SS_Rec'(F, F, T, F, T, F, F, F);
kono
parents:
diff changeset
400 SS_None : constant SS_Rec := SS_Rec'(F, F, F, F, F, F, F, F);
kono
parents:
diff changeset
401 SS_Ortm_Sreq : constant SS_Rec := SS_Rec'(F, F, F, T, T, F, F, F);
kono
parents:
diff changeset
402 SS_Sreq : constant SS_Rec := SS_Rec'(F, F, F, F, T, F, F, F);
kono
parents:
diff changeset
403 SS_Sreq_Whtm : constant SS_Rec := SS_Rec'(F, F, F, F, T, F, T, F);
kono
parents:
diff changeset
404 SS_Whtm : constant SS_Rec := SS_Rec'(F, F, F, F, F, F, T, F);
kono
parents:
diff changeset
405 SS_Unco : constant SS_Rec := SS_Rec'(F, F, F, F, F, F, F, T);
kono
parents:
diff changeset
406
kono
parents:
diff changeset
407 Goto_List : Elist_Id;
kono
parents:
diff changeset
408 -- List of goto nodes appearing in the current compilation. Used to
kono
parents:
diff changeset
409 -- recognize natural loops and convert them into bona fide loops for
kono
parents:
diff changeset
410 -- optimization purposes.
kono
parents:
diff changeset
411
kono
parents:
diff changeset
412 Label_List : Elist_Id;
kono
parents:
diff changeset
413 -- List of label nodes for labels appearing in the current compilation.
kono
parents:
diff changeset
414 -- Used by Par.Labl to construct the corresponding implicit declarations.
kono
parents:
diff changeset
415
kono
parents:
diff changeset
416 -----------------
kono
parents:
diff changeset
417 -- Scope Table --
kono
parents:
diff changeset
418 -----------------
kono
parents:
diff changeset
419
kono
parents:
diff changeset
420 -- The scope table, also referred to as the scope stack, is used to record
kono
parents:
diff changeset
421 -- the current scope context. It is organized as a stack, with inner nested
kono
parents:
diff changeset
422 -- entries corresponding to higher entries on the stack. An entry is made
kono
parents:
diff changeset
423 -- when the parser encounters the opening of a nested construct (such as a
kono
parents:
diff changeset
424 -- record, task, package etc.), and then package Par.Endh uses this stack
kono
parents:
diff changeset
425 -- to deal with END lines (including properly dealing with END nesting
kono
parents:
diff changeset
426 -- errors).
kono
parents:
diff changeset
427
kono
parents:
diff changeset
428 type SS_End_Type is
kono
parents:
diff changeset
429 -- Type of end entry required for this scope. The last two entries are
kono
parents:
diff changeset
430 -- used only in the subprogram body case to mark the case of a suspicious
kono
parents:
diff changeset
431 -- IS, or a bad IS (i.e. suspicions confirmed by missing BEGIN or END).
kono
parents:
diff changeset
432 -- See separate section on dealing with IS used in place of semicolon.
kono
parents:
diff changeset
433 -- Note that for many purposes E_Name, E_Suspicious_Is and E_Bad_Is are
kono
parents:
diff changeset
434 -- treated the same (E_Suspicious_Is and E_Bad_Is are simply special cases
kono
parents:
diff changeset
435 -- of E_Name). They are placed at the end of the enumeration so that a
kono
parents:
diff changeset
436 -- test for >= E_Name catches all three cases efficiently.
kono
parents:
diff changeset
437
kono
parents:
diff changeset
438 (E_Dummy, -- dummy entry at outer level
kono
parents:
diff changeset
439 E_Case, -- END CASE;
kono
parents:
diff changeset
440 E_If, -- END IF;
kono
parents:
diff changeset
441 E_Loop, -- END LOOP;
kono
parents:
diff changeset
442 E_Record, -- END RECORD;
kono
parents:
diff changeset
443 E_Return, -- END RETURN;
kono
parents:
diff changeset
444 E_Select, -- END SELECT;
kono
parents:
diff changeset
445 E_Name, -- END [name];
kono
parents:
diff changeset
446 E_Suspicious_Is, -- END [name]; (case of suspicious IS)
kono
parents:
diff changeset
447 E_Bad_Is); -- END [name]; (case of bad IS)
kono
parents:
diff changeset
448
kono
parents:
diff changeset
449 -- The following describes a single entry in the scope table
kono
parents:
diff changeset
450
kono
parents:
diff changeset
451 type Scope_Table_Entry is record
kono
parents:
diff changeset
452 Etyp : SS_End_Type;
kono
parents:
diff changeset
453 -- Type of end entry, as per above description
kono
parents:
diff changeset
454
kono
parents:
diff changeset
455 Lreq : Boolean;
kono
parents:
diff changeset
456 -- A flag indicating whether the label, if present, is required to
kono
parents:
diff changeset
457 -- appear on the end line. It is referenced only in the case of Etyp is
kono
parents:
diff changeset
458 -- equal to E_Name or E_Suspicious_Is where the name may or may not be
kono
parents:
diff changeset
459 -- required (yes for labeled block, no in other cases). Note that for
kono
parents:
diff changeset
460 -- all cases except begin, the question of whether a label is required
kono
parents:
diff changeset
461 -- can be determined from the other fields (for loop, it is required if
kono
parents:
diff changeset
462 -- it is present, and for the other constructs it is never required or
kono
parents:
diff changeset
463 -- allowed).
kono
parents:
diff changeset
464
kono
parents:
diff changeset
465 Ecol : Column_Number;
kono
parents:
diff changeset
466 -- Contains the absolute column number (with tabs expanded) of the
kono
parents:
diff changeset
467 -- expected column of the end assuming normal Ada indentation usage. If
kono
parents:
diff changeset
468 -- the RM_Column_Check mode is set, this value is used for generating
kono
parents:
diff changeset
469 -- error messages about indentation. Otherwise it is used only to
kono
parents:
diff changeset
470 -- control heuristic error recovery actions. This value is zero origin.
kono
parents:
diff changeset
471
kono
parents:
diff changeset
472 Labl : Node_Id;
kono
parents:
diff changeset
473 -- This field is used to provide the name of the construct being parsed
kono
parents:
diff changeset
474 -- and indirectly its kind. For loops and blocks, the field contains the
kono
parents:
diff changeset
475 -- source name or the generated one. For package specifications, bodies,
kono
parents:
diff changeset
476 -- subprogram specifications and bodies the field holds the correponding
kono
parents:
diff changeset
477 -- program unit name. For task declarations and bodies, protected types
kono
parents:
diff changeset
478 -- and bodies, and accept statements the field hold the name of the type
kono
parents:
diff changeset
479 -- or operation. For if-statements, case-statements, return statements,
kono
parents:
diff changeset
480 -- and selects, the field is initialized to Error.
kono
parents:
diff changeset
481
kono
parents:
diff changeset
482 -- Note: this is a bit of an odd (mis)use of Error, since there is no
kono
parents:
diff changeset
483 -- Error, but we use this value as a place holder to indicate that it
kono
parents:
diff changeset
484 -- is an error to have a label on the end line.
kono
parents:
diff changeset
485
kono
parents:
diff changeset
486 -- Whenever the field is a name, it is attached to the parent node of
kono
parents:
diff changeset
487 -- the construct being parsed. Thus the parent node indicates the kind
kono
parents:
diff changeset
488 -- of construct whose parse tree is being built. This is used in error
kono
parents:
diff changeset
489 -- recovery.
kono
parents:
diff changeset
490
kono
parents:
diff changeset
491 Decl : List_Id;
kono
parents:
diff changeset
492 -- Points to the list of declarations (i.e. the declarative part)
kono
parents:
diff changeset
493 -- associated with this construct. It is set only in the END [name]
kono
parents:
diff changeset
494 -- cases, and is set to No_List for all other cases which do not have a
kono
parents:
diff changeset
495 -- declarative unit associated with them. This is used for determining
kono
parents:
diff changeset
496 -- the proper location for implicit label declarations.
kono
parents:
diff changeset
497
kono
parents:
diff changeset
498 Node : Node_Id;
kono
parents:
diff changeset
499 -- Empty except in the case of entries for IF and CASE statements, in
kono
parents:
diff changeset
500 -- which case it contains the N_If_Statement or N_Case_Statement node.
kono
parents:
diff changeset
501 -- This is used for setting the End_Span field.
kono
parents:
diff changeset
502
kono
parents:
diff changeset
503 Sloc : Source_Ptr;
kono
parents:
diff changeset
504 -- Source location of the opening token of the construct. This is used
kono
parents:
diff changeset
505 -- to refer back to this line in error messages (such as missing or
kono
parents:
diff changeset
506 -- incorrect end lines). The Sloc field is not used, and is not set, if
kono
parents:
diff changeset
507 -- a label is present (the Labl field provides the text name of the
kono
parents:
diff changeset
508 -- label in this case, which is fine for error messages).
kono
parents:
diff changeset
509
kono
parents:
diff changeset
510 S_Is : Source_Ptr;
kono
parents:
diff changeset
511 -- S_Is is relevant only if Etyp is set to E_Suspicious_Is or E_Bad_Is.
kono
parents:
diff changeset
512 -- It records the location of the IS that is considered to be
kono
parents:
diff changeset
513 -- suspicious.
kono
parents:
diff changeset
514
kono
parents:
diff changeset
515 Junk : Boolean;
kono
parents:
diff changeset
516 -- A boolean flag that is set true if the opening entry is the dubious
kono
parents:
diff changeset
517 -- result of some prior error, e.g. a record entry where the record
kono
parents:
diff changeset
518 -- keyword was missing. It is used to suppress the issuing of a
kono
parents:
diff changeset
519 -- corresponding junk complaint about the end line (we do not want
kono
parents:
diff changeset
520 -- to complain about a missing end record when there was no record).
kono
parents:
diff changeset
521 end record;
kono
parents:
diff changeset
522
kono
parents:
diff changeset
523 -- The following declares the scope table itself. The Last field is the
kono
parents:
diff changeset
524 -- stack pointer, so that Scope.Table (Scope.Last) is the top entry. The
kono
parents:
diff changeset
525 -- oldest entry, at Scope_Stack (0), is a dummy entry with Etyp set to
kono
parents:
diff changeset
526 -- E_Dummy, and the other fields undefined. This dummy entry ensures that
kono
parents:
diff changeset
527 -- Scope_Stack (Scope_Stack_Ptr).Etyp can always be tested, and that the
kono
parents:
diff changeset
528 -- scope stack pointer is always in range.
kono
parents:
diff changeset
529
kono
parents:
diff changeset
530 package Scope is new Table.Table (
kono
parents:
diff changeset
531 Table_Component_Type => Scope_Table_Entry,
kono
parents:
diff changeset
532 Table_Index_Type => Int,
kono
parents:
diff changeset
533 Table_Low_Bound => 0,
kono
parents:
diff changeset
534 Table_Initial => 50,
kono
parents:
diff changeset
535 Table_Increment => 100,
kono
parents:
diff changeset
536 Table_Name => "Scope");
kono
parents:
diff changeset
537
kono
parents:
diff changeset
538 ------------------------------------------
kono
parents:
diff changeset
539 -- Table for Handling Suspicious Labels --
kono
parents:
diff changeset
540 ------------------------------------------
kono
parents:
diff changeset
541
kono
parents:
diff changeset
542 -- This is a special data structure which is used to deal very spefifically
kono
parents:
diff changeset
543 -- with the following error case
kono
parents:
diff changeset
544
kono
parents:
diff changeset
545 -- label;
kono
parents:
diff changeset
546 -- loop
kono
parents:
diff changeset
547 -- ...
kono
parents:
diff changeset
548 -- end loop label;
kono
parents:
diff changeset
549
kono
parents:
diff changeset
550 -- Similar cases apply to FOR, WHILE, DECLARE, or BEGIN
kono
parents:
diff changeset
551
kono
parents:
diff changeset
552 -- In each case the opening line looks like a procedure call because of
kono
parents:
diff changeset
553 -- the semicolon. And the end line looks illegal because of an unexpected
kono
parents:
diff changeset
554 -- label. If we did nothing special, we would just diagnose the label on
kono
parents:
diff changeset
555 -- the end as unexpected. But that does not help point to the real error
kono
parents:
diff changeset
556 -- which is that the semicolon after label should be a colon.
kono
parents:
diff changeset
557
kono
parents:
diff changeset
558 -- To deal with this, we build an entry in the Suspicious_Labels table
kono
parents:
diff changeset
559 -- whenever we encounter an identifier followed by a semicolon, followed
kono
parents:
diff changeset
560 -- by one of LOOP, FOR, WHILE, DECLARE, BEGIN. Then this entry is used to
kono
parents:
diff changeset
561 -- issue the right message when we hit the END that confirms that this was
kono
parents:
diff changeset
562 -- a bad label.
kono
parents:
diff changeset
563
kono
parents:
diff changeset
564 type Suspicious_Label_Entry is record
kono
parents:
diff changeset
565 Proc_Call : Node_Id;
kono
parents:
diff changeset
566 -- Node for the procedure call statement built for the label; construct
kono
parents:
diff changeset
567
kono
parents:
diff changeset
568 Semicolon_Loc : Source_Ptr;
kono
parents:
diff changeset
569 -- Location of the possibly wrong semicolon
kono
parents:
diff changeset
570
kono
parents:
diff changeset
571 Start_Token : Source_Ptr;
kono
parents:
diff changeset
572 -- Source location of the LOOP, FOR, WHILE, DECLARE, BEGIN token
kono
parents:
diff changeset
573 end record;
kono
parents:
diff changeset
574
kono
parents:
diff changeset
575 package Suspicious_Labels is new Table.Table (
kono
parents:
diff changeset
576 Table_Component_Type => Suspicious_Label_Entry,
kono
parents:
diff changeset
577 Table_Index_Type => Int,
kono
parents:
diff changeset
578 Table_Low_Bound => 1,
kono
parents:
diff changeset
579 Table_Initial => 50,
kono
parents:
diff changeset
580 Table_Increment => 100,
kono
parents:
diff changeset
581 Table_Name => "Suspicious_Labels");
kono
parents:
diff changeset
582
kono
parents:
diff changeset
583 -- Now when we are about to issue a message complaining about an END label
kono
parents:
diff changeset
584 -- that should not be there because it appears to end a construct that has
kono
parents:
diff changeset
585 -- no label, we first search the suspicious labels table entry, using the
kono
parents:
diff changeset
586 -- source location stored in the scope table as a key. If we find a match,
kono
parents:
diff changeset
587 -- then we check that the label on the end matches the name in the call,
kono
parents:
diff changeset
588 -- and if so, we issue a message saying the semicolon should be a colon.
kono
parents:
diff changeset
589
kono
parents:
diff changeset
590 -- Quite a bit of work, but really helpful in the case where it helps, and
kono
parents:
diff changeset
591 -- the need for this is based on actual experience with tracking down this
kono
parents:
diff changeset
592 -- kind of error (the eye often easily mistakes semicolon for colon).
kono
parents:
diff changeset
593
kono
parents:
diff changeset
594 -- Note: we actually have enough information to patch up the tree, but
kono
parents:
diff changeset
595 -- this may not be worth the effort. Also we could deal with the same
kono
parents:
diff changeset
596 -- situation for EXIT with a label, but for now don't bother with that.
kono
parents:
diff changeset
597
kono
parents:
diff changeset
598 Current_Assign_Node : Node_Id := Empty;
kono
parents:
diff changeset
599 -- This is the node of the current assignment statement being compiled.
kono
parents:
diff changeset
600 -- It is used to record the presence of target_names on its RHS. This
kono
parents:
diff changeset
601 -- context-dependent trick simplifies the analysis of such nodes, where
kono
parents:
diff changeset
602 -- the RHS must first be analyzed with expansion disabled.
kono
parents:
diff changeset
603
kono
parents:
diff changeset
604 ---------------------------------
kono
parents:
diff changeset
605 -- Parsing Routines by Chapter --
kono
parents:
diff changeset
606 ---------------------------------
kono
parents:
diff changeset
607
kono
parents:
diff changeset
608 -- Uncommented declarations in this section simply parse the construct
kono
parents:
diff changeset
609 -- corresponding to their name, and return an ID value for the Node or
kono
parents:
diff changeset
610 -- List that is created.
kono
parents:
diff changeset
611
kono
parents:
diff changeset
612 -------------
kono
parents:
diff changeset
613 -- Par.Ch2 --
kono
parents:
diff changeset
614 -------------
kono
parents:
diff changeset
615
kono
parents:
diff changeset
616 package Ch2 is
kono
parents:
diff changeset
617 function P_Pragma (Skipping : Boolean := False) return Node_Id;
kono
parents:
diff changeset
618 -- Scan out a pragma. If Skipping is True, then the caller is skipping
kono
parents:
diff changeset
619 -- the pragma in the context of illegal placement (this is used to avoid
kono
parents:
diff changeset
620 -- some junk cascaded messages). Some pragmas must be dealt with during
kono
parents:
diff changeset
621 -- the parsing phase (e.g. pragma Page, since we can generate a listing
kono
parents:
diff changeset
622 -- in syntax only mode). It is possible that the parser uses the rescan
kono
parents:
diff changeset
623 -- logic (using Save/Restore_Scan_State) with the effect of calling this
kono
parents:
diff changeset
624 -- procedure more than once for the same pragma. All parse-time pragma
kono
parents:
diff changeset
625 -- handling must be prepared to handle such multiple calls correctly.
kono
parents:
diff changeset
626
kono
parents:
diff changeset
627 function P_Identifier (C : Id_Check := None) return Node_Id;
kono
parents:
diff changeset
628 -- Scans out an identifier. The parameter C determines the treatment
kono
parents:
diff changeset
629 -- of reserved identifiers. See declaration of Id_Check for details.
kono
parents:
diff changeset
630
kono
parents:
diff changeset
631 function P_Pragmas_Opt return List_Id;
kono
parents:
diff changeset
632 -- This function scans for a sequence of pragmas in other than a
kono
parents:
diff changeset
633 -- declaration sequence or statement sequence context. All pragmas
kono
parents:
diff changeset
634 -- can appear except pragmas Assert and Debug, which are only allowed
kono
parents:
diff changeset
635 -- in a declaration or statement sequence context.
kono
parents:
diff changeset
636
kono
parents:
diff changeset
637 procedure P_Pragmas_Misplaced;
kono
parents:
diff changeset
638 -- Skips misplaced pragmas with a complaint
kono
parents:
diff changeset
639
kono
parents:
diff changeset
640 procedure P_Pragmas_Opt (List : List_Id);
kono
parents:
diff changeset
641 -- Parses optional pragmas and appends them to the List
kono
parents:
diff changeset
642 end Ch2;
kono
parents:
diff changeset
643
kono
parents:
diff changeset
644 -------------
kono
parents:
diff changeset
645 -- Par.Ch3 --
kono
parents:
diff changeset
646 -------------
kono
parents:
diff changeset
647
kono
parents:
diff changeset
648 package Ch3 is
kono
parents:
diff changeset
649 Missing_Begin_Msg : Error_Msg_Id;
kono
parents:
diff changeset
650 -- This variable is set by a call to P_Declarative_Part. Normally it
kono
parents:
diff changeset
651 -- is set to No_Error_Msg, indicating that no special processing is
kono
parents:
diff changeset
652 -- required by the caller. The special case arises when a statement
kono
parents:
diff changeset
653 -- is found in the sequence of declarations. In this case the Id of
kono
parents:
diff changeset
654 -- the message issued ("declaration expected") is preserved in this
kono
parents:
diff changeset
655 -- variable, then the caller can change it to an appropriate missing
kono
parents:
diff changeset
656 -- begin message if indeed the BEGIN is missing.
kono
parents:
diff changeset
657
kono
parents:
diff changeset
658 function P_Array_Type_Definition return Node_Id;
kono
parents:
diff changeset
659 function P_Basic_Declarative_Items return List_Id;
kono
parents:
diff changeset
660 function P_Constraint_Opt return Node_Id;
kono
parents:
diff changeset
661 function P_Declarative_Part return List_Id;
kono
parents:
diff changeset
662 function P_Discrete_Choice_List return List_Id;
kono
parents:
diff changeset
663 function P_Discrete_Range return Node_Id;
kono
parents:
diff changeset
664 function P_Discrete_Subtype_Definition return Node_Id;
kono
parents:
diff changeset
665 function P_Known_Discriminant_Part_Opt return List_Id;
kono
parents:
diff changeset
666 function P_Signed_Integer_Type_Definition return Node_Id;
kono
parents:
diff changeset
667 function P_Range return Node_Id;
kono
parents:
diff changeset
668 function P_Range_Constraint return Node_Id;
kono
parents:
diff changeset
669 function P_Record_Definition return Node_Id;
kono
parents:
diff changeset
670 function P_Subtype_Mark return Node_Id;
kono
parents:
diff changeset
671 function P_Subtype_Mark_Resync return Node_Id;
kono
parents:
diff changeset
672 function P_Unknown_Discriminant_Part_Opt return Boolean;
kono
parents:
diff changeset
673
kono
parents:
diff changeset
674 function P_Access_Definition
kono
parents:
diff changeset
675 (Null_Exclusion_Present : Boolean) return Node_Id;
kono
parents:
diff changeset
676 -- Ada 2005 (AI-231/AI-254): The caller parses the null-exclusion part
kono
parents:
diff changeset
677 -- and indicates if it was present
kono
parents:
diff changeset
678
kono
parents:
diff changeset
679 function P_Access_Type_Definition
kono
parents:
diff changeset
680 (Header_Already_Parsed : Boolean := False) return Node_Id;
kono
parents:
diff changeset
681 -- Ada 2005 (AI-254): The formal is used to indicate if the caller has
kono
parents:
diff changeset
682 -- parsed the null_exclusion part. In this case the caller has also
kono
parents:
diff changeset
683 -- removed the ACCESS token
kono
parents:
diff changeset
684
kono
parents:
diff changeset
685 procedure P_Component_Items (Decls : List_Id);
kono
parents:
diff changeset
686 -- Scan out one or more component items and append them to the given
kono
parents:
diff changeset
687 -- list. Only scans out more than one declaration in the case where the
kono
parents:
diff changeset
688 -- source has a single declaration with multiple defining identifiers.
kono
parents:
diff changeset
689
kono
parents:
diff changeset
690 function P_Defining_Identifier (C : Id_Check := None) return Node_Id;
kono
parents:
diff changeset
691 -- Scan out a defining identifier. The parameter C controls the
kono
parents:
diff changeset
692 -- treatment of errors in case a reserved word is scanned. See the
kono
parents:
diff changeset
693 -- declaration of this type for details.
kono
parents:
diff changeset
694
kono
parents:
diff changeset
695 function P_Interface_Type_Definition
kono
parents:
diff changeset
696 (Abstract_Present : Boolean) return Node_Id;
kono
parents:
diff changeset
697 -- Ada 2005 (AI-251): Parse the interface type definition part. Abstract
kono
parents:
diff changeset
698 -- Present indicates if the reserved word "abstract" has been previously
kono
parents:
diff changeset
699 -- found. It is used to report an error message because interface types
kono
parents:
diff changeset
700 -- are by definition abstract tagged. We generate a record_definition
kono
parents:
diff changeset
701 -- node if the list of interfaces is empty; otherwise we generate a
kono
parents:
diff changeset
702 -- derived_type_definition node (the first interface in this list is the
kono
parents:
diff changeset
703 -- ancestor interface).
kono
parents:
diff changeset
704
kono
parents:
diff changeset
705 function P_Null_Exclusion
kono
parents:
diff changeset
706 (Allow_Anonymous_In_95 : Boolean := False) return Boolean;
kono
parents:
diff changeset
707 -- Ada 2005 (AI-231): Parse the null-excluding part. A True result
kono
parents:
diff changeset
708 -- indicates that the null-excluding part was present.
kono
parents:
diff changeset
709 --
kono
parents:
diff changeset
710 -- Allow_Anonymous_In_95 is True if we are in a context that allows
kono
parents:
diff changeset
711 -- anonymous access types in Ada 95, in which case "not null" is legal
kono
parents:
diff changeset
712 -- if it precedes "access".
kono
parents:
diff changeset
713
kono
parents:
diff changeset
714 function P_Subtype_Indication
kono
parents:
diff changeset
715 (Not_Null_Present : Boolean := False) return Node_Id;
kono
parents:
diff changeset
716 -- Ada 2005 (AI-231): The flag Not_Null_Present indicates that the
kono
parents:
diff changeset
717 -- null-excluding part has been scanned out and it was present.
kono
parents:
diff changeset
718
kono
parents:
diff changeset
719 function P_Range_Or_Subtype_Mark
kono
parents:
diff changeset
720 (Allow_Simple_Expression : Boolean := False) return Node_Id;
kono
parents:
diff changeset
721 -- Scans out a range or subtype mark, and also permits a general simple
kono
parents:
diff changeset
722 -- expression if Allow_Simple_Expression is set to True.
kono
parents:
diff changeset
723
kono
parents:
diff changeset
724 function Init_Expr_Opt (P : Boolean := False) return Node_Id;
kono
parents:
diff changeset
725 -- If an initialization expression is present (:= expression), then
kono
parents:
diff changeset
726 -- it is scanned out and returned, otherwise Empty is returned if no
kono
parents:
diff changeset
727 -- initialization expression is present. This procedure also handles
kono
parents:
diff changeset
728 -- certain common error cases cleanly. The parameter P indicates if
kono
parents:
diff changeset
729 -- a right paren can follow the expression (default = no right paren
kono
parents:
diff changeset
730 -- allowed).
kono
parents:
diff changeset
731
kono
parents:
diff changeset
732 procedure Skip_Declaration (S : List_Id);
kono
parents:
diff changeset
733 -- Used when scanning statements to skip past a misplaced declaration
kono
parents:
diff changeset
734 -- The declaration is scanned out and appended to the given list.
kono
parents:
diff changeset
735 -- Token is known to be a declaration token (in Token_Class_Declk)
kono
parents:
diff changeset
736 -- on entry, so there definition is a declaration to be scanned.
kono
parents:
diff changeset
737
kono
parents:
diff changeset
738 function P_Subtype_Indication
kono
parents:
diff changeset
739 (Subtype_Mark : Node_Id;
kono
parents:
diff changeset
740 Not_Null_Present : Boolean := False) return Node_Id;
kono
parents:
diff changeset
741 -- This version of P_Subtype_Indication is called when the caller has
kono
parents:
diff changeset
742 -- already scanned out the subtype mark which is passed as a parameter.
kono
parents:
diff changeset
743 -- Ada 2005 (AI-231): The flag Not_Null_Present indicates that the
kono
parents:
diff changeset
744 -- null-excluding part has been scanned out and it was present.
kono
parents:
diff changeset
745
kono
parents:
diff changeset
746 function P_Subtype_Mark_Attribute (Type_Node : Node_Id) return Node_Id;
kono
parents:
diff changeset
747 -- Parse a subtype mark attribute. The caller has already parsed the
kono
parents:
diff changeset
748 -- subtype mark, which is passed in as the argument, and has checked
kono
parents:
diff changeset
749 -- that the current token is apostrophe.
kono
parents:
diff changeset
750 end Ch3;
kono
parents:
diff changeset
751
kono
parents:
diff changeset
752 -------------
kono
parents:
diff changeset
753 -- Par.Ch4 --
kono
parents:
diff changeset
754 -------------
kono
parents:
diff changeset
755
kono
parents:
diff changeset
756 package Ch4 is
kono
parents:
diff changeset
757 function P_Aggregate return Node_Id;
kono
parents:
diff changeset
758 function P_Expression return Node_Id;
kono
parents:
diff changeset
759 function P_Expression_Or_Range_Attribute return Node_Id;
kono
parents:
diff changeset
760 function P_Function_Name return Node_Id;
kono
parents:
diff changeset
761 function P_Name return Node_Id;
kono
parents:
diff changeset
762 function P_Qualified_Simple_Name return Node_Id;
kono
parents:
diff changeset
763 function P_Qualified_Simple_Name_Resync return Node_Id;
kono
parents:
diff changeset
764 function P_Simple_Expression return Node_Id;
kono
parents:
diff changeset
765 function P_Simple_Expression_Or_Range_Attribute return Node_Id;
kono
parents:
diff changeset
766
kono
parents:
diff changeset
767 function P_Case_Expression return Node_Id;
kono
parents:
diff changeset
768 -- Scans out a case expression. Called with Token pointing to the CASE
kono
parents:
diff changeset
769 -- keyword, and returns pointing to the terminating right parent,
kono
parents:
diff changeset
770 -- semicolon, or comma, but does not consume this terminating token.
kono
parents:
diff changeset
771
kono
parents:
diff changeset
772 function P_Expression_If_OK return Node_Id;
kono
parents:
diff changeset
773 -- Scans out an expression allowing an unparenthesized case expression,
kono
parents:
diff changeset
774 -- if expression, or quantified expression to appear without enclosing
kono
parents:
diff changeset
775 -- parentheses. However, if such an expression is not preceded by a left
kono
parents:
diff changeset
776 -- paren, and followed by a right paren, an error message will be output
kono
parents:
diff changeset
777 -- noting that parenthesization is required.
kono
parents:
diff changeset
778
kono
parents:
diff changeset
779 function P_Expression_No_Right_Paren return Node_Id;
kono
parents:
diff changeset
780 -- Scans out an expression in contexts where the expression cannot be
kono
parents:
diff changeset
781 -- terminated by a right paren (gives better error recovery if an errant
kono
parents:
diff changeset
782 -- right paren is found after the expression).
kono
parents:
diff changeset
783
kono
parents:
diff changeset
784 function P_Expression_Or_Range_Attribute_If_OK return Node_Id;
kono
parents:
diff changeset
785 -- Scans out an expression or range attribute where a conditional
kono
parents:
diff changeset
786 -- expression is permitted to appear without surrounding parentheses.
kono
parents:
diff changeset
787 -- However, if such an expression is not preceded by a left paren, and
kono
parents:
diff changeset
788 -- followed by a right paren, an error message will be output noting
kono
parents:
diff changeset
789 -- that parenthesization is required.
kono
parents:
diff changeset
790
kono
parents:
diff changeset
791 function P_If_Expression return Node_Id;
kono
parents:
diff changeset
792 -- Scans out an if expression. Called with Token pointing to the
kono
parents:
diff changeset
793 -- IF keyword, and returns pointing to the terminating right paren,
kono
parents:
diff changeset
794 -- semicolon or comma, but does not consume this terminating token.
kono
parents:
diff changeset
795
kono
parents:
diff changeset
796 function P_Qualified_Expression (Subtype_Mark : Node_Id) return Node_Id;
kono
parents:
diff changeset
797 -- This routine scans out a qualified expression when the caller has
kono
parents:
diff changeset
798 -- already scanned out the name and apostrophe of the construct.
kono
parents:
diff changeset
799
kono
parents:
diff changeset
800 function P_Quantified_Expression return Node_Id;
kono
parents:
diff changeset
801 -- This routine scans out a quantified expression when the caller has
kono
parents:
diff changeset
802 -- already scanned out the keyword "for" of the construct.
kono
parents:
diff changeset
803 end Ch4;
kono
parents:
diff changeset
804
kono
parents:
diff changeset
805 -------------
kono
parents:
diff changeset
806 -- Par.Ch5 --
kono
parents:
diff changeset
807 -------------
kono
parents:
diff changeset
808
kono
parents:
diff changeset
809 package Ch5 is
kono
parents:
diff changeset
810 function P_Condition return Node_Id;
kono
parents:
diff changeset
811 -- Scan out and return a condition. Note that an error is given if
kono
parents:
diff changeset
812 -- the condition is followed by a right parenthesis.
kono
parents:
diff changeset
813
kono
parents:
diff changeset
814 function P_Condition (Cond : Node_Id) return Node_Id;
kono
parents:
diff changeset
815 -- Similar to the above, but the caller has already scanned out the
kono
parents:
diff changeset
816 -- conditional expression and passes it as an argument. This form of
kono
parents:
diff changeset
817 -- the call does not check for a following right parenthesis.
kono
parents:
diff changeset
818
kono
parents:
diff changeset
819 function P_Loop_Parameter_Specification return Node_Id;
kono
parents:
diff changeset
820 -- Used in loop constructs and quantified expressions.
kono
parents:
diff changeset
821
kono
parents:
diff changeset
822 function P_Sequence_Of_Statements (SS_Flags : SS_Rec) return List_Id;
kono
parents:
diff changeset
823 -- The argument indicates the acceptable termination tokens.
kono
parents:
diff changeset
824 -- See body in Par.Ch5 for details of the use of this parameter.
kono
parents:
diff changeset
825
kono
parents:
diff changeset
826 procedure Parse_Decls_Begin_End (Parent : Node_Id);
kono
parents:
diff changeset
827 -- Parses declarations and handled statement sequence, setting
kono
parents:
diff changeset
828 -- fields of Parent node appropriately.
kono
parents:
diff changeset
829 end Ch5;
kono
parents:
diff changeset
830
kono
parents:
diff changeset
831 -------------
kono
parents:
diff changeset
832 -- Par.Ch6 --
kono
parents:
diff changeset
833 -------------
kono
parents:
diff changeset
834
kono
parents:
diff changeset
835 package Ch6 is
kono
parents:
diff changeset
836 function P_Designator return Node_Id;
kono
parents:
diff changeset
837 function P_Defining_Program_Unit_Name return Node_Id;
kono
parents:
diff changeset
838 function P_Formal_Part return List_Id;
kono
parents:
diff changeset
839 function P_Parameter_Profile return List_Id;
kono
parents:
diff changeset
840 function P_Return_Statement return Node_Id;
kono
parents:
diff changeset
841 function P_Subprogram_Specification return Node_Id;
kono
parents:
diff changeset
842
kono
parents:
diff changeset
843 procedure P_Mode (Node : Node_Id);
kono
parents:
diff changeset
844 -- Sets In_Present and/or Out_Present flags in Node scanning past IN,
kono
parents:
diff changeset
845 -- OUT or IN OUT tokens in the source.
kono
parents:
diff changeset
846
kono
parents:
diff changeset
847 function P_Subprogram (Pf_Flags : Pf_Rec) return Node_Id;
kono
parents:
diff changeset
848 -- Scans out any construct starting with either of the keywords
kono
parents:
diff changeset
849 -- PROCEDURE or FUNCTION. The parameter indicates which possible
kono
parents:
diff changeset
850 -- possible kinds of construct (body, spec, instantiation etc.)
kono
parents:
diff changeset
851 -- are permissible in the current context.
kono
parents:
diff changeset
852 end Ch6;
kono
parents:
diff changeset
853
kono
parents:
diff changeset
854 -------------
kono
parents:
diff changeset
855 -- Par.Ch7 --
kono
parents:
diff changeset
856 -------------
kono
parents:
diff changeset
857
kono
parents:
diff changeset
858 package Ch7 is
kono
parents:
diff changeset
859 function P_Package (Pf_Flags : Pf_Rec) return Node_Id;
kono
parents:
diff changeset
860 -- Scans out any construct starting with the keyword PACKAGE. The
kono
parents:
diff changeset
861 -- parameter indicates which possible kinds of construct (body, spec,
kono
parents:
diff changeset
862 -- instantiation etc.) are permissible in the current context.
kono
parents:
diff changeset
863 end Ch7;
kono
parents:
diff changeset
864
kono
parents:
diff changeset
865 -------------
kono
parents:
diff changeset
866 -- Par.Ch8 --
kono
parents:
diff changeset
867 -------------
kono
parents:
diff changeset
868
kono
parents:
diff changeset
869 package Ch8 is
kono
parents:
diff changeset
870 procedure P_Use_Clause (Item_List : List_Id);
kono
parents:
diff changeset
871 end Ch8;
kono
parents:
diff changeset
872
kono
parents:
diff changeset
873 -------------
kono
parents:
diff changeset
874 -- Par.Ch9 --
kono
parents:
diff changeset
875 -------------
kono
parents:
diff changeset
876
kono
parents:
diff changeset
877 package Ch9 is
kono
parents:
diff changeset
878 function P_Abort_Statement return Node_Id;
kono
parents:
diff changeset
879 function P_Abortable_Part return Node_Id;
kono
parents:
diff changeset
880 function P_Accept_Statement return Node_Id;
kono
parents:
diff changeset
881 function P_Delay_Statement return Node_Id;
kono
parents:
diff changeset
882 function P_Entry_Body return Node_Id;
kono
parents:
diff changeset
883 function P_Protected return Node_Id;
kono
parents:
diff changeset
884 function P_Requeue_Statement return Node_Id;
kono
parents:
diff changeset
885 function P_Select_Statement return Node_Id;
kono
parents:
diff changeset
886 function P_Task return Node_Id;
kono
parents:
diff changeset
887 function P_Terminate_Alternative return Node_Id;
kono
parents:
diff changeset
888 end Ch9;
kono
parents:
diff changeset
889
kono
parents:
diff changeset
890 --------------
kono
parents:
diff changeset
891 -- Par.Ch10 --
kono
parents:
diff changeset
892 --------------
kono
parents:
diff changeset
893
kono
parents:
diff changeset
894 package Ch10 is
kono
parents:
diff changeset
895 function P_Compilation_Unit return Node_Id;
kono
parents:
diff changeset
896 -- Note: this function scans a single compilation unit, and checks that
kono
parents:
diff changeset
897 -- an end of file follows this unit, diagnosing any unexpected input as
kono
parents:
diff changeset
898 -- an error, and then skipping it, so that Token is set to Tok_EOF on
kono
parents:
diff changeset
899 -- return. An exception is in syntax-only mode, where multiple
kono
parents:
diff changeset
900 -- compilation units are permitted. In this case, P_Compilation_Unit
kono
parents:
diff changeset
901 -- does not check for end of file and there may be more compilation
kono
parents:
diff changeset
902 -- units to scan. The caller can uniquely detect this situation by the
kono
parents:
diff changeset
903 -- fact that Token is not set to Tok_EOF on return.
kono
parents:
diff changeset
904 --
kono
parents:
diff changeset
905 -- What about multiple unit/file capability that now exists???
kono
parents:
diff changeset
906 --
kono
parents:
diff changeset
907 -- The Ignore parameter is normally set False. It is set True in the
kono
parents:
diff changeset
908 -- multiple unit per file mode if we are skipping past a unit that we
kono
parents:
diff changeset
909 -- are not interested in.
kono
parents:
diff changeset
910 end Ch10;
kono
parents:
diff changeset
911
kono
parents:
diff changeset
912 --------------
kono
parents:
diff changeset
913 -- Par.Ch11 --
kono
parents:
diff changeset
914 --------------
kono
parents:
diff changeset
915
kono
parents:
diff changeset
916 package Ch11 is
kono
parents:
diff changeset
917 function P_Handled_Sequence_Of_Statements return Node_Id;
kono
parents:
diff changeset
918 function P_Raise_Expression return Node_Id;
kono
parents:
diff changeset
919 function P_Raise_Statement return Node_Id;
kono
parents:
diff changeset
920
kono
parents:
diff changeset
921 function Parse_Exception_Handlers return List_Id;
kono
parents:
diff changeset
922 -- Parses the partial construct EXCEPTION followed by a list of
kono
parents:
diff changeset
923 -- exception handlers which appears in a number of productions, and
kono
parents:
diff changeset
924 -- returns the list of exception handlers.
kono
parents:
diff changeset
925 end Ch11;
kono
parents:
diff changeset
926
kono
parents:
diff changeset
927 --------------
kono
parents:
diff changeset
928 -- Par.Ch12 --
kono
parents:
diff changeset
929 --------------
kono
parents:
diff changeset
930
kono
parents:
diff changeset
931 package Ch12 is
kono
parents:
diff changeset
932 function P_Generic return Node_Id;
kono
parents:
diff changeset
933 function P_Generic_Actual_Part_Opt return List_Id;
kono
parents:
diff changeset
934 end Ch12;
kono
parents:
diff changeset
935
kono
parents:
diff changeset
936 --------------
kono
parents:
diff changeset
937 -- Par.Ch13 --
kono
parents:
diff changeset
938 --------------
kono
parents:
diff changeset
939
kono
parents:
diff changeset
940 package Ch13 is
kono
parents:
diff changeset
941 function P_Representation_Clause return Node_Id;
kono
parents:
diff changeset
942
kono
parents:
diff changeset
943 function Aspect_Specifications_Present
kono
parents:
diff changeset
944 (Strict : Boolean := Ada_Version < Ada_2012) return Boolean;
kono
parents:
diff changeset
945 -- This function tests whether the next keyword is WITH followed by
kono
parents:
diff changeset
946 -- something that looks reasonably like an aspect specification. If so,
kono
parents:
diff changeset
947 -- True is returned. Otherwise False is returned. In either case control
kono
parents:
diff changeset
948 -- returns with the token pointer unchanged (i.e. pointing to the WITH
kono
parents:
diff changeset
949 -- token in the case where True is returned). This function takes care
kono
parents:
diff changeset
950 -- of generating appropriate messages if aspect specifications appear
kono
parents:
diff changeset
951 -- in versions of Ada prior to Ada 2012. The parameter strict can be
kono
parents:
diff changeset
952 -- set to True, to be rather strict about considering something to be
kono
parents:
diff changeset
953 -- an aspect specification. If Strict is False, then the circuitry is
kono
parents:
diff changeset
954 -- rather more generous in considering something ill-formed to be an
kono
parents:
diff changeset
955 -- attempt at an aspect specification. The default is more strict for
kono
parents:
diff changeset
956 -- Ada versions before Ada 2012 (where aspect specifications are not
kono
parents:
diff changeset
957 -- permitted). Note: this routine never checks the terminator token
kono
parents:
diff changeset
958 -- for aspects so it does not matter whether the aspect specifications
kono
parents:
diff changeset
959 -- are terminated by semicolon or some other character.
kono
parents:
diff changeset
960 --
kono
parents:
diff changeset
961 -- Note: This function also handles the case of WHEN used where WITH
kono
parents:
diff changeset
962 -- was intended, and in that case posts an error and returns True.
kono
parents:
diff changeset
963
kono
parents:
diff changeset
964 procedure P_Aspect_Specifications
kono
parents:
diff changeset
965 (Decl : Node_Id;
kono
parents:
diff changeset
966 Semicolon : Boolean := True);
kono
parents:
diff changeset
967 -- This procedure scans out a series of aspect spefications. If argument
kono
parents:
diff changeset
968 -- Semicolon is True, a terminating semicolon is also scanned. If this
kono
parents:
diff changeset
969 -- argument is False, the scan pointer is left pointing past the aspects
kono
parents:
diff changeset
970 -- and the caller must check for a proper terminator.
kono
parents:
diff changeset
971 --
kono
parents:
diff changeset
972 -- P_Aspect_Specifications is called with the current token pointing
kono
parents:
diff changeset
973 -- to either a WITH keyword starting an aspect specification, or an
kono
parents:
diff changeset
974 -- instance of what shpould be a terminator token. In the former case,
kono
parents:
diff changeset
975 -- the aspect specifications are scanned out including the terminator
kono
parents:
diff changeset
976 -- token if it is a semicolon, and the Has_Aspect_Specifications
kono
parents:
diff changeset
977 -- flag is set in the given declaration node. A list of aspects
kono
parents:
diff changeset
978 -- is built and stored for this declaration node using a call to
kono
parents:
diff changeset
979 -- Set_Aspect_Specifications. If no WITH keyword is present, then this
kono
parents:
diff changeset
980 -- call has no effect other than scanning out the terminator if it is a
kono
parents:
diff changeset
981 -- semicolon (with the exception that it detects WHEN used in place of
kono
parents:
diff changeset
982 -- WITH).
kono
parents:
diff changeset
983
kono
parents:
diff changeset
984 -- If Decl is Error on entry, any scanned aspect specifications are
kono
parents:
diff changeset
985 -- ignored and a message is output saying aspect specifications not
kono
parents:
diff changeset
986 -- permitted here. If Decl is Empty, then scanned aspect specifications
kono
parents:
diff changeset
987 -- are also ignored, but no error message is given (this is used when
kono
parents:
diff changeset
988 -- the caller has already taken care of the error message).
kono
parents:
diff changeset
989
kono
parents:
diff changeset
990 function Get_Aspect_Specifications
kono
parents:
diff changeset
991 (Semicolon : Boolean := True) return List_Id;
kono
parents:
diff changeset
992 -- Parse a list of aspects but do not attach them to a declaration node.
kono
parents:
diff changeset
993 -- Subsidiary to P_Aspect_Specifications procedure. Used when parsing
kono
parents:
diff changeset
994 -- a subprogram specification that may be a declaration or a body.
kono
parents:
diff changeset
995 -- Semicolon has the same meaning as for P_Aspect_Specifications above.
kono
parents:
diff changeset
996
kono
parents:
diff changeset
997 function P_Code_Statement (Subtype_Mark : Node_Id) return Node_Id;
kono
parents:
diff changeset
998 -- Function to parse a code statement. The caller has scanned out
kono
parents:
diff changeset
999 -- the name to be used as the subtype mark (but has not checked that
kono
parents:
diff changeset
1000 -- it is suitable for use as a subtype mark, i.e. is either an
kono
parents:
diff changeset
1001 -- identifier or a selected component). The current token is an
kono
parents:
diff changeset
1002 -- apostrophe and the following token is either a left paren or
kono
parents:
diff changeset
1003 -- RANGE (the latter being an error to be caught by P_Code_Statement.
kono
parents:
diff changeset
1004 end Ch13;
kono
parents:
diff changeset
1005
kono
parents:
diff changeset
1006 -- Note: the parsing for annexe J features (i.e. obsolescent features)
kono
parents:
diff changeset
1007 -- is found in the logical section where these features would be if
kono
parents:
diff changeset
1008 -- they were not obsolescent. In particular:
kono
parents:
diff changeset
1009
kono
parents:
diff changeset
1010 -- Delta constraint is parsed by P_Delta_Constraint (3.5.9)
kono
parents:
diff changeset
1011 -- At clause is parsed by P_At_Clause (13.1)
kono
parents:
diff changeset
1012 -- Mod clause is parsed by P_Mod_Clause (13.5.1)
kono
parents:
diff changeset
1013
kono
parents:
diff changeset
1014 --------------
kono
parents:
diff changeset
1015 -- Par.Endh --
kono
parents:
diff changeset
1016 --------------
kono
parents:
diff changeset
1017
kono
parents:
diff changeset
1018 -- Routines for handling end lines, including scope recovery
kono
parents:
diff changeset
1019
kono
parents:
diff changeset
1020 package Endh is
kono
parents:
diff changeset
1021 function Check_End
kono
parents:
diff changeset
1022 (Decl : Node_Id := Empty;
kono
parents:
diff changeset
1023 Is_Loc : Source_Ptr := No_Location) return Boolean;
kono
parents:
diff changeset
1024 -- Called when an end sequence is required. In the absence of an error
kono
parents:
diff changeset
1025 -- situation, Token contains Tok_End on entry, but in a missing end
kono
parents:
diff changeset
1026 -- case, this may not be the case. Pop_End_Context is used to determine
kono
parents:
diff changeset
1027 -- the appropriate action to be taken. The returned result is True if
kono
parents:
diff changeset
1028 -- an End sequence was encountered and False if no End sequence was
kono
parents:
diff changeset
1029 -- present. This occurs if the END keyword encountered was determined
kono
parents:
diff changeset
1030 -- to be improper and deleted (i.e. Pop_End_Context set End_Action to
kono
parents:
diff changeset
1031 -- Skip_And_Reject). Note that the END sequence includes a semicolon,
kono
parents:
diff changeset
1032 -- except in the case of END RECORD, where a semicolon follows the END
kono
parents:
diff changeset
1033 -- RECORD, but is not part of the record type definition itself.
kono
parents:
diff changeset
1034 --
kono
parents:
diff changeset
1035 -- If Decl is non-empty, then aspect specifications are permitted
kono
parents:
diff changeset
1036 -- following the end, and Decl is the declaration node with which
kono
parents:
diff changeset
1037 -- these aspect specifications are to be associated. If Decl is empty,
kono
parents:
diff changeset
1038 -- then aspect specifications are not permitted and will generate an
kono
parents:
diff changeset
1039 -- error message.
kono
parents:
diff changeset
1040 --
kono
parents:
diff changeset
1041 -- Is_Loc is set to other than the default only for the case of a
kono
parents:
diff changeset
1042 -- package declaration. It points to the IS keyword of the declaration,
kono
parents:
diff changeset
1043 -- and is used to specialize the error messages for misplaced aspect
kono
parents:
diff changeset
1044 -- specifications in this case. Note that Decl is always Empty if Is_Loc
kono
parents:
diff changeset
1045 -- is set.
kono
parents:
diff changeset
1046
kono
parents:
diff changeset
1047 procedure End_Skip;
kono
parents:
diff changeset
1048 -- Skip past an end sequence. On entry Token contains Tok_End, and we
kono
parents:
diff changeset
1049 -- we know that the end sequence is syntactically incorrect, and that
kono
parents:
diff changeset
1050 -- an appropriate error message has already been posted. The mission
kono
parents:
diff changeset
1051 -- is simply to position the scan pointer to be the best guess of the
kono
parents:
diff changeset
1052 -- position after the end sequence. We do not issue any additional
kono
parents:
diff changeset
1053 -- error messages while carrying this out.
kono
parents:
diff changeset
1054
kono
parents:
diff changeset
1055 procedure End_Statements
kono
parents:
diff changeset
1056 (Parent : Node_Id := Empty;
kono
parents:
diff changeset
1057 Decl : Node_Id := Empty;
kono
parents:
diff changeset
1058 Is_Sloc : Source_Ptr := No_Location);
kono
parents:
diff changeset
1059 -- Called when an end is required or expected to terminate a sequence
kono
parents:
diff changeset
1060 -- of statements. The caller has already made an appropriate entry in
kono
parents:
diff changeset
1061 -- the Scope.Table to describe the expected form of the end. This can
kono
parents:
diff changeset
1062 -- only be used in cases where the only appropriate terminator is end.
kono
parents:
diff changeset
1063 -- If Parent is non-empty, then if a correct END line is encountered,
kono
parents:
diff changeset
1064 -- the End_Label field of Parent is set appropriately.
kono
parents:
diff changeset
1065 --
kono
parents:
diff changeset
1066 -- If Decl is non-null, then it is a declaration node, and aspect
kono
parents:
diff changeset
1067 -- specifications are permitted after the end statement. These aspect
kono
parents:
diff changeset
1068 -- specifications, if present, are stored in this declaration node.
kono
parents:
diff changeset
1069 -- If Decl is null, then aspect specifications are not permitted after
kono
parents:
diff changeset
1070 -- the end statement.
kono
parents:
diff changeset
1071 --
kono
parents:
diff changeset
1072 -- In the case where Decl is null, Is_Sloc determines the handling. If
kono
parents:
diff changeset
1073 -- it is set to No_Location, then aspect specifications are ignored and
kono
parents:
diff changeset
1074 -- an error message is given. Is_Sloc is used in the package declaration
kono
parents:
diff changeset
1075 -- case to point to the IS, and is used to specialize the error emssages
kono
parents:
diff changeset
1076 -- issued in this case.
kono
parents:
diff changeset
1077 end Endh;
kono
parents:
diff changeset
1078
kono
parents:
diff changeset
1079 --------------
kono
parents:
diff changeset
1080 -- Par.Sync --
kono
parents:
diff changeset
1081 --------------
kono
parents:
diff changeset
1082
kono
parents:
diff changeset
1083 -- These procedures are used to resynchronize after errors. Following an
kono
parents:
diff changeset
1084 -- error which is not immediately locally recoverable, the exception
kono
parents:
diff changeset
1085 -- Error_Resync is raised. The handler for Error_Resync typically calls
kono
parents:
diff changeset
1086 -- one of these recovery procedures to resynchronize the source position
kono
parents:
diff changeset
1087 -- to a point from which parsing can be restarted.
kono
parents:
diff changeset
1088
kono
parents:
diff changeset
1089 -- Note: these procedures output an information message that tokens are
kono
parents:
diff changeset
1090 -- being skipped, but this message is output only if the option for
kono
parents:
diff changeset
1091 -- Multiple_Errors_Per_Line is set in Options.
kono
parents:
diff changeset
1092
kono
parents:
diff changeset
1093 package Sync is
kono
parents:
diff changeset
1094 procedure Resync_Choice;
kono
parents:
diff changeset
1095 -- Used if an error occurs scanning a choice. The scan pointer is
kono
parents:
diff changeset
1096 -- advanced to the next vertical bar, arrow, or semicolon, whichever
kono
parents:
diff changeset
1097 -- comes first. We also quit if we encounter an end of file.
kono
parents:
diff changeset
1098
kono
parents:
diff changeset
1099 procedure Resync_Cunit;
kono
parents:
diff changeset
1100 -- Synchronize to next token which could be the start of a compilation
kono
parents:
diff changeset
1101 -- unit, or to the end of file token.
kono
parents:
diff changeset
1102
kono
parents:
diff changeset
1103 procedure Resync_Expression;
kono
parents:
diff changeset
1104 -- Used if an error is detected during the parsing of an expression.
kono
parents:
diff changeset
1105 -- It skips past tokens until either a token which cannot be part of
kono
parents:
diff changeset
1106 -- an expression is encountered (an expression terminator), or if a
kono
parents:
diff changeset
1107 -- comma or right parenthesis or vertical bar is encountered at the
kono
parents:
diff changeset
1108 -- current parenthesis level (a parenthesis level counter is maintained
kono
parents:
diff changeset
1109 -- to carry out this test).
kono
parents:
diff changeset
1110
kono
parents:
diff changeset
1111 procedure Resync_Past_Malformed_Aspect;
kono
parents:
diff changeset
1112 -- Used when parsing aspect specifications to skip a malformed aspect.
kono
parents:
diff changeset
1113 -- The scan pointer is positioned next to a comma, a semicolon or "is"
kono
parents:
diff changeset
1114 -- when the aspect applies to a body.
kono
parents:
diff changeset
1115
kono
parents:
diff changeset
1116 procedure Resync_Past_Semicolon;
kono
parents:
diff changeset
1117 -- Used if an error occurs while scanning a sequence of declarations.
kono
parents:
diff changeset
1118 -- The scan pointer is positioned past the next semicolon and the scan
kono
parents:
diff changeset
1119 -- resumes. The scan is also resumed on encountering a token which
kono
parents:
diff changeset
1120 -- starts a declaration (but we make sure to skip at least one token
kono
parents:
diff changeset
1121 -- in this case, to avoid getting stuck in a loop).
kono
parents:
diff changeset
1122
kono
parents:
diff changeset
1123 procedure Resync_Past_Semicolon_Or_To_Loop_Or_Then;
kono
parents:
diff changeset
1124 -- Used if an error occurs while scanning a sequence of statements. The
kono
parents:
diff changeset
1125 -- scan pointer is positioned past the next semicolon, or to the next
kono
parents:
diff changeset
1126 -- occurrence of either then or loop, and the scan resumes.
kono
parents:
diff changeset
1127
kono
parents:
diff changeset
1128 procedure Resync_Semicolon_List;
kono
parents:
diff changeset
1129 -- Used if an error occurs while scanning a parenthesized list of items
kono
parents:
diff changeset
1130 -- separated by semicolons. The scan pointer is advanced to the next
kono
parents:
diff changeset
1131 -- semicolon or right parenthesis at the outer parenthesis level, or
kono
parents:
diff changeset
1132 -- to the next is or RETURN keyword occurrence, whichever comes first.
kono
parents:
diff changeset
1133
kono
parents:
diff changeset
1134 procedure Resync_To_Semicolon;
kono
parents:
diff changeset
1135 -- Similar to Resync_Past_Semicolon, except that the scan pointer is
kono
parents:
diff changeset
1136 -- left pointing to the semicolon rather than past it.
kono
parents:
diff changeset
1137
kono
parents:
diff changeset
1138 procedure Resync_To_When;
kono
parents:
diff changeset
1139 -- Used when an error occurs scanning an entry index specification. The
kono
parents:
diff changeset
1140 -- scan pointer is positioned to the next WHEN (or to IS or semicolon if
kono
parents:
diff changeset
1141 -- either of these appear before WHEN, indicating another error has
kono
parents:
diff changeset
1142 -- occurred).
kono
parents:
diff changeset
1143 end Sync;
kono
parents:
diff changeset
1144
kono
parents:
diff changeset
1145 --------------
kono
parents:
diff changeset
1146 -- Par.Tchk --
kono
parents:
diff changeset
1147 --------------
kono
parents:
diff changeset
1148
kono
parents:
diff changeset
1149 -- Routines to check for expected tokens
kono
parents:
diff changeset
1150
kono
parents:
diff changeset
1151 package Tchk is
kono
parents:
diff changeset
1152
kono
parents:
diff changeset
1153 -- Procedures with names of the form T_xxx, where Tok_xxx is a token
kono
parents:
diff changeset
1154 -- name, check that the current token matches the required token, and
kono
parents:
diff changeset
1155 -- if so, scan past it. If not, an error is issued indicating that
kono
parents:
diff changeset
1156 -- the required token is not present (xxx expected). In most cases, the
kono
parents:
diff changeset
1157 -- scan pointer is not moved in the not-found case, but there are some
kono
parents:
diff changeset
1158 -- exceptions to this, see for example T_Id, where the scan pointer is
kono
parents:
diff changeset
1159 -- moved across a literal appearing where an identifier is expected.
kono
parents:
diff changeset
1160
kono
parents:
diff changeset
1161 procedure T_Abort;
kono
parents:
diff changeset
1162 procedure T_Arrow;
kono
parents:
diff changeset
1163 procedure T_At;
kono
parents:
diff changeset
1164 procedure T_Body;
kono
parents:
diff changeset
1165 procedure T_Box;
kono
parents:
diff changeset
1166 procedure T_Colon;
kono
parents:
diff changeset
1167 procedure T_Colon_Equal;
kono
parents:
diff changeset
1168 procedure T_Comma;
kono
parents:
diff changeset
1169 procedure T_Dot_Dot;
kono
parents:
diff changeset
1170 procedure T_For;
kono
parents:
diff changeset
1171 procedure T_Greater_Greater;
kono
parents:
diff changeset
1172 procedure T_Identifier;
kono
parents:
diff changeset
1173 procedure T_In;
kono
parents:
diff changeset
1174 procedure T_Is;
kono
parents:
diff changeset
1175 procedure T_Left_Paren;
kono
parents:
diff changeset
1176 procedure T_Loop;
kono
parents:
diff changeset
1177 procedure T_Mod;
kono
parents:
diff changeset
1178 procedure T_New;
kono
parents:
diff changeset
1179 procedure T_Of;
kono
parents:
diff changeset
1180 procedure T_Or;
kono
parents:
diff changeset
1181 procedure T_Private;
kono
parents:
diff changeset
1182 procedure T_Range;
kono
parents:
diff changeset
1183 procedure T_Record;
kono
parents:
diff changeset
1184 procedure T_Right_Paren;
kono
parents:
diff changeset
1185 procedure T_Semicolon;
kono
parents:
diff changeset
1186 procedure T_Then;
kono
parents:
diff changeset
1187 procedure T_Type;
kono
parents:
diff changeset
1188 procedure T_Use;
kono
parents:
diff changeset
1189 procedure T_When;
kono
parents:
diff changeset
1190 procedure T_With;
kono
parents:
diff changeset
1191
kono
parents:
diff changeset
1192 -- Procedures having names of the form TF_xxx, where Tok_xxx is a token
kono
parents:
diff changeset
1193 -- name check that the current token matches the required token, and
kono
parents:
diff changeset
1194 -- if so, scan past it. If not, an error message is issued indicating
kono
parents:
diff changeset
1195 -- that the required token is not present (xxx expected).
kono
parents:
diff changeset
1196
kono
parents:
diff changeset
1197 -- If the missing token is at the end of the line, then control returns
kono
parents:
diff changeset
1198 -- immediately after posting the message. If there are remaining tokens
kono
parents:
diff changeset
1199 -- on the current line, a search is conducted to see if the token
kono
parents:
diff changeset
1200 -- appears later on the current line, as follows:
kono
parents:
diff changeset
1201
kono
parents:
diff changeset
1202 -- A call to Scan_Save is issued and a forward search for the token
kono
parents:
diff changeset
1203 -- is carried out. If the token is found on the current line before a
kono
parents:
diff changeset
1204 -- semicolon, then it is scanned out and the scan continues from that
kono
parents:
diff changeset
1205 -- point. If not the scan is restored to the point where it was missing.
kono
parents:
diff changeset
1206
kono
parents:
diff changeset
1207 procedure TF_Arrow;
kono
parents:
diff changeset
1208 procedure TF_Is;
kono
parents:
diff changeset
1209 procedure TF_Loop;
kono
parents:
diff changeset
1210 procedure TF_Return;
kono
parents:
diff changeset
1211 procedure TF_Semicolon;
kono
parents:
diff changeset
1212 procedure TF_Then;
kono
parents:
diff changeset
1213 procedure TF_Use;
kono
parents:
diff changeset
1214
kono
parents:
diff changeset
1215 -- Procedures with names of the form U_xxx, where Tok_xxx is a token
kono
parents:
diff changeset
1216 -- name, are just like the corresponding T_xxx procedures except that
kono
parents:
diff changeset
1217 -- an error message, if given, is unconditional.
kono
parents:
diff changeset
1218
kono
parents:
diff changeset
1219 procedure U_Left_Paren;
kono
parents:
diff changeset
1220 procedure U_Right_Paren;
kono
parents:
diff changeset
1221 end Tchk;
kono
parents:
diff changeset
1222
kono
parents:
diff changeset
1223 --------------
kono
parents:
diff changeset
1224 -- Par.Util --
kono
parents:
diff changeset
1225 --------------
kono
parents:
diff changeset
1226
kono
parents:
diff changeset
1227 package Util is
kono
parents:
diff changeset
1228 function Bad_Spelling_Of (T : Token_Type) return Boolean;
kono
parents:
diff changeset
1229 -- This function is called in an error situation. It checks if the
kono
parents:
diff changeset
1230 -- current token is an identifier whose name is a plausible bad
kono
parents:
diff changeset
1231 -- spelling of the given keyword token, and if so, issues an error
kono
parents:
diff changeset
1232 -- message, sets Token from T, and returns True. Otherwise Token is
kono
parents:
diff changeset
1233 -- unchanged, and False is returned.
kono
parents:
diff changeset
1234
kono
parents:
diff changeset
1235 procedure Check_Bad_Layout;
kono
parents:
diff changeset
1236 -- Check for bad indentation in RM checking mode. Used for statements
kono
parents:
diff changeset
1237 -- and declarations. Checks if current token is at start of line and
kono
parents:
diff changeset
1238 -- is exdented from the current expected end column, and if so an
kono
parents:
diff changeset
1239 -- error message is generated.
kono
parents:
diff changeset
1240
kono
parents:
diff changeset
1241 procedure Check_Misspelling_Of (T : Token_Type);
kono
parents:
diff changeset
1242 pragma Inline (Check_Misspelling_Of);
kono
parents:
diff changeset
1243 -- This is similar to the function above, except that it does not
kono
parents:
diff changeset
1244 -- return a result. It is typically used in a situation where any
kono
parents:
diff changeset
1245 -- identifier is an error, and it makes sense to simply convert it
kono
parents:
diff changeset
1246 -- to the given token if it is a plausible misspelling of it.
kono
parents:
diff changeset
1247
kono
parents:
diff changeset
1248 procedure Check_95_Keyword (Token_95, Next : Token_Type);
kono
parents:
diff changeset
1249 -- This routine checks if the token after the current one matches the
kono
parents:
diff changeset
1250 -- Next argument. If so, the scan is backed up to the current token
kono
parents:
diff changeset
1251 -- and Token_Type is changed to Token_95 after issuing an appropriate
kono
parents:
diff changeset
1252 -- error message ("(Ada 83) keyword xx cannot be used"). If not,
kono
parents:
diff changeset
1253 -- the scan is backed up with Token_Type unchanged. This routine
kono
parents:
diff changeset
1254 -- is used to deal with an attempt to use a 95 keyword in Ada 83
kono
parents:
diff changeset
1255 -- mode. The caller has typically checked that the current token,
kono
parents:
diff changeset
1256 -- an identifier, matches one of the 95 keywords.
kono
parents:
diff changeset
1257
kono
parents:
diff changeset
1258 procedure Check_Future_Keyword;
kono
parents:
diff changeset
1259 -- Emit a warning if the current token is a valid identifier in the
kono
parents:
diff changeset
1260 -- language version in use, but is a reserved word in a later language
kono
parents:
diff changeset
1261 -- version (unless the language version in use is Ada 83).
kono
parents:
diff changeset
1262
kono
parents:
diff changeset
1263 procedure Check_Simple_Expression (E : Node_Id);
kono
parents:
diff changeset
1264 -- Given an expression E, that has just been scanned, so that Expr_Form
kono
parents:
diff changeset
1265 -- is still set, outputs an error if E is a non-simple expression. E is
kono
parents:
diff changeset
1266 -- not modified by this call.
kono
parents:
diff changeset
1267
kono
parents:
diff changeset
1268 procedure Check_Simple_Expression_In_Ada_83 (E : Node_Id);
kono
parents:
diff changeset
1269 -- Like Check_Simple_Expression, except that the error message is only
kono
parents:
diff changeset
1270 -- given when operating in Ada 83 mode, and includes "in Ada 83".
kono
parents:
diff changeset
1271
kono
parents:
diff changeset
1272 function Check_Subtype_Mark (Mark : Node_Id) return Node_Id;
kono
parents:
diff changeset
1273 -- Called to check that a node representing a name (or call) is
kono
parents:
diff changeset
1274 -- suitable for a subtype mark, i.e, that it is an identifier or
kono
parents:
diff changeset
1275 -- a selected component. If so, or if it is already Error, then
kono
parents:
diff changeset
1276 -- it is returned unchanged. Otherwise an error message is issued
kono
parents:
diff changeset
1277 -- and Error is returned.
kono
parents:
diff changeset
1278
kono
parents:
diff changeset
1279 function Comma_Present return Boolean;
kono
parents:
diff changeset
1280 -- Used in comma delimited lists to determine if a comma is present, or
kono
parents:
diff changeset
1281 -- can reasonably be assumed to have been present (an error message is
kono
parents:
diff changeset
1282 -- generated in the latter case). If True is returned, the scan has been
kono
parents:
diff changeset
1283 -- positioned past the comma. If False is returned, the scan position
kono
parents:
diff changeset
1284 -- is unchanged. Note that all comma-delimited lists are terminated by
kono
parents:
diff changeset
1285 -- a right paren, so the only legitimate tokens when Comma_Present is
kono
parents:
diff changeset
1286 -- called are right paren and comma. If some other token is found, then
kono
parents:
diff changeset
1287 -- Comma_Present has the job of deciding whether it is better to pretend
kono
parents:
diff changeset
1288 -- a comma was present, post a message for a missing comma and return
kono
parents:
diff changeset
1289 -- True, or return False and let the caller diagnose the missing right
kono
parents:
diff changeset
1290 -- parenthesis.
kono
parents:
diff changeset
1291
kono
parents:
diff changeset
1292 procedure Discard_Junk_Node (N : Node_Id);
kono
parents:
diff changeset
1293 procedure Discard_Junk_List (L : List_Id);
kono
parents:
diff changeset
1294 pragma Inline (Discard_Junk_Node);
kono
parents:
diff changeset
1295 pragma Inline (Discard_Junk_List);
kono
parents:
diff changeset
1296 -- These procedures do nothing at all, their effect is simply to discard
kono
parents:
diff changeset
1297 -- the argument. A typical use is to skip by some junk that is not
kono
parents:
diff changeset
1298 -- expected in the current context.
kono
parents:
diff changeset
1299
kono
parents:
diff changeset
1300 procedure Ignore (T : Token_Type);
kono
parents:
diff changeset
1301 -- If current token matches T, then give an error message and skip
kono
parents:
diff changeset
1302 -- past it, otherwise the call has no effect at all. T may be any
kono
parents:
diff changeset
1303 -- reserved word token, or comma, left or right paren, or semicolon.
kono
parents:
diff changeset
1304
kono
parents:
diff changeset
1305 function Is_Reserved_Identifier (C : Id_Check := None) return Boolean;
kono
parents:
diff changeset
1306 -- Test if current token is a reserved identifier. This test is based
kono
parents:
diff changeset
1307 -- on the token being a keyword and being spelled in typical identifier
kono
parents:
diff changeset
1308 -- style (i.e. starting with an upper case letter). The parameter C
kono
parents:
diff changeset
1309 -- determines the special treatment if a reserved word is encountered
kono
parents:
diff changeset
1310 -- that has the normal casing of a reserved word.
kono
parents:
diff changeset
1311
kono
parents:
diff changeset
1312 procedure Merge_Identifier (Prev : Node_Id; Nxt : Token_Type);
kono
parents:
diff changeset
1313 -- Called when the previous token is an identifier (whose Token_Node
kono
parents:
diff changeset
1314 -- value is given by Prev) to check if current token is an identifier
kono
parents:
diff changeset
1315 -- that can be merged with the previous one adding an underscore. The
kono
parents:
diff changeset
1316 -- merge is only attempted if the following token matches Nxt. If all
kono
parents:
diff changeset
1317 -- conditions are met, an error message is issued, and the merge is
kono
parents:
diff changeset
1318 -- carried out, modifying the Chars field of Prev.
kono
parents:
diff changeset
1319
kono
parents:
diff changeset
1320 function Next_Token_Is (Tok : Token_Type) return Boolean;
kono
parents:
diff changeset
1321 -- Looks at token after current one and returns True if the token type
kono
parents:
diff changeset
1322 -- matches Tok. The scan is unconditionally restored on return.
kono
parents:
diff changeset
1323
kono
parents:
diff changeset
1324 procedure No_Constraint;
kono
parents:
diff changeset
1325 -- Called in a place where no constraint is allowed, but one might
kono
parents:
diff changeset
1326 -- appear due to a common error (e.g. after the type mark in a procedure
kono
parents:
diff changeset
1327 -- parameter. If a constraint is present, an error message is posted,
kono
parents:
diff changeset
1328 -- and the constraint is scanned and discarded.
kono
parents:
diff changeset
1329
kono
parents:
diff changeset
1330 procedure Push_Scope_Stack;
kono
parents:
diff changeset
1331 pragma Inline (Push_Scope_Stack);
kono
parents:
diff changeset
1332 -- Push a new entry onto the scope stack. Scope.Last (the stack pointer)
kono
parents:
diff changeset
1333 -- is incremented. The Junk field is preinitialized to False. The caller
kono
parents:
diff changeset
1334 -- is expected to fill in all remaining entries of the new top stack
kono
parents:
diff changeset
1335 -- entry at Scope.Table (Scope.Last).
kono
parents:
diff changeset
1336
kono
parents:
diff changeset
1337 procedure Pop_Scope_Stack;
kono
parents:
diff changeset
1338 -- Pop an entry off the top of the scope stack. Scope_Last (the scope
kono
parents:
diff changeset
1339 -- table stack pointer) is decremented by one. It is a fatal error to
kono
parents:
diff changeset
1340 -- try to pop off the dummy entry at the bottom of the stack (i.e.
kono
parents:
diff changeset
1341 -- Scope.Last must be non-zero at the time of call).
kono
parents:
diff changeset
1342
kono
parents:
diff changeset
1343 function Separate_Present return Boolean;
kono
parents:
diff changeset
1344 -- Determines if the current token is either Tok_Separate, or an
kono
parents:
diff changeset
1345 -- identifier that is a possible misspelling of "separate" followed
kono
parents:
diff changeset
1346 -- by a semicolon. True is returned if so, otherwise False.
kono
parents:
diff changeset
1347
kono
parents:
diff changeset
1348 procedure Signal_Bad_Attribute;
kono
parents:
diff changeset
1349 -- The current token is an identifier that is supposed to be an
kono
parents:
diff changeset
1350 -- attribute identifier but is not. This routine posts appropriate
kono
parents:
diff changeset
1351 -- error messages, including a check for a near misspelling.
kono
parents:
diff changeset
1352
kono
parents:
diff changeset
1353 function Token_Is_At_Start_Of_Line return Boolean;
kono
parents:
diff changeset
1354 pragma Inline (Token_Is_At_Start_Of_Line);
kono
parents:
diff changeset
1355 -- Determines if the current token is the first token on the line
kono
parents:
diff changeset
1356
kono
parents:
diff changeset
1357 function Token_Is_At_End_Of_Line return Boolean;
kono
parents:
diff changeset
1358 -- Determines if the current token is the last token on the line
kono
parents:
diff changeset
1359
kono
parents:
diff changeset
1360 procedure Warn_If_Standard_Redefinition (N : Node_Id);
kono
parents:
diff changeset
1361 -- Issues a warning if Warn_On_Standard_Redefinition is set True, and
kono
parents:
diff changeset
1362 -- the Node N (which is a Defining_Identifier node with the Chars field
kono
parents:
diff changeset
1363 -- set) is a renaming of an entity in package Standard.
kono
parents:
diff changeset
1364
kono
parents:
diff changeset
1365 end Util;
kono
parents:
diff changeset
1366
kono
parents:
diff changeset
1367 --------------
kono
parents:
diff changeset
1368 -- Par.Prag --
kono
parents:
diff changeset
1369 --------------
kono
parents:
diff changeset
1370
kono
parents:
diff changeset
1371 -- The processing for pragmas is split off from chapter 2
kono
parents:
diff changeset
1372
kono
parents:
diff changeset
1373 function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id;
kono
parents:
diff changeset
1374 -- This function is passed a tree for a pragma that has been scanned out.
kono
parents:
diff changeset
1375 -- The pragma is syntactically well formed according to the general syntax
kono
parents:
diff changeset
1376 -- for pragmas and the pragma identifier is for one of the recognized
kono
parents:
diff changeset
1377 -- pragmas. It performs specific syntactic checks for specific pragmas.
kono
parents:
diff changeset
1378 -- The result is the input node if it is OK, or Error otherwise. The
kono
parents:
diff changeset
1379 -- reason that this is separated out is to facilitate the addition
kono
parents:
diff changeset
1380 -- of implementation defined pragmas. The second parameter records the
kono
parents:
diff changeset
1381 -- location of the semicolon following the pragma (this is needed for
kono
parents:
diff changeset
1382 -- correct processing of the List and Page pragmas). The returned value
kono
parents:
diff changeset
1383 -- is a copy of Pragma_Node, or Error if an error is found. Note that
kono
parents:
diff changeset
1384 -- at the point where Prag is called, the right paren ending the pragma
kono
parents:
diff changeset
1385 -- has been scanned out, and except in the case of pragma Style_Checks,
kono
parents:
diff changeset
1386 -- so has the following semicolon. For Style_Checks, the caller delays
kono
parents:
diff changeset
1387 -- the scanning of the semicolon so that it will be scanned using the
kono
parents:
diff changeset
1388 -- settings from the Style_Checks pragma preceding it.
kono
parents:
diff changeset
1389
kono
parents:
diff changeset
1390 --------------
kono
parents:
diff changeset
1391 -- Par.Labl --
kono
parents:
diff changeset
1392 --------------
kono
parents:
diff changeset
1393
kono
parents:
diff changeset
1394 procedure Labl;
kono
parents:
diff changeset
1395 -- This procedure creates implicit label declarations for all labels that
kono
parents:
diff changeset
1396 -- are declared in the current unit. Note that this could conceptually be
kono
parents:
diff changeset
1397 -- done at the point where the labels are declared, but it is tricky to do
kono
parents:
diff changeset
1398 -- it then, since the tree is not hooked up at the point where the label is
kono
parents:
diff changeset
1399 -- declared (e.g. a sequence of statements is not yet attached to its
kono
parents:
diff changeset
1400 -- containing scope at the point a label in the sequence is found).
kono
parents:
diff changeset
1401
kono
parents:
diff changeset
1402 --------------
kono
parents:
diff changeset
1403 -- Par.Load --
kono
parents:
diff changeset
1404 --------------
kono
parents:
diff changeset
1405
kono
parents:
diff changeset
1406 procedure Load;
kono
parents:
diff changeset
1407 -- This procedure loads all subsidiary units that are required by this
kono
parents:
diff changeset
1408 -- unit, including with'ed units, specs for bodies, and parents for child
kono
parents:
diff changeset
1409 -- units. It does not load bodies for inlined procedures and generics,
kono
parents:
diff changeset
1410 -- since we don't know till semantic analysis is complete what is needed.
kono
parents:
diff changeset
1411
kono
parents:
diff changeset
1412 -----------
kono
parents:
diff changeset
1413 -- Stubs --
kono
parents:
diff changeset
1414 -----------
kono
parents:
diff changeset
1415
kono
parents:
diff changeset
1416 -- The package bodies can see all routines defined in all other subpackages
kono
parents:
diff changeset
1417
kono
parents:
diff changeset
1418 use Ch2;
kono
parents:
diff changeset
1419 use Ch3;
kono
parents:
diff changeset
1420 use Ch4;
kono
parents:
diff changeset
1421 use Ch5;
kono
parents:
diff changeset
1422 use Ch6;
kono
parents:
diff changeset
1423 use Ch7;
kono
parents:
diff changeset
1424 use Ch8;
kono
parents:
diff changeset
1425 use Ch9;
kono
parents:
diff changeset
1426 use Ch10;
kono
parents:
diff changeset
1427 use Ch11;
kono
parents:
diff changeset
1428 use Ch12;
kono
parents:
diff changeset
1429 use Ch13;
kono
parents:
diff changeset
1430
kono
parents:
diff changeset
1431 use Endh;
kono
parents:
diff changeset
1432 use Tchk;
kono
parents:
diff changeset
1433 use Sync;
kono
parents:
diff changeset
1434 use Util;
kono
parents:
diff changeset
1435
kono
parents:
diff changeset
1436 package body Ch2 is separate;
kono
parents:
diff changeset
1437 package body Ch3 is separate;
kono
parents:
diff changeset
1438 package body Ch4 is separate;
kono
parents:
diff changeset
1439 package body Ch5 is separate;
kono
parents:
diff changeset
1440 package body Ch6 is separate;
kono
parents:
diff changeset
1441 package body Ch7 is separate;
kono
parents:
diff changeset
1442 package body Ch8 is separate;
kono
parents:
diff changeset
1443 package body Ch9 is separate;
kono
parents:
diff changeset
1444 package body Ch10 is separate;
kono
parents:
diff changeset
1445 package body Ch11 is separate;
kono
parents:
diff changeset
1446 package body Ch12 is separate;
kono
parents:
diff changeset
1447 package body Ch13 is separate;
kono
parents:
diff changeset
1448
kono
parents:
diff changeset
1449 package body Endh is separate;
kono
parents:
diff changeset
1450 package body Tchk is separate;
kono
parents:
diff changeset
1451 package body Sync is separate;
kono
parents:
diff changeset
1452 package body Util is separate;
kono
parents:
diff changeset
1453
kono
parents:
diff changeset
1454 function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id
kono
parents:
diff changeset
1455 is separate;
kono
parents:
diff changeset
1456
kono
parents:
diff changeset
1457 procedure Labl is separate;
kono
parents:
diff changeset
1458 procedure Load is separate;
kono
parents:
diff changeset
1459
kono
parents:
diff changeset
1460 Result : List_Id := Empty_List;
kono
parents:
diff changeset
1461
kono
parents:
diff changeset
1462 -- Start of processing for Par
kono
parents:
diff changeset
1463
kono
parents:
diff changeset
1464 begin
kono
parents:
diff changeset
1465 Compiler_State := Parsing;
kono
parents:
diff changeset
1466
kono
parents:
diff changeset
1467 -- Deal with configuration pragmas case first
kono
parents:
diff changeset
1468
kono
parents:
diff changeset
1469 if Configuration_Pragmas then
kono
parents:
diff changeset
1470 declare
kono
parents:
diff changeset
1471 Pragmas : constant List_Id := Empty_List;
kono
parents:
diff changeset
1472 P_Node : Node_Id;
kono
parents:
diff changeset
1473
kono
parents:
diff changeset
1474 begin
kono
parents:
diff changeset
1475 loop
kono
parents:
diff changeset
1476 if Token = Tok_EOF then
kono
parents:
diff changeset
1477 Result := Pragmas;
kono
parents:
diff changeset
1478 exit;
kono
parents:
diff changeset
1479
kono
parents:
diff changeset
1480 elsif Token /= Tok_Pragma then
kono
parents:
diff changeset
1481 Error_Msg_SC ("only pragmas allowed in configuration file");
kono
parents:
diff changeset
1482 Result := Error_List;
kono
parents:
diff changeset
1483 exit;
kono
parents:
diff changeset
1484
kono
parents:
diff changeset
1485 else
kono
parents:
diff changeset
1486 P_Node := P_Pragma;
kono
parents:
diff changeset
1487
kono
parents:
diff changeset
1488 if Nkind (P_Node) = N_Pragma then
kono
parents:
diff changeset
1489
kono
parents:
diff changeset
1490 -- Give error if bad pragma
kono
parents:
diff changeset
1491
kono
parents:
diff changeset
1492 if not Is_Configuration_Pragma_Name
kono
parents:
diff changeset
1493 (Pragma_Name_Unmapped (P_Node))
kono
parents:
diff changeset
1494 and then
kono
parents:
diff changeset
1495 Pragma_Name_Unmapped (P_Node) /= Name_Source_Reference
kono
parents:
diff changeset
1496 then
kono
parents:
diff changeset
1497 if Is_Pragma_Name (Pragma_Name_Unmapped (P_Node)) then
kono
parents:
diff changeset
1498 Error_Msg_N
kono
parents:
diff changeset
1499 ("only configuration pragmas allowed " &
kono
parents:
diff changeset
1500 "in configuration file", P_Node);
kono
parents:
diff changeset
1501 else
kono
parents:
diff changeset
1502 Error_Msg_N
kono
parents:
diff changeset
1503 ("unrecognized pragma in configuration file",
kono
parents:
diff changeset
1504 P_Node);
kono
parents:
diff changeset
1505 end if;
kono
parents:
diff changeset
1506
kono
parents:
diff changeset
1507 -- Pragma is OK config pragma, so collect it
kono
parents:
diff changeset
1508
kono
parents:
diff changeset
1509 else
kono
parents:
diff changeset
1510 Append (P_Node, Pragmas);
kono
parents:
diff changeset
1511 end if;
kono
parents:
diff changeset
1512 end if;
kono
parents:
diff changeset
1513 end if;
kono
parents:
diff changeset
1514 end loop;
kono
parents:
diff changeset
1515 end;
kono
parents:
diff changeset
1516
kono
parents:
diff changeset
1517 -- Normal case of compilation unit
kono
parents:
diff changeset
1518
kono
parents:
diff changeset
1519 else
kono
parents:
diff changeset
1520 Save_Opt_Config_Switches (Save_Config_Switches);
kono
parents:
diff changeset
1521
kono
parents:
diff changeset
1522 -- The following loop runs more than once in syntax check mode
kono
parents:
diff changeset
1523 -- where we allow multiple compilation units in the same file
kono
parents:
diff changeset
1524 -- and in Multiple_Unit_Per_file mode where we skip units till
kono
parents:
diff changeset
1525 -- we get to the unit we want.
kono
parents:
diff changeset
1526
kono
parents:
diff changeset
1527 for Ucount in Pos loop
kono
parents:
diff changeset
1528 Set_Opt_Config_Switches
kono
parents:
diff changeset
1529 (Is_Internal_Unit (Current_Source_Unit),
kono
parents:
diff changeset
1530 Main_Unit => Current_Source_Unit = Main_Unit);
kono
parents:
diff changeset
1531
kono
parents:
diff changeset
1532 -- Initialize scope table and other parser control variables
kono
parents:
diff changeset
1533
kono
parents:
diff changeset
1534 Compiler_State := Parsing;
kono
parents:
diff changeset
1535 Scope.Init;
kono
parents:
diff changeset
1536 Scope.Increment_Last;
kono
parents:
diff changeset
1537 Scope.Table (0).Etyp := E_Dummy;
kono
parents:
diff changeset
1538 SIS_Entry_Active := False;
kono
parents:
diff changeset
1539 Last_Resync_Point := No_Location;
kono
parents:
diff changeset
1540
kono
parents:
diff changeset
1541 Goto_List := New_Elmt_List;
kono
parents:
diff changeset
1542 Label_List := New_Elmt_List;
kono
parents:
diff changeset
1543
kono
parents:
diff changeset
1544 -- If in multiple unit per file mode, skip past ignored unit
kono
parents:
diff changeset
1545
kono
parents:
diff changeset
1546 if Ucount < Multiple_Unit_Index then
kono
parents:
diff changeset
1547
kono
parents:
diff changeset
1548 -- We skip in syntax check only mode, since we don't want to do
kono
parents:
diff changeset
1549 -- anything more than skip past the unit and ignore it. This means
kono
parents:
diff changeset
1550 -- we skip processing like setting up a unit table entry.
kono
parents:
diff changeset
1551
kono
parents:
diff changeset
1552 declare
kono
parents:
diff changeset
1553 Save_Operating_Mode : constant Operating_Mode_Type :=
kono
parents:
diff changeset
1554 Operating_Mode;
kono
parents:
diff changeset
1555
kono
parents:
diff changeset
1556 Save_Style_Check : constant Boolean := Style_Check;
kono
parents:
diff changeset
1557
kono
parents:
diff changeset
1558 begin
kono
parents:
diff changeset
1559 Operating_Mode := Check_Syntax;
kono
parents:
diff changeset
1560 Style_Check := False;
kono
parents:
diff changeset
1561 Discard_Node (P_Compilation_Unit);
kono
parents:
diff changeset
1562 Operating_Mode := Save_Operating_Mode;
kono
parents:
diff changeset
1563 Style_Check := Save_Style_Check;
kono
parents:
diff changeset
1564
kono
parents:
diff changeset
1565 -- If we are at an end of file, and not yet at the right unit,
kono
parents:
diff changeset
1566 -- then we have a fatal error. The unit is missing.
kono
parents:
diff changeset
1567
kono
parents:
diff changeset
1568 if Token = Tok_EOF then
kono
parents:
diff changeset
1569 Error_Msg_SC ("file has too few compilation units");
kono
parents:
diff changeset
1570 raise Unrecoverable_Error;
kono
parents:
diff changeset
1571 end if;
kono
parents:
diff changeset
1572 end;
kono
parents:
diff changeset
1573
kono
parents:
diff changeset
1574 -- Here if we are not skipping a file in multiple unit per file mode.
kono
parents:
diff changeset
1575 -- Parse the unit that we are interested in. Note that in check
kono
parents:
diff changeset
1576 -- syntax mode we are interested in all units in the file.
kono
parents:
diff changeset
1577
kono
parents:
diff changeset
1578 else
kono
parents:
diff changeset
1579 declare
kono
parents:
diff changeset
1580 Comp_Unit_Node : constant Node_Id := P_Compilation_Unit;
kono
parents:
diff changeset
1581
kono
parents:
diff changeset
1582 begin
kono
parents:
diff changeset
1583 -- If parsing was successful and we are not in check syntax
kono
parents:
diff changeset
1584 -- mode, check that language-defined units are compiled in GNAT
kono
parents:
diff changeset
1585 -- mode. For this purpose we do NOT consider renamings in annex
kono
parents:
diff changeset
1586 -- J as predefined. That allows users to compile their own
kono
parents:
diff changeset
1587 -- versions of these files. Another exception is System.RPC
kono
parents:
diff changeset
1588 -- and its children. This allows a user to supply their own
kono
parents:
diff changeset
1589 -- communication layer.
kono
parents:
diff changeset
1590 -- Similarly, we do not generate an error in CodePeer mode,
kono
parents:
diff changeset
1591 -- to allow users to analyze third-party compiler packages.
kono
parents:
diff changeset
1592
kono
parents:
diff changeset
1593 if Comp_Unit_Node /= Error
kono
parents:
diff changeset
1594 and then Operating_Mode = Generate_Code
kono
parents:
diff changeset
1595 and then Current_Source_Unit = Main_Unit
kono
parents:
diff changeset
1596 and then not GNAT_Mode
kono
parents:
diff changeset
1597 and then not CodePeer_Mode
kono
parents:
diff changeset
1598 then
kono
parents:
diff changeset
1599 declare
kono
parents:
diff changeset
1600 Uname : constant String :=
kono
parents:
diff changeset
1601 Get_Name_String
kono
parents:
diff changeset
1602 (Unit_Name (Current_Source_Unit));
kono
parents:
diff changeset
1603 Name : String (1 .. Uname'Length - 2);
kono
parents:
diff changeset
1604
kono
parents:
diff changeset
1605 begin
kono
parents:
diff changeset
1606 -- Because Unit_Name includes "%s"/"%b", we need to strip
kono
parents:
diff changeset
1607 -- the last two characters to get the real unit name.
kono
parents:
diff changeset
1608
kono
parents:
diff changeset
1609 Name := Uname (Uname'First .. Uname'Last - 2);
kono
parents:
diff changeset
1610
kono
parents:
diff changeset
1611 if Name = "ada" or else
kono
parents:
diff changeset
1612 Name = "interfaces" or else
kono
parents:
diff changeset
1613 Name = "system"
kono
parents:
diff changeset
1614 then
kono
parents:
diff changeset
1615 Error_Msg
kono
parents:
diff changeset
1616 ("language-defined units cannot be recompiled",
kono
parents:
diff changeset
1617 Sloc (Unit (Comp_Unit_Node)));
kono
parents:
diff changeset
1618
kono
parents:
diff changeset
1619 elsif Name'Length > 4
kono
parents:
diff changeset
1620 and then
kono
parents:
diff changeset
1621 Name (Name'First .. Name'First + 3) = "ada."
kono
parents:
diff changeset
1622 then
kono
parents:
diff changeset
1623 Error_Msg
kono
parents:
diff changeset
1624 ("user-defined descendants of package Ada " &
kono
parents:
diff changeset
1625 "are not allowed",
kono
parents:
diff changeset
1626 Sloc (Unit (Comp_Unit_Node)));
kono
parents:
diff changeset
1627
kono
parents:
diff changeset
1628 elsif Name'Length > 11
kono
parents:
diff changeset
1629 and then
kono
parents:
diff changeset
1630 Name (Name'First .. Name'First + 10) = "interfaces."
kono
parents:
diff changeset
1631 then
kono
parents:
diff changeset
1632 Error_Msg
kono
parents:
diff changeset
1633 ("user-defined descendants of package Interfaces " &
kono
parents:
diff changeset
1634 "are not allowed",
kono
parents:
diff changeset
1635 Sloc (Unit (Comp_Unit_Node)));
kono
parents:
diff changeset
1636
kono
parents:
diff changeset
1637 elsif Name'Length > 7
kono
parents:
diff changeset
1638 and then Name (Name'First .. Name'First + 6) = "system."
kono
parents:
diff changeset
1639 and then Name /= "system.rpc"
kono
parents:
diff changeset
1640 and then
kono
parents:
diff changeset
1641 (Name'Length < 11
kono
parents:
diff changeset
1642 or else Name (Name'First .. Name'First + 10) /=
kono
parents:
diff changeset
1643 "system.rpc.")
kono
parents:
diff changeset
1644 then
kono
parents:
diff changeset
1645 Error_Msg
kono
parents:
diff changeset
1646 ("user-defined descendants of package System " &
kono
parents:
diff changeset
1647 "are not allowed",
kono
parents:
diff changeset
1648 Sloc (Unit (Comp_Unit_Node)));
kono
parents:
diff changeset
1649 end if;
kono
parents:
diff changeset
1650 end;
kono
parents:
diff changeset
1651 end if;
kono
parents:
diff changeset
1652 end;
kono
parents:
diff changeset
1653
kono
parents:
diff changeset
1654 -- All done if at end of file
kono
parents:
diff changeset
1655
kono
parents:
diff changeset
1656 exit when Token = Tok_EOF;
kono
parents:
diff changeset
1657
kono
parents:
diff changeset
1658 -- If we are not at an end of file, it means we are in syntax
kono
parents:
diff changeset
1659 -- check only mode, and we keep the loop going to parse all
kono
parents:
diff changeset
1660 -- remaining units in the file.
kono
parents:
diff changeset
1661
kono
parents:
diff changeset
1662 end if;
kono
parents:
diff changeset
1663
kono
parents:
diff changeset
1664 Restore_Opt_Config_Switches (Save_Config_Switches);
kono
parents:
diff changeset
1665 end loop;
kono
parents:
diff changeset
1666
kono
parents:
diff changeset
1667 -- Now that we have completely parsed the source file, we can complete
kono
parents:
diff changeset
1668 -- the source file table entry.
kono
parents:
diff changeset
1669
kono
parents:
diff changeset
1670 Complete_Source_File_Entry;
kono
parents:
diff changeset
1671
kono
parents:
diff changeset
1672 -- An internal error check, the scope stack should now be empty
kono
parents:
diff changeset
1673
kono
parents:
diff changeset
1674 pragma Assert (Scope.Last = 0);
kono
parents:
diff changeset
1675
kono
parents:
diff changeset
1676 -- Here we make the SCO table entries for the main unit
kono
parents:
diff changeset
1677
kono
parents:
diff changeset
1678 if Generate_SCO then
kono
parents:
diff changeset
1679 SCO_Record_Raw (Main_Unit);
kono
parents:
diff changeset
1680 end if;
kono
parents:
diff changeset
1681
kono
parents:
diff changeset
1682 -- Remaining steps are to create implicit label declarations and to load
kono
parents:
diff changeset
1683 -- required subsidiary sources. These steps are required only if we are
kono
parents:
diff changeset
1684 -- doing semantic checking.
kono
parents:
diff changeset
1685
kono
parents:
diff changeset
1686 if Operating_Mode /= Check_Syntax or else Debug_Flag_F then
kono
parents:
diff changeset
1687 Par.Labl;
kono
parents:
diff changeset
1688 Par.Load;
kono
parents:
diff changeset
1689 end if;
kono
parents:
diff changeset
1690
kono
parents:
diff changeset
1691 -- Restore settings of switches saved on entry
kono
parents:
diff changeset
1692
kono
parents:
diff changeset
1693 Restore_Opt_Config_Switches (Save_Config_Switches);
kono
parents:
diff changeset
1694 Set_Comes_From_Source_Default (False);
kono
parents:
diff changeset
1695 end if;
kono
parents:
diff changeset
1696
kono
parents:
diff changeset
1697 Compiler_State := Analyzing;
kono
parents:
diff changeset
1698 Current_Source_File := No_Source_File;
kono
parents:
diff changeset
1699 return Result;
kono
parents:
diff changeset
1700 end Par;