1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2010, 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_Operation_Declaration_Opt return Node_Id;
44 function P_Protected_Operation_Items return List_Id;
45 function P_Task_Items return List_Id;
47 function P_Protected_Definition (Decl : Node_Id) return Node_Id;
48 -- Parses protected definition and following aspect specifications if
49 -- present. The argument is the declaration node to which the aspect
50 -- specifications are to be attached.
52 function P_Task_Definition (Decl : Node_Id) return Node_Id;
53 -- Parses task definition and following aspect specifications if present.
54 -- The argument is the declaration node to which the aspect specifications
55 -- are to be attached.
57 -----------------------------
58 -- 9.1 Task (also 10.1.3) --
59 -----------------------------
61 -- TASK_TYPE_DECLARATION ::=
62 -- task type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART]
63 -- [is [new INTERFACE_LIST with] TASK_DEFINITION]
64 -- [ASPECT_SPECIFICATIONS];
66 -- SINGLE_TASK_DECLARATION ::=
67 -- task DEFINING_IDENTIFIER
68 -- [is [new INTERFACE_LIST with] TASK_DEFINITION]
69 -- [ASPECT_SPECIFICATIONS];
72 -- task body DEFINING_IDENTIFIER is
75 -- HANDLED_SEQUENCE_OF_STATEMENTS
76 -- end [task_IDENTIFIER]
79 -- task body DEFINING_IDENTIFIER is separate;
81 -- This routine scans out a task declaration, task body, or task stub
83 -- The caller has checked that the initial token is TASK and scanned
84 -- past it, so that Token is set to the token after TASK
86 -- Error recovery: cannot raise Error_Resync
88 function P_Task return Node_Id is
91 Task_Sloc : Source_Ptr;
95 Scope.Table (Scope.Last).Etyp := E_Name;
96 Scope.Table (Scope.Last).Ecol := Start_Column;
97 Scope.Table (Scope.Last).Sloc := Token_Ptr;
98 Scope.Table (Scope.Last).Lreq := False;
99 Task_Sloc := Prev_Token_Ptr;
101 if Token = Tok_Body then
103 Name_Node := P_Defining_Identifier (C_Is);
104 Scope.Table (Scope.Last).Labl := Name_Node;
106 if Token = Tok_Left_Paren then
107 Error_Msg_SC ("discriminant part not allowed in task body");
108 Discard_Junk_List (P_Known_Discriminant_Part_Opt);
115 if Token = Tok_Separate then
116 Scan; -- past SEPARATE
117 Task_Node := New_Node (N_Task_Body_Stub, Task_Sloc);
118 Set_Defining_Identifier (Task_Node, Name_Node);
120 Pop_Scope_Stack; -- remove unused entry
125 Task_Node := New_Node (N_Task_Body, Task_Sloc);
126 Set_Defining_Identifier (Task_Node, Name_Node);
127 Parse_Decls_Begin_End (Task_Node);
132 -- Otherwise we must have a task declaration
135 if Token = Tok_Type then
137 Task_Node := New_Node (N_Task_Type_Declaration, Task_Sloc);
138 Name_Node := P_Defining_Identifier;
139 Set_Defining_Identifier (Task_Node, Name_Node);
140 Scope.Table (Scope.Last).Labl := Name_Node;
141 Set_Discriminant_Specifications
142 (Task_Node, P_Known_Discriminant_Part_Opt);
145 Task_Node := New_Node (N_Single_Task_Declaration, Task_Sloc);
146 Name_Node := P_Defining_Identifier (C_Is);
147 Set_Defining_Identifier (Task_Node, Name_Node);
148 Scope.Table (Scope.Last).Labl := Name_Node;
150 if Token = Tok_Left_Paren then
151 Error_Msg_SC ("discriminant part not allowed for single task");
152 Discard_Junk_List (P_Known_Discriminant_Part_Opt);
156 -- If we have aspect definitions present here, then we do not have
157 -- a task definition present.
159 if Aspect_Specifications_Present then
160 P_Aspect_Specifications (Task_Node);
162 -- Parse optional task definition. Note that P_Task_Definition scans
163 -- out the semicolon and possible aspect specifications as well as
164 -- the task definition itself.
166 elsif Token = Tok_Semicolon then
168 -- A little check, if the next token after semicolon is
169 -- Entry, then surely the semicolon should really be IS
171 Scan; -- past semicolon
173 if Token = Tok_Entry then
174 Error_Msg_SP -- CODEFIX
175 ("|"";"" should be IS");
176 Set_Task_Definition (Task_Node, P_Task_Definition (Task_Node));
178 Pop_Scope_Stack; -- Remove unused entry
181 -- Here we have a task definition
184 TF_Is; -- must have IS if no semicolon
188 if Token = Tok_New then
191 if Ada_Version < Ada_2005 then
192 Error_Msg_SP ("task interface is an Ada 2005 extension");
193 Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
196 Set_Interface_List (Task_Node, New_List);
199 Append (P_Qualified_Simple_Name, Interface_List (Task_Node));
200 exit when Token /= Tok_And;
204 if Token /= Tok_With then
205 Error_Msg_SC -- CODEFIX
211 if Token = Tok_Private then
212 Error_Msg_SP -- CODEFIX
213 ("PRIVATE not allowed in task type declaration");
217 Set_Task_Definition (Task_Node, P_Task_Definition (Task_Node));
224 --------------------------------
225 -- 9.1 Task Type Declaration --
226 --------------------------------
228 -- Parsed by P_Task (9.1)
230 ----------------------------------
231 -- 9.1 Single Task Declaration --
232 ----------------------------------
234 -- Parsed by P_Task (9.1)
236 --------------------------
237 -- 9.1 Task Definition --
238 --------------------------
240 -- TASK_DEFINITION ::=
244 -- end [task_IDENTIFIER];
246 -- The caller has already made the scope stack entry
248 -- Note: there is a small deviation from official syntax here in that we
249 -- regard the semicolon after end as part of the Task_Definition, and in
250 -- the official syntax, it's part of the enclosing declaration. The reason
251 -- for this deviation is that otherwise the end processing would have to
252 -- be special cased, which would be a nuisance!
254 -- Error recovery: cannot raise Error_Resync
256 function P_Task_Definition (Decl : Node_Id) return Node_Id is
260 Def_Node := New_Node (N_Task_Definition, Token_Ptr);
261 Set_Visible_Declarations (Def_Node, P_Task_Items);
263 if Token = Tok_Private then
264 Scan; -- past PRIVATE
265 Set_Private_Declarations (Def_Node, P_Task_Items);
267 -- Deal gracefully with multiple PRIVATE parts
269 while Token = Tok_Private loop
270 Error_Msg_SC ("only one private part allowed per task");
271 Scan; -- past PRIVATE
272 Append_List (P_Task_Items, Private_Declarations (Def_Node));
276 End_Statements (Def_Node, Decl);
278 end P_Task_Definition;
284 -- TASK_ITEM ::= ENTRY_DECLARATION | REPRESENTATION_CLAUSE
286 -- This subprogram scans a (possibly empty) list of task items and pragmas
288 -- Error recovery: cannot raise Error_Resync
290 -- Note: a pragma can also be returned in this position
292 function P_Task_Items return List_Id is
295 Decl_Sloc : Source_Ptr;
298 -- Get rid of active SIS entry from outer scope. This means we will
299 -- miss some nested cases, but it doesn't seem worth the effort. See
300 -- discussion in Par for further details
302 SIS_Entry_Active := False;
304 -- Loop to scan out task items
309 Decl_Sloc := Token_Ptr;
311 if Token = Tok_Pragma then
312 Append (P_Pragma, Items);
314 -- Ada 2005 (AI-397): Reserved words NOT and OVERRIDING
315 -- may begin an entry declaration.
317 elsif Token = Tok_Entry
318 or else Token = Tok_Not
319 or else Token = Tok_Overriding
321 Append (P_Entry_Declaration, Items);
323 elsif Token = Tok_For then
324 -- Representation clause in task declaration. The only rep
325 -- clause which is legal in a protected is an address clause,
326 -- so that is what we try to scan out.
328 Item_Node := P_Representation_Clause;
330 if Nkind (Item_Node) = N_At_Clause then
331 Append (Item_Node, Items);
333 elsif Nkind (Item_Node) = N_Attribute_Definition_Clause
334 and then Chars (Item_Node) = Name_Address
336 Append (Item_Node, Items);
340 ("the only representation clause " &
341 "allowed here is an address clause!", Decl_Sloc);
344 elsif Token = Tok_Identifier
345 or else Token in Token_Class_Declk
347 Error_Msg_SC ("illegal declaration in task definition");
348 Resync_Past_Semicolon;
362 -- Parsed by P_Task (9.1)
364 ----------------------------------
365 -- 9.4 Protected (also 10.1.3) --
366 ----------------------------------
368 -- PROTECTED_TYPE_DECLARATION ::=
369 -- protected type DEFINING_IDENTIFIER [KNOWN_DISCRIMINANT_PART]
370 -- is [new INTERFACE_LIST with] PROTECTED_DEFINITION
371 -- [ASPECT_SPECIFICATIONS];
373 -- SINGLE_PROTECTED_DECLARATION ::=
374 -- protected DEFINING_IDENTIFIER
375 -- is [new INTERFACE_LIST with] PROTECTED_DEFINITION;
376 -- [ASPECT_SPECIFICATIONS];
378 -- PROTECTED_BODY ::=
379 -- protected body DEFINING_IDENTIFIER is
380 -- {PROTECTED_OPERATION_ITEM}
381 -- end [protected_IDENTIFIER];
383 -- PROTECTED_BODY_STUB ::=
384 -- protected body DEFINING_IDENTIFIER is separate;
386 -- This routine scans out a protected declaration, protected body
387 -- or a protected stub.
389 -- The caller has checked that the initial token is PROTECTED and
390 -- scanned past it, so Token is set to the following token.
392 -- Error recovery: cannot raise Error_Resync
394 function P_Protected return Node_Id is
396 Protected_Node : Node_Id;
397 Protected_Sloc : Source_Ptr;
398 Scan_State : Saved_Scan_State;
402 Scope.Table (Scope.Last).Etyp := E_Name;
403 Scope.Table (Scope.Last).Ecol := Start_Column;
404 Scope.Table (Scope.Last).Lreq := False;
405 Protected_Sloc := Prev_Token_Ptr;
407 if Token = Tok_Body then
409 Name_Node := P_Defining_Identifier (C_Is);
410 Scope.Table (Scope.Last).Labl := Name_Node;
412 if Token = Tok_Left_Paren then
413 Error_Msg_SC ("discriminant part not allowed in protected body");
414 Discard_Junk_List (P_Known_Discriminant_Part_Opt);
421 if Token = Tok_Separate then
422 Scan; -- past SEPARATE
423 Protected_Node := New_Node (N_Protected_Body_Stub, Protected_Sloc);
424 Set_Defining_Identifier (Protected_Node, Name_Node);
426 Pop_Scope_Stack; -- remove unused entry
431 Protected_Node := New_Node (N_Protected_Body, Protected_Sloc);
432 Set_Defining_Identifier (Protected_Node, Name_Node);
433 Set_Declarations (Protected_Node, P_Protected_Operation_Items);
434 End_Statements (Protected_Node);
437 return Protected_Node;
439 -- Otherwise we must have a protected declaration
442 if Token = Tok_Type then
445 New_Node (N_Protected_Type_Declaration, Protected_Sloc);
446 Name_Node := P_Defining_Identifier (C_Is);
447 Set_Defining_Identifier (Protected_Node, Name_Node);
448 Scope.Table (Scope.Last).Labl := Name_Node;
449 Set_Discriminant_Specifications
450 (Protected_Node, P_Known_Discriminant_Part_Opt);
454 New_Node (N_Single_Protected_Declaration, Protected_Sloc);
455 Name_Node := P_Defining_Identifier (C_Is);
456 Set_Defining_Identifier (Protected_Node, Name_Node);
458 if Token = Tok_Left_Paren then
460 ("discriminant part not allowed for single protected");
461 Discard_Junk_List (P_Known_Discriminant_Part_Opt);
464 Scope.Table (Scope.Last).Labl := Name_Node;
467 -- Check for semicolon not followed by IS, this is something like
473 -- protected type r IS END;
475 if Token = Tok_Semicolon then
476 Save_Scan_State (Scan_State); -- at semicolon
477 Scan; -- past semicolon
479 if Token /= Tok_Is then
480 Restore_Scan_State (Scan_State);
481 Error_Msg_SC -- CODEFIX
483 Set_Protected_Definition (Protected_Node,
484 Make_Protected_Definition (Token_Ptr,
485 Visible_Declarations => Empty_List,
486 End_Label => Empty));
488 SIS_Entry_Active := False;
490 (Protected_Definition (Protected_Node), Protected_Node);
491 return Protected_Node;
494 Error_Msg_SP -- CODEFIX
495 ("|extra ""("" ignored");
502 if Token = Tok_New then
505 if Ada_Version < Ada_2005 then
506 Error_Msg_SP ("protected interface is an Ada 2005 extension");
507 Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
510 Set_Interface_List (Protected_Node, New_List);
513 Append (P_Qualified_Simple_Name,
514 Interface_List (Protected_Node));
516 exit when Token /= Tok_And;
520 if Token /= Tok_With then
521 Error_Msg_SC -- CODEFIX
528 Set_Protected_Definition
529 (Protected_Node, P_Protected_Definition (Protected_Node));
530 return Protected_Node;
534 -------------------------------------
535 -- 9.4 Protected Type Declaration --
536 -------------------------------------
538 -- Parsed by P_Protected (9.4)
540 ---------------------------------------
541 -- 9.4 Single Protected Declaration --
542 ---------------------------------------
544 -- Parsed by P_Protected (9.4)
546 -------------------------------
547 -- 9.4 Protected Definition --
548 -------------------------------
550 -- PROTECTED_DEFINITION ::=
551 -- {PROTECTED_OPERATION_DECLARATION}
553 -- {PROTECTED_ELEMENT_DECLARATION}]
554 -- end [protected_IDENTIFIER]
556 -- PROTECTED_ELEMENT_DECLARATION ::=
557 -- PROTECTED_OPERATION_DECLARATION
558 -- | COMPONENT_DECLARATION
560 -- The caller has already established the scope stack entry
562 -- Error recovery: cannot raise Error_Resync
564 function P_Protected_Definition (Decl : Node_Id) return Node_Id is
569 Def_Node := New_Node (N_Protected_Definition, Token_Ptr);
571 -- Get rid of active SIS entry from outer scope. This means we will
572 -- miss some nested cases, but it doesn't seem worth the effort. See
573 -- discussion in Par for further details
575 SIS_Entry_Active := False;
577 -- Loop to scan visible declarations (protected operation declarations)
579 Set_Visible_Declarations (Def_Node, New_List);
582 Item_Node := P_Protected_Operation_Declaration_Opt;
583 exit when No (Item_Node);
584 Append (Item_Node, Visible_Declarations (Def_Node));
587 -- Deal with PRIVATE part (including graceful handling of multiple
590 Private_Loop : while Token = Tok_Private loop
591 if No (Private_Declarations (Def_Node)) then
592 Set_Private_Declarations (Def_Node, New_List);
594 Error_Msg_SC ("duplicate private part");
597 Scan; -- past PRIVATE
599 Declaration_Loop : loop
600 if Token = Tok_Identifier then
601 P_Component_Items (Private_Declarations (Def_Node));
603 Item_Node := P_Protected_Operation_Declaration_Opt;
604 exit Declaration_Loop when No (Item_Node);
605 Append (Item_Node, Private_Declarations (Def_Node));
607 end loop Declaration_Loop;
608 end loop Private_Loop;
610 End_Statements (Def_Node, Decl);
612 end P_Protected_Definition;
614 ------------------------------------------
615 -- 9.4 Protected Operation Declaration --
616 ------------------------------------------
618 -- PROTECTED_OPERATION_DECLARATION ::=
619 -- SUBPROGRAM_DECLARATION
620 -- | ENTRY_DECLARATION
621 -- | REPRESENTATION_CLAUSE
623 -- Error recovery: cannot raise Error_Resync
625 -- Note: a pragma can also be returned in this position
627 -- We are not currently permitting representation clauses to appear as
628 -- protected operation declarations, do we have to rethink this???
630 function P_Protected_Operation_Declaration_Opt return Node_Id is
634 function P_Entry_Or_Subprogram_With_Indicator return Node_Id;
635 -- Ada 2005 (AI-397): Parse an entry or a subprogram with an overriding
636 -- indicator. The caller has checked that the initial token is NOT or
639 ------------------------------------------
640 -- P_Entry_Or_Subprogram_With_Indicator --
641 ------------------------------------------
643 function P_Entry_Or_Subprogram_With_Indicator return Node_Id is
644 Decl : Node_Id := Error;
645 Is_Overriding : Boolean := False;
646 Not_Overriding : Boolean := False;
649 if Token = Tok_Not then
652 if Token = Tok_Overriding then
653 Scan; -- past OVERRIDING
654 Not_Overriding := True;
656 Error_Msg_SC -- CODEFIX
657 ("OVERRIDING expected!");
661 Scan; -- past OVERRIDING
662 Is_Overriding := True;
665 if Is_Overriding or else Not_Overriding then
666 if Ada_Version < Ada_2005 then
667 Error_Msg_SP ("overriding indicator is an Ada 2005 extension");
668 Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
670 elsif Token = Tok_Entry then
671 Decl := P_Entry_Declaration;
673 Set_Must_Override (Decl, Is_Overriding);
674 Set_Must_Not_Override (Decl, Not_Overriding);
676 elsif Token = Tok_Function or else Token = Tok_Procedure then
677 Decl := P_Subprogram (Pf_Decl_Pexp);
679 Set_Must_Override (Specification (Decl), Is_Overriding);
680 Set_Must_Not_Override (Specification (Decl), Not_Overriding);
683 Error_Msg_SC -- CODEFIX
684 ("ENTRY, FUNCTION or PROCEDURE expected!");
689 end P_Entry_Or_Subprogram_With_Indicator;
691 -- Start of processing for P_Protected_Operation_Declaration_Opt
694 -- This loop runs more than once only when a junk declaration
698 if Token = Tok_Pragma then
701 elsif Token = Tok_Not or else Token = Tok_Overriding then
702 return P_Entry_Or_Subprogram_With_Indicator;
704 elsif Token = Tok_Entry then
705 return P_Entry_Declaration;
707 elsif Token = Tok_Function or else Token = Tok_Procedure then
708 return P_Subprogram (Pf_Decl_Pexp);
710 elsif Token = Tok_Identifier then
713 Skip_Declaration (L);
715 if Nkind (First (L)) = N_Object_Declaration then
717 ("component must be declared in private part of " &
718 "protected type", P);
721 ("illegal declaration in protected definition", P);
724 elsif Token in Token_Class_Declk then
725 Error_Msg_SC ("illegal declaration in protected definition");
726 Resync_Past_Semicolon;
728 -- Return now to avoid cascaded messages if next declaration
729 -- is a valid component declaration.
733 elsif Token = Tok_For then
735 ("representation clause not allowed in protected definition");
736 Resync_Past_Semicolon;
742 end P_Protected_Operation_Declaration_Opt;
744 -----------------------------------
745 -- 9.4 Protected Operation Item --
746 -----------------------------------
748 -- PROTECTED_OPERATION_ITEM ::=
749 -- SUBPROGRAM_DECLARATION
752 -- | REPRESENTATION_CLAUSE
754 -- This procedure parses and returns a list of protected operation items
756 -- We are not currently permitting representation clauses to appear
757 -- as protected operation items, do we have to rethink this???
759 function P_Protected_Operation_Items return List_Id is
763 Item_List := New_List;
766 if Token = Tok_Entry or else Bad_Spelling_Of (Tok_Entry) then
767 Append (P_Entry_Body, Item_List);
769 -- If the operation starts with procedure, function, or an overriding
770 -- indicator ("overriding" or "not overriding"), parse a subprogram.
772 elsif Token = Tok_Function or else Bad_Spelling_Of (Tok_Function)
774 Token = Tok_Procedure or else Bad_Spelling_Of (Tok_Procedure)
776 Token = Tok_Overriding or else Bad_Spelling_Of (Tok_Overriding)
778 Token = Tok_Not or else Bad_Spelling_Of (Tok_Not)
780 Append (P_Subprogram (Pf_Decl_Pbod_Pexp), Item_List);
782 elsif Token = Tok_Pragma or else Bad_Spelling_Of (Tok_Pragma) then
783 P_Pragmas_Opt (Item_List);
785 elsif Token = Tok_Private or else Bad_Spelling_Of (Tok_Private) then
786 Error_Msg_SC ("PRIVATE not allowed in protected body");
787 Scan; -- past PRIVATE
789 elsif Token = Tok_Identifier then
790 Error_Msg_SC ("all components must be declared in spec!");
791 Resync_Past_Semicolon;
793 elsif Token in Token_Class_Declk then
794 Error_Msg_SC ("this declaration not allowed in protected body");
795 Resync_Past_Semicolon;
803 end P_Protected_Operation_Items;
805 ------------------------------
806 -- 9.5.2 Entry Declaration --
807 ------------------------------
809 -- ENTRY_DECLARATION ::=
810 -- [OVERRIDING_INDICATOR]
811 -- entry DEFINING_IDENTIFIER [(DISCRETE_SUBTYPE_DEFINITION)]
812 -- PARAMETER_PROFILE;
813 -- [ASPECT_SPECIFICATIONS];
815 -- The caller has checked that the initial token is ENTRY, NOT or
818 -- Error recovery: cannot raise Error_Resync
820 function P_Entry_Declaration return Node_Id is
822 Scan_State : Saved_Scan_State;
824 -- Flags for optional overriding indication. Two flags are needed,
825 -- to distinguish positive and negative overriding indicators from
826 -- the absence of any indicator.
828 Is_Overriding : Boolean := False;
829 Not_Overriding : Boolean := False;
832 -- Ada 2005 (AI-397): Scan leading overriding indicator
834 if Token = Tok_Not then
837 if Token = Tok_Overriding then
838 Scan; -- part OVERRIDING
839 Not_Overriding := True;
841 Error_Msg_SC -- CODEFIX
842 ("OVERRIDING expected!");
845 elsif Token = Tok_Overriding then
846 Scan; -- part OVERRIDING
847 Is_Overriding := True;
850 if Is_Overriding or else Not_Overriding then
851 if Ada_Version < Ada_2005 then
852 Error_Msg_SP ("overriding indicator is an Ada 2005 extension");
853 Error_Msg_SP ("\unit must be compiled with -gnat05 switch");
855 elsif Token /= Tok_Entry then
856 Error_Msg_SC -- CODEFIX
861 Decl_Node := New_Node (N_Entry_Declaration, Token_Ptr);
864 Set_Defining_Identifier
865 (Decl_Node, P_Defining_Identifier (C_Left_Paren_Semicolon));
867 -- If left paren, could be (Discrete_Subtype_Definition) or Formal_Part
869 if Token = Tok_Left_Paren then
872 -- If identifier after left paren, could still be either
874 if Token = Tok_Identifier then
875 Save_Scan_State (Scan_State); -- at Id
878 -- If comma or colon after Id, must be Formal_Part
880 if Token = Tok_Comma or else Token = Tok_Colon then
881 Restore_Scan_State (Scan_State); -- to Id
882 Set_Parameter_Specifications (Decl_Node, P_Formal_Part);
884 -- Else if Id without comma or colon, must be discrete subtype
888 Restore_Scan_State (Scan_State); -- to Id
889 Set_Discrete_Subtype_Definition
890 (Decl_Node, P_Discrete_Subtype_Definition);
892 Set_Parameter_Specifications (Decl_Node, P_Parameter_Profile);
895 -- If no Id, must be discrete subtype definition
898 Set_Discrete_Subtype_Definition
899 (Decl_Node, P_Discrete_Subtype_Definition);
901 Set_Parameter_Specifications (Decl_Node, P_Parameter_Profile);
905 if Is_Overriding then
906 Set_Must_Override (Decl_Node);
907 elsif Not_Overriding then
908 Set_Must_Not_Override (Decl_Node);
911 -- Error recovery check for illegal return
913 if Token = Tok_Return then
914 Error_Msg_SC ("entry cannot have return value!");
916 Discard_Junk_Node (P_Subtype_Indication);
919 -- Error recovery check for improper use of entry barrier in spec
921 if Token = Tok_When then
922 Error_Msg_SC ("barrier not allowed here (belongs in body)");
924 Discard_Junk_Node (P_Expression_No_Right_Paren);
927 P_Aspect_Specifications (Decl_Node);
932 Resync_Past_Semicolon;
934 end P_Entry_Declaration;
936 -----------------------------
937 -- 9.5.2 Accept Statement --
938 -----------------------------
940 -- ACCEPT_STATEMENT ::=
941 -- accept entry_DIRECT_NAME
942 -- [(ENTRY_INDEX)] PARAMETER_PROFILE [do
943 -- HANDLED_SEQUENCE_OF_STATEMENTS
944 -- end [entry_IDENTIFIER]];
946 -- The caller has checked that the initial token is ACCEPT
948 -- Error recovery: cannot raise Error_Resync. If an error occurs, the
949 -- scan is resynchronized past the next semicolon and control returns.
951 function P_Accept_Statement return Node_Id is
952 Scan_State : Saved_Scan_State;
953 Accept_Node : Node_Id;
958 Scope.Table (Scope.Last).Sloc := Token_Ptr;
959 Scope.Table (Scope.Last).Ecol := Start_Column;
961 Accept_Node := New_Node (N_Accept_Statement, Token_Ptr);
963 Scope.Table (Scope.Last).Labl := Token_Node;
965 Set_Entry_Direct_Name (Accept_Node, P_Identifier (C_Do));
967 -- Left paren could be (Entry_Index) or Formal_Part, determine which
969 if Token = Tok_Left_Paren then
970 Save_Scan_State (Scan_State); -- at left paren
971 Scan; -- past left paren
973 -- If first token after left paren not identifier, then Entry_Index
975 if Token /= Tok_Identifier then
976 Set_Entry_Index (Accept_Node, P_Expression);
978 Set_Parameter_Specifications (Accept_Node, P_Parameter_Profile);
980 -- First token after left paren is identifier, could be either case
982 else -- Token = Tok_Identifier
983 Scan; -- past identifier
985 -- If identifier followed by comma or colon, must be Formal_Part
987 if Token = Tok_Comma or else Token = Tok_Colon then
988 Restore_Scan_State (Scan_State); -- to left paren
989 Set_Parameter_Specifications (Accept_Node, P_Parameter_Profile);
991 -- If identifier not followed by comma/colon, must be entry index
994 Restore_Scan_State (Scan_State); -- to left paren
995 Scan; -- past left paren (again!)
996 Set_Entry_Index (Accept_Node, P_Expression);
998 Set_Parameter_Specifications (Accept_Node, P_Parameter_Profile);
1003 -- Scan out DO if present
1005 if Token = Tok_Do then
1006 Scope.Table (Scope.Last).Etyp := E_Name;
1007 Scope.Table (Scope.Last).Lreq := False;
1009 Hand_Seq := P_Handled_Sequence_Of_Statements;
1010 Set_Handled_Statement_Sequence (Accept_Node, Hand_Seq);
1011 End_Statements (Handled_Statement_Sequence (Accept_Node));
1013 -- Exception handlers not allowed in Ada 95 node
1015 if Present (Exception_Handlers (Hand_Seq)) then
1016 if Ada_Version = Ada_83 then
1018 ("(Ada 83) exception handlers in accept not allowed",
1019 First_Non_Pragma (Exception_Handlers (Hand_Seq)));
1024 Pop_Scope_Stack; -- discard unused entry
1030 -- If error, resynchronize past semicolon
1033 when Error_Resync =>
1034 Resync_Past_Semicolon;
1035 Pop_Scope_Stack; -- discard unused entry
1038 end P_Accept_Statement;
1040 ------------------------
1041 -- 9.5.2 Entry Index --
1042 ------------------------
1044 -- Parsed by P_Expression (4.4)
1046 -----------------------
1047 -- 9.5.2 Entry Body --
1048 -----------------------
1051 -- entry DEFINING_IDENTIFIER ENTRY_BODY_FORMAL_PART ENTRY_BARRIER is
1054 -- HANDLED_SEQUENCE_OF_STATEMENTS
1055 -- end [entry_IDENTIFIER];
1057 -- The caller has checked that the initial token is ENTRY
1059 -- Error_Recovery: cannot raise Error_Resync
1061 function P_Entry_Body return Node_Id is
1062 Entry_Node : Node_Id;
1063 Formal_Part_Node : Node_Id;
1064 Name_Node : Node_Id;
1068 Entry_Node := New_Node (N_Entry_Body, Token_Ptr);
1071 Scope.Table (Scope.Last).Ecol := Start_Column;
1072 Scope.Table (Scope.Last).Lreq := False;
1073 Scope.Table (Scope.Last).Etyp := E_Name;
1075 Name_Node := P_Defining_Identifier;
1076 Set_Defining_Identifier (Entry_Node, Name_Node);
1077 Scope.Table (Scope.Last).Labl := Name_Node;
1079 Formal_Part_Node := P_Entry_Body_Formal_Part;
1080 Set_Entry_Body_Formal_Part (Entry_Node, Formal_Part_Node);
1082 Set_Condition (Formal_Part_Node, P_Entry_Barrier);
1083 Parse_Decls_Begin_End (Entry_Node);
1087 -----------------------------------
1088 -- 9.5.2 Entry Body Formal Part --
1089 -----------------------------------
1091 -- ENTRY_BODY_FORMAL_PART ::=
1092 -- [(ENTRY_INDEX_SPECIFICATION)] [PARAMETER_PART]
1094 -- Error_Recovery: cannot raise Error_Resync
1096 function P_Entry_Body_Formal_Part return Node_Id is
1097 Fpart_Node : Node_Id;
1098 Scan_State : Saved_Scan_State;
1101 Fpart_Node := New_Node (N_Entry_Body_Formal_Part, Token_Ptr);
1103 -- See if entry index specification present, and if so parse it
1105 if Token = Tok_Left_Paren then
1106 Save_Scan_State (Scan_State); -- at left paren
1107 Scan; -- past left paren
1109 if Token = Tok_For then
1110 Set_Entry_Index_Specification
1111 (Fpart_Node, P_Entry_Index_Specification);
1114 Restore_Scan_State (Scan_State); -- to left paren
1117 -- Check for (common?) case of left paren omitted before FOR. This
1118 -- is a tricky case, because the corresponding missing left paren
1119 -- can cause real havoc if a formal part is present which gets
1120 -- treated as part of the discrete subtype definition of the
1121 -- entry index specification, so just give error and resynchronize
1123 elsif Token = Tok_For then
1124 T_Left_Paren; -- to give error message
1128 Set_Parameter_Specifications (Fpart_Node, P_Parameter_Profile);
1130 end P_Entry_Body_Formal_Part;
1132 --------------------------
1133 -- 9.5.2 Entry Barrier --
1134 --------------------------
1136 -- ENTRY_BARRIER ::= when CONDITION
1138 -- Error_Recovery: cannot raise Error_Resync
1140 function P_Entry_Barrier return Node_Id is
1144 if Token = Tok_When then
1146 Bnode := P_Expression_No_Right_Paren;
1148 if Token = Tok_Colon_Equal then
1149 Error_Msg_SC -- CODEFIX
1150 ("|"":="" should be ""=""");
1152 Bnode := P_Expression_No_Right_Paren;
1156 T_When; -- to give error message
1162 end P_Entry_Barrier;
1164 --------------------------------------
1165 -- 9.5.2 Entry Index Specification --
1166 --------------------------------------
1168 -- ENTRY_INDEX_SPECIFICATION ::=
1169 -- for DEFINING_IDENTIFIER in DISCRETE_SUBTYPE_DEFINITION
1171 -- Error recovery: can raise Error_Resync
1173 function P_Entry_Index_Specification return Node_Id is
1174 Iterator_Node : Node_Id;
1177 Iterator_Node := New_Node (N_Entry_Index_Specification, Token_Ptr);
1179 Set_Defining_Identifier (Iterator_Node, P_Defining_Identifier (C_In));
1181 Set_Discrete_Subtype_Definition
1182 (Iterator_Node, P_Discrete_Subtype_Definition);
1183 return Iterator_Node;
1184 end P_Entry_Index_Specification;
1186 ---------------------------------
1187 -- 9.5.3 Entry Call Statement --
1188 ---------------------------------
1190 -- Parsed by P_Name (4.1). Within a select, an entry call is parsed
1191 -- by P_Select_Statement (9.7)
1193 ------------------------------
1194 -- 9.5.4 Requeue Statement --
1195 ------------------------------
1197 -- REQUEUE_STATEMENT ::= requeue entry_NAME [with abort];
1199 -- The caller has checked that the initial token is requeue
1201 -- Error recovery: can raise Error_Resync
1203 function P_Requeue_Statement return Node_Id is
1204 Requeue_Node : Node_Id;
1207 Requeue_Node := New_Node (N_Requeue_Statement, Token_Ptr);
1208 Scan; -- past REQUEUE
1209 Set_Name (Requeue_Node, P_Name);
1211 if Token = Tok_With then
1214 Set_Abort_Present (Requeue_Node, True);
1218 return Requeue_Node;
1219 end P_Requeue_Statement;
1221 --------------------------
1222 -- 9.6 Delay Statement --
1223 --------------------------
1225 -- DELAY_STATEMENT ::=
1226 -- DELAY_UNTIL_STATEMENT
1227 -- | DELAY_RELATIVE_STATEMENT
1229 -- The caller has checked that the initial token is DELAY
1231 -- Error recovery: cannot raise Error_Resync
1233 function P_Delay_Statement return Node_Id is
1237 -- The following check for delay until misused in Ada 83 doesn't catch
1238 -- all cases, but it's good enough to catch most of them!
1240 if Token_Name = Name_Until then
1241 Check_95_Keyword (Tok_Until, Tok_Left_Paren);
1242 Check_95_Keyword (Tok_Until, Tok_Identifier);
1245 if Token = Tok_Until then
1246 return P_Delay_Until_Statement;
1248 return P_Delay_Relative_Statement;
1250 end P_Delay_Statement;
1252 --------------------------------
1253 -- 9.6 Delay Until Statement --
1254 --------------------------------
1256 -- DELAY_UNTIL_STATEMENT ::= delay until delay_EXPRESSION;
1258 -- The caller has checked that the initial token is DELAY, scanned it
1259 -- out and checked that the current token is UNTIL
1261 -- Error recovery: cannot raise Error_Resync
1263 function P_Delay_Until_Statement return Node_Id is
1264 Delay_Node : Node_Id;
1267 Delay_Node := New_Node (N_Delay_Until_Statement, Prev_Token_Ptr);
1269 Set_Expression (Delay_Node, P_Expression_No_Right_Paren);
1272 end P_Delay_Until_Statement;
1274 -----------------------------------
1275 -- 9.6 Delay Relative Statement --
1276 -----------------------------------
1278 -- DELAY_RELATIVE_STATEMENT ::= delay delay_EXPRESSION;
1280 -- The caller has checked that the initial token is DELAY, scanned it
1281 -- out and determined that the current token is not UNTIL
1283 -- Error recovery: cannot raise Error_Resync
1285 function P_Delay_Relative_Statement return Node_Id is
1286 Delay_Node : Node_Id;
1289 Delay_Node := New_Node (N_Delay_Relative_Statement, Prev_Token_Ptr);
1290 Set_Expression (Delay_Node, P_Expression_No_Right_Paren);
1291 Check_Simple_Expression_In_Ada_83 (Expression (Delay_Node));
1294 end P_Delay_Relative_Statement;
1296 ---------------------------
1297 -- 9.7 Select Statement --
1298 ---------------------------
1300 -- SELECT_STATEMENT ::=
1302 -- | TIMED_ENTRY_CALL
1303 -- | CONDITIONAL_ENTRY_CALL
1304 -- | ASYNCHRONOUS_SELECT
1306 -- SELECTIVE_ACCEPT ::=
1309 -- SELECT_ALTERNATIVE
1312 -- SELECT_ALTERNATIVE
1314 -- SEQUENCE_OF_STATEMENTS]
1317 -- GUARD ::= when CONDITION =>
1319 -- Note: the guard preceding a select alternative is included as part
1320 -- of the node generated for a selective accept alternative.
1322 -- SELECT_ALTERNATIVE ::=
1323 -- ACCEPT_ALTERNATIVE
1324 -- | DELAY_ALTERNATIVE
1325 -- | TERMINATE_ALTERNATIVE
1327 -- TIMED_ENTRY_CALL ::=
1329 -- ENTRY_CALL_ALTERNATIVE
1331 -- DELAY_ALTERNATIVE
1334 -- CONDITIONAL_ENTRY_CALL ::=
1336 -- ENTRY_CALL_ALTERNATIVE
1338 -- SEQUENCE_OF_STATEMENTS
1341 -- ENTRY_CALL_ALTERNATIVE ::=
1342 -- ENTRY_CALL_STATEMENT [SEQUENCE_OF_STATEMENTS]
1344 -- ASYNCHRONOUS_SELECT ::=
1346 -- TRIGGERING_ALTERNATIVE
1351 -- TRIGGERING_ALTERNATIVE ::=
1352 -- TRIGGERING_STATEMENT [SEQUENCE_OF_STATEMENTS]
1354 -- TRIGGERING_STATEMENT ::= ENTRY_CALL_STATEMENT | DELAY_STATEMENT
1356 -- The caller has checked that the initial token is SELECT
1358 -- Error recovery: can raise Error_Resync
1360 function P_Select_Statement return Node_Id is
1361 Select_Node : Node_Id;
1362 Select_Sloc : Source_Ptr;
1363 Stmnt_Sloc : Source_Ptr;
1364 Ecall_Node : Node_Id;
1365 Alternative : Node_Id;
1366 Select_Pragmas : List_Id;
1367 Alt_Pragmas : List_Id;
1368 Statement_List : List_Id;
1370 Cond_Expr : Node_Id;
1371 Delay_Stmnt : Node_Id;
1375 Scope.Table (Scope.Last).Etyp := E_Select;
1376 Scope.Table (Scope.Last).Ecol := Start_Column;
1377 Scope.Table (Scope.Last).Sloc := Token_Ptr;
1378 Scope.Table (Scope.Last).Labl := Error;
1380 Select_Sloc := Token_Ptr;
1381 Scan; -- past SELECT
1382 Stmnt_Sloc := Token_Ptr;
1383 Select_Pragmas := P_Pragmas_Opt;
1385 -- If first token after select is designator, then we have an entry
1386 -- call, which must be the start of a conditional entry call, timed
1387 -- entry call or asynchronous select
1389 if Token in Token_Class_Desig then
1391 -- Scan entry call statement
1394 Ecall_Node := P_Name;
1396 -- ?? The following two clauses exactly parallel code in ch5
1397 -- and should be combined sometime
1399 if Nkind (Ecall_Node) = N_Indexed_Component then
1401 Prefix_Node : constant Node_Id := Prefix (Ecall_Node);
1402 Exprs_Node : constant List_Id := Expressions (Ecall_Node);
1405 Change_Node (Ecall_Node, N_Procedure_Call_Statement);
1406 Set_Name (Ecall_Node, Prefix_Node);
1407 Set_Parameter_Associations (Ecall_Node, Exprs_Node);
1410 elsif Nkind (Ecall_Node) = N_Function_Call then
1412 Fname_Node : constant Node_Id := Name (Ecall_Node);
1413 Params_List : constant List_Id :=
1414 Parameter_Associations (Ecall_Node);
1417 Change_Node (Ecall_Node, N_Procedure_Call_Statement);
1418 Set_Name (Ecall_Node, Fname_Node);
1419 Set_Parameter_Associations (Ecall_Node, Params_List);
1422 elsif Nkind (Ecall_Node) = N_Identifier
1423 or else Nkind (Ecall_Node) = N_Selected_Component
1425 -- Case of a call to a parameterless entry
1428 C_Node : constant Node_Id :=
1429 New_Node (N_Procedure_Call_Statement, Stmnt_Sloc);
1431 Set_Name (C_Node, Ecall_Node);
1432 Set_Parameter_Associations (C_Node, No_List);
1433 Ecall_Node := C_Node;
1440 when Error_Resync =>
1441 Resync_Past_Semicolon;
1445 Statement_List := P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm);
1447 -- OR follows, we have a timed entry call
1449 if Token = Tok_Or then
1451 Alt_Pragmas := P_Pragmas_Opt;
1453 Select_Node := New_Node (N_Timed_Entry_Call, Select_Sloc);
1454 Set_Entry_Call_Alternative (Select_Node,
1455 Make_Entry_Call_Alternative (Stmnt_Sloc,
1456 Entry_Call_Statement => Ecall_Node,
1457 Pragmas_Before => Select_Pragmas,
1458 Statements => Statement_List));
1460 -- Only possibility is delay alternative. If we have anything
1461 -- else, give message, and treat as conditional entry call.
1463 if Token /= Tok_Delay then
1465 ("only allowed alternative in timed entry call is delay!");
1466 Discard_Junk_List (P_Sequence_Of_Statements (SS_Sreq));
1467 Set_Delay_Alternative (Select_Node, Error);
1470 Set_Delay_Alternative (Select_Node, P_Delay_Alternative);
1472 (Delay_Alternative (Select_Node), Alt_Pragmas);
1475 -- ELSE follows, we have a conditional entry call
1477 elsif Token = Tok_Else then
1479 Select_Node := New_Node (N_Conditional_Entry_Call, Select_Sloc);
1481 Set_Entry_Call_Alternative (Select_Node,
1482 Make_Entry_Call_Alternative (Stmnt_Sloc,
1483 Entry_Call_Statement => Ecall_Node,
1484 Pragmas_Before => Select_Pragmas,
1485 Statements => Statement_List));
1488 (Select_Node, P_Sequence_Of_Statements (SS_Sreq));
1490 -- Only remaining case is THEN ABORT (asynchronous select)
1492 elsif Token = Tok_Abort then
1494 Make_Asynchronous_Select (Select_Sloc,
1495 Triggering_Alternative =>
1496 Make_Triggering_Alternative (Stmnt_Sloc,
1497 Triggering_Statement => Ecall_Node,
1498 Pragmas_Before => Select_Pragmas,
1499 Statements => Statement_List),
1500 Abortable_Part => P_Abortable_Part);
1505 if Ada_Version = Ada_83 then
1506 Error_Msg_BC ("OR or ELSE expected");
1508 Error_Msg_BC ("OR or ELSE or THEN ABORT expected");
1511 Select_Node := Error;
1516 -- Here we have a selective accept or an asynchronous select (first
1517 -- token after SELECT is other than a designator token).
1520 -- If we have delay with no guard, could be asynchronous select
1522 if Token = Tok_Delay then
1523 Delay_Stmnt := P_Delay_Statement;
1524 Statement_List := P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm);
1526 -- Asynchronous select
1528 if Token = Tok_Abort then
1530 Make_Asynchronous_Select (Select_Sloc,
1531 Triggering_Alternative =>
1532 Make_Triggering_Alternative (Stmnt_Sloc,
1533 Triggering_Statement => Delay_Stmnt,
1534 Pragmas_Before => Select_Pragmas,
1535 Statements => Statement_List),
1536 Abortable_Part => P_Abortable_Part);
1541 -- Delay which was not an asynchronous select. Must be a selective
1542 -- accept, and since at least one accept statement is required,
1543 -- we must have at least one OR phrase present.
1546 Alt_List := New_List (
1547 Make_Delay_Alternative (Stmnt_Sloc,
1548 Delay_Statement => Delay_Stmnt,
1549 Pragmas_Before => Select_Pragmas,
1550 Statements => Statement_List));
1552 Alt_Pragmas := P_Pragmas_Opt;
1555 -- If not a delay statement, then must be another possibility for
1556 -- a selective accept alternative, or perhaps a guard is present
1559 Alt_List := New_List;
1560 Alt_Pragmas := Select_Pragmas;
1563 Select_Node := New_Node (N_Selective_Accept, Select_Sloc);
1564 Set_Select_Alternatives (Select_Node, Alt_List);
1566 -- Scan out selective accept alternatives. On entry to this loop,
1567 -- we are just past a SELECT or OR token, and any pragmas that
1568 -- immediately follow the SELECT or OR are in Alt_Pragmas.
1571 if Token = Tok_When then
1573 if Present (Alt_Pragmas) then
1574 Error_Msg_SC ("pragmas may not precede guard");
1578 Cond_Expr := P_Expression_No_Right_Paren;
1580 Alt_Pragmas := P_Pragmas_Opt;
1586 if Token = Tok_Accept then
1587 Alternative := P_Accept_Alternative;
1589 -- Check for junk attempt at asynchronous select using
1590 -- an Accept alternative as the triggering statement
1592 if Token = Tok_Abort
1593 and then Is_Empty_List (Alt_List)
1594 and then No (Cond_Expr)
1597 ("triggering statement must be entry call or delay",
1598 Sloc (Alternative));
1599 Scan; -- past junk ABORT
1600 Discard_Junk_List (P_Sequence_Of_Statements (SS_Sreq));
1605 elsif Token = Tok_Delay then
1606 Alternative := P_Delay_Alternative;
1608 elsif Token = Tok_Terminate then
1609 Alternative := P_Terminate_Alternative;
1613 ("select alternative (ACCEPT, ABORT, DELAY) expected");
1614 Alternative := Error;
1616 if Token = Tok_Semicolon then
1617 Scan; -- past junk semicolon
1621 -- THEN ABORT at this stage is just junk
1623 if Token = Tok_Abort then
1624 Error_Msg_SP ("misplaced `THEN ABORT`");
1625 Scan; -- past junk ABORT
1626 Discard_Junk_List (P_Sequence_Of_Statements (SS_Sreq));
1631 if Alternative /= Error then
1632 Set_Condition (Alternative, Cond_Expr);
1633 Set_Pragmas_Before (Alternative, Alt_Pragmas);
1634 Append (Alternative, Alt_List);
1637 exit when Token /= Tok_Or;
1641 Alt_Pragmas := P_Pragmas_Opt;
1644 if Token = Tok_Else then
1647 (Select_Node, P_Sequence_Of_Statements (SS_Ortm_Sreq));
1649 if Token = Tok_Or then
1650 Error_Msg_SC ("select alternative cannot follow else part!");
1658 end P_Select_Statement;
1660 -----------------------------
1661 -- 9.7.1 Selective Accept --
1662 -----------------------------
1664 -- Parsed by P_Select_Statement (9.7)
1670 -- Parsed by P_Select_Statement (9.7)
1672 -------------------------------
1673 -- 9.7.1 Select Alternative --
1674 -------------------------------
1676 -- SELECT_ALTERNATIVE ::=
1677 -- ACCEPT_ALTERNATIVE
1678 -- | DELAY_ALTERNATIVE
1679 -- | TERMINATE_ALTERNATIVE
1681 -- Note: the guard preceding a select alternative is included as part
1682 -- of the node generated for a selective accept alternative.
1684 -- Error recovery: cannot raise Error_Resync
1686 -------------------------------
1687 -- 9.7.1 Accept Alternative --
1688 -------------------------------
1690 -- ACCEPT_ALTERNATIVE ::=
1691 -- ACCEPT_STATEMENT [SEQUENCE_OF_STATEMENTS]
1693 -- Error_Recovery: Cannot raise Error_Resync
1695 -- Note: the caller is responsible for setting the Pragmas_Before
1696 -- field of the returned N_Terminate_Alternative node.
1698 function P_Accept_Alternative return Node_Id is
1699 Accept_Alt_Node : Node_Id;
1702 Accept_Alt_Node := New_Node (N_Accept_Alternative, Token_Ptr);
1703 Set_Accept_Statement (Accept_Alt_Node, P_Accept_Statement);
1705 -- Note: the reason that we accept THEN ABORT as a terminator for
1706 -- the sequence of statements is for error recovery which allows
1707 -- for misuse of an accept statement as a triggering statement.
1710 (Accept_Alt_Node, P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm));
1711 return Accept_Alt_Node;
1712 end P_Accept_Alternative;
1714 ------------------------------
1715 -- 9.7.1 Delay Alternative --
1716 ------------------------------
1718 -- DELAY_ALTERNATIVE ::=
1719 -- DELAY_STATEMENT [SEQUENCE_OF_STATEMENTS]
1721 -- Error_Recovery: Cannot raise Error_Resync
1723 -- Note: the caller is responsible for setting the Pragmas_Before
1724 -- field of the returned N_Terminate_Alternative node.
1726 function P_Delay_Alternative return Node_Id is
1727 Delay_Alt_Node : Node_Id;
1730 Delay_Alt_Node := New_Node (N_Delay_Alternative, Token_Ptr);
1731 Set_Delay_Statement (Delay_Alt_Node, P_Delay_Statement);
1733 -- Note: the reason that we accept THEN ABORT as a terminator for
1734 -- the sequence of statements is for error recovery which allows
1735 -- for misuse of an accept statement as a triggering statement.
1738 (Delay_Alt_Node, P_Sequence_Of_Statements (SS_Eltm_Ortm_Tatm));
1739 return Delay_Alt_Node;
1740 end P_Delay_Alternative;
1742 ----------------------------------
1743 -- 9.7.1 Terminate Alternative --
1744 ----------------------------------
1746 -- TERMINATE_ALTERNATIVE ::= terminate;
1748 -- Error_Recovery: Cannot raise Error_Resync
1750 -- Note: the caller is responsible for setting the Pragmas_Before
1751 -- field of the returned N_Terminate_Alternative node.
1753 function P_Terminate_Alternative return Node_Id is
1754 Terminate_Alt_Node : Node_Id;
1757 Terminate_Alt_Node := New_Node (N_Terminate_Alternative, Token_Ptr);
1758 Scan; -- past TERMINATE
1761 -- For all other select alternatives, the sequence of statements
1762 -- after the alternative statement will swallow up any pragmas
1763 -- coming in this position. But the terminate alternative has no
1764 -- sequence of statements, so the pragmas here must be treated
1767 Set_Pragmas_After (Terminate_Alt_Node, P_Pragmas_Opt);
1768 return Terminate_Alt_Node;
1769 end P_Terminate_Alternative;
1771 -----------------------------
1772 -- 9.7.2 Timed Entry Call --
1773 -----------------------------
1775 -- Parsed by P_Select_Statement (9.7)
1777 -----------------------------------
1778 -- 9.7.2 Entry Call Alternative --
1779 -----------------------------------
1781 -- Parsed by P_Select_Statement (9.7)
1783 -----------------------------------
1784 -- 9.7.3 Conditional Entry Call --
1785 -----------------------------------
1787 -- Parsed by P_Select_Statement (9.7)
1789 --------------------------------
1790 -- 9.7.4 Asynchronous Select --
1791 --------------------------------
1793 -- Parsed by P_Select_Statement (9.7)
1795 -----------------------------------
1796 -- 9.7.4 Triggering Alternative --
1797 -----------------------------------
1799 -- Parsed by P_Select_Statement (9.7)
1801 ---------------------------------
1802 -- 9.7.4 Triggering Statement --
1803 ---------------------------------
1805 -- Parsed by P_Select_Statement (9.7)
1807 ---------------------------
1808 -- 9.7.4 Abortable Part --
1809 ---------------------------
1811 -- ABORTABLE_PART ::= SEQUENCE_OF_STATEMENTS
1813 -- The caller has verified that THEN ABORT is present, and Token is
1814 -- pointing to the ABORT on entry (or if not, then we have an error)
1816 -- Error recovery: cannot raise Error_Resync
1818 function P_Abortable_Part return Node_Id is
1819 Abortable_Part_Node : Node_Id;
1822 Abortable_Part_Node := New_Node (N_Abortable_Part, Token_Ptr);
1823 T_Abort; -- scan past ABORT
1825 if Ada_Version = Ada_83 then
1826 Error_Msg_SP ("(Ada 83) asynchronous select not allowed!");
1829 Set_Statements (Abortable_Part_Node, P_Sequence_Of_Statements (SS_Sreq));
1830 return Abortable_Part_Node;
1831 end P_Abortable_Part;
1833 --------------------------
1834 -- 9.8 Abort Statement --
1835 --------------------------
1837 -- ABORT_STATEMENT ::= abort task_NAME {, task_NAME};
1839 -- The caller has checked that the initial token is ABORT
1841 -- Error recovery: cannot raise Error_Resync
1843 function P_Abort_Statement return Node_Id is
1844 Abort_Node : Node_Id;
1847 Abort_Node := New_Node (N_Abort_Statement, Token_Ptr);
1849 Set_Names (Abort_Node, New_List);
1852 Append (P_Name, Names (Abort_Node));
1853 exit when Token /= Tok_Comma;
1859 end P_Abort_Statement;