aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h29
-rw-r--r--gcc/rust/parse/rust-parse.h7
2 files changed, 27 insertions, 9 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 277cd8b..d391304 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -7827,14 +7827,30 @@ Parser<ManagedTokenSource>::parse_if_let_expr (
template <typename ManagedTokenSource>
std::unique_ptr<AST::LoopExpr>
Parser<ManagedTokenSource>::parse_loop_expr (
- std::vector<AST::Attribute> outer_attrs, AST::LoopLabel label)
+ std::vector<AST::Attribute> outer_attrs, AST::LoopLabel label,
+ bool pratt_parse)
{
Location locus = Linemap::unknown_location ();
- if (label.is_error ())
- locus = lexer.peek_token ()->get_locus ();
+ if (!pratt_parse)
+ {
+ if (label.is_error ())
+ locus = lexer.peek_token ()->get_locus ();
+ else
+ locus = label.get_locus ();
+
+ if (!skip_token (LOOP))
+ {
+ skip_after_end_block ();
+ return nullptr;
+ }
+ }
else
- locus = label.get_locus ();
- skip_token (LOOP);
+ {
+ if (label.is_error ())
+ locus = lexer.peek_token ()->get_locus () - 1;
+ else
+ locus = label.get_locus ();
+ }
// parse loop body, which is required
std::unique_ptr<AST::BlockExpr> loop_body = parse_block_expr ();
@@ -12435,6 +12451,9 @@ Parser<ManagedTokenSource>::null_denotation (
// if expr
return parse_if_expr (std::move (outer_attrs), true);
}
+ case LOOP:
+ return parse_loop_expr (std::move (outer_attrs), AST::LoopLabel::error (),
+ true);
case MATCH_TOK:
// also an expression with block
return parse_match_expr (std::move (outer_attrs), true);
diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h
index b811c77..873b55e9 100644
--- a/gcc/rust/parse/rust-parse.h
+++ b/gcc/rust/parse/rust-parse.h
@@ -500,10 +500,9 @@ private:
parse_if_let_expr (std::vector<AST::Attribute> outer_attrs
= std::vector<AST::Attribute> (),
bool pratt_parse = false);
- std::unique_ptr<AST::LoopExpr>
- parse_loop_expr (std::vector<AST::Attribute> outer_attrs
- = std::vector<AST::Attribute> (),
- AST::LoopLabel label = AST::LoopLabel::error ());
+ std::unique_ptr<AST::LoopExpr> parse_loop_expr (
+ std::vector<AST::Attribute> outer_attrs = std::vector<AST::Attribute> (),
+ AST::LoopLabel label = AST::LoopLabel::error (), bool pratt_parse = false);
std::unique_ptr<AST::WhileLoopExpr>
parse_while_loop_expr (std::vector<AST::Attribute> outer_attrs
= std::vector<AST::Attribute> (),