diff options
| author | Graydon Hoare <[email protected]> | 2011-05-02 16:24:09 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-05-02 17:35:33 -0700 |
| commit | d08b443fffb1181d8d45ae5d061412f202dd4118 (patch) | |
| tree | ad75b4e4fc9407aa1201f9068012f30664d17b64 /src/comp/front/parser.rs | |
| parent | Add a regression test that exports can expose unexported items (diff) | |
| download | rust-d08b443fffb1181d8d45ae5d061412f202dd4118.tar.xz rust-d08b443fffb1181d8d45ae5d061412f202dd4118.zip | |
Revert "Use different syntax for checks that matter to typestate"
This reverts commit aa25f22f197682de3b18fc4c8ba068d1feda220f. It broke stage2, not sure why yet.
Diffstat (limited to 'src/comp/front/parser.rs')
| -rw-r--r-- | src/comp/front/parser.rs | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 3e8ca85a..fdd41cf0 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -621,7 +621,7 @@ fn parse_path(parser p, greed g) -> ast.path { if (p.peek() == token.DOT) { if (g == GREEDY) { p.bump(); - assert (is_ident(p.peek())); + check (is_ident(p.peek())); } else { more = false; } @@ -816,22 +816,19 @@ fn parse_bottom_expr(parser p) -> @ast.expr { ex = ast.expr_log(0, e, ast.ann_none); } - case (token.ASSERT) { - p.bump(); - auto e = parse_expr(p); - auto hi = e.span.hi; - ex = ast.expr_assert(e, ast.ann_none); - } - case (token.CHECK) { p.bump(); - /* Should be a predicate (pure boolean function) applied to - arguments that are all either slot variables or literals. - but the typechecker enforces that. */ - auto e = parse_expr(p); - auto hi = e.span.hi; - ex = ast.expr_check(e, ast.ann_none); - } + alt (p.peek()) { + case (token.LPAREN) { + auto e = parse_expr(p); + auto hi = e.span.hi; + ex = ast.expr_check_expr(e, ast.ann_none); + } + case (_) { + p.get_session().unimpl("constraint-check stmt"); + } + } + } case (token.RET) { p.bump(); @@ -940,7 +937,7 @@ fn expand_syntax_ext(parser p, ast.span sp, &ast.path path, vec[@ast.expr] args, option.t[str] body) -> ast.expr_ { - assert (_vec.len[ast.ident](path.node.idents) > 0u); + check (_vec.len[ast.ident](path.node.idents) > 0u); auto extname = path.node.idents.(0); if (_str.eq(extname, "fmt")) { auto expanded = extfmt.expand_syntax_ext(args, body); @@ -1676,8 +1673,7 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool { case (ast.expr_put(_,_)) { ret true; } case (ast.expr_be(_,_)) { ret true; } case (ast.expr_log(_,_,_)) { ret true; } - case (ast.expr_check(_,_)) { ret true; } - case (ast.expr_assert(_,_)) { ret true; } + case (ast.expr_check_expr(_,_)) { ret true; } } } // We should not be calling this on a cdir. @@ -2161,24 +2157,24 @@ fn parse_item(parser p) -> @ast.item { alt (p.peek()) { case (token.CONST) { - assert (lyr == ast.layer_value); + check (lyr == ast.layer_value); ret parse_item_const(p); } case (token.FN) { - assert (lyr == ast.layer_value); + check (lyr == ast.layer_value); ret parse_item_fn_or_iter(p); } case (token.ITER) { - assert (lyr == ast.layer_value); + check (lyr == ast.layer_value); ret parse_item_fn_or_iter(p); } case (token.MOD) { - assert (lyr == ast.layer_value); + check (lyr == ast.layer_value); ret parse_item_mod(p); } case (token.NATIVE) { - assert (lyr == ast.layer_value); + check (lyr == ast.layer_value); ret parse_item_native_mod(p); } case (token.TYPE) { |