diff options
| author | Graydon Hoare <[email protected]> | 2011-02-24 17:17:39 -0800 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-02-24 17:17:39 -0800 |
| commit | 88f0463c2bd6e7fd2af461afc5e83bd3417e3bc5 (patch) | |
| tree | f8b60c224a3ac6d1e62bcbc41653fe0e73730209 | |
| parent | Connect the crate and source parsers together. (diff) | |
| download | rust-88f0463c2bd6e7fd2af461afc5e83bd3417e3bc5.tar.xz rust-88f0463c2bd6e7fd2af461afc5e83bd3417e3bc5.zip | |
Support the awful alt-else form in rustboot's cexp grammar, at least transiently. Remove in the future.
| -rw-r--r-- | src/comp/front/parser.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 7ae0050e..67b9cc80 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -1170,6 +1170,23 @@ impure fn parse_alt_expr(parser p) -> @ast.expr { auto block = parse_block(p); arms += vec(rec(pat=pat, block=block, index=index)); } + + // FIXME: this is a vestigial form left over from + // rustboot, we're keeping it here for source-compat + // for the time being but it should be flushed out + // once we've bootstrapped. When we see 'else {' here, + // we pretend we saw 'case (_) {'. It has the same + // meaning, and only exists due to the cexp/pexp split + // in rustboot, which we're not maintaining. + + case (token.ELSE) { + p.bump(); + auto hi = p.get_span(); + auto pat = @spanned(lo, hi, ast.pat_wild(ast.ann_none)); + auto index = index_arm(pat); + auto block = parse_block(p); + arms += vec(rec(pat=pat, block=block, index=index)); + } case (token.RBRACE) { /* empty */ } case (?tok) { p.err("expected 'case' or '}' when parsing 'alt' statement " + |