Skip to content

Commit 88f0463

Browse files
committed
Support the awful alt-else form in rustboot's cexp grammar, at least transiently. Remove in the future.
1 parent dbf53b4 commit 88f0463

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/comp/front/parser.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,23 @@ impure fn parse_alt_expr(parser p) -> @ast.expr {
11701170
auto block = parse_block(p);
11711171
arms += vec(rec(pat=pat, block=block, index=index));
11721172
}
1173+
1174+
// FIXME: this is a vestigial form left over from
1175+
// rustboot, we're keeping it here for source-compat
1176+
// for the time being but it should be flushed out
1177+
// once we've bootstrapped. When we see 'else {' here,
1178+
// we pretend we saw 'case (_) {'. It has the same
1179+
// meaning, and only exists due to the cexp/pexp split
1180+
// in rustboot, which we're not maintaining.
1181+
1182+
case (token.ELSE) {
1183+
p.bump();
1184+
auto hi = p.get_span();
1185+
auto pat = @spanned(lo, hi, ast.pat_wild(ast.ann_none));
1186+
auto index = index_arm(pat);
1187+
auto block = parse_block(p);
1188+
arms += vec(rec(pat=pat, block=block, index=index));
1189+
}
11731190
case (token.RBRACE) { /* empty */ }
11741191
case (?tok) {
11751192
p.err("expected 'case' or '}' when parsing 'alt' statement " +

0 commit comments

Comments
 (0)