aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front/parser.rs
diff options
context:
space:
mode:
authorTim Chevalier <[email protected]>2011-04-06 17:56:44 -0700
committerTim Chevalier <[email protected]>2011-04-06 17:58:18 -0700
commit2e90bd94de32c739733966bfac96cf35e9a08655 (patch)
tree01cecc3fbc92d27e01177b5d3cb0785239877ea9 /src/comp/front/parser.rs
parentMinimal testcase for next bootstrap blocker. (diff)
downloadrust-2e90bd94de32c739733966bfac96cf35e9a08655.tar.xz
rust-2e90bd94de32c739733966bfac96cf35e9a08655.zip
Continued sketching out code for checking states against preconditions.
It's still sketchy. I added a typestate annotation field to statements tagged stmt_decl or stmt_expr, because a stmt_decl statement has a typestate that's different from that of its child node. This necessitated trivial changes to a bunch of other files all over to the compiler. I also added a few small standard library functions, some of which I didn't actually end up using but which I thought might be useful anyway.
Diffstat (limited to 'src/comp/front/parser.rs')
-rw-r--r--src/comp/front/parser.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index 27fdc7fe..7d1323cb 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -11,6 +11,7 @@ import util.common;
import util.common.filename;
import util.common.span;
import util.common.new_str_hash;
+import util.typestate_ann.ts_ann;
tag restriction {
UNRESTRICTED;
@@ -1555,13 +1556,13 @@ impure fn parse_source_stmt(parser p) -> @ast.stmt {
case (token.LET) {
auto decl = parse_let(p);
auto hi = p.get_span();
- ret @spanned(lo, hi, ast.stmt_decl(decl));
+ ret @spanned(lo, hi, ast.stmt_decl(decl, none[@ts_ann]));
}
case (token.AUTO) {
auto decl = parse_auto(p);
auto hi = p.get_span();
- ret @spanned(lo, hi, ast.stmt_decl(decl));
+ ret @spanned(lo, hi, ast.stmt_decl(decl, none[@ts_ann]));
}
case (_) {
@@ -1570,13 +1571,13 @@ impure fn parse_source_stmt(parser p) -> @ast.stmt {
auto i = parse_item(p);
auto hi = i.span;
auto decl = @spanned(lo, hi, ast.decl_item(i));
- ret @spanned(lo, hi, ast.stmt_decl(decl));
+ ret @spanned(lo, hi, ast.stmt_decl(decl, none[@ts_ann]));
} else {
// Remainder are line-expr stmts.
auto e = parse_expr(p);
auto hi = p.get_span();
- ret @spanned(lo, hi, ast.stmt_expr(e));
+ ret @spanned(lo, hi, ast.stmt_expr(e, none[@ts_ann]));
}
}
}
@@ -1613,7 +1614,7 @@ fn index_arm(@ast.pat pat) -> hashmap[ast.ident,ast.def_id] {
fn stmt_to_expr(@ast.stmt stmt) -> option.t[@ast.expr] {
alt (stmt.node) {
- case (ast.stmt_expr(?e)) { ret some[@ast.expr](e); }
+ case (ast.stmt_expr(?e,_)) { ret some[@ast.expr](e); }
case (_) { /* fall through */ }
}
ret none[@ast.expr];
@@ -1621,13 +1622,13 @@ fn stmt_to_expr(@ast.stmt stmt) -> option.t[@ast.expr] {
fn stmt_ends_with_semi(@ast.stmt stmt) -> bool {
alt (stmt.node) {
- case (ast.stmt_decl(?d)) {
+ case (ast.stmt_decl(?d,_)) {
alt (d.node) {
case (ast.decl_local(_)) { ret true; }
case (ast.decl_item(_)) { ret false; }
}
}
- case (ast.stmt_expr(?e)) {
+ case (ast.stmt_expr(?e,_)) {
alt (e.node) {
case (ast.expr_vec(_,_,_)) { ret true; }
case (ast.expr_tup(_,_)) { ret true; }