diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-07-10 10:37:05 -0700 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-07-18 20:16:41 -0700 |
| commit | f712b2d76b1077a2241916cc3269aa1d83ce3088 (patch) | |
| tree | 4c9607974f8ec81d100f90d176d140b9ee9e2936 /src/libsyntax/parse/parser.rs | |
| parent | 22f492ab092b6d4948a69eb20037a7409c6119d3 (diff) | |
| download | rust-f712b2d76b1077a2241916cc3269aa1d83ce3088.tar.gz rust-f712b2d76b1077a2241916cc3269aa1d83ce3088.zip | |
accept naked exprs with commas in pattern arms
pretty printing will use them, but indentation is slightly off if the expr is long
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9d2fb947451..a6bce303ee5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1509,8 +1509,25 @@ class parser { let pats = self.parse_pats(); let mut guard = none; if self.eat_keyword(~"if") { guard = some(self.parse_expr()); } - if self.token == token::FAT_ARROW { self.bump(); } - let blk = self.parse_block(); + let blk = if self.token != token::FAT_ARROW { + self.parse_block() + } else { + self.bump(); + if self.token == token::LBRACE { + self.parse_block() + } else { + let expr = self.parse_expr(); + if self.token != token::RBRACE { + self.expect(token::COMMA); + } + {node: {view_items: ~[], + stmts: ~[], + expr: some(expr), + id: self.get_id(), + rules: default_blk}, + span: expr.span} + } + }; vec::push(arms, {pats: pats, guard: guard, body: blk}); } let mut hi = self.span.hi; |
