From 92113489893105d5432df2fd8f727fa2ca8cec51 Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Mon, 9 Jan 2012 09:42:07 -0600 Subject: Make the parser accept 'if' as an alternative to 'when' in alt patterns. Also fix the pretty printer, making it output 'if' instead of 'when'. Issue #1396 --- src/comp/syntax/parse/parser.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/comp/syntax/parse/parser.rs') diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 6a59b395ab4..2b45115f5b9 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -1389,7 +1389,11 @@ fn parse_alt_expr(p: parser) -> @ast::expr { while p.peek() != token::RBRACE { let pats = parse_pats(p); let guard = none; - if eat_word(p, "when") { guard = some(parse_expr(p)); } + if eat_word(p, "when") { + guard = some(parse_expr(p)); + } else if eat_word(p, "if") { + guard = some(parse_expr(p)); + } let blk = parse_block(p); arms += [{pats: pats, guard: guard, body: blk}]; } -- cgit 1.4.1-3-g733a5