Loop_Parameter_Specification =>
Make_Loop_Parameter_Specification (Loc,
Defining_Identifier => Loop_Id,
+ Reverse_Present => Reverse_Present (Comp),
Discrete_Subtype_Definition => L_Range));
end if;
end if;
Sy (Iterator_Specification, Node_Id, Default_Empty),
Sy (Expression, Node_Id, Default_Empty),
Sy (Discrete_Choices, List_Id),
+ Sy (Reverse_Present, Flag),
Sy (Box_Present, Flag),
Sm (Loop_Actions, List_Id)));
elsif Token = Tok_Left_Paren then
return P_Index_Or_Discriminant_Constraint;
- elsif Token = Tok_In then
- Ignore (Tok_In);
- return P_Constraint_Opt;
-
-- One more possibility is e.g. 1 .. 10 (i.e. missing RANGE keyword)
elsif Token = Tok_Identifier or else
Iter_Spec : Node_Id;
Loop_Spec : Node_Id;
State : Saved_Scan_State;
+ In_Reverse : Boolean := False;
procedure Build_Iterated_Element_Association;
-- If the iterator includes a key expression or a filter, it is
New_Node (N_Loop_Parameter_Specification, Prev_Token_Ptr);
Set_Defining_Identifier (Loop_Spec, Id);
+ Set_Reverse_Present (Loop_Spec, In_Reverse);
+
Choice := First (Discrete_Choices (Assoc_Node));
Assoc_Node :=
New_Node (N_Iterated_Element_Association, Prev_Token_Ptr);
when Tok_In =>
Set_Defining_Identifier (Assoc_Node, Id);
T_In;
+
+ if Token = Tok_Reverse then
+ Scan; -- past REVERSE
+ Set_Reverse_Present (Assoc_Node, True);
+ In_Reverse := True;
+ end if;
+
Set_Discrete_Choices (Assoc_Node, P_Discrete_Choice_List);
-- The iterator may include a filter
TF_Arrow;
Set_Expression (Assoc_Node, P_Expression);
- when Tok_Of =>
+ when Tok_Colon | Tok_Of =>
Restore_Scan_State (State);
Scan; -- past OF
Iter_Spec := P_Iterator_Specification (Id);
elsif Token = Tok_In then
Scan; -- past IN
- elsif Prev_Token = Tok_In
- and then Present (Subtype_Indication (Node1))
- then
- -- Simplest recovery is to transform it into an element iterator.
- -- Error message on 'in" has already been emitted when parsing the
- -- optional constraint.
-
- Set_Of_Present (Node1);
- Error_Msg_N
- ("subtype indication is only legal on an element iterator",
- Subtype_Indication (Node1));
-
else
return Error;
end if;
Defining_Identifier =>
Relocate_Node (Defining_Identifier (Comp)),
Name => Copy,
- Reverse_Present => False,
+ Reverse_Present => Reverse_Present (Comp),
Iterator_Filter => Empty,
Subtype_Indication => Empty);
begin
-- At most one of (Defining_Identifier, Iterator_Specification)
-- is present at a time, in which case the other one is empty.
+ -- The Reverse_Present flag is present for cases where semantic analysis
+ -- later changes the association to have an N_Iterator_Specification
+ -- rather than a Defining_Identifier (due to the "discrete choice"
+ -- being resolved as an iterator name), and needs to set that flag on
+ -- the N_Iterator_Specification node.
-- N_Iterated_Component_Association
-- Sloc points to FOR
-- Iterator_Specification
-- Expression
-- Discrete_Choices
+ -- Reverse_Present
-- Loop_Actions
-- Box_Present