aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2022-08-17 12:50:42 -0400
committerMarc Poulhiès <poulhies@adacore.com>2022-09-12 10:16:49 +0200
commit272ada7499e6ce8e1a8bd3f82c1cc030a51d074e (patch)
tree24451793bc0d5f11414bed202922dc3440a49392 /gcc/ada
parentdad0ebe674d495a7e032a123d2d60c090729ef2c (diff)
downloadgcc-272ada7499e6ce8e1a8bd3f82c1cc030a51d074e.zip
gcc-272ada7499e6ce8e1a8bd3f82c1cc030a51d074e.tar.gz
gcc-272ada7499e6ce8e1a8bd3f82c1cc030a51d074e.tar.bz2
[Ada] Parser and lexer cleanup
This patch makes various minor cleanup changes to the parser. No change in behavior. gcc/ada/ * par-tchk.adb, par-util.adb, prep.adb, prepcomp.adb, scng.adb: Use "in" instead of chains of "=" connected with "or else". Likewise for "not in", "/=", "and then". Misc cleanup. * par-ch10.adb, par-ch12.adb, par-ch13.adb, par-ch4.adb: Likewise. * par-ch8.adb, par-ch9.adb, par-endh.adb, par-sync.adb: Likewise. * par.adb (Pf_Rec): Remove filler, which was added August 25, 1993 to get around a compiler limitation that no longer exists. Minor cleanup. Remove useless qualfications. * par-ch3.adb: Remove redundant return statements. (Component_Scan_Loop): Remove loop name; there are no nested loops, so it's unnecessary and possibly misleading, and it causes too-long lines. * par-ch5.adb: DRY: Remove comments that repeat the comments in par.adb. (P_Sequence_Of_Statements): It is better to initialize things on the declaration. And constants are better than variables. (Test_Statement_Required): Remove unnecessary insertion of a null statement. * par-ch6.adb, par-ch7.adb: DRY: Remove comments that repeat the comments in par.adb.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/par-ch10.adb29
-rw-r--r--gcc/ada/par-ch12.adb5
-rw-r--r--gcc/ada/par-ch13.adb8
-rw-r--r--gcc/ada/par-ch3.adb71
-rw-r--r--gcc/ada/par-ch4.adb824
-rw-r--r--gcc/ada/par-ch5.adb86
-rw-r--r--gcc/ada/par-ch6.adb58
-rw-r--r--gcc/ada/par-ch7.adb15
-rw-r--r--gcc/ada/par-ch8.adb2
-rw-r--r--gcc/ada/par-ch9.adb11
-rw-r--r--gcc/ada/par-endh.adb24
-rw-r--r--gcc/ada/par-sync.adb22
-rw-r--r--gcc/ada/par-tchk.adb35
-rw-r--r--gcc/ada/par-util.adb34
-rw-r--r--gcc/ada/par.adb61
-rw-r--r--gcc/ada/prep.adb43
-rw-r--r--gcc/ada/prepcomp.adb4
-rw-r--r--gcc/ada/scng.adb12
18 files changed, 574 insertions, 770 deletions
diff --git a/gcc/ada/par-ch10.adb b/gcc/ada/par-ch10.adb
index 613be37..70fd7ad 100644
--- a/gcc/ada/par-ch10.adb
+++ b/gcc/ada/par-ch10.adb
@@ -279,10 +279,7 @@ package body Ch10 is
Set_Private_Present (Comp_Unit_Node, True);
end if;
- elsif Token = Tok_Procedure
- or else Token = Tok_Function
- or else Token = Tok_Generic
- then
+ elsif Token in Tok_Procedure | Tok_Function | Tok_Generic then
Set_Private_Present (Comp_Unit_Node, True);
end if;
end if;
@@ -300,8 +297,7 @@ package body Ch10 is
-- Allow task and protected for nice error recovery purposes
- exit when Token = Tok_Task
- or else Token = Tok_Protected;
+ exit when Token in Tok_Task | Tok_Protected;
if Token = Tok_With then
Error_Msg_SC ("misplaced WITH");
@@ -376,10 +372,7 @@ package body Ch10 is
elsif Token = Tok_Separate then
Set_Unit (Comp_Unit_Node, P_Subunit);
- elsif Token = Tok_Function
- or else Token = Tok_Not
- or else Token = Tok_Overriding
- or else Token = Tok_Procedure
+ elsif Token in Tok_Function | Tok_Not | Tok_Overriding | Tok_Procedure
then
Set_Unit (Comp_Unit_Node, P_Subprogram (Pf_Decl_Gins_Pbod_Rnam_Pexp));
@@ -392,10 +385,7 @@ package body Ch10 is
if SIS_Entry_Active then
- if Token = Tok_Begin
- or else Token = Tok_Identifier
- or else Token in Token_Class_Deckn
- then
+ if Token in Tok_Begin | Tok_Identifier | Token_Class_Deckn then
Push_Scope_Stack;
Scopes (Scope.Last).Etyp := E_Name;
Scopes (Scope.Last).Sloc := SIS_Sloc;
@@ -947,10 +937,7 @@ package body Ch10 is
Save_Scan_State (Scan_State);
Scan; -- past comma
- if Token in Token_Class_Cunit
- or else Token = Tok_Use
- or else Token = Tok_Pragma
- then
+ if Token in Token_Class_Cunit | Tok_Use | Tok_Pragma then
Restore_Scan_State (Scan_State);
exit;
end if;
@@ -1047,11 +1034,7 @@ package body Ch10 is
Ignore (Tok_Semicolon);
- if Token = Tok_Function
- or else Token = Tok_Not
- or else Token = Tok_Overriding
- or else Token = Tok_Procedure
- then
+ if Token in Tok_Function | Tok_Not | Tok_Overriding | Tok_Procedure then
Body_Node := P_Subprogram (Pf_Pbod_Pexp);
elsif Token = Tok_Package then
diff --git a/gcc/ada/par-ch12.adb b/gcc/ada/par-ch12.adb
index fc76ad4..0f124f0 100644
--- a/gcc/ada/par-ch12.adb
+++ b/gcc/ada/par-ch12.adb
@@ -114,10 +114,7 @@ package body Ch12 is
-- Check for generic renaming declaration case
- if Token = Tok_Package
- or else Token = Tok_Function
- or else Token = Tok_Procedure
- then
+ if Token in Tok_Package | Tok_Function | Tok_Procedure then
Ren_Token := Token;
Scan; -- scan past PACKAGE, FUNCTION or PROCEDURE
diff --git a/gcc/ada/par-ch13.adb b/gcc/ada/par-ch13.adb
index ca925d0..62e5807 100644
--- a/gcc/ada/par-ch13.adb
+++ b/gcc/ada/par-ch13.adb
@@ -336,7 +336,7 @@ package body Ch13 is
-- Check for a missing aspect definition. Aspects with optional
-- definitions are not considered.
- if Token = Tok_Comma or else Token = Tok_Semicolon then
+ if Token in Tok_Comma | Tok_Semicolon then
if not Opt then
Error_Msg_Node_1 := Identifier (Aspect);
Error_Msg_AP ("aspect& requires an aspect definition");
@@ -367,7 +367,7 @@ package body Ch13 is
-- aspect Depends, Global, Refined_Depends, Refined_Global
-- or Refined_State lacks enclosing parentheses.
- if Token /= Tok_Left_Paren and then Token /= Tok_Null then
+ if Token not in Tok_Left_Paren | Tok_Null then
-- [Refined_]Depends
@@ -571,7 +571,7 @@ package body Ch13 is
-- Attempt to detect ' or => following a potential aspect
-- mark.
- if Token = Tok_Apostrophe or else Token = Tok_Arrow then
+ if Token in Tok_Apostrophe | Tok_Arrow then
Restore_Scan_State (Scan_State);
Error_Msg_AP -- CODEFIX
("|missing "",""");
@@ -603,7 +603,7 @@ package body Ch13 is
-- Attempt to detect ' or => following potential aspect mark
- if Token = Tok_Apostrophe or else Token = Tok_Arrow then
+ if Token in Tok_Apostrophe | Tok_Arrow then
Restore_Scan_State (Scan_State);
Error_Msg_SC -- CODEFIX
("|"";"" should be "",""");
diff --git a/gcc/ada/par-ch3.adb b/gcc/ada/par-ch3.adb
index 82df4cf..5684839 100644
--- a/gcc/ada/par-ch3.adb
+++ b/gcc/ada/par-ch3.adb
@@ -145,10 +145,7 @@ package body Ch3 is
-- Here if := or something that we will take as equivalent
- elsif Token = Tok_Colon_Equal
- or else Token = Tok_Equal
- or else Token = Tok_Is
- then
+ elsif Token in Tok_Colon_Equal | Tok_Equal | Tok_Is then
null;
-- Another possibility. If we have a literal followed by a semicolon,
@@ -400,9 +397,7 @@ package body Ch3 is
-- Ada 2005 (AI-419): AARM 3.4 (2/2)
if (Ada_Version < Ada_2005 and then Token = Tok_Limited)
- or else Token = Tok_Private
- or else Token = Tok_Record
- or else Token = Tok_Null
+ or else Token in Tok_Private | Tok_Record | Tok_Null
then
Error_Msg_AP ("TAGGED expected");
end if;
@@ -610,7 +605,7 @@ package body Ch3 is
-- LIMITED RECORD or LIMITED NULL RECORD
- if Token = Tok_Record or else Token = Tok_Null then
+ if Token in Tok_Record | Tok_Null then
if Ada_Version = Ada_83 then
Error_Msg_SP
("(Ada 83) limited record declaration not allowed!");
@@ -1005,7 +1000,7 @@ package body Ch3 is
Type_Node : Node_Id;
begin
- if Token = Tok_Identifier or else Token = Tok_Operator_Symbol then
+ if Token in Tok_Identifier | Tok_Operator_Symbol then
Type_Node := P_Subtype_Mark;
return P_Subtype_Indication (Type_Node, Not_Null_Present);
@@ -2095,10 +2090,7 @@ package body Ch3 is
-- OK, not an aspect specification, so continue test for extension
- elsif Token = Tok_With
- or else Token = Tok_Record
- or else Token = Tok_Null
- then
+ elsif Token in Tok_With | Tok_Record | Tok_Null then
T_With; -- past WITH or give error message
if Token = Tok_Limited then
@@ -2279,7 +2271,7 @@ package body Ch3 is
-- Check for error of DIGITS or DELTA after a subtype mark
- elsif Token = Tok_Digits or else Token = Tok_Delta then
+ elsif Token in Tok_Digits | Tok_Delta then
Error_Msg_SC
("accuracy definition not allowed in membership test");
Scan; -- past DIGITS or DELTA
@@ -2850,7 +2842,7 @@ package body Ch3 is
Error_Msg_GNAT_Extension ("fixed-lower-bound array", Token_Ptr);
end if;
- exit when Token = Tok_Right_Paren or else Token = Tok_Of;
+ exit when Token in Tok_Right_Paren | Tok_Of;
T_Comma;
end loop;
@@ -2865,7 +2857,7 @@ package body Ch3 is
-- constrained_array_definition, which will be processed further below.
elsif Prev_Token = Tok_Range
- and then Token /= Tok_Right_Paren and then Token /= Tok_Comma
+ and then Token not in Tok_Right_Paren | Tok_Comma
then
-- If we have an expression followed by "..", then scan farther
-- and check for "<>" to see if we have a fixed-lower-bound range.
@@ -2920,7 +2912,7 @@ package body Ch3 is
("fixed-lower-bound array", Token_Ptr);
end if;
- exit when Token = Tok_Right_Paren or else Token = Tok_Of;
+ exit when Token in Tok_Right_Paren | Tok_Of;
T_Comma;
end loop;
@@ -3382,7 +3374,7 @@ package body Ch3 is
Save_Scan_State (Scan_State); -- at Id
Scan; -- past Id
- if Token = Tok_Arrow or else Token = Tok_Vertical_Bar then
+ if Token in Tok_Arrow | Tok_Vertical_Bar then
Restore_Scan_State (Scan_State); -- to Id
Append (P_Discriminant_Association, Constr_List);
goto Loop_Continue;
@@ -3644,7 +3636,7 @@ package body Ch3 is
-- If we have an END or WHEN now, everything is fine, otherwise we
-- complain about the null, ignore it, and scan for more components.
- if Token = Tok_End or else Token = Tok_When then
+ if Token in Tok_End | Tok_When then
Set_Null_Present (Component_List_Node, True);
return Component_List_Node;
else
@@ -3657,13 +3649,11 @@ package body Ch3 is
P_Pragmas_Opt (Decls_List);
if Token /= Tok_Case then
- Component_Scan_Loop : loop
+ loop
P_Component_Items (Decls_List);
P_Pragmas_Opt (Decls_List);
- exit Component_Scan_Loop when Token = Tok_End
- or else Token = Tok_Case
- or else Token = Tok_When;
+ exit when Token in Tok_End | Tok_Case | Tok_When;
-- We are done if we do not have an identifier. However, if we
-- have a misspelled reserved identifier that is in a column to
@@ -3679,7 +3669,7 @@ package body Ch3 is
Save_Scan_State (Scan_State); -- at reserved id
Scan; -- possible reserved id
- if Token = Tok_Comma or else Token = Tok_Colon then
+ if Token in Tok_Comma | Tok_Colon then
Restore_Scan_State (Scan_State);
Scan_Reserved_Identifier (Force_Msg => True);
@@ -3688,16 +3678,16 @@ package body Ch3 is
else
Restore_Scan_State (Scan_State);
- exit Component_Scan_Loop;
+ exit;
end if;
-- Non-identifier that definitely was not reserved id
else
- exit Component_Scan_Loop;
+ exit;
end if;
end if;
- end loop Component_Scan_Loop;
+ end loop;
end if;
if Token = Tok_Case then
@@ -3948,10 +3938,7 @@ package body Ch3 is
loop
P_Pragmas_Opt (Variants_List);
- if Token /= Tok_When
- and then Token /= Tok_If
- and then Token /= Tok_Others
- then
+ if Token not in Tok_When | Tok_If | Tok_Others then
exit when Check_End;
end if;
@@ -4267,14 +4254,12 @@ package body Ch3 is
Saved_State : Saved_Scan_State;
begin
- if Token = Tok_Identifier or else Token = Tok_Operator_Symbol then
+ if Token in Tok_Identifier | Tok_Operator_Symbol then
Save_Scan_State (Saved_State);
Scan; -- past possible junk subprogram name
- if Token = Tok_Left_Paren or else Token = Tok_Semicolon then
+ if Token in Tok_Left_Paren | Tok_Semicolon then
Error_Msg_SP ("unexpected subprogram name ignored");
- return;
-
else
Restore_Scan_State (Saved_State);
end if;
@@ -4327,7 +4312,7 @@ package body Ch3 is
if Prot_Flag then
Scan; -- past PROTECTED
- if Token /= Tok_Procedure and then Token /= Tok_Function then
+ if Token not in Tok_Procedure | Tok_Function then
Error_Msg_SC -- CODEFIX
("FUNCTION or PROCEDURE expected");
end if;
@@ -4402,7 +4387,7 @@ package body Ch3 is
Set_Null_Exclusion_Present (Type_Def_Node, Not_Null_Present);
Set_Null_Excluding_Subtype (Type_Def_Node, Not_Null_Subtype);
- if Token = Tok_All or else Token = Tok_Constant then
+ if Token in Tok_All | Tok_Constant then
if Ada_Version = Ada_83 then
Error_Msg_SC ("(Ada 83) access modifier not allowed!");
end if;
@@ -4472,10 +4457,7 @@ package body Ch3 is
-- Ada 2005 (AI-254): Access_To_Subprogram_Definition
- if Token = Tok_Protected
- or else Token = Tok_Procedure
- or else Token = Tok_Function
- then
+ if Token in Tok_Protected | Tok_Procedure | Tok_Function then
Error_Msg_Ada_2005_Extension ("access-to-subprogram");
Subp_Node := P_Access_Type_Definition (Header_Already_Parsed => True);
@@ -4629,7 +4611,6 @@ package body Ch3 is
end if;
Done := True;
- return;
else
Append (P_Representation_Clause, Decls);
end if;
@@ -4873,10 +4854,9 @@ package body Ch3 is
-- If reserved identifier not followed by colon or comma, then
-- this is most likely an assignment statement to the bad id.
- if Token /= Tok_Colon and then Token /= Tok_Comma then
+ if Token not in Tok_Colon | Tok_Comma then
Restore_Scan_State (Scan_State);
Statement_When_Declaration_Expected (Decls, Done, In_Spec);
- return;
-- Otherwise we have a declaration of the bad id
@@ -4892,7 +4872,6 @@ package body Ch3 is
else
Statement_When_Declaration_Expected (Decls, Done, In_Spec);
- return;
end if;
-- The token RETURN may well also signal a missing BEGIN situation,
@@ -4941,7 +4920,7 @@ package body Ch3 is
Save_Scan_State (Scan_State);
Scan; -- past the token
- if Token /= Tok_Colon and then Token /= Tok_Comma then
+ if Token not in Tok_Colon | Tok_Comma then
Restore_Scan_State (Scan_State);
Set_Declaration_Expected;
raise Error_Resync;
diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb
index 9a00d7b..0dc6c8a 100644
--- a/gcc/ada/par-ch4.adb
+++ b/gcc/ada/par-ch4.adb
@@ -225,9 +225,7 @@ package body Ch4 is
-- If it looks like start of expression, complain and scan expression
- if Token in Token_Class_Literal
- or else Token = Tok_Left_Paren
- then
+ if Token in Token_Class_Literal | Tok_Left_Paren then
Error_Msg_SC ("name expected");
return P_Expression;
@@ -303,7 +301,7 @@ package body Ch4 is
-- The treatment for the range attribute is similar (we do not
-- consider x'range to be a name in this grammar).
- elsif Token = Tok_Left_Paren or else Token = Tok_Range then
+ elsif Token in Tok_Left_Paren | Tok_Range then
Restore_Scan_State (Scan_State); -- to apostrophe
Expr_Form := EF_Simple_Name;
return Name_Node;
@@ -334,446 +332,449 @@ package body Ch4 is
<<Scan_Name_Extension>>
- -- Character literal used as name cannot be extended. Also this
- -- cannot be a call, since the name for a call must be a designator.
- -- Return in these cases, or if there is no name extension
+ -- Character literal used as name cannot be extended. Also this
+ -- cannot be a call, since the name for a call must be a designator.
+ -- Return in these cases, or if there is no name extension
- if Token not in Token_Class_Namext
- or else Prev_Token = Tok_Char_Literal
- then
- Expr_Form := EF_Name;
- return Name_Node;
- end if;
+ if Token not in Token_Class_Namext
+ or else Prev_Token = Tok_Char_Literal
+ then
+ Expr_Form := EF_Name;
+ return Name_Node;
+ end if;
-- Merge here when we know there is a name extension
<<Scan_Name_Extension_OK>>
- if Token = Tok_Left_Paren then
+ case Token is
+ when Tok_Left_Paren =>
Scan; -- past left paren
goto Scan_Name_Extension_Left_Paren;
- elsif Token = Tok_Apostrophe then
+ when Tok_Apostrophe =>
Save_Scan_State (Scan_State); -- at apostrophe
Scan; -- past apostrophe
goto Scan_Name_Extension_Apostrophe;
- else -- Token = Tok_Dot
+ when Tok_Dot =>
Save_Scan_State (Scan_State); -- at dot
Scan; -- past dot
goto Scan_Name_Extension_Dot;
- end if;
+
+ when others => raise Program_Error;
+ end case;
-- Case of name extended by dot (selection), dot is already skipped
-- and the scan state at the point of the dot is saved in Scan_State.
<<Scan_Name_Extension_Dot>>
- -- Explicit dereference case
+ -- Explicit dereference case
- if Token = Tok_All then
- Prefix_Node := Name_Node;
- Name_Node := New_Node (N_Explicit_Dereference, Token_Ptr);
- Set_Prefix (Name_Node, Prefix_Node);
- Scan; -- past ALL
- goto Scan_Name_Extension;
+ if Token = Tok_All then
+ Prefix_Node := Name_Node;
+ Name_Node := New_Node (N_Explicit_Dereference, Token_Ptr);
+ Set_Prefix (Name_Node, Prefix_Node);
+ Scan; -- past ALL
+ goto Scan_Name_Extension;
-- Selected component case
- elsif Token in Token_Class_Name then
- Prefix_Node := Name_Node;
- Name_Node := New_Node (N_Selected_Component, Prev_Token_Ptr);
- Set_Prefix (Name_Node, Prefix_Node);
- Set_Selector_Name (Name_Node, Token_Node);
- Scan; -- past selector
- goto Scan_Name_Extension;
+ elsif Token in Token_Class_Name then
+ Prefix_Node := Name_Node;
+ Name_Node := New_Node (N_Selected_Component, Prev_Token_Ptr);
+ Set_Prefix (Name_Node, Prefix_Node);
+ Set_Selector_Name (Name_Node, Token_Node);
+ Scan; -- past selector
+ goto Scan_Name_Extension;
-- Reserved identifier as selector
- elsif Is_Reserved_Identifier then
- Scan_Reserved_Identifier (Force_Msg => False);
- Prefix_Node := Name_Node;
- Name_Node := New_Node (N_Selected_Component, Prev_Token_Ptr);
- Set_Prefix (Name_Node, Prefix_Node);
- Set_Selector_Name (Name_Node, Token_Node);
- Scan; -- past identifier used as selector
- goto Scan_Name_Extension;
+ elsif Is_Reserved_Identifier then
+ Scan_Reserved_Identifier (Force_Msg => False);
+ Prefix_Node := Name_Node;
+ Name_Node := New_Node (N_Selected_Component, Prev_Token_Ptr);
+ Set_Prefix (Name_Node, Prefix_Node);
+ Set_Selector_Name (Name_Node, Token_Node);
+ Scan; -- past identifier used as selector
+ goto Scan_Name_Extension;
-- If dot is at end of line and followed by nothing legal,
-- then assume end of name and quit (dot will be taken as
-- an incorrect form of some other punctuation by our caller).
- elsif Token_Is_At_Start_Of_Line then
- Restore_Scan_State (Scan_State);
- return Name_Node;
+ elsif Token_Is_At_Start_Of_Line then
+ Restore_Scan_State (Scan_State);
+ return Name_Node;
-- Here if nothing legal after the dot
- else
- Error_Msg_AP ("selector expected");
- raise Error_Resync;
- end if;
+ else
+ Error_Msg_AP ("selector expected");
+ raise Error_Resync;
+ end if;
-- Here for an apostrophe as name extension. The scan position at the
-- apostrophe has already been saved, and the apostrophe scanned out.
<<Scan_Name_Extension_Apostrophe>>
- Scan_Apostrophe : declare
- function Apostrophe_Should_Be_Semicolon return Boolean;
- -- Checks for case where apostrophe should probably be
- -- a semicolon, and if so, gives appropriate message,
- -- resets the scan pointer to the apostrophe, changes
- -- the current token to Tok_Semicolon, and returns True.
- -- Otherwise returns False.
-
- ------------------------------------
- -- Apostrophe_Should_Be_Semicolon --
- ------------------------------------
-
- function Apostrophe_Should_Be_Semicolon return Boolean is
- begin
- if Token_Is_At_Start_Of_Line then
- Restore_Scan_State (Scan_State); -- to apostrophe
- Error_Msg_SC ("|""''"" should be "";""");
- Token := Tok_Semicolon;
- return True;
- else
- return False;
- end if;
- end Apostrophe_Should_Be_Semicolon;
+ Scan_Apostrophe : declare
+ function Apostrophe_Should_Be_Semicolon return Boolean;
+ -- Checks for case where apostrophe should probably be
+ -- a semicolon, and if so, gives appropriate message,
+ -- resets the scan pointer to the apostrophe, changes
+ -- the current token to Tok_Semicolon, and returns True.
+ -- Otherwise returns False.
- -- Start of processing for Scan_Apostrophe
+ ------------------------------------
+ -- Apostrophe_Should_Be_Semicolon --
+ ------------------------------------
+ function Apostrophe_Should_Be_Semicolon return Boolean is
begin
- -- Check for qualified expression case in Ada 2012 mode
+ if Token_Is_At_Start_Of_Line then
+ Restore_Scan_State (Scan_State); -- to apostrophe
+ Error_Msg_SC ("|""''"" should be "";""");
+ Token := Tok_Semicolon;
+ return True;
+ else
+ return False;
+ end if;
+ end Apostrophe_Should_Be_Semicolon;
- if Ada_Version >= Ada_2012
- and then Token in Tok_Left_Paren | Tok_Left_Bracket
- then
- Name_Node := P_Qualified_Expression (Name_Node);
- goto Scan_Name_Extension;
+ -- Start of processing for Scan_Apostrophe
- -- If range attribute after apostrophe, then return with Token
- -- pointing to the apostrophe. Note that in this case the prefix
- -- need not be a simple name (cases like A.all'range). Similarly
- -- if there is a left paren after the apostrophe, then we also
- -- return with Token pointing to the apostrophe (this is the
- -- aggregate case, or some error case).
+ begin
+ -- Check for qualified expression case in Ada 2012 mode
- elsif Token = Tok_Range or else Token = Tok_Left_Paren then
- Restore_Scan_State (Scan_State); -- to apostrophe
- Expr_Form := EF_Name;
- return Name_Node;
+ if Ada_Version >= Ada_2012
+ and then Token in Tok_Left_Paren | Tok_Left_Bracket
+ then
+ Name_Node := P_Qualified_Expression (Name_Node);
+ goto Scan_Name_Extension;
- -- Here for cases where attribute designator is an identifier
+ -- If range attribute after apostrophe, then return with Token
+ -- pointing to the apostrophe. Note that in this case the prefix
+ -- need not be a simple name (cases like A.all'range). Similarly
+ -- if there is a left paren after the apostrophe, then we also
+ -- return with Token pointing to the apostrophe (this is the
+ -- aggregate case, or some error case).
- elsif Token = Tok_Identifier then
- Attr_Name := Token_Name;
+ elsif Token in Tok_Range | Tok_Left_Paren then
+ Restore_Scan_State (Scan_State); -- to apostrophe
+ Expr_Form := EF_Name;
+ return Name_Node;
- if not Is_Attribute_Name (Attr_Name) then
- if Apostrophe_Should_Be_Semicolon then
- Expr_Form := EF_Name;
- return Name_Node;
+ -- Here for cases where attribute designator is an identifier
- -- Here for a bad attribute name
+ elsif Token = Tok_Identifier then
+ Attr_Name := Token_Name;
- else
- Signal_Bad_Attribute;
- Scan; -- past bad identifier
+ if not Is_Attribute_Name (Attr_Name) then
+ if Apostrophe_Should_Be_Semicolon then
+ Expr_Form := EF_Name;
+ return Name_Node;
- if Token = Tok_Left_Paren then
- Scan; -- past left paren
+ -- Here for a bad attribute name
- loop
- Discard_Junk_Node (P_Expression_If_OK);
- exit when not Comma_Present;
- end loop;
+ else
+ Signal_Bad_Attribute;
+ Scan; -- past bad identifier
- T_Right_Paren;
- end if;
+ if Token = Tok_Left_Paren then
+ Scan; -- past left paren
- return Error;
+ loop
+ Discard_Junk_Node (P_Expression_If_OK);
+ exit when not Comma_Present;
+ end loop;
+
+ T_Right_Paren;
end if;
- end if;
- if Style_Check then
- Style.Check_Attribute_Name (False);
+ return Error;
end if;
+ end if;
- -- Here for case of attribute designator is not an identifier
+ if Style_Check then
+ Style.Check_Attribute_Name (False);
+ end if;
- else
- if Token = Tok_Delta then
- Attr_Name := Name_Delta;
+ -- Here for case of attribute designator is not an identifier
- elsif Token = Tok_Digits then
- Attr_Name := Name_Digits;
+ else
+ if Token = Tok_Delta then
+ Attr_Name := Name_Delta;
- elsif Token = Tok_Access then
- Attr_Name := Name_Access;
+ elsif Token = Tok_Digits then
+ Attr_Name := Name_Digits;
- elsif Token = Tok_Mod and then Ada_Version >= Ada_95 then
- Attr_Name := Name_Mod;
+ elsif Token = Tok_Access then
+ Attr_Name := Name_Access;
- elsif Apostrophe_Should_Be_Semicolon then
- Expr_Form := EF_Name;
- return Name_Node;
+ elsif Token = Tok_Mod and then Ada_Version >= Ada_95 then
+ Attr_Name := Name_Mod;
- else
- Error_Msg_AP ("attribute designator expected");
- raise Error_Resync;
- end if;
+ elsif Apostrophe_Should_Be_Semicolon then
+ Expr_Form := EF_Name;
+ return Name_Node;
- if Style_Check then
- Style.Check_Attribute_Name (True);
- end if;
+ else
+ Error_Msg_AP ("attribute designator expected");
+ raise Error_Resync;
end if;
- -- We come here with an OK attribute scanned, and corresponding
- -- Attribute identifier node stored in Ident_Node.
+ if Style_Check then
+ Style.Check_Attribute_Name (True);
+ end if;
+ end if;
- Prefix_Node := Name_Node;
- Name_Node := New_Node (N_Attribute_Reference, Prev_Token_Ptr);
- Scan; -- past attribute designator
- Set_Prefix (Name_Node, Prefix_Node);
- Set_Attribute_Name (Name_Node, Attr_Name);
+ -- We come here with an OK attribute scanned, and corresponding
+ -- Attribute identifier node stored in Ident_Node.
- -- Scan attribute arguments/designator. We skip this if we know
- -- that the attribute cannot have an argument (see documentation
- -- of Is_Parameterless_Attribute for further details).
+ Prefix_Node := Name_Node;
+ Name_Node := New_Node (N_Attribute_Reference, Prev_Token_Ptr);
+ Scan; -- past attribute designator
+ Set_Prefix (Name_Node, Prefix_Node);
+ Set_Attribute_Name (Name_Node, Attr_Name);
- if Token = Tok_Left_Paren
- and then not
- Is_Parameterless_Attribute (Get_Attribute_Id (Attr_Name))
- then
- -- Attribute Update contains an array or record association
- -- list which provides new values for various components or
- -- elements. The list is parsed as an aggregate, and we get
- -- better error handling by knowing that in the parser.
+ -- Scan attribute arguments/designator. We skip this if we know
+ -- that the attribute cannot have an argument (see documentation
+ -- of Is_Parameterless_Attribute for further details).
- if Attr_Name = Name_Update then
- Set_Expressions (Name_Node, New_List);
- Append (P_Aggregate, Expressions (Name_Node));
+ if Token = Tok_Left_Paren
+ and then not
+ Is_Parameterless_Attribute (Get_Attribute_Id (Attr_Name))
+ then
+ -- Attribute Update contains an array or record association
+ -- list which provides new values for various components or
+ -- elements. The list is parsed as an aggregate, and we get
+ -- better error handling by knowing that in the parser.
- -- All other cases of parsing attribute arguments
+ if Attr_Name = Name_Update then
+ Set_Expressions (Name_Node, New_List);
+ Append (P_Aggregate, Expressions (Name_Node));
- else
- Set_Expressions (Name_Node, New_List);
- Scan; -- past left paren
-
- loop
- declare
- Expr : constant Node_Id := P_Expression_If_OK;
- Rnam : Node_Id;
-
- begin
- -- Case of => for named notation
-
- if Token = Tok_Arrow then
-
- -- Named notation allowed only for the special
- -- case of System'Restriction_Set (No_Dependence =>
- -- unit_NAME), in which case construct a parameter
- -- assocation node and append to the arguments.
-
- if Attr_Name = Name_Restriction_Set
- and then Nkind (Expr) = N_Identifier
- and then Chars (Expr) = Name_No_Dependence
- then
- Scan; -- past arrow
- Rnam := P_Name;
- Append_To (Expressions (Name_Node),
- Make_Parameter_Association (Sloc (Rnam),
- Selector_Name => Expr,
- Explicit_Actual_Parameter => Rnam));
- exit;
-
- -- For all other cases named notation is illegal
-
- else
- Error_Msg_SC
- ("named parameters not permitted "
- & "for attributes");
- Scan; -- past junk arrow
- end if;
-
- -- Here for normal case (not => for named parameter)
+ -- All other cases of parsing attribute arguments
+
+ else
+ Set_Expressions (Name_Node, New_List);
+ Scan; -- past left paren
+
+ loop
+ declare
+ Expr : constant Node_Id := P_Expression_If_OK;
+ Rnam : Node_Id;
+
+ begin
+ -- Case of => for named notation
+
+ if Token = Tok_Arrow then
+
+ -- Named notation allowed only for the special
+ -- case of System'Restriction_Set (No_Dependence =>
+ -- unit_NAME), in which case construct a parameter
+ -- assocation node and append to the arguments.
+
+ if Attr_Name = Name_Restriction_Set
+ and then Nkind (Expr) = N_Identifier
+ and then Chars (Expr) = Name_No_Dependence
+ then
+ Scan; -- past arrow
+ Rnam := P_Name;
+ Append_To (Expressions (Name_Node),
+ Make_Parameter_Association (Sloc (Rnam),
+ Selector_Name => Expr,
+ Explicit_Actual_Parameter => Rnam));
+ exit;
+
+ -- For all other cases named notation is illegal
else
- -- Special handling for 'Image in Ada 2012, where
- -- the attribute can be parameterless and its value
- -- can be the prefix of a slice. Rewrite name as a
- -- slice, Expr is its low bound.
-
- if Token = Tok_Dot_Dot
- and then Attr_Name = Name_Image
- and then Ada_Version >= Ada_2012
- then
- Set_Expressions (Name_Node, No_List);
- Prefix_Node := Name_Node;
- Name_Node :=
- New_Node (N_Slice, Sloc (Prefix_Node));
- Set_Prefix (Name_Node, Prefix_Node);
- Range_Node := New_Node (N_Range, Token_Ptr);
- Set_Low_Bound (Range_Node, Expr);
- Scan; -- past ..
- Expr_Node := P_Expression;
- Check_Simple_Expression (Expr_Node);
- Set_High_Bound (Range_Node, Expr_Node);
- Set_Discrete_Range (Name_Node, Range_Node);
- T_Right_Paren;
-
- goto Scan_Name_Extension;
-
- else
- Append (Expr, Expressions (Name_Node));
- exit when not Comma_Present;
- end if;
+ Error_Msg_SC
+ ("named parameters not permitted "
+ & "for attributes");
+ Scan; -- past junk arrow
end if;
- end;
- end loop;
- T_Right_Paren;
- end if;
+ -- Here for normal case (not => for named parameter)
+
+ else
+ -- Special handling for 'Image in Ada 2012, where
+ -- the attribute can be parameterless and its value
+ -- can be the prefix of a slice. Rewrite name as a
+ -- slice, Expr is its low bound.
+
+ if Token = Tok_Dot_Dot
+ and then Attr_Name = Name_Image
+ and then Ada_Version >= Ada_2012
+ then
+ Set_Expressions (Name_Node, No_List);
+ Prefix_Node := Name_Node;
+ Name_Node :=
+ New_Node (N_Slice, Sloc (Prefix_Node));
+ Set_Prefix (Name_Node, Prefix_Node);
+ Range_Node := New_Node (N_Range, Token_Ptr);
+ Set_Low_Bound (Range_Node, Expr);
+ Scan; -- past ..
+ Expr_Node := P_Expression;
+ Check_Simple_Expression (Expr_Node);
+ Set_High_Bound (Range_Node, Expr_Node);
+ Set_Discrete_Range (Name_Node, Range_Node);
+ T_Right_Paren;
+
+ goto Scan_Name_Extension;
+
+ else
+ Append (Expr, Expressions (Name_Node));
+ exit when not Comma_Present;
+ end if;
+ end if;
+ end;
+ end loop;
+
+ T_Right_Paren;
end if;
+ end if;
- goto Scan_Name_Extension;
- end Scan_Apostrophe;
+ goto Scan_Name_Extension;
+ end Scan_Apostrophe;
-- Here for left parenthesis extending name (left paren skipped)
<<Scan_Name_Extension_Left_Paren>>
- -- We now have to scan through a list of items, terminated by a
- -- right parenthesis. The scan is handled by a finite state
- -- machine. The possibilities are:
+ -- We now have to scan through a list of items, terminated by a
+ -- right parenthesis. The scan is handled by a finite state
+ -- machine. The possibilities are:
- -- (discrete_range)
+ -- (discrete_range)
- -- This is a slice. This case is handled in LP_State_Init
+ -- This is a slice. This case is handled in LP_State_Init
- -- (expression, expression, ..)
+ -- (expression, expression, ..)
- -- This is interpreted as an indexed component, i.e. as a
- -- case of a name which can be extended in the normal manner.
- -- This case is handled by LP_State_Name or LP_State_Expr.
+ -- This is interpreted as an indexed component, i.e. as a
+ -- case of a name which can be extended in the normal manner.
+ -- This case is handled by LP_State_Name or LP_State_Expr.
- -- Note: if and case expressions (without an extra level of
- -- parentheses) are permitted in this context).
+ -- Note: if and case expressions (without an extra level of
+ -- parentheses) are permitted in this context).
- -- (..., identifier => expression , ...)
+ -- (..., identifier => expression , ...)
- -- If there is at least one occurrence of identifier => (but
- -- none of the other cases apply), then we have a call.
+ -- If there is at least one occurrence of identifier => (but
+ -- none of the other cases apply), then we have a call.
- -- Test for Id => case
+ -- Test for Id => case
- if Token = Tok_Identifier then
- Save_Scan_State (Scan_State); -- at Id
- Scan; -- past Id
+ if Token = Tok_Identifier then
+ Save_Scan_State (Scan_State); -- at Id
+ Scan; -- past Id
- -- Test for => (allow := as an error substitute)
+ -- Test for => (allow := as an error substitute)
- if Token = Tok_Arrow or else Token = Tok_Colon_Equal then
- Restore_Scan_State (Scan_State); -- to Id
- Arg_List := New_List;
- goto LP_State_Call;
+ if Token in Tok_Arrow | Tok_Colon_Equal then
+ Restore_Scan_State (Scan_State); -- to Id
+ Arg_List := New_List;
+ goto LP_State_Call;
- else
- Restore_Scan_State (Scan_State); -- to Id
- end if;
+ else
+ Restore_Scan_State (Scan_State); -- to Id
end if;
+ end if;
- -- Here we have an expression after all
-
- Expr_Node := P_Expression_Or_Range_Attribute_If_OK;
+ -- Here we have an expression after all
- -- Check cases of discrete range for a slice
+ Expr_Node := P_Expression_Or_Range_Attribute_If_OK;
- -- First possibility: Range_Attribute_Reference
+ -- Check cases of discrete range for a slice
- if Expr_Form = EF_Range_Attr then
- Range_Node := Expr_Node;
+ -- First possibility: Range_Attribute_Reference
- -- Second possibility: Simple_expression .. Simple_expression
+ if Expr_Form = EF_Range_Attr then
+ Range_Node := Expr_Node;
- elsif Token = Tok_Dot_Dot then
- Check_Simple_Expression (Expr_Node);
- Range_Node := New_Node (N_Range, Token_Ptr);
- Set_Low_Bound (Range_Node, Expr_Node);
- Scan; -- past ..
- Expr_Node := P_Expression;
- Check_Simple_Expression (Expr_Node);
- Set_High_Bound (Range_Node, Expr_Node);
+ -- Second possibility: Simple_expression .. Simple_expression
- -- Third possibility: Type_name range Range
+ elsif Token = Tok_Dot_Dot then
+ Check_Simple_Expression (Expr_Node);
+ Range_Node := New_Node (N_Range, Token_Ptr);
+ Set_Low_Bound (Range_Node, Expr_Node);
+ Scan; -- past ..
+ Expr_Node := P_Expression;
+ Check_Simple_Expression (Expr_Node);
+ Set_High_Bound (Range_Node, Expr_Node);
- elsif Token = Tok_Range then
- if Expr_Form /= EF_Simple_Name then
- Error_Msg_SC ("subtype mark must precede RANGE");
- raise Error_Resync;
- end if;
+ -- Third possibility: Type_name range Range
- Range_Node := P_Subtype_Indication (Expr_Node);
+ elsif Token = Tok_Range then
+ if Expr_Form /= EF_Simple_Name then
+ Error_Msg_SC ("subtype mark must precede RANGE");
+ raise Error_Resync;
+ end if;
- -- Otherwise we just have an expression. It is true that we might
- -- have a subtype mark without a range constraint but this case
- -- is syntactically indistinguishable from the expression case.
+ Range_Node := P_Subtype_Indication (Expr_Node);
- else
- Arg_List := New_List;
- goto LP_State_Expr;
- end if;
+ -- Otherwise we just have an expression. It is true that we might
+ -- have a subtype mark without a range constraint but this case
+ -- is syntactically indistinguishable from the expression case.
- -- Fall through here with unmistakable Discrete range scanned,
- -- which means that we definitely have the case of a slice. The
- -- Discrete range is in Range_Node.
+ else
+ Arg_List := New_List;
+ goto LP_State_Expr;
+ end if;
- if Token = Tok_Comma then
- Error_Msg_SC ("slice cannot have more than one dimension");
- raise Error_Resync;
+ -- Fall through here with unmistakable Discrete range scanned,
+ -- which means that we definitely have the case of a slice. The
+ -- Discrete range is in Range_Node.
- elsif Token /= Tok_Right_Paren then
- if Token = Tok_Arrow then
+ if Token = Tok_Comma then
+ Error_Msg_SC ("slice cannot have more than one dimension");
+ raise Error_Resync;
- -- This may be an aggregate that is missing a qualification
+ elsif Token /= Tok_Right_Paren then
+ if Token = Tok_Arrow then
- Error_Msg_SC
- ("context of aggregate must be a qualified expression");
- raise Error_Resync;
+ -- This may be an aggregate that is missing a qualification
- else
- T_Right_Paren;
- raise Error_Resync;
- end if;
+ Error_Msg_SC
+ ("context of aggregate must be a qualified expression");
+ raise Error_Resync;
else
- Scan; -- past right paren
- Prefix_Node := Name_Node;
- Name_Node := New_Node (N_Slice, Sloc (Prefix_Node));
- Set_Prefix (Name_Node, Prefix_Node);
- Set_Discrete_Range (Name_Node, Range_Node);
+ T_Right_Paren;
+ raise Error_Resync;
+ end if;
+
+ else
+ Scan; -- past right paren
+ Prefix_Node := Name_Node;
+ Name_Node := New_Node (N_Slice, Sloc (Prefix_Node));
+ Set_Prefix (Name_Node, Prefix_Node);
+ Set_Discrete_Range (Name_Node, Range_Node);
- -- An operator node is legal as a prefix to other names,
- -- but not for a slice.
+ -- An operator node is legal as a prefix to other names,
+ -- but not for a slice.
- if Nkind (Prefix_Node) = N_Operator_Symbol then
- Error_Msg_N ("illegal prefix for slice", Prefix_Node);
- end if;
+ if Nkind (Prefix_Node) = N_Operator_Symbol then
+ Error_Msg_N ("illegal prefix for slice", Prefix_Node);
+ end if;
- -- If we have a name extension, go scan it
+ -- If we have a name extension, go scan it
- if Token in Token_Class_Namext then
- goto Scan_Name_Extension_OK;
+ if Token in Token_Class_Namext then
+ goto Scan_Name_Extension_OK;
- -- Otherwise return (a slice is a name, but is not a call)
+ -- Otherwise return (a slice is a name, but is not a call)
- else
- Expr_Form := EF_Name;
- return Name_Node;
- end if;
+ else
+ Expr_Form := EF_Name;
+ return Name_Node;
end if;
+ end if;
-- In LP_State_Expr, we have scanned one or more expressions, and
-- so we have a call or an indexed component which is a name. On
@@ -781,48 +782,48 @@ package body Ch4 is
-- Arg_List contains the list of expressions encountered so far
<<LP_State_Expr>>
- Append (Expr_Node, Arg_List);
+ Append (Expr_Node, Arg_List);
- if Token = Tok_Arrow then
- Error_Msg
- ("expect identifier in parameter association", Sloc (Expr_Node));
- Scan; -- past arrow
+ if Token = Tok_Arrow then
+ Error_Msg
+ ("expect identifier in parameter association", Sloc (Expr_Node));
+ Scan; -- past arrow
- elsif not Comma_Present then
- T_Right_Paren;
+ elsif not Comma_Present then
+ T_Right_Paren;
- Prefix_Node := Name_Node;
- Name_Node := New_Node (N_Indexed_Component, Sloc (Prefix_Node));
- Set_Prefix (Name_Node, Prefix_Node);
- Set_Expressions (Name_Node, Arg_List);
+ Prefix_Node := Name_Node;
+ Name_Node := New_Node (N_Indexed_Component, Sloc (Prefix_Node));
+ Set_Prefix (Name_Node, Prefix_Node);
+ Set_Expressions (Name_Node, Arg_List);
- goto Scan_Name_Extension;
- end if;
+ goto Scan_Name_Extension;
+ end if;
- -- Comma present (and scanned out), test for identifier => case
- -- Test for identifier => case
+ -- Comma present (and scanned out), test for identifier => case
+ -- Test for identifier => case
- if Token = Tok_Identifier then
- Save_Scan_State (Scan_State); -- at Id
- Scan; -- past Id
+ if Token = Tok_Identifier then
+ Save_Scan_State (Scan_State); -- at Id
+ Scan; -- past Id
- -- Test for => (allow := as error substitute)
+ -- Test for => (allow := as error substitute)
- if Token = Tok_Arrow or else Token = Tok_Colon_Equal then
- Restore_Scan_State (Scan_State); -- to Id
- goto LP_State_Call;
+ if Token in Tok_Arrow | Tok_Colon_Equal then
+ Restore_Scan_State (Scan_State); -- to Id
+ goto LP_State_Call;
- -- Otherwise it's just an expression after all, so backup
+ -- Otherwise it's just an expression after all, so backup
- else
- Restore_Scan_State (Scan_State); -- to Id
- end if;
+ else
+ Restore_Scan_State (Scan_State); -- to Id
end if;
+ end if;
- -- Here we have an expression after all, so stay in this state
+ -- Here we have an expression after all, so stay in this state
- Expr_Node := P_Expression_If_OK;
- goto LP_State_Expr;
+ Expr_Node := P_Expression_If_OK;
+ goto LP_State_Expr;
-- LP_State_Call corresponds to the situation in which at least one
-- instance of Id => Expression has been encountered, so we know that
@@ -832,78 +833,78 @@ package body Ch4 is
<<LP_State_Call>>
- -- Test for case of Id => Expression (named parameter)
+ -- Test for case of Id => Expression (named parameter)
- if Token = Tok_Identifier then
- Save_Scan_State (Scan_State); -- at Id
- Ident_Node := Token_Node;
- Scan; -- past Id
+ if Token = Tok_Identifier then
+ Save_Scan_State (Scan_State); -- at Id
+ Ident_Node := Token_Node;
+ Scan; -- past Id
- -- Deal with => (allow := as incorrect substitute)
+ -- Deal with => (allow := as incorrect substitute)
- if Token = Tok_Arrow or else Token = Tok_Colon_Equal then
- Arg_Node := New_Node (N_Parameter_Association, Prev_Token_Ptr);
- Set_Selector_Name (Arg_Node, Ident_Node);
- T_Arrow;
- Set_Explicit_Actual_Parameter (Arg_Node, P_Expression);
- Append (Arg_Node, Arg_List);
+ if Token in Tok_Arrow | Tok_Colon_Equal then
+ Arg_Node := New_Node (N_Parameter_Association, Prev_Token_Ptr);
+ Set_Selector_Name (Arg_Node, Ident_Node);
+ T_Arrow;
+ Set_Explicit_Actual_Parameter (Arg_Node, P_Expression);
+ Append (Arg_Node, Arg_List);
- -- If a comma follows, go back and scan next entry
+ -- If a comma follows, go back and scan next entry
- if Comma_Present then
- goto LP_State_Call;
+ if Comma_Present then
+ goto LP_State_Call;
- -- Otherwise we have the end of a call
+ -- Otherwise we have the end of a call
- else
- Prefix_Node := Name_Node;
- Name_Node := New_Node (N_Function_Call, Sloc (Prefix_Node));
- Set_Name (Name_Node, Prefix_Node);
- Set_Parameter_Associations (Name_Node, Arg_List);
- T_Right_Paren;
+ else
+ Prefix_Node := Name_Node;
+ Name_Node := New_Node (N_Function_Call, Sloc (Prefix_Node));
+ Set_Name (Name_Node, Prefix_Node);
+ Set_Parameter_Associations (Name_Node, Arg_List);
+ T_Right_Paren;
- if Token in Token_Class_Namext then
- goto Scan_Name_Extension_OK;
+ if Token in Token_Class_Namext then
+ goto Scan_Name_Extension_OK;
- -- This is a case of a call which cannot be a name
+ -- This is a case of a call which cannot be a name
- else
- Expr_Form := EF_Name;
- return Name_Node;
- end if;
+ else
+ Expr_Form := EF_Name;
+ return Name_Node;
end if;
+ end if;
- -- Not named parameter: Id started an expression after all
+ -- Not named parameter: Id started an expression after all
- else
- Restore_Scan_State (Scan_State); -- to Id
- end if;
+ else
+ Restore_Scan_State (Scan_State); -- to Id
end if;
+ end if;
- -- Here if entry did not start with Id => which means that it
- -- is a positional parameter, which is not allowed, since we
- -- have seen at least one named parameter already.
+ -- Here if entry did not start with Id => which means that it
+ -- is a positional parameter, which is not allowed, since we
+ -- have seen at least one named parameter already.
- Error_Msg_SC
- ("positional parameter association " &
- "not allowed after named one");
+ Error_Msg_SC
+ ("positional parameter association " &
+ "not allowed after named one");
- Expr_Node := P_Expression_If_OK;
+ Expr_Node := P_Expression_If_OK;
- -- Leaving the '>' in an association is not unusual, so suggest
- -- a possible fix.
+ -- Leaving the '>' in an association is not unusual, so suggest
+ -- a possible fix.
- if Nkind (Expr_Node) = N_Op_Eq then
- Error_Msg_N ("\maybe `='>` was intended", Expr_Node);
- end if;
+ if Nkind (Expr_Node) = N_Op_Eq then
+ Error_Msg_N ("\maybe `='>` was intended", Expr_Node);
+ end if;
- -- We go back to scanning out expressions, so that we do not get
- -- multiple error messages when several positional parameters
- -- follow a named parameter.
+ -- We go back to scanning out expressions, so that we do not get
+ -- multiple error messages when several positional parameters
+ -- follow a named parameter.
- goto LP_State_Expr;
+ goto LP_State_Expr;
- -- End of treatment for name extensions starting with left paren
+ -- End of treatment for name extensions starting with left paren
-- End of loop through name extensions
@@ -1384,7 +1385,7 @@ package body Ch4 is
begin
Save_Scan_State (Scan_State);
Scan; -- past FOR
- Maybe := Token = Tok_All or else Token = Tok_Some;
+ Maybe := Token in Tok_All | Tok_Some;
Restore_Scan_State (Scan_State); -- to FOR
return Maybe;
end Is_Quantified_Expression;
@@ -1609,11 +1610,8 @@ package body Ch4 is
then
Append_New (Expr_Node, Assoc_List);
- elsif Token = Tok_Comma
- or else Token = Tok_Right_Paren
- or else Token = Tok_Others
- or else Token in Token_Class_Lit_Or_Name
- or else Token = Tok_Semicolon
+ elsif Token in Tok_Comma | Tok_Right_Paren | Tok_Others
+ | Token_Class_Lit_Or_Name | Tok_Semicolon
then
if Present (Assoc_List) then
Error_Msg_BC -- CODEFIX
@@ -1945,7 +1943,7 @@ package body Ch4 is
-- Check for case of errant comma or semicolon
- if Token = Tok_Comma or else Token = Tok_Semicolon then
+ if Token in Tok_Comma | Tok_Semicolon then
declare
Com : constant Boolean := Token = Tok_Comma;
Scan_State : Saved_Scan_State;
@@ -1959,7 +1957,7 @@ package body Ch4 is
-- do not deal with AND/OR because those cases get mixed up
-- with the select alternatives case.
- if Token = Tok_And or else Token = Tok_Or then
+ if Token in Tok_And | Tok_Or then
Logop := P_Logical_Operator;
Restore_Scan_State (Scan_State); -- to comma/semicolon
@@ -2008,11 +2006,7 @@ package body Ch4 is
begin
-- Case of conditional, case or quantified expression
- if Token = Tok_Case
- or else Token = Tok_If
- or else Token = Tok_For
- or else Token = Tok_Declare
- then
+ if Token in Tok_Case | Tok_If | Tok_For | Tok_Declare then
return P_Unparen_Cond_Expr_Etc;
-- Normal case, not case/conditional/quantified expression
@@ -2121,11 +2115,7 @@ package body Ch4 is
begin
-- Case of conditional, case or quantified expression
- if Token = Tok_Case
- or else Token = Tok_If
- or else Token = Tok_For
- or else Token = Tok_Declare
- then
+ if Token in Tok_Case | Tok_If | Tok_For | Tok_Declare then
return P_Unparen_Cond_Expr_Etc;
-- Normal case, not one of the above expression types
@@ -2967,7 +2957,7 @@ package body Ch4 is
Save_Scan_State (Scan_State);
Scan; -- past FOR
- if Token = Tok_All or else Token = Tok_Some then
+ if Token in Tok_All | Tok_Some then
Restore_Scan_State (Scan_State); -- To FOR
Node1 := P_Quantified_Expression;
@@ -3638,7 +3628,7 @@ package body Ch4 is
Save_Scan_State (State);
Scan; -- past semicolon
- if Token = Tok_Else or else Token = Tok_Elsif then
+ if Token in Tok_Else | Tok_Elsif then
Error_Msg_SP -- CODEFIX
("|extra "";"" ignored");
@@ -3837,7 +3827,7 @@ package body Ch4 is
Save_Scan_State (Scan_State);
Scan; -- past FOR
- if Token = Tok_All or else Token = Tok_Some then
+ if Token in Tok_All | Tok_Some then
Restore_Scan_State (Scan_State);
Result := P_Quantified_Expression;
diff --git a/gcc/ada/par-ch5.adb b/gcc/ada/par-ch5.adb
index 1be3ef8..60b52bf 100644
--- a/gcc/ada/par-ch5.adb
+++ b/gcc/ada/par-ch5.adb
@@ -103,21 +103,11 @@ package body Ch5 is
-- | LOOP_STATEMENT | BLOCK_STATEMENT
-- | ACCEPT_STATEMENT | SELECT_STATEMENT
- -- This procedure scans a sequence of statements. The caller sets SS_Flags
- -- to indicate acceptable termination conditions for the sequence:
-
- -- SS_Flags.Eftm Terminate on ELSIF
- -- SS_Flags.Eltm Terminate on ELSE
- -- SS_Flags.Extm Terminate on EXCEPTION
- -- SS_Flags.Ortm Terminate on OR
- -- SS_Flags.Tatm Terminate on THEN ABORT (Token = ABORT on return)
- -- SS_Flags.Whtm Terminate on WHEN
- -- SS_Flags.Unco Unconditional terminate after scanning one statement
-
- -- In addition, the scan is always terminated by encountering END or the
- -- end of file (EOF) condition. If one of the six above terminators is
- -- encountered with the corresponding SS_Flags flag not set, then the
- -- action taken is as follows:
+ -- This procedure scans a sequence of statements. SS_Flags indicates
+ -- termination conditions for the sequence. In addition, the sequence is
+ -- always terminated by encountering END or end of file. If one of the six
+ -- above terminators is encountered with the corresponding SS_Flags flag
+ -- not set, then the action taken is as follows:
-- If the keyword occurs to the left of the expected column of the end
-- for the current sequence (as recorded in the current end context),
@@ -131,7 +121,8 @@ package body Ch5 is
-- Note that the first action means that control can return to the caller
-- with Token set to a terminator other than one of those specified by the
- -- SS parameter. The caller should treat such a case as equivalent to END.
+ -- SS_Flags parameter. The caller should treat such a case as equivalent to
+ -- END.
-- In addition, the flag SS_Flags.Sreq is set to True to indicate that at
-- least one real statement (other than a pragma) is required in the
@@ -147,14 +138,14 @@ package body Ch5 is
function P_Sequence_Of_Statements
(SS_Flags : SS_Rec; Handled : Boolean := False) return List_Id
is
- Statement_Required : Boolean;
+ Statement_Required : Boolean := SS_Flags.Sreq;
-- This flag indicates if a subsequent statement (other than a pragma)
-- is required. It is initialized from the Sreq flag, and modified as
-- statements are scanned (a statement turns it off, and a label turns
-- it back on again since a statement must follow a label).
-- Note : this final requirement is lifted in Ada 2012.
- Statement_Seen : Boolean;
+ Statement_Seen : Boolean := False;
-- In Ada 2012, a label can end a sequence of statements, but the
-- sequence cannot contain only labels. This flag is set whenever a
-- label is encountered, to enforce this rule at the end of a sequence.
@@ -162,7 +153,7 @@ package body Ch5 is
Scan_State_Label : Saved_Scan_State;
Scan_State : Saved_Scan_State;
- Statement_List : List_Id;
+ Statement_List : constant List_Id := New_List;
Block_Label : Name_Id;
Id_Node : Node_Id;
Name_Node : Node_Id;
@@ -215,13 +206,7 @@ package body Ch5 is
and then Statement_Seen)
or else All_Pragmas)
then
- declare
- Null_Stm : constant Node_Id :=
- Make_Null_Statement (Token_Ptr);
- begin
- Set_Comes_From_Source (Null_Stm, False);
- Append_To (Statement_List, Null_Stm);
- end;
+ null;
-- If not Ada 2012, or not special case above, and no declaration
-- seen (as allowed in Ada 2020), give error message.
@@ -236,10 +221,6 @@ package body Ch5 is
-- Start of processing for P_Sequence_Of_Statements
begin
- Statement_List := New_List;
- Statement_Required := SS_Flags.Sreq;
- Statement_Seen := False;
-
-- In Ada 2022, we allow declarative items to be mixed with
-- statements. The loop below alternates between calling
-- P_Declarative_Items to parse zero or more declarative items,
@@ -270,7 +251,7 @@ package body Ch5 is
end if;
end;
- begin
+ begin -- handle Error_Resync
if Style_Check then
Style.Check_Indentation;
end if;
@@ -290,18 +271,13 @@ package body Ch5 is
-- with the exception of the cases tested for below.
(Token = Tok_Semicolon
- and then Prev_Token /= Tok_Return
- and then Prev_Token /= Tok_Null
- and then Prev_Token /= Tok_Raise
- and then Prev_Token /= Tok_End
- and then Prev_Token /= Tok_Exit)
+ and then Prev_Token not in
+ Tok_Return | Tok_Null | Tok_Raise | Tok_End | Tok_Exit)
-- If followed by colon, colon-equal, or dot, then we
-- definitely have an identifier (could not be reserved)
- or else Token = Tok_Colon
- or else Token = Tok_Colon_Equal
- or else Token = Tok_Dot
+ or else Token in Tok_Colon | Tok_Colon_Equal | Tok_Dot
-- Left paren means we have an identifier except for those
-- reserved words that can legitimately be followed by a
@@ -309,14 +285,9 @@ package body Ch5 is
or else
(Token = Tok_Left_Paren
- and then Prev_Token /= Tok_Case
- and then Prev_Token /= Tok_Delay
- and then Prev_Token /= Tok_If
- and then Prev_Token /= Tok_Elsif
- and then Prev_Token /= Tok_Return
- and then Prev_Token /= Tok_When
- and then Prev_Token /= Tok_While
- and then Prev_Token /= Tok_Separate)
+ and then Prev_Token not in
+ Tok_Case | Tok_Delay | Tok_If | Tok_Elsif | Tok_Return |
+ Tok_When | Tok_While | Tok_Separate)
then
-- Here we have an apparent reserved identifier and the
-- token past it is appropriate to this usage (and would
@@ -704,11 +675,12 @@ package body Ch5 is
-- instance of an incorrectly spelled keyword. If so, we
-- do nothing. The Bad_Spelling_Of will have reset Token
-- to the appropriate keyword, so the next time round the
- -- loop we will process the modified token. Note that we
- -- check for ELSIF before ELSE here. That's not accidental.
- -- We don't want to identify a misspelling of ELSE as
- -- ELSIF, and in particular we do not want to treat ELSEIF
- -- as ELSE IF.
+ -- loop we will process the modified token.
+ --
+ -- Note that we check for ELSIF before ELSE here, because
+ -- we don't want to identify a misspelling of ELSE as ELSIF,
+ -- and in particular we do not want to treat ELSEIF as
+ -- ELSE IF.
else
Restore_Scan_State (Scan_State_Label); -- to identifier
@@ -1452,7 +1424,7 @@ package body Ch5 is
-- If we have a WHEN or OTHERS, then that's fine keep going. Note
-- that it is a semantic check to ensure the proper use of OTHERS
- if Token = Tok_When or else Token = Tok_Others then
+ if Token in Tok_When | Tok_Others then
Append (P_Case_Statement_Alternative, Alternatives_List);
-- If we have an END, then probably we are at the end of the case
@@ -1764,7 +1736,7 @@ package body Ch5 is
-- expression it is an iterator specification. Ambiguity is resolved
-- during analysis of the loop parameter specification.
- if Token = Tok_Of or else Token = Tok_Colon then
+ if Token in Tok_Of | Tok_Colon then
Error_Msg_Ada_2012_Feature ("iterator", Token_Ptr);
return P_Iterator_Specification (ID_Node);
end if;
@@ -2272,9 +2244,7 @@ package body Ch5 is
-- END, EOF, or a token which starts declarations.
elsif Parent_Nkind = N_Package_Body
- and then (Token = Tok_End
- or else Token = Tok_EOF
- or else Token in Token_Class_Declk)
+ and then (Token in Tok_End | Tok_EOF | Token_Class_Declk)
then
Set_Null_HSS (Parent);
@@ -2384,7 +2354,7 @@ package body Ch5 is
TF_Then;
end loop;
- if Token = Tok_And or else Token = Tok_Or then
+ if Token in Tok_And | Tok_Or then
Error_Msg_SC ("unexpected logical operator");
Scan; -- past logical operator
diff --git a/gcc/ada/par-ch6.adb b/gcc/ada/par-ch6.adb
index 95fa937..4f06297 100644
--- a/gcc/ada/par-ch6.adb
+++ b/gcc/ada/par-ch6.adb
@@ -180,21 +180,6 @@ package body Ch6 is
-- FUNCTION SPECIFICATION IS (EXPRESSION)
-- [ASPECT_SPECIFICATIONS];
- -- The value in Pf_Flags indicates which of these possible declarations
- -- is acceptable to the caller:
-
- -- Pf_Flags.Decl Set if declaration OK
- -- Pf_Flags.Gins Set if generic instantiation OK
- -- Pf_Flags.Pbod Set if proper body OK
- -- Pf_Flags.Rnam Set if renaming declaration OK
- -- Pf_Flags.Stub Set if body stub OK
- -- Pf_Flags.Pexp Set if expression function OK
-
- -- If an inappropriate form is encountered, it is scanned out but an
- -- error message indicating that it is appearing in an inappropriate
- -- context is issued. The only possible values for Pf_Flags are those
- -- defined as constants in the Par package.
-
-- The caller has checked that the initial token is FUNCTION, PROCEDURE,
-- NOT or OVERRIDING.
@@ -316,7 +301,7 @@ package body Ch6 is
then
Error_Msg_SC ("overriding indicator not allowed here!");
- elsif Token /= Tok_Function and then Token /= Tok_Procedure then
+ elsif Token not in Tok_Function | Tok_Procedure then
Error_Msg_SC -- CODEFIX
("FUNCTION or PROCEDURE expected!");
end if;
@@ -737,22 +722,15 @@ package body Ch6 is
-- or a pragma, then we definitely have a subprogram body.
-- This is a common case, so worth testing first.
- if Token = Tok_Begin
- or else Token in Token_Class_Declk
- or else Token = Tok_Pragma
- then
+ if Token in Tok_Begin | Token_Class_Declk | Tok_Pragma then
return False;
-- Test for tokens which could only start an expression and
-- thus signal the case of a expression function.
- elsif Token in Token_Class_Literal
- or else Token in Token_Class_Unary_Addop
- or else Token = Tok_Left_Paren
- or else Token = Tok_Abs
- or else Token = Tok_Null
- or else Token = Tok_New
- or else Token = Tok_Not
+ elsif Token in
+ Token_Class_Literal | Token_Class_Unary_Addop |
+ Tok_Left_Paren | Tok_Abs | Tok_Null | Tok_New | Tok_Not
then
null;
@@ -1161,9 +1139,8 @@ package body Ch6 is
Save_Scan_State (Scan_State);
Scan; -- past dot
- if Token = Tok_Identifier
- or else Token = Tok_Operator_Symbol
- or else Token = Tok_String_Literal
+ if Token in
+ Tok_Identifier | Tok_Operator_Symbol | Tok_String_Literal
then
return True;
@@ -1180,8 +1157,7 @@ package body Ch6 is
Ident_Node := Token_Node;
Scan; -- past initial token
- if Prev_Token = Tok_Operator_Symbol
- or else Prev_Token = Tok_String_Literal
+ if Prev_Token in Tok_Operator_Symbol | Tok_String_Literal
or else not Real_Dot
then
return Ident_Node;
@@ -1216,7 +1192,7 @@ package body Ch6 is
exception
when Error_Resync =>
- while Token = Tok_Dot or else Token = Tok_Identifier loop
+ while Token in Tok_Dot | Tok_Identifier loop
Scan;
end loop;
@@ -1327,7 +1303,7 @@ package body Ch6 is
exception
when Error_Resync =>
- while Token = Tok_Dot or else Token = Tok_Identifier loop
+ while Token in Tok_Dot | Tok_Identifier loop
Scan;
end loop;
@@ -1462,10 +1438,8 @@ package body Ch6 is
-- and on a right paren, e.g. Parms (X Y), and also
-- on an assignment symbol, e.g. Parms (X Y := ..)
- if Token = Tok_Semicolon
- or else Token = Tok_Right_Paren
- or else Token = Tok_EOF
- or else Token = Tok_Colon_Equal
+ if Token in Tok_Semicolon | Tok_Right_Paren |
+ Tok_EOF | Tok_Colon_Equal
then
Restore_Scan_State (Scan_State);
exit Ident_Loop;
@@ -1474,9 +1448,7 @@ package body Ch6 is
-- comma, e.g. Parms (A B : ...). Also assume a missing
-- comma if we hit another comma, e.g. Parms (A B, C ..)
- elsif Token = Tok_Colon
- or else Token = Tok_Comma
- then
+ elsif Token in Tok_Colon | Tok_Comma then
Restore_Scan_State (Scan_State);
exit Look_Ahead;
end if;
@@ -1551,7 +1523,7 @@ package body Ch6 is
-- Case of IN or OUT present
else
- if Token = Tok_In or else Token = Tok_Out then
+ if Token in Tok_In | Tok_Out then
if Not_Null_Present then
Error_Msg
("`NOT NULL` can only be used with `ACCESS`",
@@ -1627,7 +1599,7 @@ package body Ch6 is
-- If we have RETURN or IS after the semicolon, then assume
-- that semicolon should have been a right parenthesis and exit
- if Token = Tok_Is or else Token = Tok_Return then
+ if Token in Tok_Is | Tok_Return then
Error_Msg_SP -- CODEFIX
("|"";"" should be "")""");
exit Specification_Loop;
diff --git a/gcc/ada/par-ch7.adb b/gcc/ada/par-ch7.adb
index 71046e2..07c910a 100644
--- a/gcc/ada/par-ch7.adb
+++ b/gcc/ada/par-ch7.adb
@@ -71,21 +71,6 @@ package body Ch7 is
-- new generic_package_NAME [GENERIC_ACTUAL_PART]
-- [ASPECT_SPECIFICATIONS];
- -- The value in Pf_Flags indicates which of these possible declarations
- -- is acceptable to the caller:
-
- -- Pf_Flags.Spcn Set if specification OK
- -- Pf_Flags.Decl Set if declaration OK
- -- Pf_Flags.Gins Set if generic instantiation OK
- -- Pf_Flags.Pbod Set if proper body OK
- -- Pf_Flags.Rnam Set if renaming declaration OK
- -- Pf_Flags.Stub Set if body stub OK
-
- -- If an inappropriate form is encountered, it is scanned out but an error
- -- message indicating that it is appearing in an inappropriate context is
- -- issued. The only possible settings for Pf_Flags are those defined as
- -- constants in package Par.
-
-- Note: in all contexts where a package specification is required, there
-- is a terminating semicolon. This semicolon is scanned out in the case
-- where Pf_Flags is set to Pf_Spcn, even though it is not strictly part
diff --git a/gcc/ada/par-ch8.adb b/gcc/ada/par-ch8.adb
index 67dce14..6e9139c 100644
--- a/gcc/ada/par-ch8.adb
+++ b/gcc/ada/par-ch8.adb
@@ -94,7 +94,7 @@ package body Ch8 is
begin
Scan; -- past USE
- if Token = Tok_Type or else Token = Tok_All then
+ if Token in Tok_Type | Tok_All then
P_Use_Type_Clause (Item_List);
else
P_Use_Package_Clause (Item_List);
diff --git a/gcc/ada/par-ch9.adb b/gcc/ada/par-ch9.adb
index 7d4ea62..310494e 100644
--- a/gcc/ada/par-ch9.adb
+++ b/gcc/ada/par-ch9.adb
@@ -343,10 +343,7 @@ package body Ch9 is
-- Ada 2005 (AI-397): Reserved words NOT and OVERRIDING may begin an
-- entry declaration.
- elsif Token = Tok_Entry
- or else Token = Tok_Not
- or else Token = Tok_Overriding
- then
+ elsif Token in Tok_Entry | Tok_Not | Tok_Overriding then
Append (P_Entry_Declaration, Items);
elsif Token = Tok_For then
@@ -760,7 +757,7 @@ package body Ch9 is
Set_Must_Override (Decl, Is_Overriding);
Set_Must_Not_Override (Decl, Not_Overriding);
- elsif Token = Tok_Function or else Token = Tok_Procedure then
+ elsif Token in Tok_Function | Tok_Procedure then
Decl := P_Subprogram (Pf_Decl_Pexp);
Set_Must_Override (Specification (Decl), Is_Overriding);
@@ -987,7 +984,7 @@ package body Ch9 is
-- If comma or colon after Id, must be Formal_Part
- if Token = Tok_Comma or else Token = Tok_Colon then
+ if Token in Tok_Comma | Tok_Colon then
Restore_Scan_State (Scan_State); -- to Id
Set_Parameter_Specifications (Decl_Node, P_Formal_Part);
@@ -1095,7 +1092,7 @@ package body Ch9 is
-- If identifier followed by comma or colon, must be Formal_Part
- if Token = Tok_Comma or else Token = Tok_Colon then
+ if Token in Tok_Comma | Tok_Colon then
Restore_Scan_State (Scan_State); -- to left paren
Set_Parameter_Specifications (Accept_Node, P_Parameter_Profile);
diff --git a/gcc/ada/par-endh.adb b/gcc/ada/par-endh.adb
index 212d451..15b21cd 100644
--- a/gcc/ada/par-endh.adb
+++ b/gcc/ada/par-endh.adb
@@ -242,7 +242,7 @@ package body Endh is
-- FOR or WHILE allowed (signalling error) to substitute for LOOP
-- if on the same line as the END.
- elsif (Token = Tok_For or else Token = Tok_While)
+ elsif Token in Tok_For | Tok_While
and then not Token_Is_At_Start_Of_Line
then
Scan; -- past FOR or WHILE
@@ -445,8 +445,7 @@ package body Endh is
-- incorrect. Same thing for a period in place of a semicolon.
elsif Token_Is_At_Start_Of_Line
- or else Token = Tok_Colon
- or else Token = Tok_Dot
+ or else Token in Tok_Colon | Tok_Dot
then
T_Semicolon;
@@ -480,10 +479,8 @@ package body Endh is
-- on the same line as the END
while not Token_Is_At_Start_Of_Line
- and then Prev_Token /= Tok_Record
- and then Prev_Token /= Tok_Semicolon
- and then Token /= Tok_End
- and then Token /= Tok_EOF
+ and then Prev_Token not in Tok_Record | Tok_Semicolon
+ and then Token not in Tok_End | Tok_EOF
loop
Scan; -- past junk
end loop;
@@ -625,9 +622,8 @@ package body Endh is
return;
end if;
- if Token /= Tok_Identifier
- and then Token /= Tok_Operator_Symbol
- and then Token /= Tok_String_Literal
+ if Token not in
+ Tok_Identifier | Tok_Operator_Symbol | Tok_String_Literal
then
exit;
end if;
@@ -655,9 +651,7 @@ package body Endh is
-- if there is no line end at the end of the last line of the file)
else
- while Token /= Tok_End
- and then Token /= Tok_EOF
- and then Token /= Tok_Semicolon
+ while Token not in Tok_End | Tok_EOF | Tok_Semicolon
and then not Token_Is_At_Start_Of_Line
loop
Scan; -- past junk token on same line
@@ -1157,9 +1151,7 @@ package body Endh is
Scan; -- past END
- if Token = Tok_Identifier
- or else Token = Tok_Operator_Symbol
- then
+ if Token in Tok_Identifier | Tok_Operator_Symbol then
Nxt_Labl := P_Designator;
-- We only consider it an error if the label is a match
diff --git a/gcc/ada/par-sync.adb b/gcc/ada/par-sync.adb
index 7a3da8e..570d229 100644
--- a/gcc/ada/par-sync.adb
+++ b/gcc/ada/par-sync.adb
@@ -58,9 +58,7 @@ package body Sync is
begin
Resync_Init;
- while Token not in Token_Class_Cunit
- and then Token /= Tok_EOF
- loop
+ while Token not in Token_Class_Cunit | Tok_EOF loop
Scan;
end loop;
@@ -92,9 +90,7 @@ package body Sync is
or else (Paren_Count = 0
and then
- (Token = Tok_Comma
- or else Token = Tok_Right_Paren
- or else Token = Tok_Vertical_Bar))
+ Token in Tok_Comma | Tok_Right_Paren | Tok_Vertical_Bar)
then
-- A special check: if we stop on the ELSE of OR ELSE or the
-- THEN of AND THEN, keep going, because this is not really an
@@ -232,7 +228,7 @@ package body Sync is
-- in this category only if it does NOT appear after WITH.
elsif Token in Token_Class_After_SM
- and then (Token /= Tok_Private or else Prev_Token /= Tok_With)
+ and then (Token /= Tok_Private or else Prev_Token /= Tok_With)
then
exit;
@@ -274,7 +270,7 @@ package body Sync is
-- Done if we are at THEN or LOOP
- elsif Token = Tok_Then or else Token = Tok_Loop then
+ elsif Token in Tok_Then | Tok_Loop then
exit;
-- Otherwise keep going
@@ -316,10 +312,7 @@ package body Sync is
Paren_Count := 0;
loop
- if Token = Tok_EOF
- or else Token = Tok_Semicolon
- or else Token = Tok_Is
- or else Token in Token_Class_After_SM
+ if Token in Tok_EOF | Tok_Semicolon | Tok_Is | Token_Class_After_SM
then
exit;
@@ -386,10 +379,7 @@ package body Sync is
loop
-- Done if at semicolon, WHEN or IS
- if Token = Tok_Semicolon
- or else Token = Tok_When
- or else Token = Tok_Is
- then
+ if Token in Tok_Semicolon | Tok_When | Tok_Is then
exit;
-- Otherwise keep going
diff --git a/gcc/ada/par-tchk.adb b/gcc/ada/par-tchk.adb
index 6a62d70..3989cd2 100644
--- a/gcc/ada/par-tchk.adb
+++ b/gcc/ada/par-tchk.adb
@@ -567,8 +567,7 @@ package body Tchk is
loop
if Prev_Token_Ptr < Current_Line_Start
- or else Token = Tok_Semicolon
- or else Token = Tok_EOF
+ or else Token in Tok_Semicolon | Tok_EOF
then
Restore_Scan_State (Scan_State); -- to where we were
return;
@@ -597,10 +596,7 @@ package body Tchk is
-- Allow OF or => or = in place of IS (with error message)
- elsif Token = Tok_Of
- or else Token = Tok_Arrow
- or else Token = Tok_Equal
- then
+ elsif Token in Tok_Of | Tok_Arrow | Tok_Equal then
T_Is; -- give missing IS message and skip bad token
else
@@ -609,8 +605,7 @@ package body Tchk is
loop
if Prev_Token_Ptr < Current_Line_Start
- or else Token = Tok_Semicolon
- or else Token = Tok_EOF
+ or else Token in Tok_Semicolon | Tok_EOF
then
Restore_Scan_State (Scan_State); -- to where we were
return;
@@ -618,10 +613,7 @@ package body Tchk is
Scan; -- continue search
- if Token = Tok_Is
- or else Token = Tok_Of
- or else Token = Tok_Arrow
- then
+ if Token in Tok_Is | Tok_Of | Tok_Arrow then
Scan; -- past IS or OF or =>
return;
end if;
@@ -642,7 +634,7 @@ package body Tchk is
-- Allow DO or THEN in place of LOOP
- elsif Token = Tok_Then or else Token = Tok_Do then
+ elsif Token in Tok_Then | Tok_Do then
T_Loop; -- give missing LOOP message
else
@@ -651,8 +643,7 @@ package body Tchk is
loop
if Prev_Token_Ptr < Current_Line_Start
- or else Token = Tok_Semicolon
- or else Token = Tok_EOF
+ or else Token in Tok_Semicolon | Tok_EOF
then
Restore_Scan_State (Scan_State); -- to where we were
return;
@@ -660,7 +651,7 @@ package body Tchk is
Scan; -- continue search
- if Token = Tok_Loop or else Token = Tok_Then then
+ if Token in Tok_Loop | Tok_Then then
Scan; -- past loop or then (message already generated)
return;
end if;
@@ -686,8 +677,7 @@ package body Tchk is
loop
if Prev_Token_Ptr < Current_Line_Start
- or else Token = Tok_Semicolon
- or else Token = Tok_EOF
+ or else Token in Tok_Semicolon | Tok_EOF
then
Restore_Scan_State (Scan_State); -- to where we were
return;
@@ -752,8 +742,7 @@ package body Tchk is
loop
if Prev_Token_Ptr < Current_Line_Start
- or else Token = Tok_EOF
- or else Token = Tok_End
+ or else Token in Tok_EOF | Tok_End
then
Restore_Scan_State (Scan_State); -- to where we were
return;
@@ -789,8 +778,7 @@ package body Tchk is
loop
if Prev_Token_Ptr < Current_Line_Start
- or else Token = Tok_Semicolon
- or else Token = Tok_EOF
+ or else Token in Tok_Semicolon | Tok_EOF
then
Restore_Scan_State (Scan_State); -- to where we were
return;
@@ -823,8 +811,7 @@ package body Tchk is
loop
if Prev_Token_Ptr < Current_Line_Start
- or else Token = Tok_Semicolon
- or else Token = Tok_EOF
+ or else Token in Tok_Semicolon | Tok_EOF
then
Restore_Scan_State (Scan_State); -- to where we were
return;
diff --git a/gcc/ada/par-util.adb b/gcc/ada/par-util.adb
index 3f1247a..0387418 100644
--- a/gcc/ada/par-util.adb
+++ b/gcc/ada/par-util.adb
@@ -336,7 +336,7 @@ package body Util is
-- probably the semicolon did end the list. Indeed that is
-- certainly the only single error correction possible here.
- if Token = Tok_Semicolon or else Token = Tok_EOF then
+ if Token in Tok_Semicolon | Tok_EOF then
Restore_Scan_State (Scan_State);
return False;
@@ -521,44 +521,34 @@ package body Util is
raise Program_Error;
when C_Comma_Right_Paren =>
- OK_Next_Tok :=
- Token = Tok_Comma or else Token = Tok_Right_Paren;
+ OK_Next_Tok := Token in Tok_Comma | Tok_Right_Paren;
when C_Comma_Colon =>
- OK_Next_Tok :=
- Token = Tok_Comma or else Token = Tok_Colon;
+ OK_Next_Tok := Token in Tok_Comma | Tok_Colon;
when C_Do =>
- OK_Next_Tok :=
- Token = Tok_Do;
+ OK_Next_Tok := Token = Tok_Do;
when C_Dot =>
- OK_Next_Tok :=
- Token = Tok_Dot;
+ OK_Next_Tok := Token = Tok_Dot;
when C_Greater_Greater =>
- OK_Next_Tok :=
- Token = Tok_Greater_Greater;
+ OK_Next_Tok := Token = Tok_Greater_Greater;
when C_In =>
- OK_Next_Tok :=
- Token = Tok_In;
+ OK_Next_Tok := Token = Tok_In;
when C_Is =>
- OK_Next_Tok :=
- Token = Tok_Is;
+ OK_Next_Tok := Token = Tok_Is;
when C_Left_Paren_Semicolon =>
- OK_Next_Tok :=
- Token = Tok_Left_Paren or else Token = Tok_Semicolon;
+ OK_Next_Tok := Token in Tok_Left_Paren | Tok_Semicolon;
when C_Use =>
- OK_Next_Tok :=
- Token = Tok_Use;
+ OK_Next_Tok := Token = Tok_Use;
when C_Vertical_Bar_Arrow =>
- OK_Next_Tok :=
- Token = Tok_Vertical_Bar or else Token = Tok_Arrow;
+ OK_Next_Tok := Token in Tok_Vertical_Bar | Tok_Arrow;
end case;
Restore_Scan_State (Scan_State);
@@ -802,7 +792,7 @@ package body Util is
function Token_Is_At_Start_Of_Line return Boolean is
begin
- return (Token_Ptr = First_Non_Blank_Location or else Token = Tok_EOF);
+ return Token_Ptr = First_Non_Blank_Location or else Token = Tok_EOF;
end Token_Is_At_Start_Of_Line;
-----------------------------------
diff --git a/gcc/ada/par.adb b/gcc/ada/par.adb
index b6ffdae..01e3c4b 100644
--- a/gcc/ada/par.adb
+++ b/gcc/ada/par.adb
@@ -361,36 +361,29 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
Expr_Form : Expr_Form_Type;
- -- The following type is used for calls to P_Subprogram, P_Package, P_Task,
- -- P_Protected to indicate which of several possibilities is acceptable.
+ -- The following type is used by P_Subprogram, P_Package, to indicate which
+ -- of several possibilities is acceptable.
type Pf_Rec is record
- Spcn : Boolean; -- True if specification OK
- Decl : Boolean; -- True if declaration OK
- Gins : Boolean; -- True if generic instantiation OK
- Pbod : Boolean; -- True if proper body OK
- Rnam : Boolean; -- True if renaming declaration OK
- Stub : Boolean; -- True if body stub OK
- Pexp : Boolean; -- True if parameterized expression OK
- Fil2 : Boolean; -- Filler to fill to 8 bits
+ Spcn : Boolean; -- True if specification OK
+ Decl : Boolean; -- True if declaration OK
+ Gins : Boolean; -- True if generic instantiation OK
+ Pbod : Boolean; -- True if proper body OK
+ Rnam : Boolean; -- True if renaming declaration OK
+ Stub : Boolean; -- True if body stub OK
+ Pexp : Boolean; -- True if parameterized expression OK
end record;
pragma Pack (Pf_Rec);
function T return Boolean renames True;
function F return Boolean renames False;
- Pf_Decl_Gins_Pbod_Rnam_Stub_Pexp : constant Pf_Rec :=
- Pf_Rec'(F, T, T, T, T, T, T, F);
- Pf_Decl_Pexp : constant Pf_Rec :=
- Pf_Rec'(F, T, F, F, F, F, T, F);
- Pf_Decl_Gins_Pbod_Rnam_Pexp : constant Pf_Rec :=
- Pf_Rec'(F, T, T, T, T, F, T, F);
- Pf_Decl_Pbod_Pexp : constant Pf_Rec :=
- Pf_Rec'(F, T, F, T, F, F, T, F);
- Pf_Pbod_Pexp : constant Pf_Rec :=
- Pf_Rec'(F, F, F, T, F, F, T, F);
- Pf_Spcn : constant Pf_Rec :=
- Pf_Rec'(T, F, F, F, F, F, F, F);
+ Pf_Decl_Gins_Pbod_Rnam_Stub_Pexp : constant Pf_Rec := (F, T, T, T, T, T, T);
+ Pf_Decl_Pexp : constant Pf_Rec := (F, T, F, F, F, F, T);
+ Pf_Decl_Gins_Pbod_Rnam_Pexp : constant Pf_Rec := (F, T, T, T, T, F, T);
+ Pf_Decl_Pbod_Pexp : constant Pf_Rec := (F, T, F, T, F, F, T);
+ Pf_Pbod_Pexp : constant Pf_Rec := (F, F, F, T, F, F, T);
+ Pf_Spcn : constant Pf_Rec := (T, F, F, F, F, F, F);
-- The above are the only allowed values of Pf_Rec arguments
type SS_Rec is record
@@ -405,15 +398,15 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
end record;
pragma Pack (SS_Rec);
- SS_Eftm_Eltm_Sreq : constant SS_Rec := SS_Rec'(T, T, F, F, T, F, F, F);
- SS_Eltm_Ortm_Tatm : constant SS_Rec := SS_Rec'(F, T, F, T, F, T, F, F);
- SS_Extm_Sreq : constant SS_Rec := SS_Rec'(F, F, T, F, T, F, F, F);
- SS_None : constant SS_Rec := SS_Rec'(F, F, F, F, F, F, F, F);
- SS_Ortm_Sreq : constant SS_Rec := SS_Rec'(F, F, F, T, T, F, F, F);
- SS_Sreq : constant SS_Rec := SS_Rec'(F, F, F, F, T, F, F, F);
- SS_Sreq_Whtm : constant SS_Rec := SS_Rec'(F, F, F, F, T, F, T, F);
- SS_Whtm : constant SS_Rec := SS_Rec'(F, F, F, F, F, F, T, F);
- SS_Unco : constant SS_Rec := SS_Rec'(F, F, F, F, F, F, F, T);
+ SS_Eftm_Eltm_Sreq : constant SS_Rec := (T, T, F, F, T, F, F, F);
+ SS_Eltm_Ortm_Tatm : constant SS_Rec := (F, T, F, T, F, T, F, F);
+ SS_Extm_Sreq : constant SS_Rec := (F, F, T, F, T, F, F, F);
+ SS_None : constant SS_Rec := (F, F, F, F, F, F, F, F);
+ SS_Ortm_Sreq : constant SS_Rec := (F, F, F, T, T, F, F, F);
+ SS_Sreq : constant SS_Rec := (F, F, F, F, T, F, F, F);
+ SS_Sreq_Whtm : constant SS_Rec := (F, F, F, F, T, F, T, F);
+ SS_Whtm : constant SS_Rec := (F, F, F, F, F, F, T, F);
+ SS_Unco : constant SS_Rec := (F, F, F, F, F, F, F, T);
Goto_List : Elist_Id;
-- List of goto nodes appearing in the current compilation. Used to
@@ -882,9 +875,9 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
function P_Sequence_Of_Statements
(SS_Flags : SS_Rec; Handled : Boolean := False) return List_Id;
- -- The argument indicates the acceptable termination tokens.
- -- See body in Par.Ch5 for details of the use of this parameter.
- -- Handled is true if we are parsing a handled sequence of statements.
+ -- SS_Flags indicates the acceptable termination tokens; see body for
+ -- details. Handled is true if we are parsing a handled sequence of
+ -- statements.
procedure Parse_Decls_Begin_End (Parent : Node_Id);
-- Parses declarations and handled statement sequence, setting
diff --git a/gcc/ada/prep.adb b/gcc/ada/prep.adb
index b67fe8d..6731bae 100644
--- a/gcc/ada/prep.adb
+++ b/gcc/ada/prep.adb
@@ -461,11 +461,8 @@ package body Prep is
-- Handle relational operator
- elsif Token = Tok_Equal
- or else Token = Tok_Less
- or else Token = Tok_Less_Equal
- or else Token = Tok_Greater
- or else Token = Tok_Greater_Equal
+ elsif Token in Tok_Equal | Tok_Less | Tok_Less_Equal |
+ Tok_Greater | Tok_Greater_Equal
then
Relop := Token;
Scan.all;
@@ -771,9 +768,7 @@ package body Prep is
begin
-- Scan until we get an end of line or we reach the end of the buffer
- while Token /= Tok_End_Of_Line
- and then Token /= Tok_EOF
- loop
+ while Token not in Tok_End_Of_Line | Tok_EOF loop
Scan.all;
end loop;
end Go_To_End_Of_Line;
@@ -1042,7 +1037,7 @@ package body Prep is
Scan.all;
- if Token /= Tok_End_Of_Line and then Token /= Tok_EOF then
+ if Token not in Tok_End_Of_Line | Tok_EOF then
Error_Msg ("extraneous text in definition", Token_Ptr);
goto Cleanup;
end if;
@@ -1056,12 +1051,12 @@ package body Prep is
Scan.all;
- if Token /= Tok_End_Of_Line and then Token /= Tok_EOF then
+ if Token not in Tok_End_Of_Line | Tok_EOF then
Error_Msg ("extraneous text in definition", Token_Ptr);
goto Cleanup;
end if;
- elsif Token = Tok_End_Of_Line or else Token = Tok_EOF then
+ elsif Token in Tok_End_Of_Line | Tok_EOF then
Data := (Symbol => Symbol_Name,
Original => Original_Name,
On_The_Command_Line => False,
@@ -1093,7 +1088,7 @@ package body Prep is
Scan.all;
- if Token /= Tok_End_Of_Line and then Token /= Tok_EOF then
+ if Token not in Tok_End_Of_Line | Tok_EOF then
Error_Msg ("extraneous text in definition", Token_Ptr);
goto Cleanup;
end if;
@@ -1144,7 +1139,7 @@ package body Prep is
<<Cleanup>>
Set_Ignore_Errors (To => True);
- while Token /= Tok_End_Of_Line and then Token /= Tok_EOF loop
+ while Token not in Tok_End_Of_Line | Tok_EOF loop
Scan.all;
end loop;
@@ -1261,9 +1256,7 @@ package body Prep is
-- It is an error to have trailing characters after
-- the condition or "then".
- if Token /= Tok_End_Of_Line
- and then Token /= Tok_EOF
- then
+ if Token not in Tok_End_Of_Line | Tok_EOF then
Error_Msg
("extraneous text on preprocessor line",
Token_Ptr);
@@ -1318,9 +1311,7 @@ package body Prep is
-- It is an error to have trailing characters after the
-- condition or "then".
- if Token /= Tok_End_Of_Line
- and then Token /= Tok_EOF
- then
+ if Token not in Tok_End_Of_Line | Tok_EOF then
Error_Msg
("extraneous text on preprocessor line",
Token_Ptr);
@@ -1384,9 +1375,7 @@ package body Prep is
-- Error of character present after "#else"
- if Token /= Tok_End_Of_Line
- and then Token /= Tok_EOF
- then
+ if Token not in Tok_End_Of_Line | Tok_EOF then
Error_Msg
("extraneous text on preprocessor line",
Token_Ptr);
@@ -1427,9 +1416,7 @@ package body Prep is
-- Error of character present after "#end if;"
- if Token /= Tok_End_Of_Line
- and then Token /= Tok_EOF
- then
+ if Token not in Tok_End_Of_Line | Tok_EOF then
Error_Msg
("extraneous text on preprocessor line",
Token_Ptr);
@@ -1496,9 +1483,7 @@ package body Prep is
Go_To_End_Of_Line;
else
- while Token /= Tok_End_Of_Line
- and then Token /= Tok_EOF
- loop
+ while Token not in Tok_End_Of_Line | Tok_EOF loop
if Token = Tok_Special
and then Special_Character = '$'
then
@@ -1564,7 +1549,7 @@ package body Prep is
end if;
end if;
- pragma Assert (Token = Tok_End_Of_Line or else Token = Tok_EOF);
+ pragma Assert (Token in Tok_End_Of_Line | Tok_EOF);
-- At this point, the token is either end of line or EOF. The line to
-- possibly output stops just before the token.
diff --git a/gcc/ada/prepcomp.adb b/gcc/ada/prepcomp.adb
index 3cd2959..a1fe025 100644
--- a/gcc/ada/prepcomp.adb
+++ b/gcc/ada/prepcomp.adb
@@ -311,7 +311,7 @@ package body Prepcomp is
-- Check the switches that may follow
- while Token /= Tok_End_Of_Line and then Token /= Tok_EOF loop
+ while Token not in Tok_End_Of_Line | Tok_EOF loop
if Token /= Tok_Minus then
Error_Msg -- CODEFIX
("`'-` expected", Token_Ptr);
@@ -755,7 +755,7 @@ package body Prepcomp is
begin
Set_Ignore_Errors (To => True);
- while Token /= Tok_End_Of_Line and then Token /= Tok_EOF loop
+ while Token not in Tok_End_Of_Line | Tok_EOF loop
Scan;
end loop;
diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb
index f5fc020..b6698a6 100644
--- a/gcc/ada/scng.adb
+++ b/gcc/ada/scng.adb
@@ -1747,15 +1747,9 @@ package body Scng is
-- In Ada 2022, a target name (i.e. @) is a valid prefix of an
-- attribute, and functions like a name.
- if Prev_Token = Tok_All
- or else Prev_Token = Tok_At_Sign
- or else Prev_Token = Tok_Delta
- or else Prev_Token = Tok_Digits
- or else Prev_Token = Tok_Identifier
- or else Prev_Token = Tok_Project
- or else Prev_Token = Tok_Right_Paren
- or else Prev_Token = Tok_Right_Bracket
- or else Prev_Token in Token_Class_Literal
+ if Prev_Token in Tok_All | Tok_At_Sign | Tok_Delta | Tok_Digits |
+ Tok_Identifier | Tok_Project | Tok_Right_Paren |
+ Tok_Right_Bracket | Token_Class_Literal
then
Token := Tok_Apostrophe;