+ ------------------------------
+ -- P_Conditional_Expression --
+ ------------------------------
+
+ function P_Conditional_Expression return Node_Id is
+ Exprs : constant List_Id := New_List;
+ Loc : constant Source_Ptr := Token_Ptr;
+ Expr : Node_Id;
+ State : Saved_Scan_State;
+
+ begin
+ Inside_Conditional_Expression := Inside_Conditional_Expression + 1;
+
+ if Token = Tok_If and then not Extensions_Allowed then
+ Error_Msg_SC ("|conditional expression is an Ada extension");
+ Error_Msg_SC ("\|use -gnatX switch to compile this unit");
+ end if;
+
+ Scan; -- past IF or ELSIF
+ Append_To (Exprs, P_Expression_No_Right_Paren);
+ TF_Then;
+ Append_To (Exprs, P_Expression);
+
+ -- We now have scanned out IF expr THEN expr
+
+ -- Check for common error of semicolon before the ELSE
+
+ if Token = Tok_Semicolon then
+ Save_Scan_State (State);
+ Scan; -- past semicolon
+
+ if Token = Tok_Else or else Token = Tok_Elsif then
+ Error_Msg_SP ("|extra "";"" ignored");
+
+ else
+ Restore_Scan_State (State);
+ end if;
+ end if;
+
+ -- Scan out ELSIF sequence if present
+
+ if Token = Tok_Elsif then
+ Expr := P_Conditional_Expression;
+ Set_Is_Elsif (Expr);
+ Append_To (Exprs, Expr);
+
+ -- Scan out ELSE phrase if present
+
+ elsif Token = Tok_Else then
+
+ -- Scan out ELSE expression
+
+ Scan; -- Past ELSE
+ Append_To (Exprs, P_Expression);
+
+ -- Two expression case (implied True, filled in during semantics)
+
+ else
+ null;
+ end if;
+
+ -- If we have an END IF, diagnose as not needed
+
+ if Token = Tok_End then
+ Error_Msg_SC
+ ("`END IF` not allowed at end of conditional expression");
+ Scan; -- past END
+
+ if Token = Tok_If then
+ Scan; -- past IF;
+ end if;
+ end if;
+
+ Inside_Conditional_Expression := Inside_Conditional_Expression - 1;
+
+ -- Return the Conditional_Expression node
+
+ return
+ Make_Conditional_Expression (Loc,
+ Expressions => Exprs);
+ end P_Conditional_Expression;
+
+ -----------------------
+ -- P_Membership_Test --
+ -----------------------
+
+ procedure P_Membership_Test (N : Node_Id) is
+ Alt : constant Node_Id :=
+ P_Range_Or_Subtype_Mark
+ (Allow_Simple_Expression => Extensions_Allowed);
+
+ begin
+ -- Set case
+
+ if Token = Tok_Vertical_Bar then
+ if not Extensions_Allowed then
+ Error_Msg_SC ("set notation is a language extension");
+ Error_Msg_SC ("\|use -gnatX switch to compile this unit");
+ end if;
+
+ Set_Alternatives (N, New_List (Alt));
+ Set_Right_Opnd (N, Empty);
+
+ -- Loop to accumulate alternatives
+
+ while Token = Tok_Vertical_Bar loop
+ Scan; -- past vertical bar
+ Append_To
+ (Alternatives (N),
+ P_Range_Or_Subtype_Mark (Allow_Simple_Expression => True));
+ end loop;
+
+ -- Not set case
+
+ else
+ Set_Right_Opnd (N, Alt);
+ Set_Alternatives (N, No_List);
+ end if;
+ end P_Membership_Test;
+