From 8122e0c54280545c28e8067c0e3a19253fe3aa9b Mon Sep 17 00:00:00 2001 From: Rafael Avila de Espindola Date: Mon, 7 Feb 2011 12:46:28 -0500 Subject: [PATCH] Add support for native mod foo = "bar" ... --- src/comp/front/parser.rs | 13 ++++++++++++- src/test/run-pass/native2.rs | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index e04b82214b8..8d1309352bb 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -1630,9 +1630,20 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool { 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); + auto has_eq; + auto native_name = ""; + if (p.peek() == token.MOD) { + has_eq = true; + } else { + native_name = parse_str_lit(p); + has_eq = false; + } expect(p, token.MOD); auto id = parse_ident(p); + if (has_eq) { + expect(p, token.EQ); + native_name = parse_str_lit(p); + } expect(p, token.LBRACE); auto m = parse_native_mod_items(p, native_name); auto hi = p.get_span(); diff --git a/src/test/run-pass/native2.rs b/src/test/run-pass/native2.rs index a6df93f5d87..4d2f0ad94a8 100644 --- a/src/test/run-pass/native2.rs +++ b/src/test/run-pass/native2.rs @@ -3,5 +3,9 @@ fn vec_buf[T](vec[T] v, uint offset) -> vbuf; } +native mod libc = "libc.dylib" { + fn write(int fd, rustrt.vbuf buf, uint count) -> int; +} + fn main(vec[str] args) { }