Skip to content

Commit 8122e0c

Browse files
author
Rafael Avila de Espindola
committed
Add support for
native mod foo = "bar" ...
1 parent 57bb9d8 commit 8122e0c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/comp/front/parser.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,9 +1630,20 @@ impure fn parse_native_mod_items(parser p,
16301630
impure fn parse_item_native_mod(parser p) -> @ast.item {
16311631
auto lo = p.get_span();
16321632
expect(p, token.NATIVE);
1633-
auto native_name = parse_str_lit(p);
1633+
auto has_eq;
1634+
auto native_name = "";
1635+
if (p.peek() == token.MOD) {
1636+
has_eq = true;
1637+
} else {
1638+
native_name = parse_str_lit(p);
1639+
has_eq = false;
1640+
}
16341641
expect(p, token.MOD);
16351642
auto id = parse_ident(p);
1643+
if (has_eq) {
1644+
expect(p, token.EQ);
1645+
native_name = parse_str_lit(p);
1646+
}
16361647
expect(p, token.LBRACE);
16371648
auto m = parse_native_mod_items(p, native_name);
16381649
auto hi = p.get_span();

src/test/run-pass/native2.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ native "rust" mod rustrt {
33
fn vec_buf[T](vec[T] v, uint offset) -> vbuf;
44
}
55

6+
native mod libc = "libc.dylib" {
7+
fn write(int fd, rustrt.vbuf buf, uint count) -> int;
8+
}
9+
610
fn main(vec[str] args) {
711
}

0 commit comments

Comments
 (0)