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
This commit is contained in:
parent
fbad0204e4
commit
9211348989
@ -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}];
|
||||
}
|
||||
|
@ -843,7 +843,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
|
||||
}
|
||||
space(s.s);
|
||||
alt arm.guard {
|
||||
some(e) { word_space(s, "when"); print_expr(s, e); space(s.s); }
|
||||
some(e) { word_space(s, "if"); print_expr(s, e); space(s.s); }
|
||||
none. { }
|
||||
}
|
||||
print_possibly_embedded_block(s, arm.body, block_normal,
|
||||
|
Loading…
x
Reference in New Issue
Block a user