mozilla/rust — pull request #6735 by huonw (2013-05-25 07:18:33+00:00)
Title: Basic support for dynamically loading syntax extensions

This adds a wrapper around `dlopen`/`dlsym` etc to `std::unstable`, with some effort to get the lifetimes of the symbols from the library to be restricted to the lifetime of the dynamic library (it requires #5922 to work properly).

It also adds a `#[syntax_extension="library"]` attribute which will load the library (requires the full filename), and call `register_syntax_extensions` to retrieve a vec of new syntax extensions which are added to the macros that are expanded.

See [ext/dynamic.rs](https://github.com/huonw/rust/pull/new/mozilla:incoming...dynamic-syntax#L6R21) for a more detailed description.

I'm only been able to test on x86-64 Linux but it doesn't break anything, although I'm not really sure how to write tests for this.

(This is definitely not ready for general use (I've hidden it behind a `-Z dynamic-syntax-extensions` flag), but makes experimenting with/rewriting syntax extensions much easier, since they don't require a full rebuild.)