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 [email protected]
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. [no.]
- 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 compiler_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
- CTFE (this may be required in 0.1, not sure)
- dmd calling convention compatibility
- self hosting
- extern (C++)
You'll need make and the latest DMD installed.
Download the Clang Binaries for Linux/x86 copy every libLLVM*.a into a directory 'llvm' at the source directory's root.
Make a directory named 'bin'.
Run make.
Copy bin/sdc into the root. Compile the runner using dmd, and run it to run the tests using SDC. You'll need LLVM's llc
in your $PATH
, and opt
if you want to use --optimise
. If you build a 64 bit SDC, be aware that DMD has some bugs that make it crash and kill your parents, particularly on errors and warnings.
(These instructions are from Jakob, so please don't contact me regarding them.)
The following are required for LLVM to function on Windows:
- LLVM >= 2.9
- 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 GNU make for the makefile
- SDC requires
A copy of llvm-2.9.dll
and llvm-2.9.lib
in DMD-compatible OMF format can be downloaded from here for convenience.
For the LLVM tools, grab "LLVM Binaries for Mingw32/x86" on the LLVM download page.
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 compiler_tests/
, then run it with runner
.