diff options
| author | Lindsey Kuper <[email protected]> | 2011-05-11 12:04:58 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-05-13 17:35:13 -0700 |
| commit | d3242b9644bb32f9a74be845518067566e2f36a7 (patch) | |
| tree | 60d52552c54048712d05e75f5fb053fd43bc8edf /src/comp | |
| parent | More progress on anonymous objects. (diff) | |
| download | rust-d3242b9644bb32f9a74be845518067566e2f36a7.tar.xz rust-d3242b9644bb32f9a74be845518067566e2f36a7.zip | |
Bug fixes.
Fixed infinite loop on anonymous objects in parser; added
expr_anon_obj to walk.rs; fixed syntax of test case.
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/front/ast.rs | 12 | ||||
| -rw-r--r-- | src/comp/front/parser.rs | 30 | ||||
| -rw-r--r-- | src/comp/middle/walk.rs | 2 |
3 files changed, 24 insertions, 20 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index d2bc6578..eda09276 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -379,18 +379,6 @@ type anon_obj = rec( // with_obj: the original object being extended, if it exists. Option.t[ident] with_obj); -tag mod_index_entry { - mie_view_item(@view_item); - mie_item(@item); - mie_tag_variant(@item /* tag item */, uint /* variant index */); -} - -tag native_mod_index_entry { - nmie_view_item(@view_item); - nmie_item(@native_item); -} - -type mod_index = hashmap[ident,mod_index_entry]; type _mod = rec(vec[@view_item] view_items, vec[@item] items); diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 267c752e..a02a2fa4 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -806,26 +806,40 @@ fn parse_bottom_expr(parser p) -> @ast::expr { auto ty_params = parse_ty_params(p); // Only make people type () if they're actually adding new fields - let option.t[vec[ast.obj_field]] fields = none[vec[ast.obj_field]]; + let option.t[vec[ast::obj_field]] fields = none[vec[ast::obj_field]]; if (p.peek() == token::LPAREN) { auto pf = parse_obj_field; + expect(p, token::LBRACE); + while (p.peek() != token::RBRACE) { + alt (p.peek()) { + case (token.WITH) { + p.bump(); + with_obj = some[ast::ident](parse_ident(p)); + } + case (_) { + Vec.push[@ast::method](meths, + parse_method(p)); + } + } + } + hi = p.get_hi_pos(); expect(p, token::LPAREN); - fields = some[vec[ast.obj_field]] - (parse_seq_to_end[ast.obj_field] + fields = some[vec[ast::obj_field]] + (parse_seq_to_end[ast::obj_field] (token::RPAREN, some(token::COMMA), pf, hi, p)); } - let vec[@ast.method] meths = vec(); - let option.t[ast.ident] with_obj = none[ast.ident]; + let vec[@ast::method] meths = vec(); + let option.t[ast::ident] with_obj = none[ast::ident]; expect(p, token::LBRACE); while (p.peek() != token::RBRACE) { alt (p.peek()) { case (token::WITH) { - with_obj = some[ast.ident](parse_ident(p)); + with_obj = some[ast::ident](parse_ident(p)); } case (_) { // fall through @@ -841,13 +855,13 @@ fn parse_bottom_expr(parser p) -> @ast::expr { // We don't need to pull ".node" out of fields because it's not a // "spanned". - let ast.anon_obj ob = rec(fields=fields, + let ast::anon_obj ob = rec(fields=fields, methods=meths, with_obj=with_obj); auto odid = rec(ty=p.next_def_id(), ctor=p.next_def_id()); - ex = ast.expr_anon_obj(ob, ty_params, odid, ast.ann_none); + ex = ast::expr_anon_obj(ob, ty_params, odid, ast::ann_none); } else if (eat_word(p, "bind")) { auto e = parse_expr_res(p, RESTRICT_NO_CALL_EXPRS); diff --git a/src/comp/middle/walk.rs b/src/comp/middle/walk.rs index 8a3c72f4..8dbcca07 100644 --- a/src/comp/middle/walk.rs +++ b/src/comp/middle/walk.rs @@ -433,6 +433,8 @@ fn walk_expr(&ast_visitor v, @ast::expr e) { case (ast::expr_chan(?x, _)) { walk_expr(v, x); } + + case (ast.expr_anon_obj(_,_,_,_)) { } } v.visit_expr_post(e); } |