aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2011-03-01 17:32:16 -0800
committerGraydon Hoare <[email protected]>2011-03-01 17:33:17 -0800
commit64ab5eaaf09de6a75392554c13784c492ed19465 (patch)
tree2c166a5924fcae5971dad486f42cc25d913c6d95 /src/comp/front
parentrustc: Remove the static "size" field from the tag info (diff)
downloadrust-64ab5eaaf09de6a75392554c13784c492ed19465.tar.xz
rust-64ab5eaaf09de6a75392554c13784c492ed19465.zip
Parse (and ignore) dtors on objs.
Diffstat (limited to 'src/comp/front')
-rw-r--r--src/comp/front/ast.rs3
-rw-r--r--src/comp/front/parser.rs30
2 files changed, 23 insertions, 10 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs
index 9b995f9a..4ed513a3 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/front/ast.rs
@@ -247,7 +247,8 @@ type method = spanned[method_];
type obj_field = rec(@ty ty, ident ident, def_id id, ann ann);
type _obj = rec(vec[obj_field] fields,
- vec[@method] methods);
+ vec[@method] methods,
+ option.t[block] dtor);
tag mod_index_entry {
mie_view_item(@view_item);
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index 696140b1..f747c084 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -1715,21 +1715,33 @@ impure fn parse_item_obj(parser p, ast.layer lyr) -> @ast.item {
some(token.COMMA),
pf, p);
- auto pm = parse_method;
- let util.common.spanned[vec[@ast.method]] meths =
- parse_seq[@ast.method]
- (token.LBRACE,
- token.RBRACE,
- none[token.token],
- pm, p);
+ let vec[@ast.method] meths = vec();
+ let option.t[ast.block] dtor = none[ast.block];
+
+ expect(p, token.LBRACE);
+ while (p.peek() != token.RBRACE) {
+ alt (p.peek()) {
+ case (token.DROP) {
+ p.bump();
+ dtor = some[ast.block](parse_block(p));
+ }
+ case (_) {
+ append[@ast.method](meths,
+ parse_method(p));
+ }
+ }
+ }
+ auto hi = p.get_span();
+ expect(p, token.RBRACE);
let ast._obj ob = rec(fields=fields.node,
- methods=meths.node);
+ methods=meths,
+ dtor=dtor);
auto item = ast.item_obj(ident, ob, ty_params,
p.next_def_id(), ast.ann_none);
- ret @spanned(lo, meths.span, item);
+ ret @spanned(lo, hi, item);
}
impure fn parse_mod_items(parser p, token.token term) -> ast._mod {