diff options
Diffstat (limited to 'src/comp/front/parser.rs')
| -rw-r--r-- | src/comp/front/parser.rs | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index fdd41cf0..3e8ca85a 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(); - check (is_ident(p.peek())); + assert (is_ident(p.peek())); } else { more = false; } @@ -816,20 +816,23 @@ fn parse_bottom_expr(parser p) -> @ast.expr { ex = ast.expr_log(0, e, ast.ann_none); } - case (token.CHECK) { + case (token.ASSERT) { p.bump(); - 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"); - } - } + 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); + } + case (token.RET) { p.bump(); alt (p.peek()) { @@ -937,7 +940,7 @@ fn expand_syntax_ext(parser p, ast.span sp, &ast.path path, vec[@ast.expr] args, option.t[str] body) -> ast.expr_ { - check (_vec.len[ast.ident](path.node.idents) > 0u); + assert (_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); @@ -1673,7 +1676,8 @@ 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_expr(_,_)) { ret true; } + case (ast.expr_check(_,_)) { ret true; } + case (ast.expr_assert(_,_)) { ret true; } } } // We should not be calling this on a cdir. @@ -2157,24 +2161,24 @@ fn parse_item(parser p) -> @ast.item { alt (p.peek()) { case (token.CONST) { - check (lyr == ast.layer_value); + assert (lyr == ast.layer_value); ret parse_item_const(p); } case (token.FN) { - check (lyr == ast.layer_value); + assert (lyr == ast.layer_value); ret parse_item_fn_or_iter(p); } case (token.ITER) { - check (lyr == ast.layer_value); + assert (lyr == ast.layer_value); ret parse_item_fn_or_iter(p); } case (token.MOD) { - check (lyr == ast.layer_value); + assert (lyr == ast.layer_value); ret parse_item_mod(p); } case (token.NATIVE) { - check (lyr == ast.layer_value); + assert (lyr == ast.layer_value); ret parse_item_native_mod(p); } case (token.TYPE) { |