diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-10-10 14:06:30 +0200 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2023-10-17 22:19:46 +0000 |
commit | 0af6a9f10640f086254d07b17f9c541f3d759acd (patch) | |
tree | 64c10aea05a1c79718576b5a38919ce19284a3fb /gcc/rust/parse | |
parent | 813d0b956fd465bc083787974f78cae038c3259b (diff) | |
download | gcc-0af6a9f10640f086254d07b17f9c541f3d759acd.zip gcc-0af6a9f10640f086254d07b17f9c541f3d759acd.tar.gz gcc-0af6a9f10640f086254d07b17f9c541f3d759acd.tar.bz2 |
Break OR tokens in closure parameter list context
The parser was unable to process as closure inside a closure because the
lexer could not differentiate an OR from two PIPE tokens.
gcc/rust/ChangeLog:
* parse/rust-parse-impl.h (Parser::parse_closure_expr_pratt): Fix
closure parsing function to handle consecutive parameter lists.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/parse')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 0ffb03d..2b2ba62 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -14464,12 +14464,17 @@ Parser<ManagedTokenSource>::parse_closure_expr_pratt (const_TokenPtr tok, if (lexer.peek_token ()->get_id () != COMMA) { + if (lexer.peek_token ()->get_id () == OR) + lexer.split_current_token (PIPE, PIPE); // not an error but means param list is done break; } // skip comma lexer.skip_token (); + if (lexer.peek_token ()->get_id () == OR) + lexer.split_current_token (PIPE, PIPE); + t = lexer.peek_token (); } |