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/prep.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/prep.adb')
-rw-r--r-- | gcc/ada/prep.adb | 43 |
1 files changed, 14 insertions, 29 deletions
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. |