aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/par-util.adb
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/par-util.adb
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/par-util.adb')
-rw-r--r--gcc/ada/par-util.adb34
1 files changed, 12 insertions, 22 deletions
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;
-----------------------------------