From 4b06dc574ba7d3ae50795cbe4f10d4be6e9c64a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Tue, 1 Feb 2011 13:40:04 -0500 Subject: Add very minimal support for native modules. For now they must be empty. --- src/comp/front/ast.rs | 6 ++++++ src/comp/front/parser.rs | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'src/comp/front') 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); -- cgit v1.2.3