diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2011-02-14 17:46:28 -0800 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2011-02-14 17:46:28 -0800 |
| commit | f1f33abdeba156523d6db1752bbff75dc4088724 (patch) | |
| tree | 9591e536c2a2197756c36859727b20fd0af19cde /src/comp/front/parser.rs | |
| parent | 88cb9663639e915d2b69cef7ec514043ed39e5f4 (diff) | |
| download | rust-f1f33abdeba156523d6db1752bbff75dc4088724.tar.gz rust-f1f33abdeba156523d6db1752bbff75dc4088724.zip | |
Move all non-decl/non-expr stmts to exprs.
Diffstat (limited to 'src/comp/front/parser.rs')
| -rw-r--r-- | src/comp/front/parser.rs | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 1296113a7c8..5ffaca197c3 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -598,6 +598,59 @@ impure fn parse_bottom_expr(parser p) -> @ast.expr { ex = ast.expr_ext(es.node, none[@ast.expr], ast.ann_none); } + case (token.FAIL) { + p.bump(); + ex = ast.expr_fail; + } + + case (token.LOG) { + p.bump(); + auto e = parse_expr(p); + auto hi = e.span; + ex = ast.expr_log(e); + } + + case (token.CHECK) { + p.bump(); + alt (p.peek()) { + case (token.LPAREN) { + auto e = parse_expr(p); + auto hi = e.span; + ex = ast.expr_check_expr(e); + } + case (_) { + p.get_session().unimpl("constraint-check stmt"); + } + } + } + + case (token.RET) { + p.bump(); + alt (p.peek()) { + case (token.SEMI) { + ex = ast.expr_ret(none[@ast.expr]); + } + case (_) { + auto e = parse_expr(p); + hi = e.span; + ex = ast.expr_ret(some[@ast.expr](e)); + } + } + } + + case (token.BE) { + p.bump(); + auto e = parse_expr(p); + // FIXME: Is this the right place for this check? + if /*check*/ (ast.is_call_expr(e)) { + hi = e.span; + ex = ast.expr_be(e); + } + else { + p.err("Non-call expression in tail call"); + } + } + case (_) { auto lit = parse_lit(p); hi = lit.span; @@ -1203,59 +1256,6 @@ impure fn parse_stmt(parser p) -> @ast.stmt { auto lo = p.get_span(); alt (p.peek()) { - case (token.LOG) { - p.bump(); - auto e = parse_expr(p); - auto hi = p.get_span(); - ret @spanned(lo, hi, ast.stmt_log(e)); - } - - case (token.CHECK) { - p.bump(); - alt (p.peek()) { - case (token.LPAREN) { - auto e = parse_expr(p); - auto hi = p.get_span(); - ret @spanned(lo, hi, ast.stmt_check_expr(e)); - } - case (_) { - p.get_session().unimpl("constraint-check stmt"); - } - } - } - - case (token.FAIL) { - p.bump(); - ret @spanned(lo, p.get_span(), ast.stmt_fail); - } - - case (token.RET) { - p.bump(); - alt (p.peek()) { - case (token.SEMI) { - ret @spanned(lo, p.get_span(), - ast.stmt_ret(none[@ast.expr])); - } - case (_) { - auto e = parse_expr(p); - ret @spanned(lo, e.span, - ast.stmt_ret(some[@ast.expr](e))); - } - } - } - - case (token.BE) { - p.bump(); - auto e = parse_expr(p); - // FIXME: Is this the right place for this check? - if /*check*/ (ast.is_call_expr(e)) { - ret @spanned(lo, e.span, ast.stmt_be(e)); - } - else { - p.err("Non-call expression in tail call"); - } - } - case (token.LET) { auto decl = parse_let(p); auto hi = p.get_span(); @@ -1396,11 +1396,6 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool { case (ast.decl_item(_)) { ret false; } } } - case (ast.stmt_ret(_)) { ret true; } - case (ast.stmt_be(_)) { ret true; } - case (ast.stmt_log(_)) { ret true; } - case (ast.stmt_check_expr(_)) { ret true; } - case (ast.stmt_fail) { ret true; } case (ast.stmt_expr(?e)) { alt (e.node) { case (ast.expr_vec(_,_)) { ret true; } @@ -1423,6 +1418,11 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool { case (ast.expr_field(_,_,_)) { ret true; } case (ast.expr_index(_,_,_)) { ret true; } case (ast.expr_path(_,_,_)) { ret true; } + case (ast.expr_fail) { ret true; } + case (ast.expr_ret(_)) { ret true; } + case (ast.expr_be(_)) { ret true; } + case (ast.expr_log(_)) { ret true; } + case (ast.expr_check_expr(_)) { ret true; } } } } |
