aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse/rust-parse-impl.h
diff options
context:
space:
mode:
authorSimplyTheOther <simplytheother@gmail.com>2020-09-26 17:21:10 +0800
committerPhilip Herron <philip.herron@embecosm.com>2020-11-28 21:13:21 +0000
commit5fbc20189d0a9648c2ab6f4f9a7cf0bd82e73186 (patch)
treed905f99c6b50fd22c46b4cbc33d27aad36f9b0ec /gcc/rust/parse/rust-parse-impl.h
parent41b1bad402aa3dcb3657c75e0c93e2a114d2e2cb (diff)
downloadgcc-5fbc20189d0a9648c2ab6f4f9a7cf0bd82e73186.zip
gcc-5fbc20189d0a9648c2ab6f4f9a7cf0bd82e73186.tar.gz
gcc-5fbc20189d0a9648c2ab6f4f9a7cf0bd82e73186.tar.bz2
Test even more generic algorithm for parsing in for lifetimes
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h26
1 files changed, 8 insertions, 18 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index da31a6c..fadbfb4 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -2868,14 +2868,6 @@ Parser<ManagedTokenSource>::parse_lifetime_params_objs (
{
std::vector<AST::LifetimeParam> lifetime_params;
- // DEBUG:
- fprintf (
- stderr,
- "about to start parse_lifetime_params_objs - current token: '%s', "
- "is_end_token(...): '%s'\n",
- lexer.peek_token ()->get_token_description (),
- std::to_string (is_end_token (lexer.peek_token ()->get_id ())).c_str ());
-
while (!is_end_token (lexer.peek_token ()->get_id ()))
{
AST::LifetimeParam lifetime_param = parse_lifetime_param ();
@@ -2900,22 +2892,17 @@ Parser<ManagedTokenSource>::parse_lifetime_params_objs (
lifetime_params.shrink_to_fit ();
- // DEBUG:
- fprintf (stderr,
- "returned lifetime_params of length %d. Current token is '%s'\n",
- static_cast<int> (lifetime_params.size ()),
- lexer.peek_token ()->get_token_description ());
-
return lifetime_params;
}
-/* Parses various types of generic parameters (templated). Will also consume any
- * trailing comma. Has extra is_end_token predicate checking.
+/* Parses a sequence of a certain grammar rule in object form (not pointer or
+ * smart pointer), delimited by commas and ending when 'is_end_token' is
+ * satisfied (templated). Will also consume any trailing comma.
* TODO: is this best solution? implements most of the same algorithm. */
template <typename ManagedTokenSource>
template <typename ParseFunction, typename EndTokenPred>
auto
-Parser<ManagedTokenSource>::parse_generic_params (
+Parser<ManagedTokenSource>::parse_non_ptr_sequence (
ParseFunction parsing_function, EndTokenPred is_end_token,
std::string error_msg) -> std::vector<decltype (parsing_function ())>
{
@@ -3316,7 +3303,10 @@ Parser<ManagedTokenSource>::parse_for_lifetimes ()
/* cannot specify end token due to parsing problems with '>' tokens being
* nested */
- params = parse_lifetime_params_objs (is_right_angle_tok);
+ //params = parse_lifetime_params_objs (is_right_angle_tok);
+ params = parse_non_ptr_sequence (
+ parse_lifetime_param, is_right_angle_tok,
+ "failed to parse lifetime param in lifetime params");
if (!skip_generics_right_angle ())
{