diff options
| author | Rafael Ávila de Espíndola <[email protected]> | 2011-02-01 13:40:04 -0500 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-02-01 16:57:33 -0800 |
| commit | 4b06dc574ba7d3ae50795cbe4f10d4be6e9c64a1 (patch) | |
| tree | 1a0d2181f0bd124dfb13277fe74ca674c9db757e /src/comp/front | |
| parent | Pick up case for expr_block from brson's other branch. (diff) | |
| download | rust-4b06dc574ba7d3ae50795cbe4f10d4be6e9c64a1.tar.xz rust-4b06dc574ba7d3ae50795cbe4f10d4be6e9c64a1.zip | |
Add very minimal support for native modules. For now they must be empty.
Diffstat (limited to 'src/comp/front')
| -rw-r--r-- | src/comp/front/ast.rs | 6 | ||||
| -rw-r--r-- | src/comp/front/parser.rs | 19 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index be47615a..5f527f2d 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -227,6 +227,8 @@ type _mod = rec(vec[@view_item] view_items, vec[@item] items, mod_index index); +type native_mod = rec(str native_name); + type variant_arg = rec(@ty ty, def_id id); type variant = rec(str name, vec[variant_arg] args, def_id id, ann ann); @@ -241,6 +243,7 @@ tag item_ { item_const(ident, @ty, @expr, def_id, ann); item_fn(ident, _fn, vec[ty_param], def_id, ann); item_mod(ident, _mod, def_id); + item_native_mod(ident, native_mod, def_id); item_ty(ident, @ty, vec[ty_param], def_id, ann); item_tag(ident, vec[variant], vec[ty_param], def_id); item_obj(ident, _obj, vec[ty_param], def_id, ann); @@ -268,6 +271,9 @@ fn index_item(mod_index index, @item it) { case (ast.item_mod(?id, _, _)) { index.insert(id, ast.mie_item(it)); } + case (ast.item_native_mod(?id, _, _)) { + index.insert(id, ast.mie_item(it)); + } case (ast.item_ty(?id, _, _, _, _)) { index.insert(id, ast.mie_item(it)); } diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 0c90df5c..16adfedb 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -1577,6 +1577,20 @@ impure fn parse_item_mod(parser p) -> @ast.item { ret @spanned(lo, hi, item); } +impure fn parse_item_native_mod(parser p) -> @ast.item { + auto lo = p.get_span(); + expect(p, token.NATIVE); + auto native_name = parse_str_lit(p); + expect(p, token.MOD); + auto id = parse_ident(p); + expect(p, token.LBRACE); + auto m = rec(native_name = native_name); + auto hi = p.get_span(); + expect(p, token.RBRACE); + auto item = ast.item_native_mod(id, m, p.next_def_id()); + ret @spanned(lo, hi, item); +} + impure fn parse_item_type(parser p) -> @ast.item { auto lo = p.get_span(); expect(p, token.TYPE); @@ -1717,6 +1731,11 @@ impure fn parse_item(parser p) -> @ast.item { check (lyr == ast.layer_value); ret parse_item_mod(p); } + case (token.NATIVE) { + check (eff == ast.eff_pure); + check (lyr == ast.layer_value); + ret parse_item_native_mod(p); + } case (token.TYPE) { check (eff == ast.eff_pure); ret parse_item_type(p); |