diff options
author | Bob Duff <duff@adacore.com> | 2022-08-17 12:50:42 -0400 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2022-09-12 10:16:49 +0200 |
commit | 272ada7499e6ce8e1a8bd3f82c1cc030a51d074e (patch) | |
tree | 24451793bc0d5f11414bed202922dc3440a49392 /gcc/ada/par-endh.adb | |
parent | dad0ebe674d495a7e032a123d2d60c090729ef2c (diff) | |
download | gcc-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-endh.adb')
-rw-r--r-- | gcc/ada/par-endh.adb | 24 |
1 files changed, 8 insertions, 16 deletions
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 |