Skip to content

Commit 80ce173

Browse files
committed
Move is_right_angle_tok to util namespace
gcc/rust/ChangeLog: * parse/rust-parse-impl.h (is_right_angle_tok): Move function ... (Parser::parse_generic_params_in_angles): Change call. (Parser::parse_for_lifetimes): Likewise. (Parser::parse_path_generic_args): Likewise. * parse/rust-parse-utils.h (is_right_angle_tok): ... to here. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
1 parent 0aa6c5b commit 80ce173

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

gcc/rust/parse/rust-parse-impl.h

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -179,23 +179,6 @@ can_tok_start_type (TokenId id)
179179
}
180180
}
181181

182-
/* Returns whether the token id is (or is likely to be) a right angle bracket.
183-
* i.e. '>', '>>', '>=' and '>>=' tokens. */
184-
inline bool
185-
is_right_angle_tok (TokenId id)
186-
{
187-
switch (id)
188-
{
189-
case RIGHT_ANGLE:
190-
case RIGHT_SHIFT:
191-
case GREATER_OR_EQUAL:
192-
case RIGHT_SHIFT_EQ:
193-
return true;
194-
default:
195-
return false;
196-
}
197-
}
198-
199182
/* HACK-y special handling for skipping a right angle token at the end of
200183
* generic arguments.
201184
* Currently, this replaces the "current token" with one that is identical
@@ -3072,7 +3055,7 @@ Parser<ManagedTokenSource>::parse_generic_params_in_angles ()
30723055
rust_debug ("skipped left angle in generic param");
30733056

30743057
std::vector<std::unique_ptr<AST::GenericParam>> generic_params
3075-
= parse_generic_params (is_right_angle_tok);
3058+
= parse_generic_params (Parse::Utils::is_right_angle_tok);
30763059

30773060
// DEBUG:
30783061
rust_debug ("finished parsing actual generic params (i.e. inside angles)");
@@ -3936,7 +3919,7 @@ Parser<ManagedTokenSource>::parse_for_lifetimes ()
39363919

39373920
/* cannot specify end token due to parsing problems with '>' tokens being
39383921
* nested */
3939-
params = parse_lifetime_params_objs (is_right_angle_tok);
3922+
params = parse_lifetime_params_objs (Parse::Utils::is_right_angle_tok);
39403923

39413924
if (!skip_generics_right_angle ())
39423925
{
@@ -6414,7 +6397,7 @@ Parser<ManagedTokenSource>::parse_path_generic_args ()
64146397

64156398
const_TokenPtr t = lexer.peek_token ();
64166399
location_t locus = t->get_locus ();
6417-
while (!is_right_angle_tok (t->get_id ()))
6400+
while (!Parse::Utils::is_right_angle_tok (t->get_id ()))
64186401
{
64196402
auto lifetime = parse_lifetime (false);
64206403
if (!lifetime)
@@ -6441,7 +6424,7 @@ Parser<ManagedTokenSource>::parse_path_generic_args ()
64416424

64426425
// TODO: think of better control structure
64436426
t = lexer.peek_token ();
6444-
while (!is_right_angle_tok (t->get_id ()))
6427+
while (!Parse::Utils::is_right_angle_tok (t->get_id ()))
64456428
{
64466429
// FIXME: Is it fine to break if there is one binding? Can't there be
64476430
// bindings in between types?
@@ -6473,7 +6456,7 @@ Parser<ManagedTokenSource>::parse_path_generic_args ()
64736456

64746457
// TODO: think of better control structure
64756458
t = lexer.peek_token ();
6476-
while (!is_right_angle_tok (t->get_id ()))
6459+
while (!Parse::Utils::is_right_angle_tok (t->get_id ()))
64776460
{
64786461
AST::GenericArgsBinding binding = parse_generic_args_binding ();
64796462
if (binding.is_error ())

gcc/rust/parse/rust-parse-utils.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,23 @@ is_simple_path_segment (TokenId id)
6565
}
6666
}
6767

68+
/* Returns whether the token id is (or is likely to be) a right angle bracket.
69+
* i.e. '>', '>>', '>=' and '>>=' tokens. */
70+
inline bool
71+
is_right_angle_tok (TokenId id)
72+
{
73+
switch (id)
74+
{
75+
case RIGHT_ANGLE:
76+
case RIGHT_SHIFT:
77+
case GREATER_OR_EQUAL:
78+
case RIGHT_SHIFT_EQ:
79+
return true;
80+
default:
81+
return false;
82+
}
83+
}
84+
6885
} // namespace Utils
6986

7087
} // namespace Parse

0 commit comments

Comments
 (0)