[erlang-questions] beta release of merl - metaprogramming in Erlang
Richard A. O'Keefe
Sun Feb 23 23:02:35 CET 2014
On 24/02/2014, at 10:41 AM, Richard Carlsson wrote:
>> Did you ever look at xoc?
> Not that I know. Reference?
An Extension-Oriented Compiler
Russell Stensby Cox
PhD thesis submitted to
MIT in September 2008. (EE&CS).
The thesis of this dissertation is that compilers can and should
allow programmers to extend programming languages with new syntax,
features, and restrictions by writing extension modules that act
as plugins for the compiler. We call compilers designed around
this idea extension-oriented. The central challenge in designing
and building an extension-oriented compiler is the creation of
extension interfaces that are simultaneously powerful, to allow
effective extensions; convenient, to make these extensions easy
to write; and composable, to make it possible to use
independently-written extensions together.
This dissertation proposes and evaluates extension-oriented syntax
trees (XSTs) as a way to meet these challenges. The key
interfaces to XSTs are grammar statements, a convenient, composable
interface to extend the input parser; syntax patterns, a way to
manipulate XSTs in terms of the original program syntax;
canonicalizers, which put XSTs into a canonical form to extend
the reach of syntax patterns; and attributes, a lazy computation
mechanism to structure analyses on XSTs and allow extensions to
cooperate. We have implemented these interfaces in a small procedural
language called zeta. Using zeta, we have built an extension
oriented compiler for C called xoc and then 13 extensions to C
ranging in size from 16 lines to 245 lines.
To evaluate XSTs and xoc, this dissertation examines two examples
in detail: a reimplementation of the programming language Alef
and a reimplementation of the Linux kernel checker Sparse.
Both of these examples consist of a handful of small extensions
used in concert.
The Systems Group here have an ongoing project on View-Oriented
Parallel Programming, basically a Distributed Shared Memory
approach to parallel programming. We were quite keen to use xoc
to add syntactic support for this to C. I am still convinced it
would be a great tool for the job. Sadly, zeta documentation is
largely non-existent. In order to enable the PhD student I
wanted to implement this to do so, I would have had to reverse
engineer a Zeta manual from the implementation...
Oddly enough, I have Masters student this year for whom xoc
could have been the perfect tool, had Zeta been documented.
The particularly interesting thing about xoc is not just that
it lets people write extensions, but the thought that Russell
Cox gave to making extensions *work together*, something that
is not always straightforward with macros.
More information about the erlang-questions