提交 214c3239 编写于 作者: B Brian Anderson

Teach rustc to parse 'else if'

上级 bf9cebfc
......@@ -447,6 +447,7 @@ TEST_XFAILS_RUSTC := $(filter-out \
div-mod.rs \
drop-bind-thunk-args.rs \
drop-on-ret.rs \
else-if.rs \
fact.rs \
fn-lval.rs \
fun-call-variants.rs \
......
......@@ -895,8 +895,7 @@ fn is_ident(token.token t) -> bool {
hi = thn.span;
alt (p.peek()) {
case (token.ELSE) {
p.bump();
auto eblk = parse_block(p);
auto eblk = parse_else_block(p);
els = some(eblk);
hi = eblk.span;
}
......@@ -905,6 +904,21 @@ fn is_ident(token.token t) -> bool {
ret @spanned(lo, hi, ast.expr_if(cond, thn, els, ast.ann_none));
}
impure fn parse_else_block(parser p) -> ast.block {
expect(p, token.ELSE);
alt (p.peek()) {
case (token.IF) {
let vec[@ast.stmt] stmts = vec();
auto ifexpr = parse_if_expr(p);
auto bloc = index_block(stmts, some(ifexpr));
ret spanned(ifexpr.span, ifexpr.span, bloc);
}
case (_) {
ret parse_block(p);
}
}
}
impure fn parse_head_local(parser p) -> @ast.decl {
auto lo = p.get_span();
let @ast.local local;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册