diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-08-14 19:20:56 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-08-15 16:20:34 -0700 |
| commit | bdb206f2855cc6f7d3d79379633f7429b7327fec (patch) | |
| tree | 05764770b6b2729780bb1289d3c2db55d1cc55c5 /src/libsyntax/parse/parser.rs | |
| parent | d54db12155257787797cd9c7eaf06a215ff516e5 (diff) | |
| download | rust-bdb206f2855cc6f7d3d79379633f7429b7327fec.tar.gz rust-bdb206f2855cc6f7d3d79379633f7429b7327fec.zip | |
rustc: Parse labeled loop, break, and again
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 642cdaa8fab..977e75362f8 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -939,10 +939,18 @@ class parser { ex = expr_ret(some(e)); } else { ex = expr_ret(none); } } else if self.eat_keyword(~"break") { - ex = expr_break; + if is_ident(self.token) { + ex = expr_break(some(self.parse_ident())); + } else { + ex = expr_break(none); + } hi = self.span.hi; } else if self.eat_keyword(~"again") { - ex = expr_again; + if is_ident(self.token) { + ex = expr_again(some(self.parse_ident())); + } else { + ex = expr_again(none); + } hi = self.span.hi; } else if self.eat_keyword(~"copy") { let e = self.parse_expr(); @@ -1585,10 +1593,18 @@ class parser { } fn parse_loop_expr() -> @expr { + let opt_ident; + if is_ident(self.token) { + opt_ident = some(self.parse_ident()); + self.expect(token::COLON); + } else { + opt_ident = none; + } + let lo = self.last_span.lo; let body = self.parse_block_no_value(); let mut hi = body.span.hi; - return self.mk_expr(lo, hi, expr_loop(body)); + return self.mk_expr(lo, hi, expr_loop(body, opt_ident)); } // For distingishing between record literals and blocks |
