File : par.adb


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