This is the home of a D compiler. SDC is at the moment, particularly stupid; it is a work in progress. Feel free to poke around, but don't expect it to compile your code. I don't know what I'm doing in terms of compiler writing. If you find some horrible design decision, that's most likely why.
The code is released under the GPL (see the LICENCE file for more details). Contact me at b.helyer@gmail.com
Last tested with: DMD releases 2.057
and 2.058
on the 6th of March.
What follows is a very high level overview of what's done, and what's still to do. This list is incomplete. SDC is in a state of flux, and this is likely to be out of date.
- Scan and handle multiple encoding formats. [yes.] -- in so far all code is treated as UTF-8 and its BOM is eaten; other BOMs are rejected.
- Handle leading script lines. [yes.]
- Split source into tokens. [yes.]
- Replace special tokens. [yes.]
- Process special token sequences. [yes.]
- Parse module declarations. [yes.]
- Parse attribute declarations. [yes.]
- Parse import declarations. [yes.]
- Parse enum declarations. [yes.]
- Parse class declarations. [partially.]
- Parse interface declarations. [no.]
- Parse aggregate declarations. [partially.]
- Parse declarations. [partially.]
- Parse constructors. [yes.]
- Parse destructors. [yes.]
- Parse invariants. [no.]
- Parse unittests. [yes.]
- Parse static constructors. [yes.]
- Parse static destructors. [yes.]
- Parse shared static constructors. [yes.]
- Parse shared static destructors. [yes.]
- Parse conditional declarations. [yes.]
- Parse static asserts. [yes.]
- Parse template declarations. [partially.]
- Parse template mixins. [no.]
- Parse mixin declarations. [partially.]
- Parse statements. [partially.]
- Import symbols from other modules. [yes.]
- Apply attributes. [partially.]
- Enums. [yes.]
- Structs. [partially.]
- Classes. [partially.]
- Functions. [partially.]
- Overloaded functions. [yes.]
- Function pointers. [yes.]
- Local variables. [yes.]
- Global variables. [yes.]
- Alias declarations. [partially.]
- Expressions. [partially.]
- Label statement. [yes.]
- If statement. [yes.]
- While statement. [yes.]
- Do statement. [yes.]
- For statement. [yes.]
- Switch statement. [no.]
- Final switch statement. [no.]
- Case statement. [no.]
- Case range statement. [no.]
- Default statement. [no.]
- Continue statement. [no.]
- Break statement. [no.]
- Return statement. [yes.]
- Goto statement. [partially.]
- With statement. [no.]
- Synchronized statement. [no.]
- Try statement. [no.]
- Scope guard statement. [no.]
- Throw statement. [no.]
- Asm statement. [no.]
- Pragma statement. [no.]
- Mixin statement. [yes.]
- Foreach range statement. [yes.]
- Conditional statement. [yes.]
- Static assert. [yes.]
- Template mixin. [no.]
- Templated scope. [partially.]
See the tests directory for a sample of what is/should-be working. libs/object.d contains the current (temporary) object.d file for SDC.
This just me thinking outloud about what features I want, when.
- druntime compiles
- phobos compiles
- inline assembler
- dmd calling convention compatibility
- self hosting
- extern (C++)
You'll need make and the latest DMD installed.
Install LLVM 3.0.
Run make
.
Copy bin/sdc
into your $PATH
somewhere.
You'll need to create a file, either /etc/sdc.conf
or ~/.sdc.conf
(the latter may change to ~/.local/share/sdc/sdc.conf
at some point, so be warned) with contents like so:
{
"defaultImportPaths":["~/path/to/SDC/libs"],
"defaultFlags":["-m64", "--debug"]
}
The last bit is optional, but SDC needs to know where to find object.d
is the point.
Then you can compile runner.d
with dmd
and run it to run the test suites. There will be a handful of failures, but the majority (> 95%) should pass.
(These instructions are from Jakob, so please don't contact me regarding them.)
The following are required for LLVM to function on Windows:
- LLVM >= 3.0
- SDC requires the core libraries as a DLL, and the
llc
andopt
tools
- SDC requires the core libraries as a DLL, and the
- MinGW
- SDC requires
gcc
, as well as GNUmake
for the makefile
- SDC requires
The above have not been updated for LLVM 3.0, unfortunately. Until then, you'll have to convert it with `implib` or so. Good luck! -B.
For the LLVM tools, grab "LLVM Binaries for Mingw32/x86" on the [LLVM download page](http://llvm.org/releases/download.html).
### Setup
Extract the LLVM DLL binary archive to the SDC repository, then build with `make -f Makefile.windows`.
When running SDC, make sure `gcc`, `llc` and `opt` are available in your PATH.
To run the tests, execute `dmd runner.d` to build the test-runner application found in `tests/`, then run it with `runner`.