This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Implement set membership, step 1 syntax


This patch is the first step to implementing set membership, defined
as shown by the following example:

pragma Extensions_Allowed (On);
procedure smem is
begin
   if A in B | C .. D | X + Y then
      null;
   end if;
end smem;

The alternatives are either simple expressions, subtype
names, or ranges. The semantics is obvious, to be defined
more carefully later. For now this patch only implements
the syntax, it will be followed up by further patches to
fully implement this feature.

Compiling the above with -gnatsG yields:

Source recreated from tree for smem (body)
------------------------------------------

pragma extensions_allowed (on);

procedure smem is
begin
   if a in b | c .. d | x + y then
      null;
   end if;
end smem;

Tested on x86_64-pc-linux-gnu, committed on trunk

2009-07-13  Robert Dewar  <dewar@adacore.com>

	* par-ch3.adb (P_Discrete_Choice_List): Choice can only be simple
	expression if extensions permitted.

	* par-ch4.adb (P_Membership_Test): New procedure (implement membership
	set tests).
	(P_Relation): Use P_Membership_Test

	* par.adb (P_Membership_Test): New procedure (implement membership set
	tests).

	* sinfo.ads, sinfo.adb (N_In, N_Not_In) Add Alternatives field for sets.

	* sprint.adb (Sprint_Node): Handle set form for membership tests.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]