1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 pragma Style_Checks (All_Checks);
27 -- Turn off subprogram body ordering check. Subprograms are in order by RM
28 -- section rather than alphabetical.
33 -- Local subprograms, used only in this chapter
35 function P_Accept_Alternative return Node_Id;
36 function P_Delay_Alternative return Node_Id;
37 function P_Delay_Relative_Statement return Node_Id;
38 function P_Delay_Until_Statement return Node_Id;
39 function P_Entry_Barrier return Node_Id;
40 function P_Entry_Body_Formal_Part return Node_Id;
41 function P_Entry_Declaration return Node_Id;
42 function P_Entry_Index_Specification return Node_Id;
43 function P_Protected_Definition return Node_Id;
44 function P_Protected_Operation_Declaration_Opt return Node_Id;
45 function P_Protected_Operation_Items return List_Id;
46 function P_Task_Definition return Node_Id;
47 function P_Task_Items return List_Id;
49 -----------------------------
50 -- 9.1 Task (also 10.1.3) --
51 -----------------------------
53 -- TASK_TYPE_DECLARATION ::=
54 -- task type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART]
55 -- [is [new INTERFACE_LIST with] TASK_DEFINITION];
57 -- SINGLE_TASK_DECLARATION ::=
58 -- task DEFINING_IDENTIFIER
59 -- [is [new INTERFACE_LIST with] TASK_DEFINITION];
62 -- task body DEFINING_IDENTIFIER is
65 -- HANDLED_SEQUENCE_OF_STATEMENTS
66 -- end [task_IDENTIFIER]
69 -- task body DEFINING_IDENTIFIER is separate;
71 -- This routine scans out a task declaration, task body, or task stub
73 -- The caller has checked that the initial token is TASK and scanned
74 -- past it, so that Token is set to the token after TASK
76 -- Error recovery: cannot raise Error_Resync
78 function P_Task return Node_Id is
81 Task_Sloc : Source_Ptr;
85 Scope.Table (Scope.Last).Etyp := E_Name;
86 Scope.Table (Scope.Last).Ecol := Start_Column;
87 Scope.Table (Scope.Last).Sloc := Token_Ptr;
88 Scope.Table (Scope.Last).Lreq := False;
89 Task_Sloc := Prev_Token_Ptr;
91 if Token = Tok_Body then
93 Name_Node := P_Defining_Identifier (C_Is);
94 Scope.Table (Scope.Last).Labl := Name_Node;
96 if Token = Tok_Left_Paren then
97 Error_Msg_SC ("discriminant part not allowed in task body");
98 Discard_Junk_List (P_Known_Discriminant_Part_Opt);
105 if Token = Tok_Separate then
106 Scan; -- past SEPARATE
107 Task_Node := New_Node (N_Task_Body_Stub, Task_Sloc);
108 Set_Defining_Identifier (Task_Node, Name_Node);
110 Pop_Scope_Stack; -- remove unused entry
115 Task_Node := New_Node (N_Task_Body, Task_Sloc);
116 Set_Defining_Identifier (Task_Node, Name_Node);
117 Parse_Decls_Begin_End (Task_Node);
122 -- Otherwise we must have a task declaration
125 if Token = Tok_Type then
127 Task_Node := New_Node (N_Task_Type_Declaration, Task_Sloc);
128 Name_Node := P_Defining_Identifier;
129 Set_Defining_Identifier (Task_Node, Name_Node);
130 Scope.Table (Scope.Last).Labl := Name_Node;
131 Set_Discriminant_Specifications
132 (Task_Node, P_Known_Discriminant_Part_Opt);
135 Task_Node := New_Node (N_Single_Task_Declaration, Task_Sloc);
136 Name_Node := P_Defining_Identifier (C_Is);
137 Set_Defining_Identifier (Task_Node, Name_Node);
138 Scope.Table (Scope.Last).Labl := Name_Node;
140 if Token = Tok_Left_Paren then
141 Error_Msg_SC ("discriminant part not allowed for single task");
142 Discard_Junk_List (P_Known_Discriminant_Part_Opt);
146 -- Parse optional task definition. Note that P_Task_Definition scans
147 -- out the semicolon as well as the task definition itself.
149 if Token = Tok_Semicolon then
151 -- A little check, if the next token after semicolon is
152 -- Entry, then surely the semicolon should really be IS
154 Scan; -- past semicolon
156 if Token = Tok_Entry then
157 Error_Msg_SP (""";"" should be IS");
158 Set_Task_Definition (Task_Node, P_Task_Definition);
160 Pop_Scope_Stack; -- Remove unused entry
163 TF_Is; -- must have IS if no semicolon
167 if Token = Tok_New then
170 if Ada_Version < Ada_05 then
171 Error_Msg_SP ("task interface is an Ada 2005 extension");
172 Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
175 Set_Interface_List (Task_Node, New_List);
178 Append (P_Qualified_Simple_Name, Interface_List (Task_Node));
179 exit when Token /= Tok_And;
183 if Token /= Tok_With then
184 Error_Msg_SC ("WITH expected");
189 if Token = Tok_Private then
191 ("PRIVATE not allowed in task type declaration");
195 Set_Task_Definition (Task_Node, P_Task_Definition);
202 --------------------------------
203 -- 9.1 Task Type Declaration --
204 --------------------------------
206 -- Parsed by P_Task (9.1)
208 ----------------------------------
209 -- 9.1 Single Task Declaration --
210 ----------------------------------
212 -- Parsed by P_Task (9.1)
214 --------------------------
215 -- 9.1 Task Definition --
216 --------------------------
218 -- TASK_DEFINITION ::=
222 -- end [task_IDENTIFIER];
224 -- The caller has already made the scope stack entry
226 -- Note: there is a small deviation from official syntax here in that we
227 -- regard the semicolon after end as part of the Task_Definition, and in
228 -- the official syntax, it's part of the enclosing declaration. The reason
229 -- for this deviation is that otherwise the end processing would have to
230 -- be special cased, which would be a nuisance!
232 -- Error recovery: cannot raise Error_Resync
234 function P_Task_Definition return Node_Id is
238 Def_Node := New_Node (N_Task_Definition, Token_Ptr);
239 Set_Visible_Declarations (Def_Node, P_Task_Items);
241 if Token = Tok_Private then
242 Scan; -- past PRIVATE
243 Set_Private_Declarations (Def_Node, P_Task_Items);
245 -- Deal gracefully with multiple PRIVATE parts
247 while Token = Tok_Private loop
248 Error_Msg_SC ("only one private part allowed per task");
249 Scan; -- past PRIVATE
250 Append_List (P_Task_Items, Private_Declarations (Def_Node));
254 End_Statements (Def_Node);
256 end P_Task_Definition;
262 -- TASK_ITEM ::= ENTRY_DECLARATION | REPRESENTATION_CLAUSE
264 -- This subprogram scans a (possibly empty) list of task items and pragmas
266 -- Error recovery: cannot raise Error_Resync
268 -- Note: a pragma can also be returned in this position
270 function P_Task_Items return List_Id is
273 Decl_Sloc : Source_Ptr;
276 -- Get rid of active SIS entry from outer scope. This means we will
277 -- miss some nested cases, but it doesn't seem worth the effort. See
278 -- discussion in Par for further details
280 SIS_Entry_Active := False;
282 -- Loop to scan out task items
287 Decl_Sloc := Token_Ptr;
289 if Token = Tok_Pragma then
290 Append (P_Pragma, Items);
292 -- Ada 2005 (AI-397): Reserved words NOT and OVERRIDING
293 -- may begin an entry declaration.
295 elsif Token = Tok_Entry
296 or else Token = Tok_Not
297 or else Token = Tok_Overriding
299 Append (P_Entry_Declaration, Items);
301 elsif Token = Tok_For then
302 -- Representation clause in task declaration. The only rep
303 -- clause which is legal in a protected is an address clause,
304 -- so that is what we try to scan out.
306 Item_Node := P_Representation_Clause;
308 if Nkind (Item_Node) = N_At_Clause then
309 Append (Item_Node, Items);
311 elsif Nkind (Item_Node) = N_Attribute_Definition_Clause
312 and then Chars (Item_Node) = Name_Address
314 Append (Item_Node, Items);
318 ("the only representation clause " &
319 "allowed here is an address clause!", Decl_Sloc);
322 elsif Token = Tok_Identifier
323 or else Token in Token_Class_Declk
325 Error_Msg_SC ("illegal declaration in task definition");
326 Resync_Past_Semicolon;
340 -- Parsed by P_Task (9.1)
342 ----------------------------------
343 -- 9.4 Protected (also 10.1.3) --
344 ----------------------------------
346 -- PROTECTED_TYPE_DECLARATION ::=
347 -- protected type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART]
348 -- is [new INTERFACE_LIST with] PROTECTED_DEFINITION;
350 -- SINGLE_PROTECTED_DECLARATION ::=
351 -- protected DEFINING_IDENTIFIER
352 -- is [new INTERFACE_LIST with] PROTECTED_DEFINITION;
354 -- PROTECTED_BODY ::=
355 -- protected body DEFINING_IDENTIFIER is
356 -- {PROTECTED_OPERATION_ITEM}
357 -- end [protected_IDENTIFIER];
359 -- PROTECTED_BODY_STUB ::=
360 -- protected body DEFINING_IDENTIFIER is separate;
362 -- This routine scans out a protected declaration, protected body
363 -- or a protected stub.
365 -- The caller has checked that the initial token is PROTECTED and
366 -- scanned past it, so Token is set to the following token.
368 -- Error recovery: cannot raise Error_Resync
370 function P_Protected return Node_Id is
372 Protected_Node : Node_Id;
373 Protected_Sloc : Source_Ptr;
377 Scope.Table (Scope.Last).Etyp := E_Name;
378 Scope.Table (Scope.Last).Ecol := Start_Column;
379 Scope.Table (Scope.Last).Lreq := False;
380 Protected_Sloc := Prev_Token_Ptr;
382 if Token = Tok_Body then
384 Name_Node := P_Defining_Identifier (C_Is);
385 Scope.Table (Scope.Last).Labl := Name_Node;
387 if Token = Tok_Left_Paren then
388 Error_Msg_SC ("discriminant part not allowed in protected body");
389 Discard_Junk_List (P_Known_Discriminant_Part_Opt);
396 if Token = Tok_Separate then
397 Scan; -- past SEPARATE
398 Protected_Node := New_Node (N_Protected_Body_Stub, Protected_Sloc);
399 Set_Defining_Identifier (Protected_Node, Name_Node);
401 Pop_Scope_Stack; -- remove unused entry
406 Protected_Node := New_Node (N_Protected_Body, Protected_Sloc);
407 Set_Defining_Identifier (Protected_Node, Name_Node);
408 Set_Declarations (Protected_Node, P_Protected_Operation_Items);
409 End_Statements (Protected_Node);
412 return Protected_Node;
414 -- Otherwise we must have a protected declaration
417 if Token = Tok_Type then
420 New_Node (N_Protected_Type_Declaration, Protected_Sloc);
421 Name_Node := P_Defining_Identifier (C_Is);
422 Set_Defining_Identifier (Protected_Node, Name_Node);
423 Scope.Table (Scope.Last).Labl := Name_Node;
424 Set_Discriminant_Specifications
425 (Protected_Node, P_Known_Discriminant_Part_Opt);
429 New_Node (N_Single_Protected_Declaration, Protected_Sloc);
430 Name_Node := P_Defining_Identifier (C_Is);
431 Set_Defining_Identifier (Protected_Node, Name_Node);
433 if Token = Tok_Left_Paren then
435 ("discriminant part not allowed for single protected");
436 Discard_Junk_List (P_Known_Discriminant_Part_Opt);
439 Scope.Table (Scope.Last).Labl := Name_Node;
446 if Token = Tok_New then
449 if Ada_Version < Ada_05 then
450 Error_Msg_SP ("task interface is an Ada 2005 extension");
451 Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
454 Set_Interface_List (Protected_Node, New_List);
457 Append (P_Qualified_Simple_Name,
458 Interface_List (Protected_Node));
460 exit when Token /= Tok_And;
464 if Token /= Tok_With then
465 Error_Msg_SC ("WITH expected");
470 if Token = Tok_Private then
472 ("PRIVATE not allowed in protected type declaration");
476 Set_Protected_Definition (Protected_Node, P_Protected_Definition);
477 return Protected_Node;
481 -------------------------------------
482 -- 9.4 Protected Type Declaration --
483 -------------------------------------
485 -- Parsed by P_Protected (9.4)
487 ---------------------------------------
488 -- 9.4 Single Protected Declaration --
489 ---------------------------------------
491 -- Parsed by P_Protected (9.4)
493 -------------------------------
494 -- 9.4 Protected Definition --
495 -------------------------------
497 -- PROTECTED_DEFINITION ::=
498 -- {PROTECTED_OPERATION_DECLARATION}
500 -- {PROTECTED_ELEMENT_DECLARATION}]
501 -- end [protected_IDENTIFIER]
503 -- PROTECTED_ELEMENT_DECLARATION ::=
504 -- PROTECTED_OPERATION_DECLARATION
505 -- | COMPONENT_DECLARATION
507 -- The caller has already established the scope stack entry
509 -- Error recovery: cannot raise Error_Resync
511 function P_Protected_Definition return Node_Id is
516 Def_Node := New_Node (N_Protected_Definition, Token_Ptr);
518 -- Get rid of active SIS entry from outer scope. This means we will
519 -- miss some nested cases, but it doesn't seem worth the effort. See
520 -- discussion in Par for further details
522 SIS_Entry_Active := False;
524 -- Loop to scan visible declarations (protected operation declarations)
526 Set_Visible_Declarations (Def_Node, New_List);
529 Item_Node := P_Protected_Operation_Declaration_Opt;
530 exit when No (Item_Node);
531 Append (Item_Node, Visible_Declarations (Def_Node));
534 -- Deal with PRIVATE part (including graceful handling
535 -- of multiple PRIVATE parts).
537 Private_Loop : while Token = Tok_Private loop
538 if No (Private_Declarations (Def_Node)) then
539 Set_Private_Declarations (Def_Node, New_List);
541 Error_Msg_SC ("duplicate private part");
544 Scan; -- past PRIVATE
546 Declaration_Loop : loop
547 if Token = Tok_Identifier then
548 P_Component_Items (Private_Declarations (Def_Node));
550 Item_Node := P_Protected_Operation_Declaration_Opt;
551 exit Declaration_Loop when No (Item_Node);
552 Append (Item_Node, Private_Declarations (Def_Node));
554 end loop Declaration_Loop;
555 end loop Private_Loop;
557 End_Statements (Def_Node);
559 end P_Protected_Definition;
561 ------------------------------------------
562 -- 9.4 Protected Operation Declaration --
563 ------------------------------------------
565 -- PROTECTED_OPERATION_DECLARATION ::=
566 -- SUBPROGRAM_DECLARATION
567 -- | ENTRY_DECLARATION
568 -- | REPRESENTATION_CLAUSE
570 -- Error recovery: cannot raise Error_Resync
572 -- Note: a pragma can also be returned in this position
574 -- We are not currently permitting representation clauses to appear as
575 -- protected operation declarations, do we have to rethink this???
577 function P_Protected_Operation_Declaration_Opt return Node_Id is
581 function P_Entry_Or_Subprogram_With_Indicator return Node_Id;
582 -- Ada 2005 (AI-397): Parse an entry or a subprogram with an overriding
583 -- indicator. The caller has checked that the initial token is NOT or
586 ------------------------------------------
587 -- P_Entry_Or_Subprogram_With_Indicator --
588 ------------------------------------------
590 function P_Entry_Or_Subprogram_With_Indicator return Node_Id is
591 Decl : Node_Id := Error;
592 Is_Overriding : Boolean := False;
593 Not_Overriding : Boolean := False;
596 if Token = Tok_Not then
599 if Token = Tok_Overriding then
600 Scan; -- past OVERRIDING
601 Not_Overriding := True;
603 Error_Msg_SC ("OVERRIDING expected!");
607 Scan; -- past OVERRIDING
608 Is_Overriding := True;
611 if (Is_Overriding or else Not_Overriding) then
612 if Ada_Version < Ada_05 then
613 Error_Msg_SP (" overriding indicator is an Ada 2005 extension");
614 Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
616 elsif Token = Tok_Entry then
617 Decl := P_Entry_Declaration;
619 Set_Must_Override (Decl, Is_Overriding);
620 Set_Must_Not_Override (Decl, Not_Overriding);
622 elsif Token = Tok_Function or else Token = Tok_Procedure then
623 Decl := P_Subprogram (Pf_Decl);
625 Set_Must_Override (Specification (Decl), Is_Overriding);
626 Set_Must_Not_Override (Specification (Decl), Not_Overriding);
629 Error_Msg_SC ("ENTRY, FUNCTION or PROCEDURE expected!");
634 end P_Entry_Or_Subprogram_With_Indicator;
636 -- Start of processing for P_Protected_Operation_Declaration_Opt
639 -- This loop runs more than once only when a junk declaration
643 if Token = Tok_Pragma then
646 elsif Token = Tok_Not or else Token = Tok_Overriding then
647 return P_Entry_Or_Subprogram_With_Indicator;
649 elsif Token = Tok_Entry then
650 return P_Entry_Declaration;
652 elsif Token = Tok_Function or else Token = Tok_Procedure then
653 return P_Subprogram (Pf_Decl);
655 elsif Token = Tok_Identifier then
658 Skip_Declaration (L);
660 if Nkind (First (L)) = N_Object_Declaration then
662 ("component must be declared in private part of " &
663 "protected type", P);
666 ("illegal declaration in protected definition", P);
669 elsif Token in Token_Class_Declk then
670 Error_Msg_SC ("illegal declaration in protected definition");
671 Resync_Past_Semicolon;
673 -- Return now to avoid cascaded messages if next declaration
674 -- is a valid component declaration.
678 elsif Token = Tok_For then
680 ("representation clause not allowed in protected definition");
681 Resync_Past_Semicolon;
687 end P_Protected_Operation_Declaration_Opt;
689 -----------------------------------
690 -- 9.4 Protected Operation Item --
691 -----------------------------------
693 -- PROTECTED_OPERATION_ITEM ::=
694 -- SUBPROGRAM_DECLARATION
697 -- | REPRESENTATION_CLAUSE
699 -- This procedure parses and returns a list of protected operation items
701 -- We are not currently permitting representation clauses to appear
702 -- as protected operation items, do we have to rethink this???
704 function P_Protected_Operation_Items return List_Id is
708 Item_List := New_List;
711 if Token = Tok_Entry or else Bad_Spelling_Of (Tok_Entry) then
712 Append (P_Entry_Body, Item_List);
714 elsif Token = Tok_Function or else Bad_Spelling_Of (Tok_Function)
716 Token = Tok_Procedure or else Bad_Spelling_Of (Tok_Procedure)
718 Append (P_Subprogram (Pf_Decl_Pbod), Item_List);
720 elsif Token = Tok_Pragma or else Bad_Spelling_Of (Tok_Pragma) then
721 P_Pragmas_Opt (Item_List);
723 elsif Token = Tok_Private or else Bad_Spelling_Of (Tok_Private) then
724 Error_Msg_SC ("PRIVATE not allowed in protected body");
725 Scan; -- past PRIVATE
727 elsif Token = Tok_Identifier then
729 ("all components must be declared in spec!");
730 Resync_Past_Semicolon;
732 elsif Token in Token_Class_Declk then
733 Error_Msg_SC ("this declaration not allowed in protected body");
734 Resync_Past_Semicolon;
742 end P_Protected_Operation_Items;
744 ------------------------------
745 -- 9.5.2 Entry Declaration --
746 ------------------------------
748 -- ENTRY_DECLARATION ::=
749 -- [OVERRIDING_INDICATOR]
750 -- entry DEFINING_IDENTIFIER [(DISCRETE_SUBTYPE_DEFINITION)]
751 -- PARAMETER_PROFILE;
753 -- The caller has checked that the initial token is ENTRY, NOT or
756 -- Error recovery: cannot raise Error_Resync
758 function P_Entry_Declaration return Node_Id is
760 Scan_State : Saved_Scan_State;
762 -- Flags for optional overriding indication. Two flags are needed,
763 -- to distinguish positive and negative overriding indicators from
764 -- the absence of any indicator.
766 Is_Overriding : Boolean := False;
767 Not_Overriding : Boolean := False;
770 -- Ada 2005 (AI-397): Scan leading overriding indicator
772 if Token = Tok_Not then
775 if Token = Tok_Overriding then
776 Scan; -- part OVERRIDING
777 Not_Overriding := True;
779 Error_Msg_SC ("OVERRIDING expected!");
782 elsif Token = Tok_Overriding then
783 Scan; -- part OVERRIDING
784 Is_Overriding := True;
787 if (Is_Overriding or else Not_Overriding) then
788 if Ada_Version < Ada_05 then
789 Error_Msg_SP (" overriding indicator is an Ada 2005 extension");
790 Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
792 elsif Token /= Tok_Entry then
793 Error_Msg_SC ("ENTRY expected!");
797 Decl_Node := New_Node (N_Entry_Declaration, Token_Ptr);
800 Set_Defining_Identifier
801 (Decl_Node, P_Defining_Identifier (C_Left_Paren_Semicolon));
803 -- If left paren, could be (Discrete_Subtype_Definition) or Formal_Part
805 if Token = Tok_Left_Paren then
808 -- If identifier after left paren, could still be either
810 if Token = Tok_Identifier then
811 Save_Scan_State (Scan_State); -- at Id
814 -- If comma or colon after Id, must be Formal_Part
816 if Token = Tok_Comma or else Token = Tok_Colon then
817 Restore_Scan_State (Scan_State); -- to Id
818 Set_Parameter_Specifications (Decl_Node, P_Formal_Part);
820 -- Else if Id wi no comma or colon, must be discrete subtype defn
823 Restore_Scan_State (Scan_State); -- to Id
824 Set_Discrete_Subtype_Definition
825 (Decl_Node, P_Discrete_Subtype_Definition);
827 Set_Parameter_Specifications (Decl_Node, P_Parameter_Profile);
830 -- If no Id, must be discrete subtype definition
833 Set_Discrete_Subtype_Definition
834 (Decl_Node, P_Discrete_Subtype_Definition);
836 Set_Parameter_Specifications (Decl_Node, P_Parameter_Profile);
840 if Is_Overriding then
841 Set_Must_Override (Decl_Node);
842 elsif Not_Overriding then
843 Set_Must_Not_Override (Decl_Node);
846 -- Error recovery check for illegal return
848 if Token = Tok_Return then
849 Error_Msg_SC ("entry cannot have return value!");
851 Discard_Junk_Node (P_Subtype_Indication);
854 -- Error recovery check for improper use of entry barrier in spec
856 if Token = Tok_When then
857 Error_Msg_SC ("barrier not allowed here (belongs in body)");
859 Discard_Junk_Node (P_Expression_No_Right_Paren);
867 Resync_Past_Semicolon;
869 end P_Entry_Declaration;
871 -----------------------------
872 -- 9.5.2 Accept Statement --
873 -----------------------------
875 -- ACCEPT_STATEMENT ::=
876 -- accept entry_DIRECT_NAME
877 -- [(ENTRY_INDEX)] PARAMETER_PROFILE [do
878 -- HANDLED_SEQUENCE_OF_STATEMENTS
879 -- end [entry_IDENTIFIER]];
881 -- The caller has checked that the initial token is ACCEPT
883 -- Error recovery: cannot raise Error_Resync. If an error occurs, the
884 -- scan is resynchronized past the next semicolon and control returns.
886 function P_Accept_Statement return Node_Id is
887 Scan_State : Saved_Scan_State;
888 Accept_Node : Node_Id;
893 Scope.Table (Scope.Last).Sloc := Token_Ptr;
894 Scope.Table (Scope.Last).Ecol := Start_Column;
896 Accept_Node := New_Node (N_Accept_Statement, Token_Ptr);
898 Scope.Table (Scope.Last).Labl := Token_Node;
900 Set_Entry_Direct_Name (Accept_Node, P_Identifier (C_Do));
902 -- Left paren could be (Entry_Index) or Formal_Part, determine which
904 if Token = Tok_Left_Paren then
905 Save_Scan_State (Scan_State); -- at left paren
906 Scan; -- past left paren
908 -- If first token after left paren not identifier, then Entry_Index
910 if Token /= Tok_Identifier then
911 Set_Entry_Index (Accept_Node, P_Expression);
913 Set_Parameter_Specifications (Accept_Node, P_Parameter_Profile);
915 -- First token after left paren is identifier, could be either case
917 else -- Token = Tok_Identifier
918 Scan; -- past identifier
920 -- If identifier followed by comma or colon, must be Formal_Part
922 if Token = Tok_Comma or else Token = Tok_Colon then
923 Restore_Scan_State (Scan_State); -- to left paren
924 Set_Parameter_Specifications (Accept_Node, P_Parameter_Profile);
926 -- If identifier not followed by comma/colon, must be entry index
929 Restore_Scan_State (Scan_State); -- to left paren
930 Scan; -- past left paren (again!)
931 Set_Entry_Index (Accept_Node, P_Expression);
933 Set_Parameter_Specifications (Accept_Node, P_Parameter_Profile);
938 -- Scan out DO if present
940 if Token = Tok_Do then
941 Scope.Table (Scope.Last).Etyp := E_Name;
942 Scope.Table (Scope.Last).Lreq := False;
944 Hand_Seq := P_Handled_Sequence_Of_Statements;
945 Set_Handled_Statement_Sequence (Accept_Node, Hand_Seq);
946 End_Statements (Handled_Statement_Sequence (Accept_Node));
948 -- Exception handlers not allowed in Ada 95 node
950 if Present (Exception_Handlers (Hand_Seq)) then
951 if Ada_Version = Ada_83 then
953 ("(Ada 83) exception handlers in accept not allowed",
954 First_Non_Pragma (Exception_Handlers (Hand_Seq)));
959 Pop_Scope_Stack; -- discard unused entry
965 -- If error, resynchronize past semicolon
969 Resync_Past_Semicolon;
970 Pop_Scope_Stack; -- discard unused entry
973 end P_Accept_Statement;
975 ------------------------
976 -- 9.5.2 Entry Index --
977 ------------------------
979 -- Parsed by P_Expression (4.4)
981 -----------------------
982 -- 9.5.2 Entry Body --
983 -----------------------
986 -- entry DEFINING_IDENTIFIER ENTRY_BODY_FORMAL_PART ENTRY_BARRIER is
989 -- HANDLED_SEQUENCE_OF_STATEMENTS
990 -- end [entry_IDENTIFIER];
992 -- The caller has checked that the initial token is ENTRY
994 -- Error_Recovery: cannot raise Error_Resync
996 function P_Entry_Body return Node_Id is
997 Entry_Node : Node_Id;
998 Formal_Part_Node : Node_Id;
1003 Entry_Node := New_Node (N_Entry_Body, Token_Ptr);
1006 Scope.Table (Scope.Last).Ecol := Start_Column;
1007 Scope.Table (Scope.Last).Lreq := False;
1008 Scope.Table (Scope.Last).Etyp := E_Name;
1010 Name_Node := P_Defining_Identifier;
1011 Set_Defining_Identifier (Entry_Node, Name_Node);
1012 Scope.Table (Scope.Last).Labl := Name_Node;
1014 Formal_Part_Node := P_Entry_Body_Formal_Part;
1015 Set_Entry_Body_Formal_Part (Entry_Node, Formal_Part_Node);
1017 Set_Condition (Formal_Part_Node, P_Entry_Barrier);
1018 Parse_Decls_Begin_End (Entry_Node);
1022 -----------------------------------
1023 -- 9.5.2 Entry Body Formal Part --
1024 -----------------------------------
1026 -- ENTRY_BODY_FORMAL_PART ::=
1027 -- [(ENTRY_INDEX_SPECIFICATION)] [PARAMETER_PART]
1029 -- Error_Recovery: cannot raise Error_Resync
1031 function P_Entry_Body_Formal_Part return Node_Id is
1032 Fpart_Node : Node_Id;
1033 Scan_State : Saved_Scan_State;
1036 Fpart_Node := New_Node (N_Entry_Body_Formal_Part, Token_Ptr);
1038 -- See if entry index specification present, and if so parse it
1040 if Token = Tok_Left_Paren then
1041 Save_Scan_State (Scan_State); -- at left paren
1042 Scan; -- past left paren
1044 if Token = Tok_For then
1045 Set_Entry_Index_Specification
1046 (Fpart_Node, P_Entry_Index_Specification);
1049 Restore_Scan_State (Scan_State); -- to left paren
1052 -- Check for (common?) case of left paren omitted before FOR. This
1053 -- is a tricky case, because the corresponding missing left paren
1054 -- can cause real havoc if a formal part is present which gets
1055 -- treated as part of the discrete subtype definition of the
1056 -- entry index specification, so just give error and resynchronize
1058 elsif Token = Tok_For then
1059 T_Left_Paren; -- to give error message
1063 Set_Parameter_Specifications (Fpart_Node, P_Parameter_Profile);
1065 end P_Entry_Body_Formal_Part;
1067 --------------------------
1068 -- 9.5.2 Entry Barrier --
1069 --------------------------
1071 -- ENTRY_BARRIER ::= when CONDITION
1073 -- Error_Recovery: cannot raise Error_Resync
1075 function P_Entry_Barrier return Node_Id is
1079 if Token = Tok_When then
1081 Bnode := P_Expression_No_Right_Paren;
1083 if Token = Tok_Colon_Equal then
1084 Error_Msg_SC (""":="" should be ""=""");
1086 Bnode := P_Expression_No_Right_Paren;
1090 T_When; -- to give error message
1096 end P_Entry_Barrier;
1098 --------------------------------------
1099 -- 9.5.2 Entry Index Specification --
1100 --------------------------------------
1102 -- ENTRY_INDEX_SPECIFICATION ::=
1103 -- for DEFINING_IDENTIFIER in DISCRETE_SUBTYPE_DEFINITION
1105 -- Error recovery: can raise Error_Resync
1107 function P_Entry_Index_Specification return Node_Id is
1108 Iterator_Node : Node_Id;
1111 Iterator_Node := New_Node (N_Entry_Index_Specification, Token_Ptr);
1113 Set_Defining_Identifier (Iterator_Node, P_Defining_Identifier (C_In));
1115 Set_Discrete_Subtype_Definition
1116 (Iterator_Node, P_Discrete_Subtype_Definition);
1117 return Iterator_Node;
1118 end P_Entry_Index_Specification;
1120 ---------------------------------
1121 -- 9.5.3 Entry Call Statement --
1122 ---------------------------------
1124 -- Parsed by P_Name (4.1). Within a select, an entry call is parsed
1125 -- by P_Select_Statement (9.7)
1127 ------------------------------
1128 -- 9.5.4 Requeue Statement --
1129 ------------------------------
1131 -- REQUEUE_STATEMENT ::= requeue entry_NAME [with abort];
1133 -- The caller has checked that the initial token is requeue
1135 -- Error recovery: can raise Error_Resync
1137 function P_Requeue_Statement return Node_Id is
1138 Requeue_Node : Node_Id;
1141 Requeue_Node := New_Node (N_Requeue_Statement, Token_Ptr);
1142 Scan; -- past REQUEUE
1143 Set_Name (Requeue_Node, P_Name);
1145 if Token = Tok_With then
1148 Set_Abort_Present (Requeue_Node, True);
1152 return Requeue_Node;
1153 end P_Requeue_Statement;
1155 --------------------------
1156 -- 9.6 Delay Statement --
1157 --------------------------
1159 -- DELAY_STATEMENT ::=
1160 -- DELAY_UNTIL_STATEMENT
1161 -- | DELAY_RELATIVE_STATEMENT
1163 -- The caller has checked that the initial token is DELAY
1165 -- Error recovery: cannot raise Error_Resync
1167 function P_Delay_Statement return Node_Id is
1171 -- The following check for delay until misused in Ada 83 doesn't catch
1172 -- all cases, but it's good enough to catch most of them!
1174 if Token_Name = Name_Until then
1175 Check_95_Keyword (Tok_Until, Tok_Left_Paren);
1176 Check_95_Keyword (Tok_Until, Tok_Identifier);
1179 if Token = Tok_Until then
1180 return P_Delay_Until_Statement;
1182 return P_Delay_Relative_Statement;
1184 end P_Delay_Statement;
1186 --------------------------------
1187 -- 9.6 Delay Until Statement --
1188 --------------------------------
1190 -- DELAY_UNTIL_STATEMENT ::= delay until delay_EXPRESSION;
1192 -- The caller has checked that the initial token is DELAY, scanned it
1193 -- out and checked that the current token is UNTIL
1195 -- Error recovery: cannot raise Error_Resync
1197 function P_Delay_Until_Statement return Node_Id is
1198 Delay_Node : Node_Id;
1201 Delay_Node := New_Node (N_Delay_Until_Statement, Prev_Token_Ptr);
1203 Set_Expression (Delay_Node, P_Expression_No_Right_Paren);
1206 end P_Delay_Until_Statement;
1208 -----------------------------------
1209 -- 9.6 Delay Relative Statement --
1210 -----------------------------------
1212 -- DELAY_RELATIVE_STATEMENT ::= delay delay_EXPRESSION;
1214 -- The caller has checked that the initial token is DELAY, scanned it
1215 -- out and determined that the current token is not UNTIL
1217 -- Error recovery: cannot raise Error_Resync
1219 function P_Delay_Relative_Statement return Node_Id is
1220 Delay_Node : Node_Id;
1223 Delay_Node := New_Node (N_Delay_Relative_Statement, Prev_Token_Ptr);
1224 Set_Expression (Delay_Node, P_Expression_No_Right_Paren);
1225 Check_Simple_Expression_In_Ada_83 (Expression (Delay_Node));
1228 end P_Delay_Relative_Statement;
1230 ---------------------------
1231 -- 9.7 Select Statement --
1232 ---------------------------
1234 -- SELECT_STATEMENT ::=
1236 -- | TIMED_ENTRY_CALL
1237 -- | CONDITIONAL_ENTRY_CALL
1238 -- | ASYNCHRONOUS_SELECT
1240 -- SELECTIVE_ACCEPT ::=
1243 -- SELECT_ALTERNATIVE
1246 -- SELECT_ALTERNATIVE
1248 -- SEQUENCE_OF_STATEMENTS]
1251 -- GUARD ::= when CONDITION =>
1253 -- Note: the guard preceding a select alternative is included as part
1254 -- of the node generated for a selective accept alternative.
1256 -- SELECT_ALTERNATIVE ::=
1257 -- ACCEPT_ALTERNATIVE
1258 -- | DELAY_ALTERNATIVE
1259 -- | TERMINATE_ALTERNATIVE
1261 -- TIMED_ENTRY_CALL ::=
1263 -- ENTRY_CALL_ALTERNATIVE
1265 -- DELAY_ALTERNATIVE
1268 -- CONDITIONAL_ENTRY_CALL ::=
1270 -- ENTRY_CALL_ALTERNATIVE
1272 -- SEQUENCE_OF_STATEMENTS
1275 -- ENTRY_CALL_ALTERNATIVE ::=
1276 -- ENTRY_CALL_STATEMENT [SEQUENCE_OF_STATEMENTS]
1278 -- ASYNCHRONOUS_SELECT ::=
1280 -- TRIGGERING_ALTERNATIVE
1285 -- TRIGGERING_ALTERNATIVE ::=
1286 -- TRIGGERING_STATEMENT [SEQUENCE_OF_STATEMENTS]
1288 -- TRIGGERING_STATEMENT ::= ENTRY_CALL_STATEMENT | DELAY_STATEMENT
1290 -- The caller has checked that the initial token is SELECT
1292 -- Error recovery: can raise Error_Resync
1294 function P_Select_Statement return Node_Id is
1295 Select_Node : Node_Id;
1296 Select_Sloc : Source_Ptr;
1297 Stmnt_Sloc : Source_Ptr;
1298 Ecall_Node : Node_Id;
1299 Alternative : Node_Id;
1300 Select_Pragmas : List_Id;
1301 Alt_Pragmas : List_Id;
1302 Statement_List : List_Id;
1304 Cond_Expr : Node_Id;
1305 Delay_Stmnt : Node_Id;
1309 Scope.Table (Scope.Last).Etyp := E_Select;
1310 Scope.Table (Scope.Last).Ecol := Start_Column;
1311 Scope.Table (Scope.Last).Sloc := Token_Ptr;
1312 Scope.Table (Scope.Last).Labl := Error;
1314 Select_Sloc := Token_Ptr;
1315 Scan; -- past SELECT
1316 Stmnt_Sloc := Token_Ptr;
1317 Select_Pragmas := P_Pragmas_Opt;
1319 -- If first token after select is designator, then we have an entry
1320 -- call, which must be the start of a conditional entry call, timed
1321 -- entry call or asynchronous select
1323 if Token in Token_Class_Desig then
1325 -- Scan entry call statement
1328 Ecall_Node := P_Name;
1330 -- ?? The following two clauses exactly parallel code in ch5
1331 -- and should be commoned sometime
1333 if Nkind (Ecall_Node) = N_Indexed_Component then
1335 Prefix_Node : constant Node_Id := Prefix (Ecall_Node);
1336 Exprs_Node : constant List_Id := Expressions (Ecall_Node);
1339 Change_Node (Ecall_Node, N_Procedure_Call_Statement);
1340 Set_Name (Ecall_Node, Prefix_Node);
1341 Set_Parameter_Associations (Ecall_Node, Exprs_Node);
1344 elsif Nkind (Ecall_Node) = N_Function_Call then
1346 Fname_Node : constant Node_Id := Name (Ecall_Node);
1347 Params_List : constant List_Id :=
1348 Parameter_Associations (Ecall_Node);
1351 Change_Node (Ecall_Node, N_Procedure_Call_Statement);
1352 Set_Name (Ecall_Node, Fname_Node);
1353 Set_Parameter_Associations (Ecall_Node, Params_List);
1356 elsif Nkind (Ecall_Node) = N_Identifier
1357 or else Nkind (Ecall_Node) = N_Selected_Component
1359 -- Case of a call to a parameterless entry
1362 C_Node : constant Node_Id :=
1363 New_Node (N_Procedure_Call_Statement, Stmnt_Sloc);
1365 Set_Name (C_Node, Ecall_Node);
1366 Set_Parameter_Associations (C_Node, No_List);
1367 Ecall_Node := C_Node;
1374 when Error_Resync =>
1375 Resync_Past_Semicolon;
1379 Statement_List := P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm);
1381 -- OR follows, we have a timed entry call
1383 if Token = Tok_Or then
1385 Alt_Pragmas := P_Pragmas_Opt;
1387 Select_Node := New_Node (N_Timed_Entry_Call, Select_Sloc);
1388 Set_Entry_Call_Alternative (Select_Node,
1389 Make_Entry_Call_Alternative (Stmnt_Sloc,
1390 Entry_Call_Statement => Ecall_Node,
1391 Pragmas_Before => Select_Pragmas,
1392 Statements => Statement_List));
1394 -- Only possibility is delay alternative. If we have anything
1395 -- else, give message, and treat as conditional entry call.
1397 if Token /= Tok_Delay then
1399 ("only allowed alternative in timed entry call is delay!");
1400 Discard_Junk_List (P_Sequence_Of_Statements (SS_Sreq));
1401 Set_Delay_Alternative (Select_Node, Error);
1404 Set_Delay_Alternative (Select_Node, P_Delay_Alternative);
1406 (Delay_Alternative (Select_Node), Alt_Pragmas);
1409 -- ELSE follows, we have a conditional entry call
1411 elsif Token = Tok_Else then
1413 Select_Node := New_Node (N_Conditional_Entry_Call, Select_Sloc);
1415 Set_Entry_Call_Alternative (Select_Node,
1416 Make_Entry_Call_Alternative (Stmnt_Sloc,
1417 Entry_Call_Statement => Ecall_Node,
1418 Pragmas_Before => Select_Pragmas,
1419 Statements => Statement_List));
1422 (Select_Node, P_Sequence_Of_Statements (SS_Sreq));
1424 -- Only remaining case is THEN ABORT (asynchronous select)
1426 elsif Token = Tok_Abort then
1428 Make_Asynchronous_Select (Select_Sloc,
1429 Triggering_Alternative =>
1430 Make_Triggering_Alternative (Stmnt_Sloc,
1431 Triggering_Statement => Ecall_Node,
1432 Pragmas_Before => Select_Pragmas,
1433 Statements => Statement_List),
1434 Abortable_Part => P_Abortable_Part);
1439 if Ada_Version = Ada_83 then
1440 Error_Msg_BC ("OR or ELSE expected");
1442 Error_Msg_BC ("OR or ELSE or THEN ABORT expected");
1445 Select_Node := Error;
1450 -- Here we have a selective accept or an an asynchronous select (first
1451 -- token after SELECT is other than a designator token).
1454 -- If we have delay with no guard, could be asynchronous select
1456 if Token = Tok_Delay then
1457 Delay_Stmnt := P_Delay_Statement;
1458 Statement_List := P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm);
1460 -- Asynchronous select
1462 if Token = Tok_Abort then
1464 Make_Asynchronous_Select (Select_Sloc,
1465 Triggering_Alternative =>
1466 Make_Triggering_Alternative (Stmnt_Sloc,
1467 Triggering_Statement => Delay_Stmnt,
1468 Pragmas_Before => Select_Pragmas,
1469 Statements => Statement_List),
1470 Abortable_Part => P_Abortable_Part);
1475 -- Delay which was not an asynchronous select. Must be a selective
1476 -- accept, and since at least one accept statement is required,
1477 -- we must have at least one OR phrase present.
1480 Alt_List := New_List (
1481 Make_Delay_Alternative (Stmnt_Sloc,
1482 Delay_Statement => Delay_Stmnt,
1483 Pragmas_Before => Select_Pragmas,
1484 Statements => Statement_List));
1486 Alt_Pragmas := P_Pragmas_Opt;
1489 -- If not a delay statement, then must be another possibility for
1490 -- a selective accept alternative, or perhaps a guard is present
1493 Alt_List := New_List;
1494 Alt_Pragmas := Select_Pragmas;
1497 Select_Node := New_Node (N_Selective_Accept, Select_Sloc);
1498 Set_Select_Alternatives (Select_Node, Alt_List);
1500 -- Scan out selective accept alternatives. On entry to this loop,
1501 -- we are just past a SELECT or OR token, and any pragmas that
1502 -- immediately follow the SELECT or OR are in Alt_Pragmas.
1505 if Token = Tok_When then
1507 if Present (Alt_Pragmas) then
1508 Error_Msg_SC ("pragmas may not precede guard");
1512 Cond_Expr := P_Expression_No_Right_Paren;
1514 Alt_Pragmas := P_Pragmas_Opt;
1520 if Token = Tok_Accept then
1521 Alternative := P_Accept_Alternative;
1523 -- Check for junk attempt at asynchronous select using
1524 -- an Accept alternative as the triggering statement
1526 if Token = Tok_Abort
1527 and then Is_Empty_List (Alt_List)
1528 and then No (Cond_Expr)
1531 ("triggering statement must be entry call or delay",
1532 Sloc (Alternative));
1533 Scan; -- past junk ABORT
1534 Discard_Junk_List (P_Sequence_Of_Statements (SS_Sreq));
1539 elsif Token = Tok_Delay then
1540 Alternative := P_Delay_Alternative;
1542 elsif Token = Tok_Terminate then
1543 Alternative := P_Terminate_Alternative;
1547 ("select alternative (ACCEPT, ABORT, DELAY) expected");
1548 Alternative := Error;
1550 if Token = Tok_Semicolon then
1551 Scan; -- past junk semicolon
1555 -- THEN ABORT at this stage is just junk
1557 if Token = Tok_Abort then
1558 Error_Msg_SP ("misplaced `THEN ABORT`");
1559 Scan; -- past junk ABORT
1560 Discard_Junk_List (P_Sequence_Of_Statements (SS_Sreq));
1565 if Alternative /= Error then
1566 Set_Condition (Alternative, Cond_Expr);
1567 Set_Pragmas_Before (Alternative, Alt_Pragmas);
1568 Append (Alternative, Alt_List);
1571 exit when Token /= Tok_Or;
1575 Alt_Pragmas := P_Pragmas_Opt;
1578 if Token = Tok_Else then
1581 (Select_Node, P_Sequence_Of_Statements (SS_Ortm_Sreq));
1583 if Token = Tok_Or then
1584 Error_Msg_SC ("select alternative cannot follow else part!");
1592 end P_Select_Statement;
1594 -----------------------------
1595 -- 9.7.1 Selective Accept --
1596 -----------------------------
1598 -- Parsed by P_Select_Statement (9.7)
1604 -- Parsed by P_Select_Statement (9.7)
1606 -------------------------------
1607 -- 9.7.1 Select Alternative --
1608 -------------------------------
1610 -- SELECT_ALTERNATIVE ::=
1611 -- ACCEPT_ALTERNATIVE
1612 -- | DELAY_ALTERNATIVE
1613 -- | TERMINATE_ALTERNATIVE
1615 -- Note: the guard preceding a select alternative is included as part
1616 -- of the node generated for a selective accept alternative.
1618 -- Error recovery: cannot raise Error_Resync
1620 -------------------------------
1621 -- 9.7.1 Accept Alternative --
1622 -------------------------------
1624 -- ACCEPT_ALTERNATIVE ::=
1625 -- ACCEPT_STATEMENT [SEQUENCE_OF_STATEMENTS]
1627 -- Error_Recovery: Cannot raise Error_Resync
1629 -- Note: the caller is responsible for setting the Pragmas_Before
1630 -- field of the returned N_Terminate_Alternative node.
1632 function P_Accept_Alternative return Node_Id is
1633 Accept_Alt_Node : Node_Id;
1636 Accept_Alt_Node := New_Node (N_Accept_Alternative, Token_Ptr);
1637 Set_Accept_Statement (Accept_Alt_Node, P_Accept_Statement);
1639 -- Note: the reason that we accept THEN ABORT as a terminator for
1640 -- the sequence of statements is for error recovery which allows
1641 -- for misuse of an accept statement as a triggering statememt.
1644 (Accept_Alt_Node, P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm));
1645 return Accept_Alt_Node;
1646 end P_Accept_Alternative;
1648 ------------------------------
1649 -- 9.7.1 Delay Alternative --
1650 ------------------------------
1652 -- DELAY_ALTERNATIVE ::=
1653 -- DELAY_STATEMENT [SEQUENCE_OF_STATEMENTS]
1655 -- Error_Recovery: Cannot raise Error_Resync
1657 -- Note: the caller is responsible for setting the Pragmas_Before
1658 -- field of the returned N_Terminate_Alternative node.
1660 function P_Delay_Alternative return Node_Id is
1661 Delay_Alt_Node : Node_Id;
1664 Delay_Alt_Node := New_Node (N_Delay_Alternative, Token_Ptr);
1665 Set_Delay_Statement (Delay_Alt_Node, P_Delay_Statement);
1667 -- Note: the reason that we accept THEN ABORT as a terminator for
1668 -- the sequence of statements is for error recovery which allows
1669 -- for misuse of an accept statement as a triggering statememt.
1672 (Delay_Alt_Node, P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm));
1673 return Delay_Alt_Node;
1674 end P_Delay_Alternative;
1676 ----------------------------------
1677 -- 9.7.1 Terminate Alternative --
1678 ----------------------------------
1680 -- TERMINATE_ALTERNATIVE ::= terminate;
1682 -- Error_Recovery: Cannot raise Error_Resync
1684 -- Note: the caller is responsible for setting the Pragmas_Before
1685 -- field of the returned N_Terminate_Alternative node.
1687 function P_Terminate_Alternative return Node_Id is
1688 Terminate_Alt_Node : Node_Id;
1691 Terminate_Alt_Node := New_Node (N_Terminate_Alternative, Token_Ptr);
1692 Scan; -- past TERMINATE
1695 -- For all other select alternatives, the sequence of statements
1696 -- after the alternative statement will swallow up any pragmas
1697 -- coming in this position. But the terminate alternative has no
1698 -- sequence of statements, so the pragmas here must be treated
1701 Set_Pragmas_After (Terminate_Alt_Node, P_Pragmas_Opt);
1702 return Terminate_Alt_Node;
1703 end P_Terminate_Alternative;
1705 -----------------------------
1706 -- 9.7.2 Timed Entry Call --
1707 -----------------------------
1709 -- Parsed by P_Select_Statement (9.7)
1711 -----------------------------------
1712 -- 9.7.2 Entry Call Alternative --
1713 -----------------------------------
1715 -- Parsed by P_Select_Statement (9.7)
1717 -----------------------------------
1718 -- 9.7.3 Conditional Entry Call --
1719 -----------------------------------
1721 -- Parsed by P_Select_Statement (9.7)
1723 --------------------------------
1724 -- 9.7.4 Asynchronous Select --
1725 --------------------------------
1727 -- Parsed by P_Select_Statement (9.7)
1729 -----------------------------------
1730 -- 9.7.4 Triggering Alternative --
1731 -----------------------------------
1733 -- Parsed by P_Select_Statement (9.7)
1735 ---------------------------------
1736 -- 9.7.4 Triggering Statement --
1737 ---------------------------------
1739 -- Parsed by P_Select_Statement (9.7)
1741 ---------------------------
1742 -- 9.7.4 Abortable Part --
1743 ---------------------------
1745 -- ABORTABLE_PART ::= SEQUENCE_OF_STATEMENTS
1747 -- The caller has verified that THEN ABORT is present, and Token is
1748 -- pointing to the ABORT on entry (or if not, then we have an error)
1750 -- Error recovery: cannot raise Error_Resync
1752 function P_Abortable_Part return Node_Id is
1753 Abortable_Part_Node : Node_Id;
1756 Abortable_Part_Node := New_Node (N_Abortable_Part, Token_Ptr);
1757 T_Abort; -- scan past ABORT
1759 if Ada_Version = Ada_83 then
1760 Error_Msg_SP ("(Ada 83) asynchronous select not allowed!");
1763 Set_Statements (Abortable_Part_Node, P_Sequence_Of_Statements (SS_Sreq));
1764 return Abortable_Part_Node;
1765 end P_Abortable_Part;
1767 --------------------------
1768 -- 9.8 Abort Statement --
1769 --------------------------
1771 -- ABORT_STATEMENT ::= abort task_NAME {, task_NAME};
1773 -- The caller has checked that the initial token is ABORT
1775 -- Error recovery: cannot raise Error_Resync
1777 function P_Abort_Statement return Node_Id is
1778 Abort_Node : Node_Id;
1781 Abort_Node := New_Node (N_Abort_Statement, Token_Ptr);
1783 Set_Names (Abort_Node, New_List);
1786 Append (P_Name, Names (Abort_Node));
1787 exit when Token /= Tok_Comma;
1793 end P_Abort_Statement;