www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Xoc, yaspl (yet another SPL)

reply Justin Johansson <no spam.com> writes:
Has anyone here come across Xoc before?

Here's the abstract

 From http://portal.acm.org/citation.cfm?id=1346281.1346312

ABSTRACT

Today's system programmers go to great lengths to extend the languages 
in which they program. For instance, system-specific compilers find 
errors in Linux and other systems, and add support for specialized 
control flow to Qt and event-based programs. These compilers are 
difficult to build and cannot always understand each other's language 
changes. However, they can greatly improve code understandability and 
correctness, advantages that should be accessible to all programmers.

We describe an extension-oriented compiler for C called xoc. An 
extension-oriented compiler, unlike a conventional extensible compiler, 
implements new features via many small extensions that are loaded 
together as needed. Xoc gives extension writers full control over 
program syntax and semantics while hiding many compiler internals. Xoc 
programmers concisely define powerful compiler extensions that, by 
construction, can be combined; even some parts of the base compiler, 
such as GNU C compatibility, are structured as extensions.

Xoc is based on two key interfaces. Syntax patterns allow extension 
writers to manipulate language fragments using concrete syntax. Lazy 
computation of attributes allows extension writers to use the results of 
analyses by other extensions or the core without needing to worry about 
pass scheduling.

Extensions built using xoc include xsparse, a 345-line extension that 
mimics Sparse, Linux's C front end, and xlambda, a 170-line extension 
that adds function expressions to C. An evaluation of xoc using these 
and 13 other extensions shows that xoc extensions are typically more 
concise than equivalent extensions written for conventional extensible 
compilers and that it is possible to compose extensions.

<>
Aug 17 2010
parent reply bearophile <bearophileHUGS lycos.com> writes:
Justin Johansson:
 Has anyone here come across Xoc before?
Never seen it before. It looks interesting. The good thing of LLVM is that there is a bit higher probability that similar works become integrated with it, instead of just dying as hundreds of similar experiments have done in the last thirty years or so. More info here: http://pdos.csail.mit.edu/xoc/ A paper about it: http://pdos.csail.mit.edu/xoc/asplos08.pdf The xoc-unstable.tgz-1\xoc-unstable\zeta\xoc\x directory inside here shows most of the examples discussed in the paper: http://pdos.csail.mit.edu/xoc/xoc-unstable.tgz Even the examples look interesting, like the extension "Sparse" written by Linux to avoid bugs when writing the kernel... As example, I think this is the code necessary to add >>> and <<< to C: from xoc import *; extend grammar C99 { expr: expr "<<<" expr [Shift] | expr ">>>" expr [Shift]; } extend attribute type(term: C.expr): C.type { switch(term){ case `{\a <<< \b} || `{\a >>> \b}: if(a.type.isinteger && b.type.isinteger) return a.type.integerpromotion; errorast(term, "non-integer rotate"); return `C.type{int}; } return default(term); } extend attribute compiled(term: C.expr): COutput.expr { switch(term){ case `{\a <<< \b}: n := a.type.sizeof * 8; term = `C.expr{ ({ \(a.type.unsigned) x = \a; \(b.type) y = \b; (x << y) | (x >> (\n-y)); }) }; return term.compiled; case `{\a >>> \b}: n := term.type.sizeof * 8; term = `C.expr{ \a <<< (\n-\b) }; return term.compiled; } return default(term); } Bye, bearophile
Aug 17 2010
parent reply Justin Johansson <no spam.com> writes:
On 18/08/10 03:38, bearophile wrote:
 Justin Johansson:
 Has anyone here come across Xoc before?
Never seen it before. It looks interesting. The good thing of LLVM is that there is a bit higher probability that similar works become integrated with it, instead of just dying as hundreds of similar experiments have done in the last thirty years or so. More info here: http://pdos.csail.mit.edu/xoc/ A paper about it: http://pdos.csail.mit.edu/xoc/asplos08.pdf The xoc-unstable.tgz-1\xoc-unstable\zeta\xoc\x directory inside here shows most of the examples discussed in the paper: http://pdos.csail.mit.edu/xoc/xoc-unstable.tgz Even the examples look interesting, like the extension "Sparse" written by Linux to avoid bugs when writing the kernel...
Yes, well, I just noticed from that link http://pdos.csail.mit.edu/xoc/ a mention of Russ Cox. Russ Cox's Ph.D. thesis, “An Extension-Oriented Compiler”, gives more details about the entire system, as well as a definition of the zeta language. Now isn't Russ Cox one of the Go PL authors?
Aug 19 2010
parent Justin Johansson <no spam.com> writes:
On 19/08/10 22:19, Justin Johansson wrote:
 The xoc-unstable.tgz-1\xoc-unstable\zeta\xoc\x directory inside here
 shows most of the examples discussed in the paper:
 http://pdos.csail.mit.edu/xoc/xoc-unstable.tgz
 Even the examples look interesting, like the extension "Sparse"
 written by Linux to avoid bugs when writing the kernel...
Yes, well, I just noticed from that link http://pdos.csail.mit.edu/xoc/ a mention of Russ Cox. Russ Cox's Ph.D. thesis, “An Extension-Oriented Compiler”, gives more details about the entire system, as well as a definition of the zeta language. Now isn't Russ Cox one of the Go PL authors?
Hmm, I'm a bit slow to realize as well that Xoc is Cox spelt backwards!
Aug 19 2010